Openembedded Core Discussions
 help / color / mirror / Atom feed
* How to query installed rpm packages
@ 2012-05-28 13:14 Giuseppe Condorelli
  2012-05-28 13:26 ` Paul Eggleton
  0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Condorelli @ 2012-05-28 13:14 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Hi All,

I need to query, via rpm command, the packages installed building an own
image recipe.
I know the populate_rootfs step for images uses rpm to install the packages
(if we set PACKAGE_CLASSES).
To do this it sets a dbpath and a root path for installing the packages.
I need to know how to query them (rpm -qa ....) given that dbpath is set to
/var/lib/rpm but I think it actually doesn't override
the real /var/lib/rpm database (also I'm not building as superuser).

Please can you help me?
Best Regards,
Giuseppe

[-- Attachment #2: Type: text/html, Size: 647 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-28 13:14 How to query installed rpm packages Giuseppe Condorelli
@ 2012-05-28 13:26 ` Paul Eggleton
  2012-05-28 15:30   ` Giuseppe Condorelli
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Eggleton @ 2012-05-28 13:26 UTC (permalink / raw)
  To: Giuseppe Condorelli; +Cc: openembedded-core

On Monday 28 May 2012 15:14:32 Giuseppe Condorelli wrote:
> I need to query, via rpm command, the packages installed building an own
> image recipe.
> I know the populate_rootfs step for images uses rpm to install the packages
> (if we set PACKAGE_CLASSES).
> To do this it sets a dbpath and a root path for installing the packages.
> I need to know how to query them (rpm -qa ....) given that dbpath is set to
> /var/lib/rpm but I think it actually doesn't override
> the real /var/lib/rpm database (also I'm not building as superuser).

Have a look at list_installed_packages() in classes/rootfs_rpm.bbclass; that 
does exactly this. You can call this from your own shell function which you 
can add to ROOTFS_POSTPROCESS_COMMAND.

Note that if all you want is a listing of the installed packages in a file that 
gets written every time an image is built, you can get that using buildhistory 
without any extra work:

https://wiki.yoctoproject.org/wiki/Buildhistory

Cheers,
Paul

--

Paul Eggleton
Intel Open Source Technology Centre



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-28 13:26 ` Paul Eggleton
@ 2012-05-28 15:30   ` Giuseppe Condorelli
  2012-05-28 16:23     ` Paul Eggleton
  0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Condorelli @ 2012-05-28 15:30 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1774 bytes --]

Hi Paul,

first of all many thanks for your quick reply. :)

2012/5/28 Paul Eggleton <paul.eggleton@linux.intel.com>

