1 |
eulisse |
1.29 |
#!/bin/bash
|
2 |
eulisse |
1.41 |
# Revision: $Revision: 1.40 $
|
3 |
eulisse |
1.1 |
|
4 |
|
|
if [ X"$(id -u)" = X0 ]; then
|
5 |
|
|
echo "*** CMS SOFTWARE INSTALLATION ABORTED ***" 1>&2
|
6 |
|
|
echo "CMS software cannot be installed as the super-user." 1>&2
|
7 |
|
|
echo "(We recommend reading any standard unix security guide.)" 1>&2
|
8 |
|
|
exit 1
|
9 |
|
|
fi
|
10 |
|
|
|
11 |
eulisse |
1.41 |
# We have our own version of find-provides for bootstrap, so that we don't
|
12 |
|
|
# depend on a "system" rpm installation. This is particularly handy in the case
|
13 |
|
|
# of macosx and other unsupported distributions which don't use rpm as a
|
14 |
|
|
# package manager (e.g. ubuntu).
|
15 |
|
|
rpmFindProvides=/tmp/my-find-provides
|
16 |
|
|
cat > $rpmFindProvides <<\EOF_FIND_PROVIDES
|
17 |
|
|
#!/bin/bash
|
18 |
|
|
|
19 |
|
|
# This script reads filenames from STDIN and outputs any relevant provides
|
20 |
|
|
# information that needs to be included in the package.
|
21 |
|
|
|
22 |
|
|
filelist=`sed "s/['\"]/\\\&/g"`
|
23 |
|
|
|
24 |
|
|
solist=$(echo $filelist | grep "\\.so" | grep -v "^/lib/ld.so" | \
|
25 |
|
|
xargs file -L 2>/dev/null | grep "ELF.*shared object" | cut -d: -f1)
|
26 |
|
|
pythonlist=
|
27 |
|
|
tcllist=
|
28 |
|
|
|
29 |
|
|
#
|
30 |
|
|
# --- Alpha does not mark 64bit dependencies
|
31 |
|
|
case `uname -m` in
|
32 |
|
|
alpha*) mark64="" ;;
|
33 |
|
|
*) mark64="()(64bit)" ;;
|
34 |
|
|
esac
|
35 |
|
|
|
36 |
|
|
#
|
37 |
|
|
# --- Library sonames and weak symbol versions (from glibc).
|
38 |
|
|
for f in $solist; do
|
39 |
|
|
soname=$(objdump -p $f | awk '/SONAME/ {print $2}')
|
40 |
|
|
|
41 |
|
|
lib64=`if file -L $f 2>/dev/null | \
|
42 |
|
|
grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi`
|
43 |
|
|
if [ "$soname" != "" ]; then
|
44 |
|
|
if [ ! -L $f ]; then
|
45 |
|
|
echo $soname$lib64
|
46 |
|
|
objdump -p $f | awk '
|
47 |
|
|
BEGIN { START=0 ; }
|
48 |
|
|
/Version definitions:/ { START=1; }
|
49 |
|
|
/^[0-9]/ && (START==1) { print $4; }
|
50 |
|
|
/^$/ { START=0; }
|
51 |
|
|
' | \
|
52 |
|
|
grep -v $soname | \
|
53 |
|
|
while read symbol ; do
|
54 |
|
|
echo "$soname($symbol)`echo $lib64 | sed 's/()//'`"
|
55 |
|
|
done
|
56 |
|
|
fi
|
57 |
|
|
else
|
58 |
|
|
echo ${f##*/}$lib64
|
59 |
|
|
fi
|
60 |
|
|
done | sort -u
|
61 |
|
|
|
62 |
|
|
#
|
63 |
|
|
# --- Perl modules.
|
64 |
|
|
[ -x /usr/lib/rpm/perl.prov ] &&
|
65 |
|
|
echo $filelist | tr '[:blank:]' \\n | grep '\.pm$' | /usr/lib/rpm/perl.prov | sort -u
|
66 |
|
|
|
67 |
|
|
#
|
68 |
|
|
# --- Python modules.
|
69 |
|
|
[ -x /usr/lib/rpm/python.prov -a -n "$pythonlist" ] &&
|
70 |
|
|
echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.prov | sort -u
|
71 |
|
|
|
72 |
|
|
#
|
73 |
|
|
# --- Tcl modules.
|
74 |
|
|
[ -x /usr/lib/rpm/tcl.prov -a -n "$tcllist" ] &&
|
75 |
|
|
echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.prov | sort -u
|
76 |
|
|
|
77 |
|
|
exit 0
|
78 |
|
|
EOF_FIND_PROVIDES
|
79 |
|
|
|
80 |
|
|
source() { . ${1+"$@"}; }
|
81 |
|
|
|
82 |
|
|
chmod u+x $rpmFindProvides
|
83 |
eulisse |
1.29 |
|
84 |
eulisse |
1.1 |
server=cmsrep.cern.ch
|
85 |
|
|
server_main_dir=cms/cpt/Software/download
|
86 |
|
|
repository=/cms
|
87 |
|
|
apt_dir=apt
|
88 |
|
|
groups="lcg cms external"
|
89 |
|
|
|
90 |
|
|
rootdir=$(pwd)
|
91 |
|
|
unsupportedDistribution=false
|
92 |
eulisse |
1.4 |
testInstance=false
|
93 |
eulisse |
1.1 |
|
94 |
|
|
while [ $# -gt 0 ]; do
|
95 |
|
|
case $1 in
|
96 |
|
|
setup )
|
97 |
|
|
command=setup
|
98 |
|
|
shift ;;
|
99 |
|
|
reseed )
|
100 |
|
|
command=reseed
|
101 |
|
|
shift;;
|
102 |
|
|
-path )
|
103 |
|
|
[ $# -gt 0 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; }
|
104 |
|
|
if [ "$(echo $2 | cut -b 1)" != "/" ]; then
|
105 |
|
|
rootdir="$PWD/$2"
|
106 |
|
|
else
|
107 |
|
|
rootdir="$2"
|
108 |
|
|
fi
|
109 |
|
|
shift; shift ;;
|
110 |
|
|
-server )
|
111 |
|
|
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; }
|
112 |
eulisse |
1.4 |
server=$2
|
113 |
|
|
testInstance=true
|
114 |
|
|
shift; shift ;;
|
115 |
eulisse |
1.1 |
-server-path )
|
116 |
|
|
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; }
|
117 |
|
|
server_main_dir=`echo $2 | sed -e "s|\(.*\)/.*/.*|\1|"`
|
118 |
|
|
apt_dir=`echo $2 | sed -e "s|.*/||"`
|
119 |
|
|
repository=/`echo $2 | sed -e "s|.*/\(.*\)/.*|\1|"`
|
120 |
|
|
echo "server_main_dir $server_main_dir"
|
121 |
|
|
echo "apt_dir $apt_dir"
|
122 |
|
|
echo "repository $repository"
|
123 |
eulisse |
1.4 |
testInstance=true
|
124 |
eulisse |
1.1 |
shift; shift ;;
|
125 |
eulisse |
1.4 |
-repository )
|
126 |
|
|
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; }
|
127 |
eulisse |
1.26 |
repository=/$2
|
128 |
|
|
testInstance=true
|
129 |
|
|
shift; shift ;;
|
130 |
eulisse |
1.4 |
-groups )
|
131 |
|
|
[ $# -gt 1 ] || { echo "Option \`$1' requires at lease one argument" 1>&2; exit 1; }
|
132 |
|
|
shift
|
133 |
|
|
groups=""
|
134 |
|
|
while [ "$(echo $1 | cut -b1)" != "-" ] && [ $# -gt 0 ]
|
135 |
|
|
do
|
136 |
|
|
groups="$groups $1"
|
137 |
|
|
shift
|
138 |
|
|
done
|
139 |
|
|
testInstance=true
|
140 |
|
|
;;
|
141 |
eulisse |
1.41 |
-architecture )
|
142 |
|
|
[ $# -gt 1 ] || { echo "Option \`$1' requires at lease one argument" 1>&2; exit 1; }
|
143 |
|
|
cmsplatf="$2"
|
144 |
|
|
shift; shift ;;
|
145 |
eulisse |
1.1 |
-unsupported_distribution_hack )
|
146 |
|
|
unsupportedDistribution=true; shift
|
147 |
|
|
;;
|
148 |
|
|
-help )
|
149 |
|
|
cat << \EOF_HELP
|
150 |
|
|
bootstrap.sh
|
151 |
|
|
|
152 |
|
|
A script to bootstrap a CMS software area.
|
153 |
|
|
|
154 |
|
|
Syntax:
|
155 |
|
|
bootstrap.sh setup [-path <cms-path>] [-server <server>] [-server-path <download-path>]
|
156 |
|
|
|
157 |
|
|
-path <cms-path> : location of where the installation must be done (default $PWD).
|
158 |
|
|
-server <server> : repositories are to be found on server <server> (default cmsrep.cern.ch).
|
159 |
|
|
-server-path <download-path> : package structure is found on <download-path> on server (default cms/cpt/Software/download/apt).
|
160 |
eulisse |
1.4 |
-repository <repository> : use private apt repository cms.<username> (default: public repository)
|
161 |
|
|
-groups <groups-list> : list of the channels we want to subscribe to (default: "cms external lcg virtual").
|
162 |
eulisse |
1.1 |
EOF_HELP
|
163 |
|
|
exit 1
|
164 |
|
|
;;
|
165 |
|
|
* )
|
166 |
|
|
echo "bootstrap.sh: argument $1 not supported"; exit 1;;
|
167 |
|
|
esac
|
168 |
|
|
done
|
169 |
|
|
|
170 |
eulisse |
1.41 |
rpmdb=$cmsplatf/var/lib/rpm
|
171 |
|
|
rpmlock=$rootdir/$cmsplatf/var/lib/rpm/__db.0
|
172 |
|
|
tmp=$rootdir/$cmsplatf/tmp/system-import
|
173 |
eulisse |
1.1 |
|
174 |
|
|
perlHarvester () {
|
175 |
|
|
echo Harvesting for perl modules >&2
|
176 |
|
|
for x in $(perl -e'print join "\n", @INC')
|
177 |
|
|
do
|
178 |
|
|
find -L $x \
|
179 |
|
|
| grep -v -e '\(^[.]/\|[/]$\)' \
|
180 |
|
|
| grep -e '\([.]pm$\|[.]pl$\|[.]pod$\)' \
|
181 |
|
|
| sed -e "s|$x/||;s|[.]pm||;s|[.]pod||;s|/|::|g;s|^\(.*\)|Provides: perl(\1)|" 2> /dev/null
|
182 |
|
|
done
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
generateSeedSpec () {
|
186 |
|
|
# Seed system info
|
187 |
|
|
# GL asound odbc java libtcl libtk
|
188 |
|
|
echo "Seeding RPM database from selected system RPMs."
|
189 |
eulisse |
1.41 |
|
190 |
|
|
seed="$platformSeeds"
|
191 |
eulisse |
1.1 |
|
192 |
|
|
if [ "$unsupportedDistribution" != "false" ]
|
193 |
|
|
then
|
194 |
eulisse |
1.41 |
echo "WARNING: you are running on an unsupported distribution."
|
195 |
|
|
echo "This might lead to unknown problems."
|
196 |
|
|
seed="$seed $unsupportedSeeds"
|
197 |
eulisse |
1.1 |
fi
|
198 |
|
|
|
199 |
|
|
rm -rf $tmp
|
200 |
|
|
mkdir -p $tmp
|
201 |
|
|
cd $tmp
|
202 |
|
|
mkdir -p SOURCES BUILD SPEC RPMS SRPMS tmp
|
203 |
|
|
: > SOURCES/none
|
204 |
|
|
# FIXME: It might be better to use rootdir rather than PWD
|
205 |
|
|
(echo "%define _sourcedir $PWD/SOURCES"
|
206 |
|
|
echo "%define _builddir $PWD/BUILD"
|
207 |
|
|
echo "%define _specdir $PWD/SPEC"
|
208 |
|
|
echo "%define _rpmdir $PWD/RPMS"
|
209 |
|
|
echo "%define _srcrpmdir $PWD/SRPMS"
|
210 |
|
|
echo "%define _tmppath $PWD/tmp"
|
211 |
|
|
echo "%define _topdir $PWD"
|
212 |
|
|
echo "%define _rpmfilename system-base-import.rpm"
|
213 |
|
|
echo;
|
214 |
|
|
echo "Name: system-base-import"
|
215 |
|
|
echo "Version: 1.0"
|
216 |
|
|
echo "Release: `date +%s`"
|
217 |
|
|
echo "Summary: Base system seed"
|
218 |
|
|
echo "License: Unknown"
|
219 |
|
|
echo "Group: Hacks"
|
220 |
|
|
echo "Packager: install.sh"
|
221 |
|
|
echo "Source: none"
|
222 |
eulisse |
1.41 |
for provide in $additionalProvides
|
223 |
|
|
do
|
224 |
|
|
echo "Provides: $provide"
|
225 |
|
|
done
|
226 |
eulisse |
1.1 |
|
227 |
|
|
if [ "$unsupportDistribution" != "false" ]
|
228 |
|
|
then
|
229 |
eulisse |
1.19 |
# Guess perl
|
230 |
|
|
echo "Provides: perl = `perl -MConfig -e 'print $Config{version}'`"
|
231 |
eulisse |
1.41 |
for provide in $unsupportedProvides
|
232 |
|
|
do
|
233 |
|
|
echo "Provides: $provide"
|
234 |
|
|
done
|
235 |
eulisse |
1.1 |
fi
|
236 |
|
|
|
237 |
eulisse |
1.41 |
case $cmsplatf in
|
238 |
|
|
osx* )
|
239 |
|
|
find /bin | sed 's!^!Provides: !'
|
240 |
|
|
/bin/ls -1 /usr/lib/*.dylib | awk -F"/" '{print $4}' | sed 's!^!Provides: !'
|
241 |
|
|
/bin/ls -1 /usr/lib/*/*.dylib | awk -F"/" '{print $5}' | sed 's!^!Provides: !'
|
242 |
|
|
/bin/ls -1 /usr/X11R6/lib/*.dylib | awk -F"/" '{print $5}' | sed 's!^!Provides: !'
|
243 |
|
|
;;
|
244 |
|
|
esac
|
245 |
|
|
|
246 |
eulisse |
1.18 |
if [ "$(which dpkg 2>&1 | grep 'no dpkg' )" = "" ]
|
247 |
eulisse |
1.1 |
then
|
248 |
|
|
echo "dpkg found in $(which dpkg), using it to seed the database." >&2
|
249 |
|
|
for p in $seed; do
|
250 |
eulisse |
1.18 |
if [ "$(dpkg -L $p 2>&1 | grep 'is not installed')" = "" ]; then
|
251 |
eulisse |
1.1 |
dpkg -L $p 2>/dev/null | sed -e "s|^|Provides:|"
|
252 |
eulisse |
1.19 |
# FIXME: this relies on rpm being installed. We should really have our
|
253 |
|
|
# own version of find-provides, but this will bring in more rpm helper
|
254 |
|
|
# script, so we live with it for the moment.
|
255 |
eulisse |
1.29 |
dpkg -L $p 2>/dev/null | $rpmFindProvides | sed -e "s|^|Provides:|"
|
256 |
eulisse |
1.1 |
fi
|
257 |
|
|
done
|
258 |
|
|
perlHarvester
|
259 |
|
|
fi
|
260 |
eulisse |
1.18 |
if which rpm 2>&1 >/dev/null && [ "$(rpm -qa 2>&1 | grep 'use alien')" = "" ]
|
261 |
eulisse |
1.1 |
then
|
262 |
|
|
echo "rpm found in $(which rpm), using it to seed the database." >&2
|
263 |
|
|
for p in $seed; do
|
264 |
ratnik |
1.37 |
rpm -q $p >&2
|
265 |
ratnik |
1.36 |
if [ "$?" == "0" ]
|
266 |
|
|
then
|
267 |
|
|
rpm -q $p --provides | sed 's!<*=.*!!; s!^!Provides: !'
|
268 |
|
|
rpm -q $p --list | grep '\.so' | sed 's!^.*/!Provides: !'
|
269 |
|
|
rpm -q $p --list | grep '/bin/' | sed 's!^!Provides: !'
|
270 |
|
|
fi
|
271 |
eulisse |
1.1 |
done
|
272 |
|
|
fi
|
273 |
|
|
echo; echo "%description"; echo "Seeds RPM repository from the base system."
|
274 |
|
|
echo; echo "%prep"; echo "%build"; echo "%install"; echo "%files";
|
275 |
|
|
) > system-base-import.spec
|
276 |
|
|
cd $was
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
seed ()
|
280 |
|
|
{
|
281 |
eulisse |
1.12 |
rcfile=$1
|
282 |
eulisse |
1.10 |
cd $tmp
|
283 |
eulisse |
1.12 |
(rpmbuild -ba --rcfile $rcfile system-base-import.spec
|
284 |
eulisse |
1.1 |
echo Seeding database in in $rootdir/$rpmdb
|
285 |
eulisse |
1.13 |
rpm --define "_rpmlock_path $rpmlock" -Uvh -r $rootdir --rcfile $rcfile --dbpath $rootdir/$rpmdb RPMS/system-base-import.rpm
|
286 |
eulisse |
1.1 |
) || exit $?
|
287 |
|
|
cd $was
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
setup() {
|
291 |
eulisse |
1.13 |
# FIXME: this is the ugliest trick ever found in a shell script.
|
292 |
|
|
# The problem is that rpm sometimes applies the value of --root
|
293 |
|
|
# to dbpath, some other times it does not.
|
294 |
|
|
# At some point this should be really fixed in the rpm sources,
|
295 |
|
|
# but for the time being we keep it as it is.
|
296 |
eulisse |
1.32 |
if [ "$rootdir" = "" ]
|
297 |
eulisse |
1.31 |
then
|
298 |
eulisse |
1.32 |
echo Installation path not specified.
|
299 |
eulisse |
1.31 |
exit 1
|
300 |
|
|
fi
|
301 |
|
|
|
302 |
|
|
rootdir=`echo $rootdir | perl -p -e 's|/$||'`
|
303 |
|
|
|
304 |
|
|
eval `echo $rootdir | awk -F \/ '{print "fakelink=$rootdir/"$2}'`
|
305 |
|
|
if [ ! -e $fakelink ]
|
306 |
|
|
then
|
307 |
|
|
echo $rootdir | awk -F \/ '{print "ln -s /"$2" $rootdir/"$2}'
|
308 |
|
|
command=`echo $rootdir | awk -F \/ '{print "ln -s /"$2" $rootdir/"$2}'`
|
309 |
|
|
eval $command
|
310 |
|
|
fi
|
311 |
eulisse |
1.13 |
|
312 |
eulisse |
1.1 |
# Fetch the required RPMS for RPM and APT from the server and install them using rpmcpio
|
313 |
|
|
export DOWNLOAD_DIR=$rootdir/tmp/BOOTSTRAP
|
314 |
|
|
mkdir -p $DOWNLOAD_DIR
|
315 |
|
|
cd $DOWNLOAD_DIR
|
316 |
eulisse |
1.41 |
downloadPath=$server/$server_main_dir/$repository/RPMS/$cmsplatf
|
317 |
|
|
# Get the architecture driver from the web
|
318 |
|
|
eval `curl -s -f $server/$server_main_dir/$repository/$cmsplatf-driver.txt || echo download_error=true`
|
319 |
ratnik |
1.33 |
|
320 |
eulisse |
1.41 |
if [ "X$download_error" = Xtrue ]
|
321 |
ratnik |
1.33 |
then
|
322 |
eulisse |
1.41 |
echo "Error downloading bootstrap driver for architecture $cmsplatf:"
|
323 |
|
|
echo "$server/$server_main_dir/$repository/$cmsplatf-driver.txt"
|
324 |
|
|
echo "Exiting."
|
325 |
ratnik |
1.33 |
fi
|
326 |
eulisse |
1.41 |
|
327 |
|
|
for pkg in $packageList
|
328 |
|
|
do
|
329 |
|
|
curl -s -f $downloadPath/$pkg > $pkg || { echo "Error downloading $pkg. Exiting."; exit 1; }
|
330 |
|
|
done
|
331 |
|
|
|
332 |
eulisse |
1.1 |
was=`pwd`
|
333 |
|
|
cd $rootdir
|
334 |
ratnik |
1.39 |
if [ -d $rootdir/$rpmdb ]
|
335 |
eulisse |
1.1 |
then
|
336 |
|
|
read -e -p "Warning, $rootdir already set up. Do you want to reconfigure it? [ y / N ] " override
|
337 |
|
|
case $(echo $override | tr [A-Z] [a-z]) in
|
338 |
|
|
y|ye|yes) ;;
|
339 |
|
|
*) echo "No changes made. Exiting... "; exit 1;;
|
340 |
|
|
esac
|
341 |
|
|
else
|
342 |
|
|
mkdir -p $rootdir/$rpmdb
|
343 |
|
|
fi
|
344 |
eulisse |
1.41 |
|
345 |
eulisse |
1.1 |
# Extract the packages via rpm, source the init.sh
|
346 |
eulisse |
1.41 |
# Some packages might actually not be there (gcc on darwin, for example, .
|
347 |
|
|
# where we use the system one).
|
348 |
eulisse |
1.10 |
cd $DOWNLOAD_DIR
|
349 |
eulisse |
1.41 |
# http://linuxmafia.com/pub/linux/utilities-general/rpm2cpio
|
350 |
|
|
cat > myrpm2cpio <<\EOF_RPM2CPIO
|
351 |
|
|
#!/usr/bin/env perl
|
352 |
|
|
|
353 |
|
|
# Why does the world need another rpm2cpio? Because the existing one
|
354 |
|
|
# won't build unless you have half a ton of things that aren't really
|
355 |
|
|
# required for it, since it uses the same library used to extract RPMs.
|
356 |
|
|
# In particular, it won't build on the HPsUX box I'm on.
|
357 |
|
|
|
358 |
|
|
#
|
359 |
|
|
# Expanded quick-reference help by Rick Moen (not the original author
|
360 |
|
|
# of this script).
|
361 |
|
|
#
|
362 |
|
|
|
363 |
|
|
# add a path if desired
|
364 |
|
|
$gzip = "gzip";
|
365 |
|
|
|
366 |
|
|
sub printhelp {
|
367 |
|
|
print "\n";
|
368 |
|
|
print "rpm2cpio, perl version by orabidoo <odar\@pobox.com>\n";
|
369 |
|
|
print "\n";
|
370 |
|
|
print "use: rpm2cpio [file.rpm]\n";
|
371 |
|
|
print "dumps the contents to stdout as a GNU cpio archive\n";
|
372 |
|
|
print "\n";
|
373 |
|
|
print "In case it's non-obvious, you'll need to redirect output\n";
|
374 |
|
|
print "from this script, e.g., './rpm2cpio package.rpm > package.cpio'.\n";
|
375 |
|
|
print "Then, unpack in, say, /tmp with a cpio incantation like this one:\n";
|
376 |
|
|
print "'cpio -ivd < package.cpio'\n";
|
377 |
|
|
print "\n";
|
378 |
|
|
print "You can optionally combine both steps:\n";
|
379 |
|
|
print "'rpm2cpio package.rpm | cpio -iduv'\n";
|
380 |
|
|
print "\n";
|
381 |
|
|
print "In either event, you will also need the 'cpio' utility available\n";
|
382 |
|
|
print "on your system. If you can't find it elsewhere, source code for\n";
|
383 |
|
|
print "GNU cpio is always available at ftp://ftp.gnu.org/gnu/cpio/.)\n";
|
384 |
|
|
print "You'll also, of course, need Perl, and will want this Perl script\n";
|
385 |
|
|
print "set as executable, i.e., by doing 'chmod 775 rpm2cpio'\n";
|
386 |
|
|
print "\n";
|
387 |
|
|
print "Be aware that this script works ONLY on version 3 or 4-format RPM\n";
|
388 |
|
|
print "archives. You can check an archive's RPM-format version
|
389 |
|
|
sing\n";
|
390 |
|
|
print "the Unix 'file' utility. Also, be aware that the 'cpio'\n";
|
391 |
|
|
print "incantations above will unpack files at the current directory\n";
|
392 |
|
|
print "level.\n";
|
393 |
|
|
print "\n";
|
394 |
|
|
exit 0;
|
395 |
|
|
}
|
396 |
|
|
|
397 |
|
|
if ($#ARGV == -1) {
|
398 |
|
|
printhelp if -t STDIN;
|
399 |
|
|
$f = "STDIN";
|
400 |
|
|
} elsif ($#ARGV == 0) {
|
401 |
|
|
open(F, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
|
402 |
|
|
$f = 'F';
|
403 |
|
|
} else {
|
404 |
|
|
printhelp;
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
printhelp if -t STDOUT;
|
408 |
|
|
|
409 |
|
|
# gobble the file up
|
410 |
|
|
undef $/;
|
411 |
|
|
$|=1;
|
412 |
|
|
$rpm = <$f>;
|
413 |
|
|
close ($f);
|
414 |
|
|
|
415 |
|
|
($magic, $major, $minor, $crap) = unpack("NCC C90", $rpm);
|
416 |
|
|
|
417 |
|
|
die "Not an RPM\n" if $magic != 0xedabeedb;
|
418 |
|
|
die "Not a version 3 or 4 RPM\n" if $major != 3 and $major != 4;
|
419 |
|
|
|
420 |
|
|
$rpm = substr($rpm, 96);
|
421 |
|
|
|
422 |
|
|
while ($rpm ne '') {
|
423 |
|
|
$rpm =~ s/^\c@*//s;
|
424 |
|
|
($magic, $crap, $sections, $bytes) = unpack("N4", $rpm);
|
425 |
|
|
$smagic = unpack("n", $rpm);
|
426 |
|
|
last if $smagic eq 0x1f8b;
|
427 |
|
|
die "Error: header not recognized\n" if $magic != 0x8eade801;
|
428 |
|
|
$rpm = substr($rpm, 16*(1+$sections) + $bytes);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
die "bogus RPM\n" if $rpm eq '';
|
432 |
|
|
|
433 |
|
|
open(ZCAT, "|gzip -cd") || die "can't pipe to gzip\n";
|
434 |
|
|
|
435 |
|
|
print ZCAT $rpm;
|
436 |
|
|
close ZCAT;
|
437 |
|
|
EOF_RPM2CPIO
|
438 |
|
|
|
439 |
|
|
for pkg in $packageList
|
440 |
|
|
do
|
441 |
|
|
perl ./myrpm2cpio $DOWNLOAD_DIR/$pkg | cpio -idu
|
442 |
|
|
done
|
443 |
ratnik |
1.33 |
|
444 |
eulisse |
1.1 |
# Generate the seed spec using the old rpm:
|
445 |
eulisse |
1.5 |
generateSeedSpec
|
446 |
eulisse |
1.1 |
# Now move to use the new RPM by sourcing its init.sh
|
447 |
eulisse |
1.41 |
perl -p -i -e "s!(/[^ ]*$cmsplatf)!$DOWNLOAD_DIR\$1!g" `grep -R -e "/[^ ]*$cmsplatf" $DOWNLOAD_DIR$instroot | grep -v Binary | cut -d: -f1 | uniq`
|
448 |
|
|
source $DOWNLOAD_DIR$instroot/$cmsplatf/external/rpm/$rpm_version/etc/profile.d/init.sh
|
449 |
eulisse |
1.10 |
cd $rootdir
|
450 |
eulisse |
1.1 |
# Initialise the rpmdb using the new rpm.
|
451 |
eulisse |
1.12 |
rpm --define "_rpmlock_path $rpmlock" -r $rootdir --dbpath $rootdir/$rpmdb --initdb
|
452 |
eulisse |
1.1 |
# Build the seed spec and install it, in order to seed the newly generated db.
|
453 |
eulisse |
1.41 |
rpmOptions="-r $rootdir --dbpath $rootdir/$rpmdb --rcfile $DOWNLOAD_DIR@INSTROOT@/$cmsplatf/external/rpm/$rpm_version/lib/rpm/rpmrc --nodeps --prefix $rootdir --ignoreos --ignorearch"
|
454 |
|
|
seed $DOWNLOAD_DIR$instroot/$cmsplatf/external/rpm/latest/lib/rpm/rpmrc
|
455 |
eulisse |
1.22 |
|
456 |
eulisse |
1.1 |
# Install the packages, this time using rpm.
|
457 |
eulisse |
1.41 |
for pkg in $packageList
|
458 |
|
|
do
|
459 |
|
|
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/$pkg
|
460 |
|
|
done
|
461 |
ratnik |
1.33 |
|
462 |
eulisse |
1.1 |
# Source the apt environment and upgrade what's already there.
|
463 |
eulisse |
1.41 |
source $rootdir/$cmsplatf/external/apt/latest/etc/profile.d/init.sh
|
464 |
eulisse |
1.1 |
apt-get update
|
465 |
|
|
apt-get dist-upgrade
|
466 |
|
|
|
467 |
eulisse |
1.4 |
# If we want to use a test instance, we need to adjust the sources.list accordingly.
|
468 |
eulisse |
1.18 |
if [ "$testInstance" = "true" ]
|
469 |
eulisse |
1.4 |
then
|
470 |
eulisse |
1.27 |
perl -p -i -e "s|^|#|;
|
471 |
|
|
s|###||;
|
472 |
|
|
s|\@GROUPS\@|$groups|;
|
473 |
|
|
s|\@SERVER\@|$server|;
|
474 |
|
|
s|\@SERVER_PATH\@|$server_main_dir|;
|
475 |
eulisse |
1.41 |
s|\@REPOSITORY\@|$repository|" $rootdir/$cmsplatf/external/apt/latest/etc/sources.list
|
476 |
eulisse |
1.4 |
fi
|
477 |
eulisse |
1.1 |
|
478 |
|
|
cd $was
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
##########################################################
|
482 |
|
|
case $command in
|
483 |
|
|
setup )
|
484 |
|
|
setup ;;
|
485 |
|
|
reseed )
|
486 |
eulisse |
1.23 |
generateSeedSpec
|
487 |
eulisse |
1.41 |
seed $cmsplatf/external/rpm/latest/lib/rpm/rpmrc
|
488 |
eulisse |
1.23 |
;;
|
489 |
eulisse |
1.1 |
esac
|
490 |
|
|
|
491 |
|
|
exit 0
|