summaryrefslogtreecommitdiffstats
path: root/inc/functions.iso.sh
blob: 3fdece8ea107bf1557f9a9260218514c9fb4178a (plain) (blame)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
SHORT_OPTS=":vfdh"
LONG_OPTS="version,force,debug,help"

KERNEL="kernel-preboot-latest"
INITRAMFS="initramfs-default"

LOG_DIR="/tmp/pbmtk"
TMP_DIR=/tmp/openslx-iso


run_module_checks () {
	
	if [ ! -z $1 ]; then
	    perror "Too many parameters. \n"
	    print_usage
	    exit 1
	fi
	
	if [ -z $(which genisoimage) ]; then
	    perror "'genisoimage' is missing (if you are on a debian/ubuntu system: apt-get install genisoimage)"
	    exit 1
	fi
}

init_params () {
	FORCE=0
	DEBUG=0
}

print_usage() {
  echo "Usage: $(basename $SELF) iso [OPTIONS]"
  echo -e "  -d  --debug   \t give more debug output"
  echo -e "  -f  --force   \t don't ask questions"
  echo -e "  -h  --help    \t print help"
  echo -e "  -v  --version \t print version information"
}

read_params() {
	getopt_start $@
	
	eval set -- "$GETOPT_TEMP"
	
	while true ; do
	        case "$1" in
	                -v|--version)
	                     echo  "OpenSLX PreBoot .. ($VERSION - $VDATE)."
	                     exit 0
	                   ;;
	                -h|--help)
	                     print_usage
	                     exit 0
	                   ;;
	                -f|--force) pinfo "Disable user-interaction."; FORCE=1; shift ;;
	                -d|--debug) pinfo "Enabled debugmode."; DEBUG=1; unset_quiet; shift ;;
	                --) shift ; break ;;
	                *) perror "Internal error!" ; exit 1 ;;
	        esac
	done
}

pre_start_cleanup () {
	pinfo "Cleanup installer tmp."
	rm -rfv $TMP_DIR
}

setup_dir_structure () {
	pinfo "Create dir structure."
	mkdir -p $TMP_DIR/isolinux
}

copy_files () {
	pinfo "Copy required files."
	cp -v $ROOT_DIR/build/kernel-preboot-latest $TMP_DIR/isolinux/kernel
	
	cp -v $ROOT_DIR/build/initramfs-default $TMP_DIR/isolinux/initramfs
	
	cp -v $SYSLINUX/com32/menu/menu.c32 $TMP_DIR/isolinux/
	cp -v $SYSLINUX/com32/menu/vesamenu.c32 $TMP_DIR/isolinux/
	
	# exchange this for another theme
	cp -v ${ROOT_DIR}/config/extlinux/pbs2.png $TMP_DIR/isolinux/
	sed -e "s,USB,ISO," $ROOT_DIR/config/extlinux/extlinux.conf \
	  > $TMP_DIR/isolinux/isolinux.cfg
	
	cp -v ${SYSLINUX}/core/isolinux.bin $TMP_DIR/isolinux/
	
	# create an autorun.inf file
	echo -en "icon=\boot\openslx.ico,0\r\nlabel=OpenSLX PreBoot Linux\r\n" \
	  > $TMP_DIR/autorun.inf
	cp ${ROOT_DIR}/COPYING $TMP_DIR/copying.txt

}


create_iso () {
	pinfo "Create ISO."

	genisoimage \
		-b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
        -r -J -l -boot-info-table -hide-list config/hide.conf \
        -abstract /tmp/openslx-iso/isolinux/info.txt -relaxed-filenames \
        -biblio /tmp/openslx-iso/isolinux/info.txt -publisher "OpenSLX GmbH" \
        -p "OpenSLX Project, http://lab.openslx.org, info@openslx.org" \
        -V "OpenSLX PreBoot Linux ISO Image" -input-charset iso8859-1 \
        -volset "PreBoot Linux of the OpenSLX Project" -joliet-long \
        -copyright /tmp/openslx-iso/copying.txt \
        -o $ROOT_DIR/openslx.iso $TMP_DIR

}


run () {
	set_quiet
	
	pre_start_cleanup
	setup_dir_structure	
	copy_files
	create_iso
	
	unset_quiet
	
	pinfo "FINISHED: ISO can be found here: $ROOT_DIR/openslx.iso!"	
}