[yocto] ALTERNATIVE_TARGET, ALTERNATIVE_PRIORITY problem

Joseph Andrew de la Peña jdelapena at lexmark.com
Wed Jan 28 03:12:11 PST 2015


Good day Mark,

Thank you for the response! Really appreciate it. The purpose is the latter
as what you've provided (three packages that all provide 'bar'. )

When I tried this one, bar3 is the one pointed by bar. The aim is for bar
to point bar1 instead. Running rpm -qp as you suggested, they all have same
priority of 10 w/c made me hypothesize that the result is due to bar3 being
the last one set as target for bar. Am I correct?

So my questions:
1. Is RPROVIDES not needed anymore when using ALTERNATIVES?
2. How can I set priority between packages within the same unit/recipe? (so
that I can reflect bar1 as the one pointed by bar)
3. When using ALTERNATIVES, is there no need anymore to add the "name" (eg.
bar) to the packagegroup's RDEPENDS?


Your response is really really valued!

Thanks,
Joseph

On Wed, Jan 28, 2015 at 12:53 AM, Mark Hatle <mark.hatle at windriver.com>
wrote:

> On 1/27/15 9:37 AM, Joseph Andrew de la Peña wrote:
> > Good day Yocto Community,
> >
> > I would like to ask what's wrong with my implementation with
> update-alternatives:
>
> I think that you have some of the variables confused below.  I've quoted
> bits of
> the class's header (internal documentation):
>
> # List all of the alternatives needed by a package:
> # ALTERNATIVE_<pkg> = "name1 name2 name3 ..."
>
> # The pathname of the link
> # ALTERNATIVE_LINK_NAME[name] = "target"
>
> # NOTE: If ALTERNATIVE_LINK_NAME is not defined, it defaults to
> ${bindir}/name
>
>
> # The default link to create for all targets
> # ALTERNATIVE_TARGET = "target"
>
> or
>
> # A non-default link to create for a target
> # ALTERNATIVE_TARGET[name] = "target"
>
> # A package specific link for a target
> # ALTERNATIVE_TARGET_<pkg>[name] = "target"
> #
> #   This is useful when a recipe provides multiple alternatives for the
> #   same item.
>
>
> So if you have a single binary called 'bar', and want it to show up as
> bar1,
> bar2 and bar3 using the alternatives you would do:
>
> PACKAGES =+ "${PN}-bar1 ${PN}-bar2 ${PN}-bar3"
> ALTERNATIVE_${PN}-bar1 = "bar1"
> ALTERNATIVE_${PN}-bar2 = "bar2"
> ALTERNATIVE_${PN}-bar3 = "bar3"
>
> ALTERNATIVE_TARGET = "/bin/bar"
>
> ALTERNATIVE_LINK_NAME[bar1] = "/bin/bar1"
> ALTERNATIVE_LINK_NAME[bar2] = "/bin/bar2"
> ALTERNATIVE_LINK_NAME[bar3] = "/bin/bar3"
>
> FILES_${PN} = "/bin/bar"
>
> The result would be:
>
> package ${PN} contains /bin/bar
>
> package ${PN}-bar1 would create a link /bin/bar1 -> /bin/bar
> package ${PN}-bar2 would create a link /bin/bar2 -> /bin/bar
> package ${PN}-bar3 would create a link /bin/bar3 -> /bin/bar
>
>
> If you want to do the other way around, have three packages that all
> provide
> 'bar'.  You would do:
>
> PACKAGES =+ "${PN}-bar1 ${PN}-bar2 ${PN}-bar3"
> ALTERNATIVE_${PN}-bar1 = "bar"
> ALTERNATIVE_${PN}-bar2 = "bar"
> ALTERNATIVE_${PN}-bar3 = "bar"
>
> ALTERNATIVE_LINK_NAME[bar] = "/bin/bar"
>
> ALTERNATIVE_TARGET_${PN}-bar1 = "/bin/bar1"
> ALTERNATIVE_TARGET_${PN}-bar2 = "/bin/bar2"
> ALTERNATIVE_TARGET_${PN}-bar3 = "/bin/bar3"
>
> FILES_${PN}-bar1 = "/bin/bar1"
> FILES_${PN}-bar2 = "/bin/bar2"
> FILES_${PN}-bar3 = "/bin/bar3"
>
>
> package ${PN}-bar1 would own a file /bin/bar1 and link it to /bin/bar
> package ${PN}-bar2 would own a file /bin/bar2 and link it to /bin/bar
> package ${PN}-bar3 would own a file /bin/bar3 and link it to /bin/bar
>
>
> (You can verify the above by looking at the package data, if using RPM,
> rpm -qp
> <package> --scripts will show you the logic for adding the alternative.)
>
>
> As for the install time, the packaging system will "choose" to install a
> package
> that meets the dependency you select.  If you don't specifically name
> ${PN}-bar1
> in your install, it may not be selected in favor of one of the other
> providers.
>  The PRIORITY only affects if multiple packages are installed, which one
> takes
> priority over the others.
>
> --Mark
>
> > =================
> >
> > *bar_git.bb <http://bar_git.bb/>:*
> >
> > PACKAGES =+ "${PN}-bar1 ${PN}-bar2 ${PN}-bar3"
> > RPROVIDES_${PN}-bar1 = "bar"
> > RPROVIDES_${PN}-bar2 = "bar"
> > RPROVIDES_${PN}-bar3 = "bar"
> >
> > ALTERNATIVE_LINK_NAME[bar] = "${datadir}/foo/bar"
> >
> > ALTERNATIVE_${PN}-bar1 = "bar"
> > ALTERNATIVE_TARGET_${PN}-bar1 = "${datadir}/foo/bar1"
> > ALTERNATIVE_PRIORITY_${PN}-bar1 = "99"
> >
> > ALTERNATIVE_${PN}-bar2 = "bar"
> > ALTERNATIVE_TARGET_${PN}-bar2 = "${datadir}/foo/bar2"
> > ALTERNATIVE_PRIORITY_${PN}-bar2 = "98"
> >
> > ALTERNATIVE_${PN}-bar3 = "bar"
> > ALTERNATIVE_TARGET_${PN}-bar3 = "${datadir}/foo/bar3"
> > ALTERNATIVE_PRIORITY_${PN}-bar3 = "97"
> >
> > inherit update-alternatives
> >
> > *packagegroup-foobar.bb <http://packagegroup-foobar.bb/>:*
> >
> > RDEPENDS_foobar = "bar"
> >
> > =================
> >
> > The end result is always bar3 is present and bar is pointing to bar3. I
> never
> > get bar1 being present which is the result I want.
> >
> > Please do recommend how will I properly use ALTERNATIVE_TARGET and
> > ALTERNATIVE_PRIORITY.
> >
> > Thanks,
> > Joseph
> >
> >
>
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20150128/4b845bf4/attachment.html>


More information about the yocto mailing list