summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/functions/patch-iso.sh
blob: 782737e0d94e3f10ad2789a0b5e7b700b480ba03 (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
#!/bin/bash
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# stefan.k.berg@ericsson.com
# jonas.bjurel@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

# This is a temporary script - this should be rolled into a separate
# build target "make ci-iso" instead!

exit_handler() {
  rm -Rf $tmpnewdir
  fusermount -u $tmporigdir 2>/dev/null
  test -d $tmporigdir && mdir $tmporigdir
}

trap exit_handler exit

error_exit() {
  echo "$@"
  exit 1
}


top=$(cd `dirname $0`; pwd)
origiso=$(cd `dirname $1`; echo `pwd`/`basename $1`)
newiso=$(cd `dirname $2`; echo `pwd`/`basename $2`)
tmpdir=$3
tmporigdir=/${tmpdir}/origiso
tmpnewdir=/${tmpdir}/newiso

test -f $origiso || error_exit "Could not find origiso $origiso"
test -d $tmpdir || error_exit "Could not find tmpdir $tmpdir"


if [ "`whoami`" != "root" ]; then
  error_exit "You need be root to run this script"
fi

echo "Copying..."
rm -Rf $tmporigdir $tmpnewdir
mkdir -p $tmporigdir $tmpnewdir
fuseiso $origiso $tmporigdir || error_exit "Failed fuseiso"
cd $tmporigdir
find . | cpio -pd $tmpnewdir
cd $tmpnewdir
fusermount -u $tmporigdir
rmdir $tmporigdir
chmod -R 755 $tmpnewdir

echo "Patching..."
cd $tmpnewdir
# Patch ISO to make it suitable for automatic deployment
cat $top/ks.cfg.patch | patch -p0 || error_exit "Failed patch 1"
cat $top/isolinux.cfg.patch | patch -p0 || error_exit "Failed patch 2"
rm -rf .rr_moved

echo "Creating iso $newiso"
mkisofs -quiet -r  \
  -J -R -b isolinux/isolinux.bin \
  -no-emul-boot \
  -boot-load-size 4 -boot-info-table \
  --hide-rr-moved \
  -x "lost+found" -o $newiso . || error_exit "Failed making iso"