trpm 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #! /bin/sh
  2. #
  3. # Browse contents of an installed RPM package.
  4. # This filesystem works on the entries of the "rpms" filesystem.
  5. #
  6. # Written by Erik Troan (ewt@redhat.com) 1996
  7. # Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996
  8. # Tomasz K³oczko (kloczek@rudy.mif.pg.gda.pl) 1997
  9. # minor changes by Wojtek Pilorz (wpilorz@bdk.lublin.pl) 1997
  10. # minor changes by Michele Marziani (marziani@fe.infn.it) 1997
  11. # slight changes to put rpm to Trpm by Balazs Nagy (julian7@kva.hu) 1998
  12. # locale bugfix by Michal Svec (rebel@penguin.cz) 2000
  13. # (C) 1996 The Free Software Foundation.
  14. #
  15. #
  16. # override any locale for dates
  17. unset LC_ALL
  18. LC_TIME=C
  19. export LC_TIME
  20. if rpm --nosignature --version >/dev/null 2>&1; then
  21. RPM="rpm --nosignature"
  22. else
  23. RPM="rpm"
  24. fi
  25. mcrpmfs_list ()
  26. {
  27. # set MCFASTRPM_DFLT to 1 for faster rpm files handling by default, to 0 for
  28. # slower handling
  29. MCFASTRPM_DFLT=0
  30. if test -z "$MCFASTRPM"; then
  31. MCFASTRPM=$MCFASTRPM_DFLT
  32. fi
  33. FILEPREF="-r--r--r-- 1 root root "
  34. DESC=`$RPM -qi -- "$1"`
  35. DATE=`$RPM -q --qf "%{BUILDTIME:date}" -- "$1" | cut -c 5-11,21-24`
  36. HEADERSIZE=`echo "$DESC" | wc -c`
  37. echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER"
  38. echo "-r-xr-xr-x 1 root root 40 $DATE UNINSTALL"
  39. echo "dr-xr-xr-x 3 root root 0 $DATE INFO"
  40. echo "$FILEPREF 0 $DATE INFO/NAME-VERSION-RELEASE"
  41. echo "$FILEPREF 0 $DATE INFO/GROUP"
  42. echo "$FILEPREF 0 $DATE INFO/BUILDHOST"
  43. echo "$FILEPREF 0 $DATE INFO/SOURCERPM"
  44. if test "$MCFASTRPM" = 0 ; then
  45. test "`$RPM -q --qf \"%{DISTRIBUTION}\" -- "$1"`" = "(none)" ||
  46. echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION"
  47. test "`$RPM -q --qf \"%{VENDOR}\" -- "$1"`" = "(none)" ||
  48. echo "$FILEPREF 0 $DATE INFO/VENDOR"
  49. test "`$RPM -q --qf \"%{DESCRIPTION}\" -- "$1"`" = "(none)" ||
  50. echo "$FILEPREF 0 $DATE INFO/DESCRIPTION"
  51. test "`$RPM -q --qf \"%{SUMMARY}\" -- "$1"`" = "(none)" ||
  52. echo "$FILEPREF 0 $DATE INFO/SUMMARY"
  53. if test "`$RPM -q --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" -- "$1"`" != "(none)(none)(none)(none)(none)"; then
  54. echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS"
  55. test "`$RPM -q --qf \"%{RPMTAG_PREIN}\" -- "$1"`" = '(none)' ||
  56. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN"
  57. test "`$RPM -q --qf \"%{RPMTAG_POSTIN}\" -- "$1"`" = '(none)' ||
  58. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN"
  59. test "`$RPM -q --qf \"%{RPMTAG_PREUN}\" -- "$1"`" = '(none)' ||
  60. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN"
  61. test "`$RPM -q --qf \"%{RPMTAG_POSTUN}\" -- "$1"`" = '(none)' ||
  62. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN"
  63. test "`$RPM -q --qf \"%{VERIFYSCRIPT}\" -- "$1"`" = '(none)' ||
  64. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT"
  65. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL"
  66. fi
  67. else
  68. echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION"
  69. echo "$FILEPREF 0 $DATE INFO/VENDOR"
  70. echo "$FILEPREF 0 $DATE INFO/DESCRIPTION"
  71. echo "$FILEPREF 0 $DATE INFO/SUMMARY"
  72. echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS"
  73. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN"
  74. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN"
  75. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN"
  76. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN"
  77. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT"
  78. echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL"
  79. fi
  80. if test "$MCFASTRPM" = 0 ; then
  81. test "`$RPM -q --qf \"%{PACKAGER}\" -- "$1"`" = "(none)" ||
  82. echo "$FILEPREF 0 $DATE INFO/PACKAGER"
  83. test "`$RPM -q --qf \"%{URL}\" -- "$1"`" = "(none)" ||
  84. echo "$FILEPREF 0 $DATE INFO/URL"
  85. test "`$RPM -q --qf \"%{EPOCH}\" -- "$1"`" = "(none)" ||
  86. echo "$FILEPREF 0 $DATE INFO/EPOCH"
  87. test "`$RPM -q --qf \"%{LICENSE}\" -- "$1"`" = "(none)" ||
  88. echo "$FILEPREF 0 $DATE INFO/LICENSE"
  89. else
  90. echo "$FILEPREF 0 $DATE INFO/PACKAGER"
  91. echo "$FILEPREF 0 $DATE INFO/URL"
  92. echo "$FILEPREF 0 $DATE INFO/EPOCH"
  93. echo "$FILEPREF 0 $DATE INFO/LICENSE"
  94. fi
  95. echo "$FILEPREF 0 $DATE INFO/BUILDTIME"
  96. echo "$FILEPREF 0 $DATE INFO/RPMVERSION"
  97. echo "$FILEPREF 0 $DATE INFO/OS"
  98. echo "$FILEPREF 0 $DATE INFO/SIZE"
  99. if test "$MCFASTRPM" != 0 ; then
  100. $RPM -q --qf "[%{REQUIRENAME}\n]" -- "$1" | grep "(none)" > /dev/null ||
  101. echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
  102. $RPM -q --qf "[%{OBSOLETES}\n]" -- "$1" | grep "(none)" > /dev/null ||
  103. echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
  104. $RPM -q --qf "[%{PROVIDES}\n]" -- "$1" | grep "(none)" > /dev/null ||
  105. echo "$FILEPREF 0 $DATE INFO/PROVIDES"
  106. $RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" | grep "(none)" > /dev/null ||
  107. echo "$FILEPREF 0 $DATE INFO/CONFLICTS"
  108. test "`$RPM -q --qf \"%{CHANGELOGTEXT}\" -- "$1"`" = "(none)" ||
  109. echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
  110. else
  111. echo "$FILEPREF 0 $DATE INFO/REQUIRENAME"
  112. echo "$FILEPREF 0 $DATE INFO/OBSOLETES"
  113. echo "$FILEPREF 0 $DATE INFO/PROVIDES"
  114. echo "$FILEPREF 0 $DATE INFO/CONFLICTS"
  115. echo "$FILEPREF 0 $DATE INFO/CHANGELOG"
  116. fi
  117. $RPM -qlv -- "$1" | grep '^[A-Za-z0-9-]'
  118. }
  119. mcrpmfs_copyout ()
  120. {
  121. case "$2" in
  122. HEADER) $RPM -qi -- "$1" > "$3"; exit 0;;
  123. UNINSTALL) echo "# Run this to uninstall this RPM package" > "$3"; exit 0;;
  124. INFO/NAME-VERSION-RELEASE) $RPM -q --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" -- "$1" > "$3"; exit 0;;
  125. INFO/RELEASE) $RPM -q --qf "%{RELEASE}\n" -- "$1" > "$3"; exit 0;;
  126. INFO/GROUP) $RPM -q --qf "%{GROUP}\n" -- "$1" > "$3"; exit 0;;
  127. INFO/DISTRIBUTION) $RPM -q --qf "%{DISTRIBUTION}\n" -- "$1" > "$3"; exit 0;;
  128. INFO/VENDOR) $RPM -q --qf "%{VENDOR}\n" -- "$1" > "$3"; exit 0;;
  129. INFO/BUILDHOST) $RPM -q --qf "%{BUILDHOST}\n" -- "$1" > "$3"; exit 0;;
  130. INFO/SOURCERPM) $RPM -q --qf "%{SOURCERPM}\n" -- "$1" > "$3"; exit 0;;
  131. INFO/DESCRIPTION) $RPM -q --qf "%{DESCRIPTION}\n" -- "$1" > "$3"; exit 0;;
  132. INFO/PACKAGER) $RPM -q --qf "%{PACKAGER}\n" -- "$1" > "$3"; exit 0;;
  133. INFO/URL) $RPM -q --qf "%{URL}\n" -- "$1" > "$3"; exit 0;;
  134. INFO/BUILDTIME) $RPM -q --qf "%{BUILDTIME:date}\n" -- "$1" > "$3"; exit 0;;
  135. INFO/EPOCH) $RPM -q --qf "%{EPOCH}\n" -- "$1" > "$3"; exit 0;;
  136. INFO/LICENSE) $RPM -q --qf "%{LICENSE}\n" -- "$1" > "$3"; exit 0;;
  137. INFO/RPMVERSION) $RPM -q --qf "%{RPMVERSION}\n" -- "$1" > "$3"; exit 0;;
  138. INFO/REQUIRENAME) $RPM -q --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" -- "$1" > "$3"; exit 0;;
  139. INFO/OBSOLETES) $RPM -q --qf "[%{OBSOLETENAME} %|OBSOLETEFLAGS?{%{OBSOLETEFLAGS:depflags} %{OBSOLETEVERSION}}:{}|\n]" -- "$1" > "$3"; exit 0;;
  140. INFO/PROVIDES) $RPM -q --qf "[%{PROVIDES}\n]" -- "$1" > "$3"; exit 0;;
  141. INFO/CONFLICTS) $RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" > "$3"; exit 0;;
  142. INFO/SCRIPTS/PREIN) $RPM -q --qf "%{RPMTAG_PREIN}\n" -- "$1" > "$3"; exit 0;;
  143. INFO/SCRIPTS/POSTIN) $RPM -q --qf "%{RPMTAG_POSTIN}\n" -- "$1" > "$3"; exit 0;;
  144. INFO/SCRIPTS/PREUN) $RPM -q --qf "%{RPMTAG_PREUN}\n" -- "$1" > "$3"; exit 0;;
  145. INFO/SCRIPTS/POSTUN) $RPM -q --qf "%{RPMTAG_POSTUN}\n" -- "$1" > "$3"; exit 0;;
  146. INFO/SCRIPTS/VERIFYSCRIPT) $RPM -q --qf "%{VERIFYSCRIPT}\n" -- "$1" > "$3"; exit 0;;
  147. INFO/SCRIPTS/ALL) $RPM -q --scripts -- "$1" > "$3"; exit 0;;
  148. INFO/SUMMARY) $RPM -q --qf "%{SUMMARY}\n" -- "$1" > "$3"; exit 0;;
  149. INFO/OS) $RPM -q --qf "%{OS}\n" -- "$1" > "$3"; exit 0;;
  150. INFO/CHANGELOG) $RPM -q --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" -- "$1" > "$3"; exit 0;;
  151. INFO/SIZE) $RPM -q --qf "%{SIZE} bytes\n" -- "$1" > "$3"; exit 0;;
  152. *)
  153. cp "/$2" "$3"
  154. esac
  155. }
  156. mcrpmfs_run ()
  157. {
  158. case "$2" in
  159. UNINSTALL) echo "Uninstalling $1"; rpm -e -- "$1"; exit 0;;
  160. esac
  161. }
  162. name=`sed 's/.*\///;s/\.trpm$//' "$2"`
  163. case "$1" in
  164. list) mcrpmfs_list "$name"; exit 0;;
  165. copyout) mcrpmfs_copyout "$name" "$3" "$4"; exit 0;;
  166. run) mcrpmfs_run "$name" "$3"; exit 1;;
  167. esac
  168. exit 1