summaryrefslogtreecommitdiff
path: root/scripts/trpm
blob: 806d08241b62e8cfe2b1cf8badc234c1bc9ed78d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#!/bin/sh

ulimit -S -c unlimited
dbg=	# echo

rpm=/bin/rpm
#rpm=/X/src/rpm/rpm
#rpmi=mrpm
#rpmi="strace -o xxx /bin/rpm"
rpmi="$rpm"
#rpmi=/usr/lib/rpm/rpmi
rpmb=/usr/bin/rpmbuild
rpmq=/usr/bin/rpmquery
rpmdb=/usr/bin/rpmdb
rpmk=/usr/bin/rpmsign

pgppubkey="`echo /usr/share/doc/rpm-4*/RPM-PGP-KEY`"
gpgpubkey="`echo /usr/share/doc/rpm-4*/RPM-GPG-KEY`"
betapubkey="`echo /usr/share/doc/rpm-4*/BETA-GPG-KEY`"

#rpm=/X/src/rpm402/rpm
#rpmb=/X/src/rpm402/rpmb
#rpmq=/X/src/rpm402/rpmq
#rpmdb=/X/src/rpm402/rpmdb

#rpm=/X/src/rpm307/rpm
#rpmb=$rpm
#rpmq=$rpm
#rpmdb=$rpm

dist=8.0
type=min
arch=`$rpm --eval '%{_arch}' | sed -e 's/i686/i386/'`

top=`pwd`
root=$top/$dist
sudo=sudo
justdb="--justdb --noscripts --notriggers --ignoresize"
dmopts="-l dmalloc.log -i 100 low"
db1=
rc="--rcfile $top/rpmrc-$dist"
sorted=	# "| sort"

min0glob="
basesystem-
bash-[12]
filesystem-
glibc-common-
glibc-2
ldconfig-
libtermcap-2
mktemp-
setup-
termcap-
"

min1glob="
$min0glob
bzip2-[01]
bzip2-libs-
chkconfig-
coreutils-
db1-1
db2-2
db3-3
db4-4
dev-
diffutils-
e2fsprogs-1
fileutils-
findutils-
gawk-
gdb-
gdbm-1
grep-
gzip-
info-
less-
libacl-2
libattr-2
mount-
ncurses-[45]
pcre-
procps-2
psmisc-
sed-
shadow-utils-
readline-[24]
rmt-
tar-
textutils-
vim-common-
vim-minimal-
zlib-1
"

min2glob="
$min1glob
cpio-
cracklib-
glib-1
logrotate-
mingetty-
popt-
pwdb-
slang-[01]
which-
words-
"

baseglob="
$min2glob
ash-
bdflush-
console-tools-
cyrus-sasl-[12]
cyrus-sasl-md5-
elfutils-libelf-
glib2-2
gmp-[234]
initscripts-
iputils-
iproute-
kbd-
kernel-2
krb5-libs-
libuser-
libelf-*
losetup-
lvm-
mkinitrd-
modutils-
net-tools-
openldap-2
openssl-0
pam-0
pamconfig-
redhat-release-
sh-utils-
sysklogd-
usermode-1
util-linux-
vixie-cron-
rpm-[34]
rpm-devel-[34]
sash-
SysVinit-
"

develglob="
$baseglob
bzip2-devel-
db1-devel-
db2-devel-
db3-devel-
db4-devel-
gdbm-devel-
glibc-devel-
glibc-kernheaders-
gmp-devel-
kernel-headers-
readline-devel-[24]
tcl-
zlib-devel-
"

buildglob="
$develglob
autoconf-
automake-
bash2-
binutils-
cpp-
cvs-
db3-utils-
db4-utils-
egcs-1
egcs-c++-1
expat-1
gcc-[23]
gcc-c++-[23]
gettext-
krb5-configs-
libgcc-3
libgcj-3
libstdc++-
libtool-
make-
m4-
ncurses-devel-
patch-
perl-5
perl-CGI-
perl-Filter-
perl-Parse-RecDescent-
python-[12]
rpm-build-
file-3
tcsh-
zip-
"

mozillaglob="
$buildglob
compat-libstdc++-7
curl-
fontconfig-2
freetype-2
gtk+-1
indexhtml-
libao-0
libjpeg-
libpng-
libogg-
libvorbis-
mozilla-
ORBit-0
redhat-menus-
vorbis-tools-
XFree86-Mesa-libGL-
XFree86-libs-[34]
XFree86-libs-data-
"

classes="min0 min1 min2 base devel build mozilla"
notallpat="(kernel-[^2h])"

