#! /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 # bug files by Marc Merlin (marcsoft@merlins.org) 1998 # locale bugfix by Michal Svec (rebel@penguin.cz) 2000 # (C) 1996 The Free Software Foundation. # # # override any locale for dates unset LC_ALL LC_TIME=C export LC_TIME if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" else RPM="rpm" fi RPM2CPIO="rpm2cpio" 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 " DESC=`$RPM -qip "$1" 2>/dev/null` || { echo "$FILEPREF 0 "`date +"%b %d %H:%M"`" ERROR" exit 1 } DATE=`$RPM -qp --qf "%{BUILDTIME:date}\n" "$1" | cut -c 5-11,21-24` HEADERSIZE=`echo "$DESC" | wc -c` echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER" 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 test "`$RPM -qp --qf \"%{DISTRIBUTION}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" test "`$RPM -qp --qf \"%{VENDOR}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/VENDOR" test "`$RPM -qp --qf \"%{DESCRIPTION}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" test "`$RPM -qp --qf \"%{SUMMARY}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/SUMMARY" if test "`$RPM -qp --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" \"$1\"`" != "(none)(none)(none)(none)(none)"; then echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" test "`$RPM -qp --qf \"%{RPMTAG_PREIN}\" \"$1\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" test "`$RPM -qp --qf \"%{RPMTAG_POSTIN}\" \"$1\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" test "`$RPM -qp --qf \"%{RPMTAG_PREUN}\" \"$1\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" test "`$RPM -qp --qf \"%{RPMTAG_POSTUN}\" \"$1\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" test "`$RPM -qp --qf \"%{VERIFYSCRIPT}\" \"$1\"`" = '(none)' || 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 test "`$RPM -qp --qf \"%{PACKAGER}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/PACKAGER" test "`$RPM -qp --qf \"%{URL}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/URL" test "`$RPM -qp --qf \"%{SERIAL}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/SERIAL" test "`$RPM -qp --qf \"%{COPYRIGHT}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/COPYRIGHT" test "`$RPM -qp --qf \"%{LICENSE}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/LICENSE" 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" echo "$FILEPREF 0 $DATE INFO/LICENSE" 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 $RPM -qp --qf "[%{REQUIRENAME}\n]" "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" $RPM -qp --qf "[%{OBSOLETES}\n]" "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/OBSOLETES" $RPM -qp --qf "[%{PROVIDES}\n]" "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/PROVIDES" test "`$RPM -qp --qf \"%{CHANGELOGTEXT}\" \"$1\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/CHANGELOG" else echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" echo "$FILEPREF 0 $DATE INFO/OBSOLETES" echo "$FILEPREF 0 $DATE INFO/PROVIDES" echo "$FILEPREF 0 $DATE INFO/CHANGELOG" fi $RPM2CPIO "$1" | cpio -tv --quiet echo "$FILEPREF 0 $DATE CONTENTS.cpio" } mcrpmfs_copyout () { case "$2" in HEADER) $RPM -qip "$1" > "$3"; exit 0;; INSTALL) echo "# Run this to install this RPM package" > "$3"; exit 0;; UPGRADE) echo "# Run this to upgrade this RPM package" > "$3"; exit 0;; ERROR) $RPM -qip "$1" > /dev/null 2> "$3"; exit 0;; INFO/NAME-VERSION-RELEASE) $RPM -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" "$1" > "$3"; exit 0;; INFO/RELEASE) $RPM -qp --qf "%{RELEASE}\n" "$1" > "$3"; exit 0;; INFO/GROUP) $RPM -qp --qf "%{GROUP}\n" "$1" > "$3"; exit 0;; INFO/DISTRIBUTION) $RPM -qp --qf "%{DISTRIBUTION}\n" "$1" > "$3"; exit 0;; INFO/VENDOR) $RPM -qp --qf "%{VENDOR}\n" "$1" > "$3"; exit 0;; INFO/BUILDHOST) $RPM -qp --qf "%{BUILDHOST}\n" "$1" > "$3"; exit 0;; INFO/SOURCERPM) $RPM -qp --qf "%{SOURCERPM}\n" "$1" > "$3"; exit 0;; INFO/DESCRIPTION) $RPM -qp --qf "%{DESCRIPTION}\n" "$1" > "$3"; exit 0;; INFO/PACKAGER) $RPM -qp --qf "%{PACKAGER}\n" "$1" > "$3"; exit 0;; INFO/URL) $RPM -qp --qf "%{URL}\n" "$1" >"$3"; exit 0;; INFO/BUILDTIME) $RPM -qp --qf "%{BUILDTIME:date}\n" "$1" >"$3"; exit 0;; INFO/SERIAL) $RPM -qp --qf "%{SERIAL}\n" "$1" >"$3"; exit 0;; INFO/COPYRIGHT) $RPM -qp --qf "%{COPYRIGHT}\n" "$1" >"$3"; exit 0;; INFO/RPMVERSION) $RPM -qp --qf "%{RPMVERSION}\n" "$1" >"$3"; exit 0;; INFO/REQUIRENAME) $RPM -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" "$1" >"$3"; exit 0;; INFO/PROVIDES) $RPM -qp --qf "[%{PROVIDES}\n]" "$1" >"$3"; exit 0;; INFO/SCRIPTS/PREIN) $RPM -qp --qf "%{RPMTAG_PREIN}\n" "$1" >"$3"; exit 0;; INFO/SCRIPTS/POSTIN) $RPM -qp --qf "%{RPMTAG_POSTIN}\n" "$1" >"$3"; exit 0;; INFO/SCRIPTS/PREUN) $RPM -qp --qf "%{RPMTAG_PREUN}\n" "$1" >"$3"; exit 0;; INFO/SCRIPTS/POSTUN) $RPM -qp --qf "%{RPMTAG_POSTUN}\n" "$1" >"$3"; exit 0;; INFO/SCRIPTS/VERIFYSCRIPT) $RPM -qp --qf "%{VERIFYSCRIPT}\n" "$1" >"$3"; exit 0;; INFO/SCRIPTS/ALL) $RPM -qp --scripts "$1" > "$3"; exit 0;; INFO/SUMMARY) $RPM -qp --qf "%{SUMMARY}\n" "$1" > "$3"; exit 0;; INFO/OS) $RPM -qp --qf "%{OS}\n" "$1" > "$3"; exit 0;; INFO/CHANGELOG) $RPM -qp --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" "$1" > "$3"; exit 0;; INFO/SIZE) $RPM -qp --qf "%{SIZE} bytes\n" "$1" > "$3"; exit 0;; CONTENTS.cpio) $RPM2CPIO "$1" > "$3"; exit 0;; *) TMPDIR=/tmp/mctmpdir.$$ mkdir $TMPDIR || exit 1 cd $TMPDIR # Files in RPM version 4 and above start with "./" - try both $RPM2CPIO "$1" | cpio -iumd --quiet "$2" "./$2" >/dev/null mv "$2" "$3" 2>/dev/null cd / rm -rf $TMPDIR;; esac } mcrpmfs_run () { case "$2" in INSTALL) echo "Installing \"$1\""; $RPM -ivh "$1"; exit 0;; UPGRADE) echo "Upgrading \"$1\""; $RPM -iUvh "$1"; exit 0;; esac } umask 077 case "$1" in list) mcrpmfs_list "$2"; exit 0;; copyout) mcrpmfs_copyout "$2" "$3" "$4"; exit 0;; run) mcrpmfs_run "$2" "$3"; exit 1;; esac exit 1