-
Notifications
You must be signed in to change notification settings - Fork 4
/
build
executable file
·50 lines (37 loc) · 1.56 KB
/
build
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
#!/bin/sh
set -e
INPUTFILE=$1
OUTPUTFILE=$2
if test -z "$INPUTFILE"
then
echo "missing input file -- first argument should be a debian ISO file"
exit 1
fi
if test -z "$OUTPUTFILE"
then
echo "missing output file -- second argument should be the name of a new preseed ISO file"
exit 1
fi
CURDIR="$(dirname $0)"
ISO_FILES="$(mktemp -d)"
POSTINSTALL_FILES="$(mktemp -d)"
CONFIGURATION_FILES="$(mktemp -d)"
xorriso -osirrox on -indev $INPUTFILE -extract / $ISO_FILES
chmod +w -R $ISO_FILES/install.amd/
gunzip $ISO_FILES/install.amd/initrd.gz
# contains all of the files that we want on the remote system
tar -c -z -f $CONFIGURATION_FILES/postinstall.tar.gz -C $CURDIR postinstall.d
# now add these all to the initrd file
cp $CURDIR/preseed.cfg $CONFIGURATION_FILES/preseed.cfg
(cd $CONFIGURATION_FILES; echo preseed.cfg | cpio -H newc -o -A -F $ISO_FILES/install.amd/initrd)
(cd $CONFIGURATION_FILES; echo postinstall.tar.gz | cpio -H newc -o -A -F $ISO_FILES/install.amd/initrd)
echo postinstall | cpio -H newc -o -A -F $ISO_FILES/install.amd/initrd
gzip $ISO_FILES/install.amd/initrd
chmod -w -R $ISO_FILES/install.amd/
chmod +w $ISO_FILES/md5sum.txt
(cd $ISO_FILES; md5sum `find -follow -type f` > md5sum.txt)
chmod -w $ISO_FILES/md5sum.txt
xorriso -as mkisofs -o $OUTPUTFILE -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat $ISO_FILES
chmod +w -R $ISO_FILES
rm -rf $ISO_FILES
rm -rf $CONFIGURATION_FILES