summaryrefslogtreecommitdiff
path: root/scripts/trpm
blob: 71863c4526e261180a8e766824820677c910dcf4 (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
#!/bin/sh

dbg=	# echo

dist=7.0
type=all
arch=`/bin/rpm --eval '%{_arch}'`

root=`pwd`/root
sudo=sudo
rpm="/X/src/rpm401/rpm --root $root"
rpmb=/usr/bin/rpmbuild
rpmdb=/usr/bin/rpmdb
justdb="--justdb --noscripts --notriggers --ignoresize"
dmopts="-l dmalloc.log -i 100 low"
db1=
sorted=	# "| sort"

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

min1glob="
$minglob
bzip2-[01]
chkconfig-
db1-1
db2-2
db3-3
dev-
diffutils-
e2fsprogs-1
fileutils-
findutils-
gawk-
gdb-
gdbm-1
grep-
gzip-
info-
mount-
ncurses-[45]
procps-2
psmisc-
sed-
shadow-utils-
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
console-tools-
initscripts-
kernel-2
modutils-
pam-0
pamconfig-
sh-utils-
sysklogd-
util-linux-
vixie-cron-
rpm-[34]
rpm-devel-[34]
"

develglob="
$baseglob
bzip2-devel-
db1-devel-
db2-devel-
db3-devel-
gdbm-devel-
glibc-devel-
kernel-headers-
ncurses-devel-
tcl-
zlib-devel-
"

buildglob="
$develglob
autoconf-
automake-
binutils-
cpp-
cvs-
db3-utils-
egcs-2
gcc-2
gettext-
krb5-libs-
libstdc++-
libtool-
make-
m4-
perl-
tcsh-
"

notallpat="(kernel-[^2h])"

for cmd in $*
do
    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.0|7.1)	dist=$cmd	;;
    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
	for l in min min1 min2 base devel build
	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
	done
	;;
    --initdb)
	[ -d $root ] && \
		$dbg $sudo mv $root ${root}-$$ && \
		$dbg $sudo rm -rf ${root}-$$ &
	sleep 2
	$dbg $sudo mkdir -p $root/var/lib/rpm
	$dbg $sudo $rpm $db1 --initdb
	;;
    --savedb)
	( $dbg cd $root/var/lib && $dbg $sudo tar czvf rpmdb.tar.gz rpm ; )
	;;
    --rebuilddb)
	$dbg $sudo $rpm --rebuilddb -vv
	;;
    --justdb)
	[ -f $type-$dist-$arch ] || {
	    echo $type-$dist-$arch not found
	    exit 1
	}
	$dbg $sudo $rpm $db1 -Uv $justdb `cat $type-$dist-$arch`
	;;
    -U*|-F*)
	[ -f $type-$dist-$arch ] || {
	    echo $type-$dist-$arch not found
	    exit 1
	}
	$dbg $sudo $rpm $db1 $cmd `cat $type-$dist-$arch`
	;;
    -[Vqei]*)
	$dbg $sudo $rpm $cmd
	;;
    chroot)
	$dbg $sudo cp /etc/resolv.conf $root/etc
	$dbg $sudo env HOME=/root chroot $root
	;;
    *)		type=$cmd	;;
    esac
done
echo "=======> finish	`date`"