1999-01-20 02:34:26 +03:00
#! /bin/sh
#
2003-05-31 00:27:07 +04:00
# Browse contents of an installed RPM package.
# This filesystem works on the entries of the "rpms" filesystem.
#
1999-01-20 02:34:26 +03:00
# Written by Erik Troan (ewt@redhat.com) 1996
# Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996
# Tomasz K<> oczko (kloczek@rudy.mif.pg.gda.pl) 1997
# minor changes by Wojtek Pilorz (wpilorz@bdk.lublin.pl) 1997
# minor changes by Michele Marziani (marziani@fe.infn.it) 1997
# slight changes to put rpm to Trpm by Balazs Nagy (julian7@kva.hu) 1998
2000-03-28 14:49:26 +04:00
# locale bugfix by Michal Svec (rebel@penguin.cz) 2000
1999-01-20 02:34:26 +03:00
# (C) 1996 The Free Software Foundation.
#
#
2000-03-28 14:49:26 +04:00
# override any locale for dates
unset LC_ALL
LC_TIME=C
export LC_TIME
2004-10-27 18:03:43 +04:00
if rpm --nosignature --version >/dev/null 2>&1; then
RPM="rpm --nosignature"
else
RPM="rpm"
fi
1999-01-20 02:34:26 +03:00
mcrpmfs_list ()
{
# set MCFASTRPM_DFLT to 1 for faster rpm files handling by default, to 0 for
# slower handling
MCFASTRPM_DFLT=0
if test -z "$MCFASTRPM"; then
MCFASTRPM=$MCFASTRPM_DFLT
fi
FILEPREF="-r--r--r-- 1 root root "
2004-10-27 18:44:31 +04:00
DESC=`$RPM -qi -- "$1"`
DATE=`$RPM -q --qf "%{BUILDTIME:date}" -- "$1" | cut -c 5-11,21-24`
1999-01-20 02:34:26 +03:00
HEADERSIZE=`echo "$DESC" | wc -c`
echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER"
2004-10-27 18:03:43 +04:00
echo "-r-xr-xr-x 1 root root 40 $DATE UNINSTALL"
1999-01-20 02:34:26 +03:00
echo "dr-xr-xr-x 3 root root 0 $DATE INFO"
echo "$FILEPREF 0 $DATE INFO/NAME-VERSION-RELEASE"
echo "$FILEPREF 0 $DATE INFO/GROUP"
echo "$FILEPREF 0 $DATE INFO/BUILDHOST"
echo "$FILEPREF 0 $DATE INFO/SOURCERPM"
if test "$MCFASTRPM" = 0 ; then
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{DISTRIBUTION}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{VENDOR}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/VENDOR"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{DESCRIPTION}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/DESCRIPTION"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{SUMMARY}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SUMMARY"
2004-10-27 18:44:31 +04:00
if test "`$RPM -q --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" -- "$1"`" != "(none)(none)(none)(none)(none)"; then
1999-01-20 02:34:26 +03:00
echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{RPMTAG_PREIN}\" -- "$1"`" = '(none)' ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{RPMTAG_POSTIN}\" -- "$1"`" = '(none)' ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{RPMTAG_PREUN}\" -- "$1"`" = '(none)' ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{RPMTAG_POSTUN}\" -- "$1"`" = '(none)' ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{VERIFYSCRIPT}\" -- "$1"`" = '(none)' ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL"
fi
else
echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION"
echo "$FILEPREF 0 $DATE INFO/VENDOR"
echo "$FILEPREF 0 $DATE INFO/DESCRIPTION"
echo "$FILEPREF 0 $DATE INFO/SUMMARY"
echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT"
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL"
fi
if test "$MCFASTRPM" = 0 ; then
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{PACKAGER}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/PACKAGER"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{URL}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/URL"
2006-07-13 18:23:08 +04:00
test "`$RPM -q --qf \"%{EPOCH}\" -- "$1"`" = "(none)" ||
echo "$FILEPREF 0 $DATE INFO/EPOCH"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{LICENSE}\" -- "$1"`" = "(none)" ||
2004-10-27 18:03:43 +04:00
echo "$FILEPREF 0 $DATE INFO/LICENSE"
1999-01-20 02:34:26 +03:00
else
echo "$FILEPREF 0 $DATE INFO/PACKAGER"
echo "$FILEPREF 0 $DATE INFO/URL"
2006-07-13 18:23:08 +04:00
echo "$FILEPREF 0 $DATE INFO/EPOCH"
2004-10-27 18:03:43 +04:00
echo "$FILEPREF 0 $DATE INFO/LICENSE"
1999-01-20 02:34:26 +03:00
fi
echo "$FILEPREF 0 $DATE INFO/BUILDTIME"
echo "$FILEPREF 0 $DATE INFO/RPMVERSION"
echo "$FILEPREF 0 $DATE INFO/OS"
echo "$FILEPREF 0 $DATE INFO/SIZE"
if test "$MCFASTRPM" != 0 ; then
2004-10-27 18:44:31 +04:00
$RPM -q --qf "[%{REQUIRENAME}\n]" -- "$1" | grep "(none)" > /dev/null ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
2004-10-27 18:44:31 +04:00
$RPM -q --qf "[%{OBSOLETES}\n]" -- "$1" | grep "(none)" > /dev/null ||
2004-10-27 18:03:43 +04:00
echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
2004-10-27 18:44:31 +04:00
$RPM -q --qf "[%{PROVIDES}\n]" -- "$1" | grep "(none)" > /dev/null ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/PROVIDES"
2006-11-01 13:30:26 +03:00
$RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" | grep "(none)" > /dev/null ||
echo "$FILEPREF 0 $DATE INFO/CONFLICTS"
2004-10-27 18:44:31 +04:00
test "`$RPM -q --qf \"%{CHANGELOGTEXT}\" -- "$1"`" = "(none)" ||
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
else
echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
2004-10-27 18:03:43 +04:00
echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/PROVIDES"
2006-11-01 13:30:26 +03:00
echo "$FILEPREF 0 $DATE INFO/CONFLICTS"
1999-01-20 02:34:26 +03:00
echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
fi
2004-10-27 18:44:31 +04:00
$RPM -qlv -- "$1" | grep '^[A-Za-z0-9-]'
1999-01-20 02:34:26 +03:00
}
mcrpmfs_copyout ()
{
case "$2" in
2004-10-27 18:44:31 +04:00
HEADER) $RPM -qi -- "$1" > "$3"; exit 0;;
2004-10-27 18:03:43 +04:00
UNINSTALL) echo "# Run this to uninstall this RPM package" > "$3"; exit 0;;
2004-10-27 18:44:31 +04:00
INFO/NAME-VERSION-RELEASE) $RPM -q --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" -- "$1" > "$3"; exit 0;;
INFO/RELEASE) $RPM -q --qf "%{RELEASE}\n" -- "$1" > "$3"; exit 0;;
INFO/GROUP) $RPM -q --qf "%{GROUP}\n" -- "$1" > "$3"; exit 0;;
INFO/DISTRIBUTION) $RPM -q --qf "%{DISTRIBUTION}\n" -- "$1" > "$3"; exit 0;;
INFO/VENDOR) $RPM -q --qf "%{VENDOR}\n" -- "$1" > "$3"; exit 0;;
INFO/BUILDHOST) $RPM -q --qf "%{BUILDHOST}\n" -- "$1" > "$3"; exit 0;;
INFO/SOURCERPM) $RPM -q --qf "%{SOURCERPM}\n" -- "$1" > "$3"; exit 0;;
INFO/DESCRIPTION) $RPM -q --qf "%{DESCRIPTION}\n" -- "$1" > "$3"; exit 0;;
INFO/PACKAGER) $RPM -q --qf "%{PACKAGER}\n" -- "$1" > "$3"; exit 0;;
INFO/URL) $RPM -q --qf "%{URL}\n" -- "$1" > "$3"; exit 0;;
INFO/BUILDTIME) $RPM -q --qf "%{BUILDTIME:date}\n" -- "$1" > "$3"; exit 0;;
2006-07-13 18:23:08 +04:00
INFO/EPOCH) $RPM -q --qf "%{EPOCH}\n" -- "$1" > "$3"; exit 0;;
2004-10-27 18:44:31 +04:00
INFO/LICENSE) $RPM -q --qf "%{LICENSE}\n" -- "$1" > "$3"; exit 0;;
INFO/RPMVERSION) $RPM -q --qf "%{RPMVERSION}\n" -- "$1" > "$3"; exit 0;;
INFO/REQUIRENAME) $RPM -q --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" -- "$1" > "$3"; exit 0;;
INFO/OBSOLETES) $RPM -q --qf "[%{OBSOLETENAME} %|OBSOLETEFLAGS?{%{OBSOLETEFLAGS:depflags} %{OBSOLETEVERSION}}:{}|\n]" -- "$1" > "$3"; exit 0;;
INFO/PROVIDES) $RPM -q --qf "[%{PROVIDES}\n]" -- "$1" > "$3"; exit 0;;
2006-11-01 13:30:26 +03:00
INFO/CONFLICTS) $RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" > "$3"; exit 0;;
2004-10-27 18:44:31 +04:00
INFO/SCRIPTS/PREIN) $RPM -q --qf "%{RPMTAG_PREIN}\n" -- "$1" > "$3"; exit 0;;
INFO/SCRIPTS/POSTIN) $RPM -q --qf "%{RPMTAG_POSTIN}\n" -- "$1" > "$3"; exit 0;;
INFO/SCRIPTS/PREUN) $RPM -q --qf "%{RPMTAG_PREUN}\n" -- "$1" > "$3"; exit 0;;
INFO/SCRIPTS/POSTUN) $RPM -q --qf "%{RPMTAG_POSTUN}\n" -- "$1" > "$3"; exit 0;;
INFO/SCRIPTS/VERIFYSCRIPT) $RPM -q --qf "%{VERIFYSCRIPT}\n" -- "$1" > "$3"; exit 0;;
INFO/SCRIPTS/ALL) $RPM -q --scripts -- "$1" > "$3"; exit 0;;
INFO/SUMMARY) $RPM -q --qf "%{SUMMARY}\n" -- "$1" > "$3"; exit 0;;
INFO/OS) $RPM -q --qf "%{OS}\n" -- "$1" > "$3"; exit 0;;
INFO/CHANGELOG) $RPM -q --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" -- "$1" > "$3"; exit 0;;
INFO/SIZE) $RPM -q --qf "%{SIZE} bytes\n" -- "$1" > "$3"; exit 0;;
1999-01-20 02:34:26 +03:00
*)
2004-10-27 18:03:43 +04:00
cp "/$2" "$3"
1999-01-20 02:34:26 +03:00
esac
}
mcrpmfs_run ()
{
case "$2" in
2004-10-27 18:44:31 +04:00
UNINSTALL) echo "Uninstalling $1"; rpm -e -- "$1"; exit 0;;
1999-01-20 02:34:26 +03:00
esac
}
2003-05-31 00:27:07 +04:00
name=`sed 's/.*\///;s/\.trpm$//' "$2"`
1999-01-20 02:34:26 +03:00
case "$1" in
2004-10-27 18:03:43 +04:00
list) mcrpmfs_list "$name"; exit 0;;
copyout) mcrpmfs_copyout "$name" "$3" "$4"; exit 0;;
run) mcrpmfs_run "$name" "$3"; exit 1;;
1999-01-20 02:34:26 +03:00
esac
exit 1