for cmd in $*
do
    [ $# -eq 0 ] && break
    shift
    echo "******** args: $*"
    echo "=======> start $cmd	`date`"
    case $cmd in
    debug)		dbg=echo	;;
    dmalloc)		eval `dmalloc -b $dmopts`	;;
    db1)		db1="--define '%_dbapi 1'"	;;
    5.2|6.2|7.*|8.*)
	dist=$cmd
	root=$top/$dist
	rc="--rcfile $top/rpmrc-$dist $db1"
	$dbg mkdir -p $root/{dev,X/RPMS,X/SRPMS}
	[ -c $root/dev/null ] || $dbg $sudo mknod $root/dev/null c 1 3
	[ -f $top/rpmrc-$dist ] || cat << EOF > $top/rpmrc-$dist
include:    /usr/lib/rpm/rpmrc
macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:$top/macros:$top/macros-$dist-$arch
EOF
	[ -f $top/macros-$dist-$arch ] || cat << EOF > $top/macros-$dist-$arch
%_topdir	$root/X
EOF
	;;
    config)
	[ -f $top/macros ] || cat << EOF > $top/macros
%_ntopdir	%{_topdir}/%{name}-%{version}-%{release}
%_builddir	%{_ntopdir}
%_sourcedir	%{_ntopdir}
%_specdir	%{_ntopdir}
%_rpmfilename	%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%_rpmdir	%{_topdir}/RPMS
%_srcrpmdir	%{_topdir}/SRPMS
EOF
	;;
    manifest)
	rm -f *-$dist-$arch
	pkgs="/$dist/$arch"
 	ls -1 ${pkgs}/*.rpm | egrep "(noarch|$arch).rpm" > list-$dist-$arch
	cat list-$dist-$arch | egrep -v $notallpat > all-$dist-$arch
	$dbg $rpmq $rc -qp --qf "/$dist/SRPMS/%{sourcerpm}\\n" \
`cat all-$dist-$arch` | sort | uniq > all-$dist-$arch-srpms
	for l in $classes ; do
	    glv='$'${l}glob
	    glist="`eval echo $glv`"
	    for g in $glist ; do
		ls -1 ${pkgs}/${g}*.rpm 2> /dev/null
	    done | egrep "(noarch|$arch).rpm" $sorted > $l-$dist-$arch
	    $dbg $rpmq $rc -qp --qf "/$dist/SRPMS/%{sourcerpm}\\n" \
`cat $l-$dist-$arch` | sort | uniq > $l-$dist-$arch-srpms
	done
	;;
    clean)
	$dbg rm -f $top/{rpmrc-$dist,macros-$dist-$arch,macros}
	$dbg $sudo mv $root ${root}-$$ && $dbg $sudo rm -rf ${root}-$$
	;;
    --rebuild)
	for srpm in `cat $type-$dist-$arch-srpms` ; do
	    $dbg $rpmb $rc $cmd $srpm
	done
	;;
    --initdb)
	$dbg $sudo mkdir -p $root/var/lib/rpm
	$dbg $sudo mkdir -p $root/etc
	$dbg $sudo touch $root/etc/fstab
	$dbg $sudo touch $root/etc/mtab
	$dbg $sudo $rpmdb $rc --root $root --initdb
	if [ X"`$rpm --version`" = X"RPM version 4.2" ]; then
	    $dbg $sudo $rpmk $rc --root $root --import $pgppubkey
	    $dbg $sudo $rpmk $rc --root $root --import $gpgpubkey
	    $dbg $sudo $rpmk $rc --root $root --import $betapubkey
	fi
	;;
    --savedb)
	( $dbg cd $root/var/lib && $dbg $sudo tar czvf rpmdb.tar.gz rpm ; )
	;;
    --rebuilddb)
	$dbg $sudo $rpmdb $rc --root $root --rebuilddb -vv
	;;
    --justdb)
	[ -f $type-$dist-$arch ] || {
	    echo $type-$dist-$arch not found
	    exit 1
	}
	$dbg $sudo $rpmi $rc --root $root -Uv $justdb `cat $type-$dist-$arch`
	;;
    -U*|-F*)
	[ -f $type-$dist-$arch ] || {
	    echo $type-$dist-$arch not found
	    exit 1
	}
	$dbg $sudo $rpmi $rc --root $root $cmd $* `cat $type-$dist-$arch`
	set ""
	;;
    -[Vqei]*|--showrc)
	$dbg $sudo $rpm $rc --root $root $cmd
	;;
    chroot)
	$dbg $sudo touch $root/etc/mtab
	$dbg $sudo cp /etc/resolv.conf /etc/fstab $root/etc
	$dbg $sudo env HOME=/root chroot $root
	;;
    *)		type=$cmd	;;
    esac
done
echo "=======> finish	`date`"