> On Monday 28 May 2012 15:14:32 Giuseppe Condorelli wrote:
> > I need to query, via rpm command, the packages installed building an own
> > image recipe.
> > I know the populate_rootfs step for images uses rpm to install the
> packages
> > (if we set PACKAGE_CLASSES).
> > To do this it sets a dbpath and a root path for installing the packages.
> > I need to know how to query them (rpm -qa ....) given that dbpath is set
> to
> > /var/lib/rpm but I think it actually doesn't override
> > the real /var/lib/rpm database (also I'm not building as superuser).
>
> Have a look at list_installed_packages() in classes/rootfs_rpm.bbclass;
> that
> does exactly this. You can call this from your own shell function which you
> can add to ROOTFS_POSTPROCESS_COMMAND.
>

Well, I added ROOTFS_POSTPROCESS_COMMAND += "list_installed_packages ; " in
the image recipe I want to build.
Build went right but I don't know where to find the output the
list_installed_packages has provided.
Any suggestion? Am I wrong?


>
> Note that if all you want is a listing of the installed packages in a file
> that
> gets written every time an image is built, you can get that using
> buildhistory
> without any extra work:
>
> https://wiki.yoctoproject.org/wiki/Buildhistory
>

I've tried this and the generated output is very usefull for me.
At the moment, given that I already had all the packages built, it created
only the image history information.
Now I'll run a clean build to collect also packages info.


>
> Cheers,
> Paul
>
Cheers,
Giuseppe

>
> --
>
> Paul Eggleton
> Intel Open Source Technology Centre
>

[-- Attachment #2: Type: text/html, Size: 2974 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-28 15:30   ` Giuseppe Condorelli
@ 2012-05-28 16:23     ` Paul Eggleton
  2012-05-29 13:20       ` Giuseppe Condorelli
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Eggleton @ 2012-05-28 16:23 UTC (permalink / raw)
  To: Giuseppe Condorelli; +Cc: openembedded-core

On Monday 28 May 2012 17:30:34 Giuseppe Condorelli wrote:
> Well, I added ROOTFS_POSTPROCESS_COMMAND += "list_installed_packages ; " in
> the image recipe I want to build.
> Build went right but I don't know where to find the output the
> list_installed_packages has provided.
> Any suggestion? Am I wrong?

All list_installed_packages does is print a list of the packages; if you just 
add it to ROOTFS_POSTPROCESS_COMMAND the output will be going into the log file 
for the image task which is probably not what you want. If you wanted to 
proceed with this I think you'd need to redirect the output to some file 
somewhere - this is easily done by instead calling your own shell function and 
then calling list_installed_packages > path/to/some_output_file.txt within it. 
However it sounds like buildhistory will do what you want here anyway.
 
Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-28 16:23     ` Paul Eggleton
@ 2012-05-29 13:20       ` Giuseppe Condorelli
  2012-05-29 13:32         ` Paul Eggleton
  0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Condorelli @ 2012-05-29 13:20 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

2012/5/28 Paul Eggleton <paul.eggleton@linux.intel.com>

> On Monday 28 May 2012 17:30:34 Giuseppe Condorelli wrote:
> > Well, I added ROOTFS_POSTPROCESS_COMMAND += "list_installed_packages ; "
> in
> > the image recipe I want to build.
> > Build went right but I don't know where to find the output the
> > list_installed_packages has provided.
> > Any suggestion? Am I wrong?
>
> All list_installed_packages does is print a list of the packages; if you
> just
> add it to ROOTFS_POSTPROCESS_COMMAND the output will be going into the log
> file
> for the image task which is probably not what you want. If you wanted to
> proceed with this I think you'd need to redirect the output to some file
> somewhere - this is easily done by instead calling your own shell function
> and
> then calling list_installed_packages > path/to/some_output_file.txt within
> it.
>
Thanks for the reply. What I'm not understanding is how I can invoke my
shell function. Do you mean
I have to invoke it as append function of populate_rootfs one? What I
really need is a way to query the rpm database
out from the build system, as we normally do with host packages.
I tried to have a standalone run of  the rpm command the
list_installed_packages invokes but (obviously) I got a long series of
errors.


> However it sounds like buildhistory will do what you want here anyway.
>
> Well, that adds usefull information but I actually need the one above.

> Cheers,
> Paul
>
>
Thanks again,
Giuseppe


> --
>
> Paul Eggleton
> Intel Open Source Technology Centre
>

[-- Attachment #2: Type: text/html, Size: 2697 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-29 13:20       ` Giuseppe Condorelli
@ 2012-05-29 13:32         ` Paul Eggleton
  2012-05-29 13:49           ` Giuseppe Condorelli
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Eggleton @ 2012-05-29 13:32 UTC (permalink / raw)
  To: Giuseppe Condorelli; +Cc: openembedded-core

On Tuesday 29 May 2012 15:20:14 Giuseppe Condorelli wrote:
> What I'm not understanding is how I can invoke my shell function. Do you
> mean I have to invoke it as append function of populate_rootfs one? 

If you aren't including packaging data in the resulting image (i.e. 
IMAGE_FEATURES does not contain "package-management"), you need to do your rpm 
calls from a function called via ROOTFS_POSTPROCESS_COMMAND because afterwards 
the data will be removed and rpm will not be usable.

> What I really need is a way to query the rpm database
> out from the build system, as we normally do with host packages.
> I tried to have a standalone run of  the rpm command the
> list_installed_packages invokes but (obviously) I got a long series of
> errors.

Below is what I meant - you could put this into some bbclass that you could 
add using INHERIT += "someclass.bbclass" in local.conf:

------------- snip --------------
ROOTFS_POSTPROCESS_COMMAND += "do_some_packaging_stuff ; "

do_some_packaging_stuff() {
	list_installed_packages > /path/to/output/file
}
------------- snip --------------

Substitute list_installed_packages for a similar rpm query command to the one 
list_installed_packages uses.

Out of interest, what information are you querying from the packaging system?

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-29 13:32         ` Paul Eggleton
@ 2012-05-29 13:49           ` Giuseppe Condorelli
  2012-05-30 10:29             ` Giuseppe Condorelli
  0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Condorelli @ 2012-05-29 13:49 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2498 bytes --]

2012/5/29 Paul Eggleton <paul.eggleton@linux.intel.com>

> On Tuesday 29 May 2012 15:20:14 Giuseppe Condorelli wrote:
> > What I'm not understanding is how I can invoke my shell function. Do you
> > mean I have to invoke it as append function of populate_rootfs one?
>
> If you aren't including packaging data in the resulting image (i.e.
> IMAGE_FEATURES does not contain "package-management"), you need to do your
> rpm
> calls from a function called via ROOTFS_POSTPROCESS_COMMAND because
> afterwards
> the data will be removed and rpm will not be usable.
>
> > What I really need is a way to query the rpm database
> > out from the build system, as we normally do with host packages.
> > I tried to have a standalone run of  the rpm command the
> > list_installed_packages invokes but (obviously) I got a long series of
> > errors.
>
> Below is what I meant - you could put this into some bbclass that you could
> add using INHERIT += "someclass.bbclass" in local.conf:
>
> ------------- snip --------------
> ROOTFS_POSTPROCESS_COMMAND += "do_some_packaging_stuff ; "
>
> do_some_packaging_stuff() {
>        list_installed_packages > /path/to/output/file
> }
> ------------- snip --------------
>
> Substitute list_installed_packages for a similar rpm query command to the
> one
> list_installed_packages uses.
>
Yes!!!! Very very simple solution (that obviously I didn't though... :| ).


>
> Out of interest, what information are you querying from the packaging
> system?
>
What I'm trying to obtain is a way to install and to query rpm packages out
from build system.
I mean, I would like to have the rpms built via bitbake/oe-core repository
and than to install them
into a specific root path without the build system support. Also, after
having installed them (or part of
them) I need to query the rpm database in case of debug.
So I started asking my questions to understand if (internally) there was a
way for querying (and it was!).
This for backword compatibility with what I'm currently managing (a
distribution totally rpm based) and
what I'm thinking to implement in next future (a distribution oe based).
For a while I would like both scenarios
will exist in parallel.
If you have other suggestions, or if you think my way to proceed is going
to a black scenario, please don't
hesitate to correct me.

>
> Cheers,
> Paul
>
Cheers,
Giuseppe

>
> --
>
> Paul Eggleton
> Intel Open Source Technology Centre
>

[-- Attachment #2: Type: text/html, Size: 3694 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-29 13:49           ` Giuseppe Condorelli
@ 2012-05-30 10:29             ` Giuseppe Condorelli
  2012-05-30 10:34               ` Paul Eggleton
  0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Condorelli @ 2012-05-30 10:29 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3076 bytes --]

