some new scripts, functions,....
[grml-live.git] / scripts / grml-live
1 #!/bin/zsh
2 # Filename:      grml-live
3 # Purpose:       build script for creating grml live-cd
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.
7 # Latest change: Tue Feb 13 00:16:11 CET 2007
8 ################################################################################
9
10 LANG=C ; LC_ALL=C
11 set -e # fail on any error
12
13 # functions
14 FUNCTIONSFILE='functions.sh' # TODO: fix location
15 for file in $FUNCTIONSFILE /etc/grml/lsb-functions  /etc/grml/script-functions ; do
16     [ -r "$file" ] && source "$file" || { print "Reading $file failed. Fatal error, exiting." ; exit 1 }
17 done
18
19 # Clean exit
20 trap bailout 1 2 3 15
21
22 # We need root permissions to execute all the chroot stuff
23 check4root || bailout 1
24
25 # default variables
26 [ -n "$DEBOOTSTRAP" ] || DEBOOTSTRAP='debootstrap'
27 [ -n "$ARCH" ]        || ARCH="$(dpkg --print-architecture)"
28 [ -n "$RELEASE" ]     || RELEASE='sid'
29 [ -n "$MIRROR" ]      || MIRROR='ftp://ftp.tugraz.at/mirror/debian'
30 [ -n "$TARGET" ]      || TARGET="$(pwd)/grml-live/chroot/"
31
32 # cmdline parsing, allow overwriting of variables
33 while true ; do
34    case "${1}" in
35         (-c|--config) CONFIG="${2}"
36                 shift 2 ;;
37         (-r|--root) TARGET="${2}"
38                 shift 2 ;;
39         (-h|--hook) HOOK="${2}"
40                 shift 2 ;;
41         (-v|--version) usage
42                 exit 1 ;;
43         (--) shift
44                 break ;;
45         (*) break ;;
46    esac
47 done
48
49 # configuration file
50 if [ -n "$CONFIG" ] ; then
51    [ -r "$CONFIG" ] || bailout 1 "Sorry, configuration file $CONFIG could not be read. Fatal error, exiting"
52    debug "sourcing $CONFIG"
53    source "$CONFIG"
54 else
55    source ../config/grml-live.conf # TODO: fix location
56 fi
57
58 # make sure we have some variables, directories,... available before main execution
59 [ -d "$TARGET" ] || mkdir "$TARGET"
60 [ -n "$ARCH" ] && ARCH="$DEB_HOST_ARCH" || bailout 1 "\$ARCH not set, exiting."
61
62 # TODO: fix location
63 source 01_bootstrap.sh
64 source 02_chroot.sh
65
66 if [ -n "$HOOK" ] ; then
67    debug "executing given hook $HOOK"
68    $HOOK
69    exit 0
70 fi
71
72 ## main execution
73
74 # 01_bootstrap.sh
75 bootstrap
76
77 # 02_chroot.sh
78 patch_chroot apply
79 chroot_shell
80 patch_chroot deapply
81
82 ## END OF FILE #################################################################
83 # vim: ai tw=80 ft=zsh expandtab