ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: devel@altlinux.ru
Subject: [devel] rpmpeek
Date: Tue, 13 Sep 2005 22:13:24 +0400
Message-ID: <20050913181324.GC3290@solemn.turbinal.org> (raw)


[-- 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 --]

                 reply	other threads:[~2005-09-13 18:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050913181324.GC3290@solemn.turbinal.org \
    --to=at@altlinux.ru \
    --cc=devel@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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