RPM Community Forums

Mailing List Message of <rpm-users>

Re: How not to use rpm owner/group info on unpack?

From: Jeff Johnson <n3npq@mac.com>
Date: Tue 09 Nov 2010 - 03:12:00 CET
Message-id: <7661C0EB-C2DF-4287-AAB4-8702B2E559CF@mac.com>

On Nov 8, 2010, at 8:49 PM, Marc MERLIN wrote:

> I was debugging an rpm problem and pulled my hair on this:
> As root, both:
> rpm2cpio file.rpm | cpio -idv
> and
> alien --to-tgz file.rpm ; tar xvzf file.rpm
> unpack the package but lose the owner/group info for files.


Um, and this is an rpm problem ... how? You're not even invoking rpm.

> Yet, installing the rpm on a system does use the right user/group info.
> Argh, lost half a day on this :(
> What is the proper way to unpack an rpm without losing the user/group info 
> (i.e. without installing it and without relying on an rpmdb, just unpacking
> its files with proper perms).

See the popt aliases that queries user/group/mode, pipes to awk,
and write the commands that do what you want:
	rpm -p --setugids foo*.rpm
	rpm -p --setperms foo*.rpm
in spite of what cpio/alien/tar choose to do.

When you discover that you need "./" prefixed to
that path in the --queryformat, then look at the popt alias
(usually in /usr/lib/rpm/rpmpopt):

rpm     alias --setugids -q --qf \
        '[ch %{FILEUSERNAME:shescape} %{FILEGROUPNAME:shescape} %{FILENAMES:shes
cape}\n]' \
        --pipe "(echo 'ch() { chown -h -- \"$1\" \"$3\";chgrp -h -- \"$2\" \"$3\
"; }';grep -v \(none\))|sh" \
        --POPTdesc=$"set user/group ownership of files in a package"

and figger out where to add the "./" prefix.

73 de Jeff
Received on Tue Nov 9 03:13:12 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.