Hi Paul,

just another clarification.

> If you aren't including packaging data in the resulting image (i.e.
> IMAGE_FEATURES does not contain "package-management"),

Adding the package-management I saw target rpm is set to be built.
So I can think I'll have the rpm inside the target fs I'll install via oe
system.
How can it help me if I query installed packages from host?

Cheers,
Giuseppe

2012/5/29 Giuseppe Condorelli <giuseppe.condorelli@gmail.com>

> 2012/5/29 Paul Eggleton <paul.eggleton@linux.intel.com>
>
>> On Tuesday 29 May 2012 15:20:14 Giuseppe Condorelli wrote:
>> > What I'm not understanding is how I can invoke my shell function. Do you
>> > mean I have to invoke it as append function of populate_rootfs one?
>>
>> If you aren't including packaging data in the resulting image (i.e.
>> IMAGE_FEATURES does not contain "package-management"), you need to do
>> your rpm
>> calls from a function called via ROOTFS_POSTPROCESS_COMMAND because
>> afterwards
>> the data will be removed and rpm will not be usable.
>>
>> > What I really need is a way to query the rpm database
>> > out from the build system, as we normally do with host packages.
>> > I tried to have a standalone run of  the rpm command the
>> > list_installed_packages invokes but (obviously) I got a long series of
>> > errors.
>>
>> Below is what I meant - you could put this into some bbclass that you
>> could
>> add using INHERIT += "someclass.bbclass" in local.conf:
>>
>> ------------- snip --------------
>> ROOTFS_POSTPROCESS_COMMAND += "do_some_packaging_stuff ; "
>>
>> do_some_packaging_stuff() {
>>        list_installed_packages > /path/to/output/file
>> }
>> ------------- snip --------------
>>
>> Substitute list_installed_packages for a similar rpm query command to the
>> one
>> list_installed_packages uses.
>>
> Yes!!!! Very very simple solution (that obviously I didn't though... :| ).
>
>
>>
>> Out of interest, what information are you querying from the packaging
>> system?
>>
> What I'm trying to obtain is a way to install and to query rpm packages
> out from build system.
> I mean, I would like to have the rpms built via bitbake/oe-core repository
> and than to install them
> into a specific root path without the build system support. Also, after
> having installed them (or part of
> them) I need to query the rpm database in case of debug.
> So I started asking my questions to understand if (internally) there was a
> way for querying (and it was!).
> This for backword compatibility with what I'm currently managing (a
> distribution totally rpm based) and
> what I'm thinking to implement in next future (a distribution oe based).
> For a while I would like both scenarios
> will exist in parallel.
> If you have other suggestions, or if you think my way to proceed is going
> to a black scenario, please don't
> hesitate to correct me.
>
>>
>> Cheers,
>> Paul
>>
> Cheers,
> Giuseppe
>
>>
>> --
>>
>> Paul Eggleton
>> Intel Open Source Technology Centre
>>
>
>

