3 # Purpose: build process script for generating a (grml based) Linux Live-ISO
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 # Latest change: Sun Sep 16 23:53:24 CEST 2007 [mika]
8 ################################################################################
10 # read configuration files, set some misc variables {{{
18 # we need root permissions for the build-process:
19 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
20 echo "Error: please run this script with uid 0 (root)." >&2
24 # make sure they are not set by default
28 # source main configuration file:
29 . /etc/grml/grml-live.conf
38 [ -n "$1" ] && EXIT="$1" || EXIT="1"
39 [ -n "$2" ] && echo "$2">&2
45 # check for important variables {{{
46 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
47 [ -n "$HOSTNAME" ] || HOSTNAME=grml
48 [ -n "$USERNAME" ] || USERNAME=grml
49 [ -n "$CLASSES" ] || CLASSES="GRML,I386"
50 [ -n "$TARGET" ] || bailout 1 "${PN}: \$TARGET not specified. Please adjust /etc/grml/grml-live.conf. Exiting."
53 # usage information {{{
57 $PN - build process script for generating a (grml based) Linux Live-ISO
59 Usage: $PN [-c <classe[s]>] [-t <target_directory>] [-F] [-h|--help] [additional_arguments_for_fai]
64 $PN -c GRML,I386 -t /dev/shm/grml
65 $PN -c GRML,GRML_X,I386 -t /grml/
68 More details: man grml-live
69 /usr/share/doc/grml-live/grml-live.html
71 Please send your bug reports, feedback,.. to the grml-team.
77 # command line parsing {{{
79 while getopts "c:s:t:Fhv" opt; do
81 c) CLASSES="$OPTARG" ;;
82 # f) FLAVOUR="$OPTARG" ;; # TODO
84 h) usage ; bailout 0 ;;
87 CHROOT_TARGET="$TARGET/grml_chroot"
88 BUILD_TARGET="$TARGET/grml_cd"
89 ISO_TARGET="$TARGET/grml_isos"
92 ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
95 shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
99 # some misc checks before executing FAI {{{
100 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in /etc/grml/grml-live.conf or
101 specify it on the command line using the -c|--classes option."
102 [ -n "$TARGET" ] || bailout 1 "Error: \$TARGET unset, please set it in /etc/grml/grml-live.conf or
103 specify it on the command line using the -t|--target option."
106 # ask user whether the setup is ok {{{
107 if [ -z "$FORCE" ] ; then
109 echo "$PN - check your configuration (or invoke using -F to force execution without prompting)"
111 echo " FAI classes: $CLASSES"
112 echo " output directory: $TARGET"
113 [ -n "$CHROOT_TARGET" ] && echo " chroot target: $CHROOT_TARGET"
114 [ -n "$BUILD_TARGET" ] && echo " build target: $BUILD_TARGET"
115 [ -n "$ISO_TARGET" ] && echo " ISO target: $ISO_TARGET"
116 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
117 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
118 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
120 echo -n "Is this ok for you? [y/N] "
122 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
123 bailout 1 "Exiting as requested."
129 # on-the-fly configuration {{{
130 if [ -n "$GRML_LIVE_SOURCES" ] ; then
131 echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
134 # we assume that it is set to 'etch' by default
135 if [ -n "$SUITE" ] ; then
136 sed -i "s#etch #$SUITE #" /etc/grml/fai/make-fai-nfsroot.conf
137 sed -i "s#etch #$SUITE #" /etc/grml/grml-live.conf
138 sed -i "s# etch # $SUITE #" /etc/grml/grml-live.conf
139 sed -i "s# etch # $SUITE #" /etc/grml/fai/apt/sources.list
142 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
143 sed -i "s#^FAI_DEBOOTSTRAP#FAI_DEBOOTSTRAP=$FAI_DEBOOTSTRAP#" /etc/grml/fai/make-fai-nfsroot.conf
147 # CHROOT_TARGET - execute FAI {{{
148 [ -n "$CHROOT_TARGET" ] || CHROOT_TARGET="$TARGET/grml_chroot"
150 if [ -d "$CHROOT_TARGET" ] ; then
151 echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirnstall'"
153 mkdir "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI"
154 fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" dirinstall "$CHROOT_TARGET" $FAI_ARGS
155 umount $CHROOT_TARGET/proc 2>/dev/null || /bin/true
156 umount $CHROOT_TARGET/sys 2>/dev/null || /bin/true
157 echo " [*] Finished execution of stage 'fai dirinstall'"
161 # BUILD_TARGET - execute arch specific stuff and squashfs {{{
162 [ -n "$BUILD_TARGET" ] || BUILD_TARGET="$TARGET/grml_cd"
163 mkdir -p "$BUILD_TARGET" || bailout 6 "Problem with creating $BUILD_TARGET for stage ARCH"
166 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
167 if [ "$ARCH" = i386 ] ; then
168 if [ -d "$BUILD_TARGET"/boot/isolinux ] ; then
169 echo " [x] $BUILD_TARGET/boot/isolinux exists already - skipping stage 'boot/isolinux'"
173 mkdir -p "$BUILD_TARGET"/boot/isolinux
174 mkdir "$BUILD_TARGET"/GRML
175 cp /boot/memtest86+.bin "$BUILD_TARGET"/boot/isolinux/memtest
176 cp "$CHROOT_TARGET"/boot/initrd* "$BUILD_TARGET"/boot/isolinux/initrd.gz
177 cp "$CHROOT_TARGET"/boot/vmlinuz* "$BUILD_TARGET"/boot/isolinux/linux26
178 cp /usr/lib/syslinux/chain.c32 "$BUILD_TARGET"/boot/isolinux/
179 cp /usr/lib/syslinux/isolinux.bin "$BUILD_TARGET"/boot/isolinux/
180 cp /usr/lib/syslinux/memdisk "$BUILD_TARGET"/boot/isolinux/
181 cp /usr/lib/syslinux/menu.c32 "$BUILD_TARGET"/boot/isolinux/
182 cp /usr/share/grml-live/i386_files/boot/isolinux/allinone.img "$BUILD_TARGET"/boot/isolinux/
183 cp /usr/share/grml-live/i386_files/boot/isolinux/balder10.imz "$BUILD_TARGET"/boot/isolinux/
184 cp /usr/share/grml-live/i386_files/boot/isolinux/boot-beep.msg "$BUILD_TARGET"/boot/isolinux/
185 cp /usr/share/grml-live/i386_files/boot/isolinux/boot.msg "$BUILD_TARGET"/boot/isolinux/
186 cp /usr/share/grml-live/i386_files/boot/isolinux/f* "$BUILD_TARGET"/boot/isolinux/
187 cp /usr/share/grml-live/i386_files/boot/isolinux/isolinux.cfg "$BUILD_TARGET"/boot/isolinux/
188 cp /usr/share/grml-live/i386_files/boot/isolinux/logo.16 "$BUILD_TARGET"/boot/isolinux/
189 cp /usr/share/grml-live/i386_files/boot/isolinux/syslinux.cfg "$BUILD_TARGET"/boot/isolinux/
190 # autostart for Windows:
191 cp /usr/share/grml-live/windows/autostart/autorun.bat "$BUILD_TARGET"/
192 cp /usr/share/grml-live/windows/autostart/autorun.inf "$BUILD_TARGET"/
193 cp /usr/share/grml-live/windows/autostart/autorun.pif "$BUILD_TARGET"/
194 cp /usr/share/grml-live/windows/autostart/cdrom.ico "$BUILD_TARGET"/
196 if [ -n "$WINDOWS_BINARIES" ] ; then
197 if [ -d "$BUILD_TARGET"/windows ] ; then
198 echo " [x] $BUILD_TARGET/windows exists already - skipping stage 'WINDOWS_BINARIES'"
201 mkdir "$BUILD_TARGET"/windows
202 ( cd "$BUILD_TARGET"/windows
203 for file in pageant plink pscp psftp putty puttygen ; do
204 wget ${WINDOWS_BINARIES}/${file}.exe
207 echo " [*] Finished execution of stage 'WINDOWS_BINARIES'"
209 echo " [*] Finished execution of stage 'boot/isolinux'"
212 elif [ "$ARCH" = amd64 ] ; then
213 echo 'Warning: gebi, it is your turn. :)'>&2
215 elif [ "$ARCH" = powerpc ] ; then
216 echo 'Warning: formorer, it is your turn. :)'>&2
219 echo 'Warning: Unsupported ARCH, sorry. Want to support it? Contribute!'>&2
222 if [ -d "$BUILD_TARGET"/live ] ; then
223 echo " [x] $BUILD_TARGET/live exists already, skipping stage 'squashfs'"
225 mkdir "$BUILD_TARGET"/live
226 mksquashfs $CHROOT_TARGET/* $BUILD_TARGET/live/grml.squashfs -noappend
228 echo " [*] Finished execution of stage 'squashfs'"
231 # ISO_TARGET - mkisofs {{{
232 [ -n "$ISO_TARGET" ] || ISO_TARGET="$TARGET/grml_isos"
233 if [ -d "$ISO_TARGET" ] ; then
234 echo " [x] $ISO_TARGET exists already, skipping the stage 'iso build'"
236 mkdir -p "$ISO_TARGET" || bailout 6 "Problem with creating $ISO_TARGET for stage 'iso build'"
237 ( cd "$BUILD_TARGET" &&
238 mkisofs -V "Debian/etch grml" -publisher 'Michael Prokop <mika@grml.org>' \
239 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
240 -c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin \
241 -o "$ISO_TARGET"/grml_0.0-1.iso .
243 echo " [*] Finished execution of stage 'iso build'"
248 echo " [*] Sucessfully finished execution of $PN"
252 ## END OF FILE #################################################################
253 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=2