2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
18 if [ -n "$TMP_HOSTMOUNT" ]; then
19 if [ -d "$TMP_HOSTMOUNT" ]; then
20 fusermount -u $TMP_HOSTMOUNT
25 if [ -d "$TMP_OLDISO" ]; then
26 fusermount -u $TMP_OLDISO
30 if [ -f "$CONF" ]; then
34 if [ -d "$TMP_ISOPUPPET" ]; then
40 ar p $1 control.tar.gz | tar xzO ./control | grep "^Package:.* " | sed 's/.* //'
41 if [ $PIPESTATUS -ne 0 ]; then
42 echo "Error in get_deb_name($1)"
48 ar p $1 control.tar.gz | tar xzO ./control | grep "^Version:.* " | sed 's/.* //'
49 if [ $PIPESTATUS -ne 0 ]; then
50 echo "Error in get_deb_rev($1)"
56 # Added logic for ".orig" files:
57 # 1. Is there an .orig file for the new file?
58 # 2. If the file is not present in base ISO -> Error!
59 # 3. If the file is changed i base ISO -> Error! (need manual rebase)
60 # 4. If there is no .orig file, but file is present in base ISO: Error!
65 pushd $NEWDIR >/dev/null
66 for f in $(find * -type f -name '*.orig')
69 oldfile=$OLDDIR/$(echo $f | sed 's/.orig$//')
70 newfile=$NEWDIR/$(echo $f | sed 's/.orig$//')
72 origfile=${newfile}.orig
73 # If no corresponding base file, error
74 if [ ! -f $oldfile ]; then
76 echo "Error: found ${newfile} but no"
77 echo "Error: ${oldfile}"
78 echo "Error: Manual rebase is needed!"
83 # If orig file differs from base file, error
84 if ! diff -q $origfile $oldfile > /dev/null; then
86 echo "Error: $origfile differs from"
87 echo "Error: $oldfile!"
88 echo "Error: Manual rebase is needed!"
96 # Check that there we're not overwriting oldfiles without having a ".orig" copy
97 for f in $(find * -type f ! -name '*.orig')
99 newfile=$NEWDIR/$(echo $f | sed 's/.orig$//')
100 origfile=${newfile}.orig
102 if [ -f $oldfile ]; then
103 if [ ! -f $origfile ]; then
105 echo "Error: Will overwrite $oldfile, but there is no"
106 echo "Error: $origfile!"
107 echo "Error: You need to create the `basename $origfile`!"
120 REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64
122 ssh-copy-id root@$FUELHOST
123 sshfs root@1${FUELHOST}:/ $TMP_HOSTMOUNT
125 if [ -f $REPO/dists/trusty/main/binary-amd64/Packages.backup ]; then
126 echo "Error - found backup file for Packages!"
130 if [ -f $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup ]; then
131 echo "Error - found backup file for Packages.gz!"
135 if [ -f $REPO/dists/trusty/Release.backup ]; then
136 echo "Error - found backup file for Release!"
140 if [ -d $DEST/etc/puppet.backup ]; then
141 echo "Error - found backup file for Puppet!"
145 cp $REPO/dists/trusty/main/binary-amd64/Packages $REPO/dists/trusty/main/binary-amd64/Packages.backup
146 cp $REPO/dists/trusty/main/binary-amd64/Packages.gz $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup
147 cp $REPO/dists/trusty/Release $REPO/dists/trusty/Release.backup
148 cp -Rvp $DEST/etc/puppet $DEST/etc/puppet.backup
152 if [ -d $TOP/release/puppet/modules ]; then
153 echo "Installing into Puppet:"
154 cd $TOP/release/puppet/modules
155 if [ `ls -1 | wc -l` -gt 0 ]; then
159 cp -Rp $dir $DEST/etc/puppet/modules
175 echo "Preparing ISO..."
176 echo "Unpack of old ISO..."
177 if [ -d newiso ]; then
182 fusermount -u $TMP_OLDISO 2>/dev/null || cat /dev/null
183 fuseiso -p $ORIGISO $TMP_OLDISO
186 find . | cpio -pd $TOP/newiso
188 fusermount -u $TMP_OLDISO
190 chmod -R 755 $TOP/newiso
196 find . -name TRANS.TBL -exec rm {} \;
199 if [[ -z "$OPNFV_GIT_SHA" ]]; then
200 OPNFV_GIT_SHA=$(git rev-parse --verify HEAD)
203 mkisofs --quiet -r -V "$VOLUMEID" -publisher "$PUBLISHER" \
204 -p "$OPNFV_GIT_SHA" -J -R -b isolinux/isolinux.bin \
206 -boot-load-size 4 -boot-info-table \
209 -x "lost+found" -o $NEWISO .
211 isoinfo -d -i $NEWISO
214 # iso_copy_puppet: Create a new puppet-slave.tgz for the iso
216 echo "Installing into Puppet..."
217 mkdir -p $TMP_ISOPUPPET/release/puppet
218 cd $TMP_ISOPUPPET/release/puppet
219 tar xzf $DEST/puppet-slave.tgz
220 cd $TOP/release/puppet/modules
222 # Remove all .orig files before copying as they now have been verfied
224 if [ -d $TOP/release/puppet/modules ]; then
225 if [ `ls -1 | wc -l` -gt 0 ]; then
226 verify_orig_files $TMP_ISOPUPPET/release/puppet $TOP/release/puppet/modules
227 find $TOP/release/puppet/modules -type f -name '*.orig' -exec rm {} \;
228 for dir in $TOP/release/puppet/modules/*
231 cp -Rp $dir $TMP_ISOPUPPET/release/puppet
236 cd $TMP_ISOPUPPET/release/puppet
237 tar czf $DEST/puppet-slave.tgz .
239 rm -Rf $TMP_ISOPUPPET
242 # iso_modify_image: Add/patch files in the ISO root
243 iso_modify_image () {
244 # TODO: Add logic for ".orig" files (hey! make a function!), which would look
246 # 1. Is there an .orig file?
247 # 2. If the file is not present in origiso -> Error exit
248 # 3. If the file is changed in origiso -> Error exit (need manual rebase)
249 # 4. Otherwise continue, but don't copy orig file (or maybe we should?)
250 # ... and corresponding reverse logic:
251 # 1. If there is no .orig file, but file is present in origiso -> Error exit
252 echo "Modify ISO files (wild copy)..."
254 verify_orig_files $DEST $TOP/release/isoroot
255 # Remove all .orig files before copying as they now have been verfied
256 find $TOP/release/isoroot -type f -name '*.orig' -exec rm {} \;
258 cd $TOP/release/isoroot
261 # Add all Git info files
262 sort $TOP/gitinfo*.txt > $DEST/gitinfo.txt
263 cp $DEST/gitinfo.txt $REPORTFILE
275 echo "Copying Debian packages..."
276 cd $TOP/release/packages/ubuntu/pool/debian-installer
278 for udeb in `ls -1 | grep '\.udeb$'`
281 cp $udeb $REPO/pool/debian-installer
282 echo "Did not expect a package here, not supported"
286 cd $TOP/release/packages/ubuntu/pool/main
287 for deb in `ls -1 | grep '\.deb$'`
290 cp $deb $REPO/pool/main
291 echo "Did not expect a package here, not supported"
295 echo "Running Fuel package patch file"
296 pushd $REPO/pool/main > /dev/null
298 for line in `cat $TOP/apply_patches | grep -v "^#" | grep -v "^$"`; do
300 echo "Did not expect a line here, not supported"
302 ref=`echo $line | cut -d '>' -f 1`
303 origpkg=`echo $line| cut -d '>' -f 2`
304 url=`echo $line | cut -d '>' -f 3`
306 if [ -z "$origpkg" ]; then
307 echo "Error: No origpkg for patching"
311 if [ -z "$url" ]; then
312 echo "Error: No url for patching"
316 if [ -z "$ref" ]; then
317 echo "Error: No reference text for patching"
321 echo "CM: Patching Fuel package for $ref" | tee -a $REPORTFILE
322 echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE
323 oldrev=`get_deb_rev $origpkg`
326 topkg=`basename $url`
327 echo "CM: MD5 of new package:" | tee -a $REPORTFILE
328 md5sum $topkg | tee -a $REPORTFILE
330 patchname=`get_deb_name $topkg`
331 patchrev=`get_deb_rev $topkg`
332 echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
333 $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
334 if [ $PIPESTATUS -ne 0 ]; then
339 printf "Done running Fuel patch file\n\n"
340 echo "Running add packages file"
341 for line in `cat $TOP/add_opnfv_packages | grep -v "^#" | grep -v "^$"`; do
343 echo "Did not expect a line here, not supported"
345 ref=`echo $line | cut -d '>' -f 1`
346 origpkg=`echo $line| cut -d '>' -f 2`
347 url=`echo $line | cut -d '>' -f 3`
349 if [ -z "$origpkg" ]; then
350 echo "Error: No origpkg for patching"
354 if [ -z "$url" ]; then
355 echo "Error: No url for patching"
359 if [ -z "$ref" ]; then
360 echo "Error: No reference text for patching"
364 if [ "$origpkg" != "NONE" ]; then
365 echo "CM: Patching added package for $ref" | tee -a $REPORTFILE
366 echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE
367 oldrev=`get_deb_rev $origpkg`
370 echo "CM: Adding previoulsy uninstalled package for $ref" tee -a $REPORTFILE
373 topkg=`basename $url`
374 echo "CM: MD5 of new package:" | tee -a $REPORTFILE
375 md5sum $topkg | tee -a $REPORTFILE
376 if [ "$origpkg" != "NONE" ]; then
377 patchname=`get_deb_name $topkg`
378 patchrev=`get_deb_rev $topkg`
379 echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
380 $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
381 if [ $PIPESTATUS -ne 0 ]; then
386 printf "Done running add packages file\n\n"
390 if [ -f $TOP/patch-packages/release/patch-replacements ]; then
391 echo "Applying package patches" | tee -a $REPORTFILE
392 pushd $REPO/pool/main > /dev/null
393 printf "\n\n" | tee -a $REPORTFILE
394 for line in `cat $TOP/patch-packages/release/patch-replacements`
396 echo "Did not expect a line here, not supported"
398 frompkg=`echo $line | cut -d ">" -f 1`
399 topkg=`echo $line | cut -d ">" -f 2`
400 echo "CM: Applying patch to $frompkg" | tee -a $REPORTFILE
401 echo "CM: New package rev after patch: $topkg" | tee -a $REPORTFILE
403 if [ ! -f $frompkg ]; then
404 echo "Error: Can't find $frompkg in repo"
407 oldrev=`get_deb_rev $frompkg`
408 echo "Removing $frompkg from repo"
412 if [ ! -f $TOP/patch-packages/release/packages/$topkg ]; then
413 echo "Error: Can't find $topkg in patch release"
416 echo "Adding $topkg to repo"
417 cp $TOP/patch-packages/release/packages/$topkg .
420 patchname=`get_deb_name $topkg`
421 patchrev=`get_deb_rev $topkg`
422 echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
423 $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
424 if [ $PIPESTATUS -ne 0 ]; then
431 echo "Generating metadata..."
432 pushd $REPO > /dev/null
434 # The below methods are from 15B
435 APT_REL_CONF="$TOP/install/apt-ftparchive-release.conf"
436 APT_DEB_CONF="$TOP/install/apt-ftparchive-deb.conf"
437 APT_UDEB_CONF="$TOP/install/apt-ftparchive-udeb.conf"
439 echo Not running echo apt-ftparchive -c "${APT_REL_CONF}" generate "${APT_DEB_CONF}"
440 echo Not running apt-ftparchive -c "${APT_REL_CONF}" generate "${APT_DEB_CONF}"
441 echo Not running apt-ftparchive generate "${APT_UDEB_CONF}"
442 echo Not running apt-ftparchive generate "${APT_UDEB_CONF}"
444 # Fuel also needs this index file
445 # cat dists/trusty/main/binary-amd64/Packages | \
446 # awk '/^Package:/{pkg=$2}
447 # /^Version:/{print pkg ": \"" $2 "\""}' > ubuntu-versions.yaml
448 # cp ubuntu-versions.yaml $DEST
450 # apt-ftparchive -c "${APT_REL_CONF}" release dists/trusty/ > dists/trusty/Release
451 # gzip -9cf dists/trusty/Release > dists/trusty/Release.gz
458 #############################################################################
462 CONF=`mktemp /tmp/XXXXXXX`
466 if [ $MODE = "iso" ]; then
468 TMP_OLDISO=`mktemp -d /tmp/XXXXXXX`
469 TMP_ISOPUPPET=`mktemp -d /tmp/XXXXXXX`
473 REPORTFILE="${NEWISO}.txt"
474 echo "Opening reportfile at $REPORTFILE"
476 if [ ! -f $ORIGISO ]; then
477 echo "Can't find original iso at $ORIGISO"
484 echo "Unknown mode: $MODE"