[-- Attachment #2: Type: text/html, Size: 4664 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to query installed rpm packages
  2012-05-30 10:29             ` Giuseppe Condorelli
@ 2012-05-30 10:34               ` Paul Eggleton
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2012-05-30 10:34 UTC (permalink / raw)
  To: Giuseppe Condorelli; +Cc: openembedded-core

On Wednesday 30 May 2012 12:29:02 Giuseppe Condorelli wrote:
> > If you aren't including packaging data in the resulting image (i.e.
> > IMAGE_FEATURES does not contain "package-management"),
> 
> Adding the package-management I saw target rpm is set to be built.
> So I can think I'll have the rpm inside the target fs I'll install via oe
> system.
> How can it help me if I query installed packages from host?

Adding package-management to IMAGE_FEATURES does two things:

1) Adds rpm to the image to be run on the target
2) Avoids deleting the rpm database files so that rpm actually works

It's #2 that I was referring to earlier - if the rpm database has been 
deleted, rpm on the host will not be able to query the contents of the image. 
Even if they are going to be deleted we can just put our operations before 
that happens - we just need to inject them in the right place. Putting a call 
into ROOTFS_POSTPROCESS_COMMAND achieves this.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-30 10:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 13:14 How to query installed rpm packages Giuseppe Condorelli
2012-05-28 13:26 ` Paul Eggleton
2012-05-28 15:30   ` Giuseppe Condorelli
2012-05-28 16:23     ` Paul Eggleton
2012-05-29 13:20       ` Giuseppe Condorelli
2012-05-29 13:32         ` Paul Eggleton
2012-05-29 13:49           ` Giuseppe Condorelli
2012-05-30 10:29             ` Giuseppe Condorelli
2012-05-30 10:34               ` Paul Eggleton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox