use external command line parameter-processing script
[grml-debootstrap.git] / grml-debootstrap.clp
1 # -*- shell-script -*-
2
3 #
4 # shell script command line parameter-processing for:
5 #
6 # grml-debootstrap - wrapper around debootstrap for installing plain Debian via
7 # grml
8 #
9 # @Author:  Tong SUN
10 # @Release: $Revision: $, under the BSD license
11 # @HomeURL: http://xpt.sourceforge.net/
12 #
13
14
15 eval set -- `getopt \
16   -o +m:i:r:t:p:c:hv --long \
17     mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,config:,packages::,debconf::,keep_src_list,hostname:,password:,bootappend:,groot:,grub:,help,version \
18   -- "$@"`
19
20 while :; do
21   case "$1" in
22
23   # == Bootstrap options
24   --mirror|-m)         # Mirror which should be used for apt-get/aptitude.
25     shift; _opt_mirror="$1"
26     ;;
27   --iso|-i)            # Mountpoint where a Debian ISO is mounted to, for use instead
28     shift; _opt_iso="$1"
29     ;;
30   --release|-r)        # Release of new Debian system (default: stable).
31     shift; _opt_release="$1"
32     ;;
33   --target|-t)         # Target partition (/dev/...) or directory.
34     shift; _opt_target="$1"
35     ;;
36   --mntpoint|-p)       # Mountpoint used for mounting the target system.
37     shift; _opt_mntpoint="$1"
38     ;;
39   --debopt)            # Extra parameters passed to the debootstrap.
40     shift; _opt_debopt="$1"
41     ;;
42   --interactive)       # Use interactive mode (frontend).
43     _opt_interactive=T
44     ;;
45   #
46
47   # == Configuration options
48   --config|-c)         # Use specified configuration file, defaults to /etc/debootstr
49     shift; _opt_config="$1"
50     ;;
51   --packages)          # Install packages defined in /etc/debootstrap/packages. Optio
52     shift; _opt_packages="$1"
53     _opt_packages_set=T
54     ;;
55   --debconf)           # Pre-seed packages using /etc/debootstrap/debconf-selections.
56     shift; _opt_debconf="$1"
57     _opt_debconf_set=T
58     ;;
59   --keep_src_list)     # Do not overwrite user provided apt sources.list.
60     _opt_keep_src_list=T
61     ;;
62   --hostname)          # Hostname of Debian system.
63     shift; _opt_hostname="$1"
64     ;;
65   --password)          # Use specified password as password for user root.
66     shift; _opt_password="$1"
67     ;;
68   #
69   --bootappend)        # Add specified appendline to kernel whilst booting.
70     shift; _opt_bootappend="$1"
71     ;;
72   --groot)             # Root device for usage in grub, corresponds with $TARGET in g
73     shift; _opt_groot="$1"
74     ;;
75   --grub)              # Target for grub installation. Use grub syntax for specifying
76     shift; _opt_grub="$1"
77     ;;
78
79   # == Other options
80   --help|-h)           # Print this usage information and exit.
81     _opt_help=T
82     ;;
83   --version|-v)        # Show summary of options and exit.
84     _opt_version=T
85     ;;
86   --)
87     shift; break
88     ;;
89   *)
90     eerror "Internal getopt error!"; eend 1 ; exit 1
91     ;;
92   esac
93   shift
94 done
95
96
97 [ "$_opt_debug" ] && {
98   echo "[grml-debootstrap] debug: _opt_mirror=$_opt_mirror"
99   echo "[grml-debootstrap] debug: _opt_iso=$_opt_iso"
100   echo "[grml-debootstrap] debug: _opt_release=$_opt_release"
101   echo "[grml-debootstrap] debug: _opt_target=$_opt_target"
102   echo "[grml-debootstrap] debug: _opt_mntpoint=$_opt_mntpoint"
103   echo "[grml-debootstrap] debug: _opt_debopt=$_opt_debopt"
104   echo "[grml-debootstrap] debug: _opt_interactive=$_opt_interactive"
105   echo "[grml-debootstrap] debug: _opt_config=$_opt_config"
106   echo "[grml-debootstrap] debug: _opt_packages=$_opt_packages"
107   echo "[grml-debootstrap] debug: _opt_debconf=$_opt_debconf"
108   echo "[grml-debootstrap] debug: _opt_keep_src_list=$_opt_keep_src_list"
109   echo "[grml-debootstrap] debug: _opt_hostname=$_opt_hostname"
110   echo "[grml-debootstrap] debug: _opt_password=$_opt_password"
111   echo "[grml-debootstrap] debug: _opt_bootappend=$_opt_bootappend"
112   echo "[grml-debootstrap] debug: _opt_groot=$_opt_groot"
113   echo "[grml-debootstrap] debug: _opt_grub=$_opt_grub"
114   echo "[grml-debootstrap] debug: _opt_help=$_opt_help"
115   echo "[grml-debootstrap] debug: _opt_version=$_opt_version"
116 }
117
118 if [ "$_opt_check_failed" ]; then
119   eerror "Not all mandatory options are set."; eend 1 ; exit 1
120 fi
121
122 # End