8 |
|
exit 1 |
9 |
|
fi |
10 |
|
|
11 |
+ |
if [ "X`printf hasprintf 2>/dev/null`" = Xhasprintf ]; then |
12 |
+ |
echo_n() { printf "%s" ${1+"$@"}; } |
13 |
+ |
elif [ "X`echo -n`" = "X-n" ]; then |
14 |
+ |
echo_n() { echo ${1+"$@"}"\c"; } |
15 |
+ |
else |
16 |
+ |
echo_n() { echo -n ${1+"$@"}; } |
17 |
+ |
fi |
18 |
+ |
|
19 |
|
cleanup_and_exit () { |
20 |
|
exitcode=$1 |
21 |
|
exitmessage=$2 |
22 |
< |
[ "X$exitmessage" = X ] || echo -e $exitmessage 1>&2 |
22 |
> |
[ "X$exitmessage" = X ] || { echo && echo $exitmessage 1>&2; } |
23 |
|
[ "X$debug" = Xtrue ] && exit $exitcode |
24 |
|
[ "X$tempdir" = X ] || [ -d $tempdir ] && rm -rf $tempdir |
25 |
|
[ "X$DOWNLOAD_DIR" = X ] || [ -d $DOWNLOAD_DIR ] && rm -rf $DOWNLOAD_DIR |
26 |
|
[ "X$importTmp" = X ] || [ -d $importTmp ] && rm -rf $importTmp |
27 |
< |
exit $exitcode |
27 |
> |
exit $exitcode |
28 |
|
} |
29 |
|
|
30 |
|
download_method= |
31 |
|
download_curl () { curl -f -q -s "$1" -o "$2.tmp" && mv "$2.tmp" "$2"; } |
32 |
< |
download_wget () { wget --no-check-certificate -q -O "$2.tmp" "$1" && mv "$2.tmp" "$2"; } |
32 |
> |
download_wget () { (wget --no-check-certificate -q -O "$2.tmp" "$1" 2>/dev/null || wget -q -O "$2.tmp" "$1") && mv "$2.tmp" "$2"; } |
33 |
|
download_none () { cleanup_and_exit 1 "No curl or wget, cannot fetch $1" |
34 |
|
} |
35 |
|
|
45 |
|
fi |
46 |
|
|
47 |
|
# Safely create a user-specific temp directory. |
48 |
< |
[ "X$TMPDIR" = X ] && TMPDIR=/tmp |
49 |
< |
tempdir=$TMPDIR/`mktemp tmpXXXXX` |
42 |
< |
mkdir -p $tempdir |
48 |
> |
[ "X$TMPDIR" = X ] && TMPDIR=/tmp/$USER |
49 |
> |
tempdir=`mktemp -d $TMPDIR/tmpXXXXX` |
50 |
|
|
51 |
|
# We have our own version of find-provides for bootstrap, so that we don't |
52 |
|
# depend on a "system" rpm installation. This is particularly handy in the case |
191 |
|
verbose=true; shift |
192 |
|
doReturn="\n" |
193 |
|
;; |
194 |
+ |
-debug ) |
195 |
+ |
debug=true; shift |
196 |
+ |
doReturn="\n" |
197 |
+ |
;; |
198 |
|
-assume-yes|-y ) |
199 |
|
assumeYes=true; shift |
200 |
|
;; |
243 |
|
|
244 |
|
# Get the architecture driver from the web |
245 |
|
driver=$server/$server_main_dir/$repository/$cmsplatf-driver.txt |
246 |
< |
[ "X$verbose" = Xtrue ] && echo -e "Downloading driver file...\c" |
246 |
> |
[ "X$verbose" = Xtrue ] && echo_n "Downloading driver file..." |
247 |
|
download_${download_method} $driver $tempdir/$cmsplatf-driver.txt |
248 |
< |
[ -f $tempdir/$cmsplatf-driver.txt ] || cleanup_and_exit 1 "${doReturn}FATAL: Unable to download platform driver: $driver" |
248 |
> |
[ -f $tempdir/$cmsplatf-driver.txt ] || cleanup_and_exit 1 "FATAL: Unable to download platform driver: $driver" |
249 |
|
eval `cat $tempdir/$cmsplatf-driver.txt` |
250 |
|
[ "X$verbose" = Xtrue ] && echo "Done." |
251 |
|
|
252 |
|
|
253 |
|
perlHarvester () { |
254 |
< |
[ "X$verbose" = Xtrue ] && echo -e "\n...Harvesting for perl modules" 1>&2 |
254 |
> |
[ "X$verbose" = Xtrue ] && echo && echo "...Harvesting for perl modules" 1>&2 |
255 |
|
for x in `perl -e'print join "\n", @INC'` |
256 |
|
do |
257 |
|
find -L $x 2>/dev/null \ |
264 |
|
generateSeedSpec () { |
265 |
|
# Seed system info |
266 |
|
# GL asound odbc java libtcl libtk |
267 |
< |
[ "X$verbose" = Xtrue ] && echo -e "\n...Seeding RPM database from selected system RPMs." 1>&2 |
267 |
> |
[ "X$verbose" = Xtrue ] && echo && echo "...Seeding RPM database from selected system RPMs." 1>&2 |
268 |
|
|
269 |
|
seed="$platformSeeds" |
270 |
|
|
325 |
|
|
326 |
|
if [ "$(which dpkg 2>&1 | grep 'no dpkg' )" = "" ] |
327 |
|
then |
328 |
< |
[ "X$verbose" = Xtrue ] && echo -e "\n...dpkg found in $(which dpkg), using it to seed the database." >&2 |
328 |
> |
[ "X$verbose" = Xtrue ] && echo && echo "...dpkg found in $(which dpkg), using it to seed the database." >&2 |
329 |
|
for p in $seed; do |
330 |
|
if [ "$(dpkg -L $p 2>&1 | grep 'is not installed')" = "" ]; then |
331 |
|
dpkg -L $p 2>/dev/null | sed -e "s|^|Provides:|" |
321 |
– |
# FIXME: this relies on rpm being installed. We should really have our |
322 |
– |
# own version of find-provides, but this will bring in more rpm helper |
323 |
– |
# script, so we live with it for the moment. |
332 |
|
dpkg -L $p 2>/dev/null | $rpmFindProvides | sed -e "s|^|Provides:|" |
333 |
|
fi |
334 |
|
done |
336 |
|
fi |
337 |
|
if which rpm 2>&1 >/dev/null && [ "$(rpm -qa 2>&1 | grep 'use alien')" = "" ] |
338 |
|
then |
339 |
< |
[ "X$verbose" = Xtrue ] && echo -e "\n...rpm found in $(which rpm), using it to seed the database." >&2 |
339 |
> |
[ "X$verbose" = Xtrue ] && echo && echo "...rpm found in $(which rpm), using it to seed the database." >&2 |
340 |
|
for p in $seed; do |
341 |
|
rpm -q $p >/dev/null |
342 |
|
if [ "$?" == "0" ] |
350 |
|
echo; echo "%description"; echo "Seeds RPM repository from the base system." |
351 |
|
echo; echo "%prep"; echo "%build"; echo "%install"; echo "%files"; |
352 |
|
) > system-base-import.spec |
353 |
+ |
perl -p -i -e 's|^Provides:[\s]*$||' system-base-import.spec |
354 |
|
cd $was |
355 |
|
} |
356 |
|
|
359 |
|
rcfile=$1 |
360 |
|
cd $importTmp |
361 |
|
(rpmbuild -ba --rcfile $rcfile system-base-import.spec >/dev/null 2>&1 |
362 |
< |
[ "X$verbose" = Xtrue ] && echo -e "\n...Seeding database in in $rootdir/$rpmdb" |
362 |
> |
[ "X$verbose" = Xtrue ] && echo && echo "...Seeding database in in $rootdir/$rpmdb" |
363 |
|
rpm --define "_rpmlock_path $rpmlock" -U -r $rootdir --rcfile $rcfile --dbpath $rootdir/$rpmdb RPMS/system-base-import.rpm |
364 |
< |
) || cleanup_and_exit $? "\nError while seeding rpm database with system packages." |
364 |
> |
) || cleanup_and_exit $? "Error while seeding rpm database with system packages." |
365 |
|
cd $was |
366 |
|
} |
367 |
|
|
374 |
|
[ "$rootdir" = "" ] && cleanup_and_exit 1 "Installation path not specified." |
375 |
|
|
376 |
|
rootdir=`echo $rootdir | perl -p -e 's|/$||'` |
377 |
< |
|
377 |
> |
mkdir -p $rootdir |
378 |
|
eval `echo $rootdir | awk -F \/ '{print "fakelink=$rootdir/"$2}'` |
379 |
|
if [ ! -e $fakelink ] |
380 |
|
then |
381 |
< |
echo $rootdir | awk -F \/ '{print "ln -s /"$2" $rootdir/"$2}' |
381 |
> |
#echo $rootdir | awk -F \/ '{print "ln -s /"$2" $rootdir/"$2}' |
382 |
|
command=`echo $rootdir | awk -F \/ '{print "ln -s /"$2" $rootdir/"$2}'` |
383 |
|
eval $command |
384 |
|
fi |
390 |
|
downloadPath=$server/$server_main_dir/$repository/RPMS/$cmsplatf |
391 |
|
# Get the architecture driver from the web |
392 |
|
driver=$server/$server_main_dir/$repository/$cmsplatf-driver.txt |
393 |
< |
echo -e "Downloading driver file...\c" |
393 |
> |
echo_n "Downloading driver file..." |
394 |
|
download_${download_method} $driver $tempdir/$cmsplatf-driver.txt |
395 |
< |
[ -f $tempdir/$cmsplatf-driver.txt ] || cleanup_and_exit 1 "\nUnable to download platform driver: $driver" |
395 |
> |
[ -f $tempdir/$cmsplatf-driver.txt ] || cleanup_and_exit 1 "Unable to download platform driver: $driver" |
396 |
|
eval `cat $tempdir/$cmsplatf-driver.txt` |
397 |
|
echo "Done." |
398 |
|
|
399 |
< |
echo -e "Downloading bootstrap core packages...\c" |
399 |
> |
echo_n "Downloading bootstrap core packages..." |
400 |
|
for pkg in $packageList |
401 |
|
do |
402 |
|
download_${download_method} $downloadPath/$pkg $pkg |
403 |
< |
[ -f $pkg ] || cleanup_and_exit 1 "\nError downloading $pkg. Exiting." |
403 |
> |
[ -f $pkg ] || cleanup_and_exit 1 "Error downloading $pkg. Exiting." |
404 |
|
done |
405 |
|
echo "Done." |
406 |
|
|
522 |
|
close ZCAT; |
523 |
|
EOF_RPM2CPIO |
524 |
|
|
525 |
< |
echo -e "Unpacking core packages...\c" |
525 |
> |
echo_n "Unpacking core packages..." |
526 |
|
for pkg in $packageList |
527 |
|
do |
528 |
< |
perl ./myrpm2cpio $DOWNLOAD_DIR/$pkg | cpio -idu || cleanup_and_exit 1 "\nUnable to unpack $DOWNLOAD_DIR/$pkg" |
528 |
> |
perl ./myrpm2cpio $DOWNLOAD_DIR/$pkg | cpio -idu 2>/dev/null || cleanup_and_exit 1 "Unable to unpack $DOWNLOAD_DIR/$pkg" |
529 |
|
done |
530 |
|
echo "Done." |
531 |
|
|
532 |
|
# Generate the seed spec using the old rpm: |
533 |
< |
echo -e "Harvesting system for locally available software...\c" |
533 |
> |
echo_n "Harvesting system for locally available software..." |
534 |
|
generateSeedSpec |
535 |
|
# Now move to use the new RPM by sourcing its init.sh |
536 |
|
perl -p -i -e "s!(/[^ ]*$cmsplatf)!$DOWNLOAD_DIR\$1!g" `grep -R -e "/[^ ]*$cmsplatf" $DOWNLOAD_DIR$instroot | grep -v Binary | cut -d: -f1 | uniq` |
538 |
|
cd $rootdir |
539 |
|
echo "Done." |
540 |
|
# Initialise the rpmdb using the new rpm. |
541 |
< |
echo -e "Initializing local rpm database...\c" |
542 |
< |
rpm --define "_rpmlock_path $rpmlock" -r $rootdir --dbpath $rootdir/$rpmdb --initdb || cleanup_and_exit 1 "\nUnable to initialize $rootdir/$rpmdb. Exiting." |
541 |
> |
echo_n "Initializing local rpm database..." |
542 |
> |
rpm --define "_rpmlock_path $rpmlock" -r $rootdir --dbpath $rootdir/$rpmdb --initdb || cleanup_and_exit 1 "Unable to initialize $rootdir/$rpmdb. Exiting." |
543 |
|
# Build the seed spec and install it, in order to seed the newly generated db. |
544 |
|
rpmOptions="-r $rootdir --dbpath $rootdir/$rpmdb --rcfile $DOWNLOAD_DIR$instroot/$cmsplatf/external/rpm/$rpm_version/lib/rpm/rpmrc --nodeps --prefix $rootdir --ignoreos --ignorearch" |
545 |
|
seed $DOWNLOAD_DIR$instroot/$cmsplatf/external/rpm/$rpm_version/lib/rpm/rpmrc |
546 |
|
echo "Done." |
547 |
|
|
548 |
|
# Install the packages, this time using rpm. |
549 |
< |
echo -e "Installing packages in the local rpm database...\c" |
549 |
> |
echo_n "Installing packages in the local rpm database..." |
550 |
|
for pkg in $packageList |
551 |
|
do |
552 |
< |
rpm -U $forceOption --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/$pkg || cleanup_and_exit 1 "\nError while installing $pkg. Exiting." |
552 |
> |
rpm -U $forceOption --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/$pkg || cleanup_and_exit 1 "Error while installing $pkg. Exiting." |
553 |
|
done |
554 |
|
echo "Done" |
555 |
|
|
565 |
|
fi |
566 |
|
|
567 |
|
# Source the apt environment and upgrade what's already there. |
568 |
< |
echo -e "Initializing apt-get environment.\c" |
568 |
> |
echo_n "Initializing apt-get environment." |
569 |
|
source $rootdir/$cmsplatf/external/apt/$apt_version/etc/profile.d/init.sh |
570 |
< |
apt-get update >$tempdir/apt-get-update.log 2>&1 || { echo -e "\nWARNING: There was a problem while running apt-get update. \ |
570 |
> |
apt-get update >$tempdir/apt-get-update.log 2>&1 || { echo && echo "WARNING: There was a problem while running apt-get update. \ |
571 |
|
While this might not be a problem you might want to tweak your sources.list \ |
572 |
|
to avoid warnings in future. "; cat $tempdir/apt-get-update.log; } |
573 |
|
|
574 |
|
echo "Done" |
575 |
< |
[ "X$additionalPkgs" = X ] || apt-get install -y $additionalPkgs >$tempdir/apt-get-install.log 2>&1 || { echo -e "\nWARNING: a set of additional \ |
576 |
< |
packages where required by the bootstrap options/driver, but they are impossible to install. \ |
577 |
< |
Error message is:"; cat $tempdir/apt-get-install.log; } |
575 |
> |
echo_n "Installing default packages." |
576 |
> |
defaultPackages="$additionalPkgs $defaultPkgs" |
577 |
> |
[ "X$defaultPackages" = X ] || apt-get install -y $defaultPackages >$tempdir/apt-get-install.log 2>&1 || { echo && echo "ERROR: \ |
578 |
> |
packages ($defaultPackages) were required by the bootstrap options/driver, but they are impossible to install. \ |
579 |
> |
Error message is:"; cat $tempdir/apt-get-install.log; cleanup_and_exit 1 "Unable to install packages." } |
580 |
> |
echo "Done" |
581 |
> |
|
582 |
> |
echo "Bootstrap environment to be found in: " |
583 |
> |
echo "### $rootdir/$cmsplatf/external/apt/$apt_version/etc/profile.d/init.sh" |
584 |
|
|
585 |
|
cd $was |
586 |
|
} |