1998-02-27 07:54:42 +03:00
#! /bin/sh
#
# 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
1998-12-09 14:29:54 +03:00
# bug files by Marc Merlin (marcsoft@merlins.org) 1998
2000-03-28 14:49:26 +04:00
# locale bugfix by Michal Svec (rebel@penguin.cz) 2000
2004-01-24 03:48:46 +03:00
# Whitespace(s) & single quote(s) in filename workaround
# by Andrew V. Samoilov <sav@bcs.zp.ua> 2004
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=64007
1998-02-27 07:54:42 +03:00
#
2004-01-24 03:48:46 +03:00
# (C) 1996-2004 The Free Software Foundation.
1998-02-27 07:54:42 +03:00
#
2000-03-28 14:49:26 +04:00
# override any locale for dates
unset LC_ALL
LC_TIME=C
export LC_TIME
2002-12-29 12:19:36 +03:00
if rpm --nosignature --version >/dev/null 2>&1; then
RPM="rpm --nosignature"
else
RPM="rpm"
fi
2002-12-17 03:32:38 +03:00
RPM2CPIO="rpm2cpio"
1998-02-27 07:54:42 +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
2004-01-24 03:48:46 +03:00
f="\"$1\""
1998-02-27 07:54:42 +03:00
FILEPREF="-r--r--r-- 1 root root "
2004-01-24 03:48:46 +03:00
DESC=`$RPM -qip "$f" 2>/dev/null` || {
2000-10-06 05:43:46 +04:00
echo "$FILEPREF 0 "`date +"%b %d %H:%M"`" ERROR"
2004-01-24 03:48:46 +03:00
exit 1
2000-10-06 05:43:46 +04:00
}
2004-01-24 03:48:46 +03:00
DATE=`$RPM -qp --qf "%{BUILDTIME:date}\n" "$f" | cut -c 5-11,21-24`
HEADERSIZE=`echo "$DESC" | wc -c`
echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER"
1998-02-27 07:54:42 +03:00
echo "-r-xr-xr-x 1 root root 39 $DATE INSTALL"
echo "-r-xr-xr-x 1 root root 39 $DATE UPGRADE"
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-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{DISTRIBUTION}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{VENDOR}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/VENDOR"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{DESCRIPTION}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/DESCRIPTION"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{SUMMARY}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SUMMARY"
2004-01-24 03:48:46 +03:00
if test "`$RPM -qp --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" \"$f\"`" != "(none)(none)(none)(none)(none)"; then
1998-02-27 07:54:42 +03:00
echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{RPMTAG_PREIN}\" \"$f\"`" = '(none)' ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{RPMTAG_POSTIN}\" \"$f\"`" = '(none)' ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{RPMTAG_PREUN}\" \"$f\"`" = '(none)' ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{RPMTAG_POSTUN}\" \"$f\"`" = '(none)' ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{VERIFYSCRIPT}\" \"$f\"`" = '(none)' ||
1998-02-27 07:54:42 +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-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{PACKAGER}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/PACKAGER"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{URL}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/URL"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{SERIAL}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/SERIAL"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{COPYRIGHT}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/COPYRIGHT"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{LICENSE}\" \"$f\"`" = "(none)" ||
1998-11-24 04:20:10 +03:00
echo "$FILEPREF 0 $DATE INFO/LICENSE"
1998-02-27 07:54:42 +03:00
else
echo "$FILEPREF 0 $DATE INFO/PACKAGER"
echo "$FILEPREF 0 $DATE INFO/URL"
echo "$FILEPREF 0 $DATE INFO/SERIAL"
echo "$FILEPREF 0 $DATE INFO/COPYRIGHT"
1998-11-24 04:20:10 +03:00
echo "$FILEPREF 0 $DATE INFO/LICENSE"
1998-02-27 07:54:42 +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-01-24 03:48:46 +03:00
$RPM -qp --qf "[%{REQUIRENAME}\n]" "$f" | grep "(none)" > /dev/null ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
2004-01-24 03:48:46 +03:00
$RPM -qp --qf "[%{OBSOLETES}\n]" "$f" | grep "(none)" > /dev/null ||
1998-11-24 04:20:10 +03:00
echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
2004-01-24 03:48:46 +03:00
$RPM -qp --qf "[%{PROVIDES}\n]" "$f" | grep "(none)" > /dev/null ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/PROVIDES"
2004-01-24 03:48:46 +03:00
test "`$RPM -qp --qf \"%{CHANGELOGTEXT}\" \"$f\"`" = "(none)" ||
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
else
echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
1998-11-24 04:20:10 +03:00
echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
1998-02-27 07:54:42 +03:00
echo "$FILEPREF 0 $DATE INFO/PROVIDES"
echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
fi
2002-12-17 03:32:38 +03:00
$RPM2CPIO "$1" | cpio -tv --quiet
2000-02-22 21:21:41 +03:00
echo "$FILEPREF 0 $DATE CONTENTS.cpio"
1998-02-27 07:54:42 +03:00
}
mcrpmfs_copyout ()
{
2004-01-24 03:48:46 +03:00
f="\"$1\""
1998-02-27 07:54:42 +03:00
case "$2" in
2004-01-24 03:48:46 +03:00
HEADER) $RPM -qip "$f" > "$3"; exit 0;;
1998-12-09 14:29:54 +03:00
INSTALL) echo "# Run this to install this RPM package" > "$3"; exit 0;;
UPGRADE) echo "# Run this to upgrade this RPM package" > "$3"; exit 0;;
2004-01-24 03:48:46 +03:00
ERROR) $RPM -qip "$f" > /dev/null 2> "$3"; exit 0;;
INFO/NAME-VERSION-RELEASE) $RPM -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" "$f" > "$3"; exit 0;;
INFO/RELEASE) $RPM -qp --qf "%{RELEASE}\n" "$f" > "$3"; exit 0;;
INFO/GROUP) $RPM -qp --qf "%{GROUP}\n" "$f" > "$3"; exit 0;;
INFO/DISTRIBUTION) $RPM -qp --qf "%{DISTRIBUTION}\n" "$f" > "$3"; exit 0;;
INFO/VENDOR) $RPM -qp --qf "%{VENDOR}\n" "$f" > "$3"; exit 0;;
INFO/BUILDHOST) $RPM -qp --qf "%{BUILDHOST}\n" "$f" > "$3"; exit 0;;
INFO/SOURCERPM) $RPM -qp --qf "%{SOURCERPM}\n" "$f" > "$3"; exit 0;;
INFO/DESCRIPTION) $RPM -qp --qf "%{DESCRIPTION}\n" "$f" > "$3"; exit 0;;
INFO/PACKAGER) $RPM -qp --qf "%{PACKAGER}\n" "$f" > "$3"; exit 0;;
INFO/URL) $RPM -qp --qf "%{URL}\n" "$f" >"$3"; exit 0;;
INFO/BUILDTIME) $RPM -qp --qf "%{BUILDTIME:date}\n" "$f" >"$3"; exit 0;;
INFO/SERIAL) $RPM -qp --qf "%{SERIAL}\n" "$f" >"$3"; exit 0;;
INFO/COPYRIGHT) $RPM -qp --qf "%{COPYRIGHT}\n" "$f" >"$3"; exit 0;;
INFO/RPMVERSION) $RPM -qp --qf "%{RPMVERSION}\n" "$f" >"$3"; exit 0;;
INFO/REQUIRENAME) $RPM -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" "$f" >"$3"; exit 0;;
INFO/PROVIDES) $RPM -qp --qf "[%{PROVIDES}\n]" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/PREIN) $RPM -qp --qf "%{RPMTAG_PREIN}\n" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/POSTIN) $RPM -qp --qf "%{RPMTAG_POSTIN}\n" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/PREUN) $RPM -qp --qf "%{RPMTAG_PREUN}\n" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/POSTUN) $RPM -qp --qf "%{RPMTAG_POSTUN}\n" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/VERIFYSCRIPT) $RPM -qp --qf "%{VERIFYSCRIPT}\n" "$f" >"$3"; exit 0;;
INFO/SCRIPTS/ALL) $RPM -qp --scripts "$f" > "$3"; exit 0;;
INFO/SUMMARY) $RPM -qp --qf "%{SUMMARY}\n" "$f" > "$3"; exit 0;;
INFO/OS) $RPM -qp --qf "%{OS}\n" "$f" > "$3"; exit 0;;
INFO/CHANGELOG) $RPM -qp --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" "$f" > "$3"; exit 0;;
INFO/SIZE) $RPM -qp --qf "%{SIZE} bytes\n" "$f" > "$3"; exit 0;;
2002-12-17 03:32:38 +03:00
CONTENTS.cpio) $RPM2CPIO "$1" > "$3"; exit 0;;
2001-04-16 21:54:48 +04:00
*)
TMPDIR=/tmp/mctmpdir.$$
mkdir $TMPDIR || exit 1
cd $TMPDIR
2001-04-20 00:51:41 +04:00
# Files in RPM version 4 and above start with "./" - try both
2002-12-17 03:32:38 +03:00
$RPM2CPIO "$1" | cpio -iumd --quiet "$2" "./$2" >/dev/null
2001-04-20 00:51:41 +04:00
mv "$2" "$3" 2>/dev/null
2001-04-16 21:54:48 +04:00
cd /
rm -rf $TMPDIR;;
1998-02-27 07:54:42 +03:00
esac
}
mcrpmfs_run ()
{
case "$2" in
2004-01-24 03:48:46 +03:00
INSTALL) echo "Installing \"\"$1\"\""; $RPM -ivh "$1"; exit 0;;
UPGRADE) echo "Upgrading \"\"$1\"\""; $RPM -iUvh "$1"; exit 0;;
1998-02-27 07:54:42 +03:00
esac
}
1998-12-16 09:16:13 +03:00
umask 077
1998-02-27 07:54:42 +03:00
case "$1" in
1998-12-09 14:29:54 +03:00
list) mcrpmfs_list "$2"; exit 0;;
copyout) mcrpmfs_copyout "$2" "$3" "$4"; exit 0;;
run) mcrpmfs_run "$2" "$3"; exit 1;;
1998-02-27 07:54:42 +03:00
esac
exit 1