1 | | #! /bin/sh |
2 | | # |
3 | | # Written by Erik Troan (ewt@redhat.com) 1996 |
4 | | # Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996,2004 |
5 | | # Tomasz K³oczko (kloczek@rudy.mif.pg.gda.pl) 1997 |
6 | | # minor changes by Wojtek Pilorz (wpilorz@bdk.lublin.pl) 1997 |
7 | | # minor changes by Michele Marziani (marziani@fe.infn.it) 1997 |
8 | | # bug files by Marc Merlin (marcsoft@merlins.org) 1998 |
9 | | # locale bugfix by Michal Svec (rebel@penguin.cz) 2000 |
10 | | # Whitespace(s) & single quote(s) in filename workaround |
11 | | # by Andrew V. Samoilov <sav@bcs.zp.ua> 2004 |
12 | | # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=64007 |
13 | | # |
14 | | # (C) 1996-2004 The Free Software Foundation. |
15 | | # |
16 | | |
17 | | # override any locale for dates |
18 | | unset LC_ALL |
19 | | LC_TIME=C |
20 | | export LC_TIME |
21 | | |
22 | | if rpmbuild --version >/dev/null 2>&1; then |
23 | | RPMBUILD="rpmbuild" |
24 | | else |
25 | | RPMBUILD="rpm" |
26 | | fi |
27 | | |
28 | | if rpm --nosignature --version >/dev/null 2>&1; then |
29 | | RPM="rpm --nosignature" |
30 | | RPMBUILD="$RPMBUILD --nosignature" |
31 | | else |
32 | | RPM="rpm" |
33 | | fi |
34 | | RPM2CPIO="rpm2cpio" |
35 | | SED="sed" |
36 | | # Surround the whole filename with single quotes and handle specially |
37 | | # \', ' and \ at the end of the string. |
38 | | SEDCMD="s/\\(\\\\\\?\\)'/'\\1\\1\\\\''/g;s/\\\\\$/'\\\\\\\\'/;s/^/'/;s/\$/'/" |
39 | | |
40 | | mcrpmfs_list () |
41 | | { |
42 | | # set MCFASTRPM_DFLT to 1 for faster rpm files handling by default, to 0 for |
43 | | # slower handling |
44 | | MCFASTRPM_DFLT=0 |
45 | | if test -z "$MCFASTRPM"; then |
46 | | MCFASTRPM=$MCFASTRPM_DFLT |
47 | | fi |
48 | | f="`echo "$1" | $SED "$SEDCMD"`" |
49 | | FILEPREF="-r--r--r-- 1 root root " |
50 | | DESC=`$RPM -qip "$f" 2>/dev/null` || { |
51 | | echo "$FILEPREF 0 "`date +"%b %d %H:%M"`" ERROR" |
52 | | exit 1 |
53 | | } |
54 | | DATE=`$RPM -qp --qf "%{BUILDTIME:date}\n" "$f" | cut -c 5-11,21-24` |
55 | | HEADERSIZE=`echo "$DESC" | wc -c` |
56 | | echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER" |
57 | | echo "-r-xr-xr-x 1 root root 39 $DATE INSTALL" |
58 | | echo "-r-xr-xr-x 1 root root 39 $DATE REBUILD" |
59 | | echo "dr-xr-xr-x 3 root root 0 $DATE INFO" |
60 | | echo "$FILEPREF 0 $DATE INFO/NAME-VERSION-RELEASE" |
61 | | echo "$FILEPREF 0 $DATE INFO/GROUP" |
62 | | echo "$FILEPREF 0 $DATE INFO/BUILDHOST" |
63 | | echo "$FILEPREF 0 $DATE INFO/SOURCERPM" |
64 | | if test "$MCFASTRPM" = 0 ; then |
65 | | test "`$RPM -qp --qf \"%{DISTRIBUTION}\" \"$f\"`" = "(none)" || |
66 | | echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" |
67 | | test "`$RPM -qp --qf \"%{VENDOR}\" \"$f\"`" = "(none)" || |
68 | | echo "$FILEPREF 0 $DATE INFO/VENDOR" |
69 | | test "`$RPM -qp --qf \"%{DESCRIPTION}\" \"$f\"`" = "(none)" || |
70 | | echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" |
71 | | test "`$RPM -qp --qf \"%{SUMMARY}\" \"$f\"`" = "(none)" || |
72 | | echo "$FILEPREF 0 $DATE INFO/SUMMARY" |
73 | | if test "`$RPM -qp --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" \"$f\"`" != "(none)(none)(none)(none)(none)"; then |
74 | | echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" |
75 | | test "`$RPM -qp --qf \"%{RPMTAG_PREIN}\" \"$f\"`" = '(none)' || |
76 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" |
77 | | test "`$RPM -qp --qf \"%{RPMTAG_POSTIN}\" \"$f\"`" = '(none)' || |
78 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" |
79 | | test "`$RPM -qp --qf \"%{RPMTAG_PREUN}\" \"$f\"`" = '(none)' || |
80 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" |
81 | | test "`$RPM -qp --qf \"%{RPMTAG_POSTUN}\" \"$f\"`" = '(none)' || |
82 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" |
83 | | test "`$RPM -qp --qf \"%{VERIFYSCRIPT}\" \"$f\"`" = '(none)' || |
84 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" |
85 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" |
86 | | fi |
87 | | else |
88 | | echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" |
89 | | echo "$FILEPREF 0 $DATE INFO/VENDOR" |
90 | | echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" |
91 | | echo "$FILEPREF 0 $DATE INFO/SUMMARY" |
92 | | echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" |
93 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" |
94 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" |
95 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" |
96 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" |
97 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" |
98 | | echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" |
99 | | fi |
100 | | if test "$MCFASTRPM" = 0 ; then |
101 | | test "`$RPM -qp --qf \"%{PACKAGER}\" \"$f\"`" = "(none)" || |
102 | | echo "$FILEPREF 0 $DATE INFO/PACKAGER" |
103 | | test "`$RPM -qp --qf \"%{URL}\" \"$f\"`" = "(none)" || |
104 | | echo "$FILEPREF 0 $DATE INFO/URL" |
105 | | test "`$RPM -qp --qf \"%{EPOCH}\" \"$f\"`" = "(none)" || |
106 | | echo "$FILEPREF 0 $DATE INFO/EPOCH" |
107 | | test "`$RPM -qp --qf \"%{LICENSE}\" \"$f\"`" = "(none)" || |
108 | | echo "$FILEPREF 0 $DATE INFO/LICENSE" |
109 | | else |
110 | | echo "$FILEPREF 0 $DATE INFO/PACKAGER" |
111 | | echo "$FILEPREF 0 $DATE INFO/URL" |
112 | | echo "$FILEPREF 0 $DATE INFO/EPOCH" |
113 | | echo "$FILEPREF 0 $DATE INFO/LICENSE" |
114 | | fi |
115 | | echo "$FILEPREF 0 $DATE INFO/BUILDTIME" |
116 | | echo "$FILEPREF 0 $DATE INFO/RPMVERSION" |
117 | | echo "$FILEPREF 0 $DATE INFO/OS" |
118 | | echo "$FILEPREF 0 $DATE INFO/SIZE" |
119 | | if test "$MCFASTRPM" != 0 ; then |
120 | | $RPM -qp --qf "[%{REQUIRENAME}\n]" "$f" | grep "(none)" > /dev/null || |
121 | | echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" |
122 | | $RPM -qp --qf "[%{OBSOLETES}\n]" "$f" | grep "(none)" > /dev/null || |
123 | | echo "$FILEPREF 0 $DATE INFO/OBSOLETES" |
124 | | $RPM -qp --qf "[%{PROVIDES}\n]" "$f" | grep "(none)" > /dev/null || |
125 | | echo "$FILEPREF 0 $DATE INFO/PROVIDES" |
126 | | $RPM -qp --qf "[%{CONFLICTS}\n]" "$f" | grep "(none)" > /dev/null || |
127 | | echo "$FILEPREF 0 $DATE INFO/CONFLICTS" |
128 | | test "`$RPM -qp --qf \"%{CHANGELOGTEXT}\" \"$f\"`" = "(none)" || |
129 | | echo "$FILEPREF 0 $DATE INFO/CHANGELOG" |
130 | | else |
131 | | echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" |
132 | | echo "$FILEPREF 0 $DATE INFO/OBSOLETES" |
133 | | echo "$FILEPREF 0 $DATE INFO/PROVIDES" |
134 | | echo "$FILEPREF 0 $DATE INFO/CONFLICTS" |
135 | | echo "$FILEPREF 0 $DATE INFO/CHANGELOG" |
136 | | fi |
137 | | |
138 | | echo "$FILEPREF 0 $DATE CONTENTS.cpio" |
139 | | } |
140 | | |
141 | | mcrpmfs_copyout () |
142 | | { |
143 | | f="`echo "$1" | $SED "$SEDCMD"`" |
144 | | case "$2" in |
145 | | HEADER) $RPM -qip "$f" > "$3"; exit 0;; |
146 | | INSTALL) echo "# Run this to install this RPM package" > "$3"; exit 0;; |
147 | | REBUILD) echo "# Run this to rebuild this RPM package" > "$3"; exit 0;; |
148 | | ERROR) $RPM -qip "$f" > /dev/null 2> "$3"; exit 0;; |
149 | | INFO/NAME-VERSION-RELEASE) $RPM -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" "$f" > "$3"; exit 0;; |
150 | | INFO/RELEASE) $RPM -qp --qf "%{RELEASE}\n" "$f" > "$3"; exit 0;; |
151 | | INFO/GROUP) $RPM -qp --qf "%{GROUP}\n" "$f" > "$3"; exit 0;; |
152 | | INFO/DISTRIBUTION) $RPM -qp --qf "%{DISTRIBUTION}\n" "$f" > "$3"; exit 0;; |
153 | | INFO/VENDOR) $RPM -qp --qf "%{VENDOR}\n" "$f" > "$3"; exit 0;; |
154 | | INFO/BUILDHOST) $RPM -qp --qf "%{BUILDHOST}\n" "$f" > "$3"; exit 0;; |
155 | | INFO/SOURCERPM) $RPM -qp --qf "%{SOURCERPM}\n" "$f" > "$3"; exit 0;; |
156 | | INFO/DESCRIPTION) $RPM -qp --qf "%{DESCRIPTION}\n" "$f" > "$3"; exit 0;; |
157 | | INFO/PACKAGER) $RPM -qp --qf "%{PACKAGER}\n" "$f" > "$3"; exit 0;; |
158 | | INFO/URL) $RPM -qp --qf "%{URL}\n" "$f" >"$3"; exit 0;; |
159 | | INFO/BUILDTIME) $RPM -qp --qf "%{BUILDTIME:date}\n" "$f" >"$3"; exit 0;; |
160 | | INFO/EPOCH) $RPM -qp --qf "%{EPOCH}\n" "$f" >"$3"; exit 0;; |
161 | | INFO/LICENSE) $RPM -qp --qf "%{LICENSE}\n" "$f" >"$3"; exit 0;; |
162 | | INFO/RPMVERSION) $RPM -qp --qf "%{RPMVERSION}\n" "$f" >"$3"; exit 0;; |
163 | | INFO/REQUIRENAME) $RPM -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" "$f" >"$3"; exit 0;; |
164 | | INFO/PROVIDES) $RPM -qp --qf "[%{PROVIDES}\n]" "$f" >"$3"; exit 0;; |
165 | | INFO/SCRIPTS/PREIN) $RPM -qp --qf "%{RPMTAG_PREIN}\n" "$f" >"$3"; exit 0;; |
166 | | INFO/SCRIPTS/POSTIN) $RPM -qp --qf "%{RPMTAG_POSTIN}\n" "$f" >"$3"; exit 0;; |
167 | | INFO/SCRIPTS/PREUN) $RPM -qp --qf "%{RPMTAG_PREUN}\n" "$f" >"$3"; exit 0;; |
168 | | INFO/SCRIPTS/POSTUN) $RPM -qp --qf "%{RPMTAG_POSTUN}\n" "$f" >"$3"; exit 0;; |
169 | | INFO/SCRIPTS/VERIFYSCRIPT) $RPM -qp --qf "%{VERIFYSCRIPT}\n" "$f" >"$3"; exit 0;; |
170 | | INFO/SCRIPTS/ALL) $RPM -qp --scripts "$f" > "$3"; exit 0;; |
171 | | INFO/SUMMARY) $RPM -qp --qf "%{SUMMARY}\n" "$f" > "$3"; exit 0;; |
172 | | INFO/OS) $RPM -qp --qf "%{OS}\n" "$f" > "$3"; exit 0;; |
173 | | INFO/CHANGELOG) $RPM -qp --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" "$f" > "$3"; exit 0;; |
174 | | INFO/SIZE) $RPM -qp --qf "%{SIZE} bytes\n" "$f" > "$3"; exit 0;; |
175 | | INFO/OBSOLETES) $RPM -qp --qf "[%{OBSOLETENAME} %|OBSOLETEFLAGS?{%{OBSOLETEFLAGS:depflags} %{OBSOLETEVERSION}}:{}|\n]" "$f" > "$3"; exit 0;; |
176 | | INFO/CONFLICTS) $RPM -qp --qf "[%{CONFLICTNAME} %{CONFLICTFLAGS:depflags} %{CONFLICTVERSION}\n]" "$f" >"$3"; exit 0;; |
177 | | CONTENTS.cpio) $RPM2CPIO "$1" > "$3"; exit 0;; |
178 | | *) |
179 | | ;; |
180 | | esac |
181 | | } |
182 | | |
183 | | mcrpmfs_run () |
184 | | { |
185 | | f="`echo "$1" | $SED "$SEDCMD"`" |
186 | | case "$2" in |
187 | | INSTALL) echo "Installing \"\"$f\"\""; $RPM -ivh "$f"; exit 0;; |
188 | | REBUILD) echo "Rebuilding \"$1\""; $RPMBUILD --rebuild "$1"; exit 0;; |
189 | | esac |
190 | | } |
191 | | |
192 | | umask 077 |
193 | | case "$1" in |
194 | | list) mcrpmfs_list "$2"; exit 0;; |
195 | | copyout) mcrpmfs_copyout "$2" "$3" "$4"; exit 0;; |
196 | | run) mcrpmfs_run "$2" "$3"; exit 1;; |
197 | | esac |
198 | | exit 1 |