16 |
|
|
17 |
|
rootdir=$(pwd) |
18 |
|
unsupportedDistribution=false |
19 |
+ |
testInstance=false |
20 |
|
|
21 |
|
while [ $# -gt 0 ]; do |
22 |
|
case $1 in |
36 |
|
shift; shift ;; |
37 |
|
-server ) |
38 |
|
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; } |
39 |
< |
server=$2; shift; shift ;; |
39 |
> |
server=$2 |
40 |
> |
testInstance=true |
41 |
> |
shift; shift ;; |
42 |
|
-server-path ) |
43 |
|
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; } |
44 |
|
server_main_dir=`echo $2 | sed -e "s|\(.*\)/.*/.*|\1|"` |
47 |
|
echo "server_main_dir $server_main_dir" |
48 |
|
echo "apt_dir $apt_dir" |
49 |
|
echo "repository $repository" |
50 |
+ |
testInstance=true |
51 |
|
shift; shift ;; |
52 |
+ |
-repository ) |
53 |
+ |
[ $# -gt 1 ] || { echo "Option \`$1' requires an argument" 1>&2; exit 1; } |
54 |
+ |
repository=/$2; shift; shift ;; |
55 |
+ |
-groups ) |
56 |
+ |
[ $# -gt 1 ] || { echo "Option \`$1' requires at lease one argument" 1>&2; exit 1; } |
57 |
+ |
shift |
58 |
+ |
groups="" |
59 |
+ |
while [ "$(echo $1 | cut -b1)" != "-" ] && [ $# -gt 0 ] |
60 |
+ |
do |
61 |
+ |
groups="$groups $1" |
62 |
+ |
shift |
63 |
+ |
done |
64 |
+ |
testInstance=true |
65 |
+ |
;; |
66 |
|
-unsupported_distribution_hack ) |
67 |
|
unsupportedDistribution=true; shift |
68 |
|
;; |
78 |
|
-path <cms-path> : location of where the installation must be done (default $PWD). |
79 |
|
-server <server> : repositories are to be found on server <server> (default cmsrep.cern.ch). |
80 |
|
-server-path <download-path> : package structure is found on <download-path> on server (default cms/cpt/Software/download/apt). |
81 |
+ |
-repository <repository> : use private apt repository cms.<username> (default: public repository) |
82 |
+ |
-groups <groups-list> : list of the channels we want to subscribe to (default: "cms external lcg virtual"). |
83 |
|
EOF_HELP |
84 |
|
exit 1 |
85 |
|
;; |
90 |
|
|
91 |
|
rpmdb=@CMSPLATF@/var/lib/rpm |
92 |
|
rpmlock=$rootdir/@CMSPLATF@/var/lib/rpm/lock |
93 |
+ |
tmp=$rootdir/@CMSPLATF@/tmp/system-import |
94 |
|
|
95 |
|
perlHarvester () { |
96 |
|
echo Harvesting for perl modules >&2 |
124 |
|
seed="$seed xorg-x11-Mesa compat-readline4 compat-curl2 freetype2 xorg-x11-libX11" |
125 |
|
fi |
126 |
|
|
106 |
– |
(set -e |
107 |
– |
tmp=$rootdir/@CMSPLATF@/tmp/system-import |
127 |
|
rm -rf $tmp |
128 |
|
mkdir -p $tmp |
129 |
|
cd $tmp |
207 |
|
|
208 |
|
seed () |
209 |
|
{ |
210 |
< |
cd tmp |
211 |
< |
(rpmbuild -ba system-base-import.spec |
210 |
> |
rcfile=$1 |
211 |
> |
cd $tmp |
212 |
> |
(rpmbuild -ba --rcfile $rcfile system-base-import.spec |
213 |
|
echo Seeding database in in $rootdir/$rpmdb |
214 |
< |
rpm --define "_rpmlock_path $rpmlock" --dbpath $rootdir/$rpmdb -Uvh RPMS/system-base-import.rpm |
214 |
> |
rpm --define "_rpmlock_path $rpmlock" -Uvh -r $rootdir --rcfile $rcfile --dbpath $rootdir/$rpmdb RPMS/system-base-import.rpm |
215 |
|
) || exit $? |
216 |
|
cd $was |
217 |
|
} |
218 |
|
|
219 |
|
setup() { |
220 |
+ |
# FIXME: this is the ugliest trick ever found in a shell script. |
221 |
+ |
# The problem is that rpm sometimes applies the value of --root |
222 |
+ |
# to dbpath, some other times it does not. |
223 |
+ |
# At some point this should be really fixed in the rpm sources, |
224 |
+ |
# but for the time being we keep it as it is. |
225 |
+ |
firstdir=$(echo $rootdir | cut -d/ -f1,2) |
226 |
+ |
ln -sf $firstdir .$firstdir |
227 |
+ |
|
228 |
|
# Fetch the required RPMS for RPM and APT from the server and install them using rpmcpio |
229 |
|
export DOWNLOAD_DIR=$rootdir/tmp/BOOTSTRAP |
230 |
|
mkdir -p $DOWNLOAD_DIR |
231 |
|
cd $DOWNLOAD_DIR |
232 |
< |
downloadPath=$server/$server_main_dir/RPMS/@CMSPLATF@ |
233 |
< |
wget $downloadPath/external+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm |
234 |
< |
wget $downloadPath/external+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm |
235 |
< |
wget $downloadPath/external+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm |
236 |
< |
wget $downloadPath/external+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm |
237 |
< |
wget $downloadPath/external+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm |
238 |
< |
wget $downloadPath/external+elfutils+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm |
239 |
< |
wget $downloadPath/external+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm |
240 |
< |
wget $downloadPath/external+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm |
241 |
< |
wget $downloadPath/external+apt+@APT_VERSION@-1-@APT_REVISION@.@CMSPLATF@.rpm |
232 |
> |
downloadPath=$server/$server_main_dir/$repository/RPMS/@CMSPLATF@ |
233 |
> |
wget -N $downloadPath/external+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm |
234 |
> |
wget -N $downloadPath/external+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm |
235 |
> |
wget -N $downloadPath/external+openssl+@OPENSSL_VERSION@-1-@OPENSSL_REVISION@.@CMSPLATF@.rpm |
236 |
> |
wget -N $downloadPath/external+db4+@DB4_VERSION@-1-@DB4_REVISION@.@CMSPLATF@.rpm |
237 |
> |
wget -N $downloadPath/external+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm |
238 |
> |
wget -N $downloadPath/external+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm |
239 |
> |
wget -N $downloadPath/external+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm |
240 |
> |
wget -N $downloadPath/external+elfutils+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm |
241 |
> |
wget -N $downloadPath/external+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm |
242 |
> |
wget -N $downloadPath/external+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm |
243 |
> |
wget -N $downloadPath/external+libxml2+@LIBXML2_VERSION@-1-@LIBXML2_REVISION@.@CMSPLATF@.rpm |
244 |
> |
wget -N $downloadPath/external+apt+@APT_VERSION@-1-@APT_REVISION@.@CMSPLATF@.rpm |
245 |
|
was=`pwd` |
246 |
|
cd $rootdir |
247 |
|
if [ -f $rootdir/$rpmdb ] |
255 |
|
mkdir -p $rootdir/$rpmdb |
256 |
|
fi |
257 |
|
# Extract the packages via rpm, source the init.sh |
258 |
< |
rpm2cpio external+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm | cpio -id |
259 |
< |
rpm2cpio external+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm | cpio -id |
260 |
< |
rpm2cpio external+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm | cpio -id |
261 |
< |
rpm2cpio external+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm | cpop -id |
262 |
< |
rpm2cpio external+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm | cpio -id |
263 |
< |
rpm2cpio external+elfutil+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm | cpio -id |
264 |
< |
rpm2cpio external+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm | cpio -id |
265 |
< |
rpm2cpio external+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm | cpio -id |
258 |
> |
cd $DOWNLOAD_DIR |
259 |
> |
rpm2cpio $DOWNLOAD_DIR/external+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm | cpio -idu |
260 |
> |
rpm2cpio $DOWNLOAD_DIR/external+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm | cpio -idu |
261 |
> |
rpm2cpio $DOWNLOAD_DIR/external+db4+@DB4_VERSION@-1-@DB4_REVISION@.@CMSPLATF@.rpm | cpio -idu |
262 |
> |
rpm2cpio $DOWNLOAD_DIR/external+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm | cpio -idu |
263 |
> |
rpm2cpio $DOWNLOAD_DIR/external+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm | cpio -idu |
264 |
> |
rpm2cpio $DOWNLOAD_DIR/external+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm | cpio -idu |
265 |
> |
rpm2cpio $DOWNLOAD_DIR/external+elfutils+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm | cpio -idu |
266 |
> |
rpm2cpio $DOWNLOAD_DIR/external+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm | cpio -idu |
267 |
> |
rpm2cpio $DOWNLOAD_DIR/external+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm | cpio -idu |
268 |
|
# Generate the seed spec using the old rpm: |
269 |
< |
generateSeedSpec () |
269 |
> |
generateSeedSpec |
270 |
|
# Now move to use the new RPM by sourcing its init.sh |
271 |
< |
source $arch/external/rpm/@RPM_VERSION@/etc/profile.d/init.sh |
271 |
> |
# FIXME: This actually only works if the packages are all generated in the same directory. |
272 |
> |
perl -p -i -e "s!@INSTROOT@!$DOWNLOAD_DIR@INSTROOT@!g" `grep -R @INSTROOT@ $DOWNLOAD_DIR@INSTROOT@ | grep -v Binary | cut -d: -f1 | uniq` |
273 |
> |
source $DOWNLOAD_DIR@INSTROOT@/@CMSPLATF@/external/rpm/@RPM_VERSION@/etc/profile.d/init.sh |
274 |
> |
cd $rootdir |
275 |
|
# Initialise the rpmdb using the new rpm. |
276 |
< |
rpm --define "_rpmlock_path $rpmlock" --dbpath $rootdir/$rpmdb --initdb |
276 |
> |
rpm --define "_rpmlock_path $rpmlock" -r $rootdir --dbpath $rootdir/$rpmdb --initdb |
277 |
|
# Build the seed spec and install it, in order to seed the newly generated db. |
278 |
< |
seed () |
278 |
> |
rpmOptions="-r $rootdir --dbpath $rootdir/$rpmdb --rcfile $DOWNLOAD_DIR@INSTROOT@/@CMSPLATF@/external/rpm/@RPM_VERSION@/lib/rpm/rpmrc" |
279 |
> |
seed $DOWNLOAD_DIR@INSTROOT@/@CMSPLATF@/external/rpm/@RPM_VERSION@/lib/rpm/rpmrc |
280 |
|
# Install the packages, this time using rpm. |
281 |
< |
rpm -ivh extarnal+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm |
282 |
< |
rpm -ivh extarnal+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm |
283 |
< |
rpm -ivh extarnal+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm |
284 |
< |
rpm -ivh extarnal+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm |
285 |
< |
rpm -ivh extarnal+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm |
286 |
< |
rpm -ivh extarnal+elfutils+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm |
287 |
< |
rpm -ivh extarnal+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm |
288 |
< |
rpm -ivh extarnal+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm |
281 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+gcc+@GCC_VERSION@-1-@GCC_REVISION@.@CMSPLATF@.rpm |
282 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+expat+@EXPAT_VERSION@-1-@EXPAT_REVISION@.@CMSPLATF@.rpm |
283 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+db4+@DB4_VERSION@-1-@DB4_REVISION@.@CMSPLATF@.rpm |
284 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+beecrypt+@BEECRYPT_VERSION@-1-@BEECRYPT_REVISION@.@CMSPLATF@.rpm |
285 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+zlib+@ZLIB_VERSION@-1-@ZLIB_REVISION@.@CMSPLATF@.rpm |
286 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+bz2lib+@BZ2LIB_VERSION@-1-@BZ2LIB_REVISION@.@CMSPLATF@.rpm |
287 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+elfutils+@ELFUTILS_VERSION@-1-@ELFUTILS_REVISION@.@CMSPLATF@.rpm |
288 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+neon+@NEON_VERSION@-1-@NEON_REVISION@.@CMSPLATF@.rpm |
289 |
> |
rpm -Uvh --define "_rpmlock_path $rpmlock" $rpmOptions $DOWNLOAD_DIR/external+rpm+@RPM_VERSION@-1-@RPM_REVISION@.@CMSPLATF@.rpm |
290 |
> |
source @CMSPLATF@/external/rpm/@RPM_VERSION@/etc/profile.d/init.sh |
291 |
|
# Install the packages required by apt |
292 |
< |
rpm -ivh external+apt+@APT_VERSION@-1-@APT_REVISION@.@CMSPLATF@.rpm |
292 |
> |
rpm -Uvh $rpmOptions $DOWNLOAD_DIR/external+openssl+@OPENSSL_VERSION@-1-@OPENSSL_REVISION@.@CMSPLATF@.rpm |
293 |
> |
rpm -Uvh $rpmOptions $DOWNLOAD_DIR/external+libxml2+@LIBXML2_VERSION@-1-@LIBXML2_REVISION@.@CMSPLATF@.rpm |
294 |
> |
rpm -Uvh $rpmOptions $DOWNLOAD_DIR/external+apt+@APT_VERSION@-1-@APT_REVISION@.@CMSPLATF@.rpm |
295 |
|
# Source the apt environment and upgrade what's already there. |
296 |
|
source $rootdir/@CMSPLATF@/external/apt/@APT_VERSION@/etc/profile.d/init.sh |
297 |
|
apt-get update |
302 |
|
|
303 |
|
rm -rf $rootdir/$rpmdb |
304 |
|
mkdir -p $rootdir/$rpmdb |
305 |
< |
rpm --define "_rpmlock_path $rpmlock" --dbpath $rootdir/$rpmdb --initdb |
305 |
> |
rpmdb --define "_rpmlock_path $rpmlock" --dbpath $rootdir/$rpmdb --initdb |
306 |
> |
# If we want to use a test instance, we need to adjust the sources.list accordingly. |
307 |
> |
if [ "$testInstance" == "true" ] |
308 |
> |
then |
309 |
> |
perl -p -i -e "s/^/#/;s/###//; |
310 |
> |
s/\@GROUPS\@/$groups/; |
311 |
> |
s/\@SERVER\@/$server/; |
312 |
> |
s/\@SERVER_PATH\@/$server_main_dir/; |
313 |
> |
s/\@REPOSITORY\@/$repository/" $rootdir/@CMSPLATF@/etc/apt/sources.list |
314 |
> |
fi |
315 |
|
|
316 |
|
cd $was |
317 |
|
} |