ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] rpmpeek
@ 2005-09-13 18:13 Alexey Tourbin
  0 siblings, 0 replies; only message in thread
From: Alexey Tourbin @ 2005-09-13 18:13 UTC (permalink / raw)
  To: devel


[-- Attachment #1.1: Type: text/plain, Size: 1089 bytes --]

Изобрел новую команду для работы со внутренностями rpm'а.
Она распаковывает rpm во временный каталог, затем переходит
в этот каталог и выполняет команду.  Многие операции с rpm'ами
у меня теперь заметно упрощаются.  Вот пример не очень эффективного
использования этой команды:

$ ./rpmpeek ~/RPM/RPMS/libnetpbm-10.20-alt1.i686.rpm find -type f -print0 |
	./rpmpeek ~/RPM/RPMS/libnetpbm-10.20-alt1.i686.rpm xargs -r0 file --
./usr/lib/libnetpbm.so.10.20:                   ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), stripped
./usr/share/doc/netpbm-10.20/README:            ASCII English text
./usr/share/doc/netpbm-10.20/COPYRIGHT.PATENT:  ASCII English text
./usr/share/doc/netpbm-10.20/HISTORY:           ISO-8859 English text
./usr/share/doc/netpbm-10.20/copyright_summary: ASCII English text
./.fakedata:                                    ASCII text
$

Использование не очень эффективно, потому что rpm распаковывается
дважды -- один раз для выполнения find, другой раз для выполнения
xargs file.  Однако же понятие эффективности очень ситуативно.

[-- Attachment #1.2: rpmpeek --]
[-- Type: text/plain, Size: 1202 bytes --]

#!/bin/sh -ef
export LC_ALL=C

while getopts h opt; do
	case "$opt" in
		h) pod2usage --exit=0 "$0"; exit 0 ;;
		*) pod2usage --exit=2 "$0"; exit 2 ;;
	esac
done
shift "$((OPTIND-1))"

if [ $# -lt 2 ]; then
	echo "${0##*/}: not enough arguments" >&2
	pod2usage --exit=2 "$0"; exit 2
fi

atexit()
{
	local rc=$?
	trap - EXIT
	chmod -Rf u+rwX "$tmpdir"
	rm -rf "$tmpdir"
	exit $rc
}
tmpdir="$(mktemp -d -t "${0##*/}.XXXXXXXX")"
trap atexit EXIT HUP INT QUIT PIPE TERM

rpm2cpio "$1" |(cd "$tmpdir"; fakeroot -s .fakedata -- \
	cpio -idmu --quiet --no-absolute-filenames) || exit 2
shift
cd "$tmpdir"
fakeroot -i .fakedata -- "$@" || exit 1

: <<'__EOF__'

=head1	NAME

rpmpeek - execute command within RPM contents

=head1	SYNOPSIS

B<rpmpeek> [B<-h>] I<command> [I<args>...]

=head1	AUTHOR

Written by Alexey Tourbin <at@altlinux.org>.

=head1	COPYING

Copyright (c) 2005 Alexey Tourbin, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=head1	SEE ALSO

rpm(8),
rpm2cpio(8),
fakeroot(1)

=cut

__EOF__

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-13 18:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-13 18:13 [devel] rpmpeek Alexey Tourbin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git