source: drbl-hadoop-live/create-hadoop-live @ 223

Last change on this file since 223 was 154, checked in by jazz, 14 years ago
  • fix two typos and verified the output iso includes cloudera's distribution for hadoop.
  • Property svn:executable set to *
File size: 30.1 KB
Line 
1#!/bin/bash
2# Author: Steven Shiau <steven _at_ nchc org tw>
3# License: GPL
4# Description: This script will create a DRBL live CD/USB flash drive iso/zip
5# This script works with live helper 1.0~a42-2 or later (Patched by DRBL team)
6
7#
8set -e
9
10#
11DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"
12
13. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
14. $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
15. $DRBL_SCRIPT_PATH/sbin/ocs-functions
16
17# debian_mirror_url_def, debian_mirror_security_url_def, DRBL_REPOSITORY_URL_def and DRBL_GPG_KEY_URL are loaded from drbl-ocs.conf
18
19# debian_type can be minimal (about 67 MB for Etch)/minimal-net (about 85 MB for Etch).
20# We have to use standard, since if using minimal, it will ignore apt key from DRBL.
21#debian_type="minimal"
22debian_type="standard"
23DEBIAN_DIST_DEF="lenny"
24pkgs="$PKG_FROM_DBN_WHICH_OCS_LIVE_NEED drbl $PKG_FROM_DBN $PKG_TO_QUERY $PKG_FROM_DRBL"
25categories_default="main non-free"
26cpu_flavor_default="486"
27bootstrap_default="cdebootstrap"
28
29# The files in dir $ocs_live_script_dir/ will be copied to the dir live-hook-dir in dir chroot. The file "drbl-live-hook" is in $ocs_live_script_dir
30ocs_live_script_dir="$DRBL_SCRIPT_PATH/setup/files/ocs/live-hook"
31# The script inside $ocs_live_script_dir/ will be run when chroot. There are many files in $$ocs_live_script_dir/, we will just run one here.
32run_hook_script="hadoop-live-hook"
33
34#
35check_if_root
36#
37prog="$(basename $0)"
38full_cmd="$prog $*"
39
40# functions
41USAGE() {
42    echo "Usage:"
43    echo "To create a Debian live CD which is used a template for Clonezilla live:"
44    echo "$prog [OPTION]"
45    echo "OPTION:"
46    language_help_prompt_by_idx_no
47    echo "-b, --branch [s|stable|t|testing|u|unstable]  Specify the DRBL branch to be used in Live CD. Default is stable."
48    echo "-bt, --bootstrap BOOTSTRAP  Specify the bootsrap type as BOOTSTRAP (cdebootstrap or debootstrap). If not specified, $bootstrap_default will be used."
49    echo "-c, --categories CAT   Sepcify the category, e.g. 'main', 'main non-free', default is \'$categories_default\' if not specified."
50    echo "-d, --debian-dist [stable|testing|unstable|lenny|squeeze|sid...]  Assign Debian dist, the default is $DEBIAN_DIST_DEF if not assigned."
51    echo "-f, --arch-flavor ARCH  Assign the CPU architecture flavor as ARCH, e.g. 486 or 686. If it's not assigned, $cpu_flavor will be used."
52    echo "-g, --drbl-repo-url URL  Assign the DRBL repository URL instead of default one $DRBL_REPOSITORY_URL_def."
53    echo "-n, --live-kernel-pkg KERNEL_VER Assign kernel version as KERNEL_VER (KERNEL VER package must exist in repository. Ex. if KERNEL_VER is 2.6.20-1-486, then linux-image-2.6.20-1-486, squashfs-modules-2.6.20-1-486, and unionfs-modules-2.6.20-1-486 will be used."
54    echo "-i, --assign-version-no NO  Assign the version no as NO instead of date."
55    echo "-e, --drbl-live-branch [s|stable|t|testing|u|unstable|e|experimental]  specifies the DRBL live branch to be used in Live CD. Default is stable."
56    echo "-k, --package FILE  Specify package FILE to be installed in Live CD."
57    echo "-p, --packages-list FILE  specifies an external package list file (such as xfce, gnome, kde...), one package for each line"
58    echo "-m, --mirror-url URL  Assign the Debian repository URL instead of default one $debian_mirror_url_def. "
59    echo "-r, --rm-tmp-iso    Remove the first stage temp iso file"
60    echo "-s, --mirror-security-url URL  Assign the Debian security repository URL instead of default one $debian_mirror_security_url_def."
61    echo "-t, --target-media-file  [cd|iso|usb|zip|b|both] Assign the target media file as CD (cd or iso), USB flash drive (usb or zip) or both of them (b or both). Default is both"
62    echo "-u, --use-existing-tmp-iso  Use the existing first stage temp iso file"
63    echo "-x, --extra-boot-param  EXTRA_PARAM  Assign extra boot parameter EXTRA_PARAM for the kernel to read. These parameters are the same with that from live-initramfs. Ex. \"noprompt\" can be use to not prompt to eject the CD on reboot."
64    echo "-v, --verbose    Run lh helper in verbose mode"
65    echo "Ex: $0 -l en -d etch -p xfce -b u -k \"iceweasel-l10n-zh-tw x-ttcidfont-conf ttf-arphic-newsung gparted scim-chewing scim-tables-zh im-switch mlterm mlterm-im-scim discover1 xresprobe mdetect\" -e e -n 2.6.24-etchnhalf.1 -i 0.9.11-7"
66}
67#
68clean_tmp_dirs_files() {
69  [ -d "$stage1_iso_TMP" -a -n "$(echo $stage1_iso_TMP | grep "ocs-iso-tmp")" ] && rm -rf $stage1_iso_TMP
70  [ -d "$ISOSYSLNX_TMP" -a -n "$(echo $ISOSYSLNX_TMP | grep "isolnx-tmp")" ] && rm -rf $ISOSYSLNX_TMP
71  [ -d "$USB_TMP" -a -n "$(echo $USB_TMP | grep "ocs-usb-dev")" ] && rm -rf $USB_TMP
72  # clean the tmp iso.
73  [ "$rm_tmp_iso" = "yes" -a -f "$stage1_target_iso" ] && rm -f $stage1_target_iso
74} # end of clean_tmp_dirs_files
75#
76create_version_tag_in_live() {
77  local tag_file_in_abs_path="$1"
78  local ver_tag_="$2"
79  local drbl_v clonezilla_v
80  drbl_v="$(dpkg -l drbl | tail -n 1 | awk -F" " '{print $3}')"
81  clonezilla_v="$(dpkg -l clonezilla | tail -n 1 | awk -F" " '{print $3}')"
82  cat <<-TAG_END > $tag_file_in_abs_path
83$ver_tag_
84DRBL: $drbl_v
85Clonezilla: $clonezilla_v
86This DRBL live was created by:
87$full_cmd
88TAG_END
89}
90#
91create_drbl_live_iso(){
92  echo "$msg_delimiter_star_line"
93  echo "Creating DRBL server iso file..."
94  echo "$msg_delimiter_star_line"
95  #
96  # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
97  # Find the kernel and initrd in $stage1_iso_TMP/casper or $stage1_iso_TMP/live
98  # Ex: $stage1_iso_TMP/casper/vmlinuz1, /$stage1_iso_TMP/casper/initrd1.img
99  # $live_sys_files_dir_list is from drbl-ocs.conf.
100  # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
101  sys_files_dir=""
102  for i in $live_sys_files_dir_list; do
103    krnfile="$(find $stage1_iso_TMP/$i/ -maxdepth 1 -name "vmlinuz*" -print 2>/dev/null)"
104    if [ -n "$krnfile" ]; then
105      krnfile="$(basename $krnfile)"
106      sys_files_dir="$i"
107      irdfile="$(find $stage1_iso_TMP/$i/ -maxdepth 1 -name "initrd*" -print)"
108      irdfile="$(basename $irdfile)"
109      break
110    fi
111  done
112  BOOT_ITEM_DIR=$ISOSYSLNX_TMP/$sys_files_dir
113  [ ! -d $BOOT_ITEM_DIR ] && mkdir $BOOT_ITEM_DIR
114
115  if [ -z "$sys_files_dir" ]; then
116    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
117    echo "No system files from template live iso are found! Something went wrong!"
118    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
119    echo "$msg_program_stop"
120    exit 1
121  fi
122 
123  if [ -z "$krnfile" -o -z "$irdfile" ]; then
124     [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
125     echo "Kernel and initrd files NOT found in path $stage1_iso_TMP/$sys_files_dir/!"
126     echo "$msg_program_stop"
127     [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
128     exit 1
129  fi
130
131  # Now we can insert the boot menu of isolinux
132  mkdir -p $ISOSYSLNX_TMP/syslinux $ISOSYSLNX_TMP/isolinux
133  # create isolinux menu
134  # isolinux should be rw, so we have to copy it, and exclude the one in iso image.
135  rsync -a --exclude f*.txt --exclude boot.cat --exclude isolinux.txt --exclude isolinux.bin --exclude splash.rle --exclude doc $stage1_iso_TMP/isolinux $ISOSYSLNX_TMP/
136  # We have to overwrite isolinux.bin since vesamenu.c32 should be same version with that.
137  # For isolinux
138  cp -af $isolinux_file $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $pxelinux_chain_file $ISOSYSLNX_TMP/isolinux/
139  # For syslinux
140  cp -af $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $pxelinux_chain_file $ISOSYSLNX_TMP/syslinux/
141
142  etherboot_zlilo="$($query_pkglist_cmd drbl-etherboot | grep -E "eb-.*-etherboot-pci.zlilo$")"
143  if [ -n "$etherboot_zlilo" ]; then
144    # We have to force it name as etherboot.zdsk, since isolinux only uses the "plain" ISO 9660 filenames, i.e. it does not support Rock Ridge or Joliet filenames.
145    # ref: http://syslinux.zytor.com/archives/2006-October/007440.html
146    # "-" will be regards as "_" if you want to use "-" for isolinux.
147    # In syslinux on vfat, etherboot.zlilo is too long, make it ever shorter as eb.zli
148    cp -af $etherboot_zlilo $BOOT_ITEM_DIR/eb.zli
149  fi
150  # Same reason, we have to use different name in isolinux
151  gpxe_lkn="$($query_pkglist_cmd gpxe 2>/dev/null | grep -E "gpxe.lkrn$")"
152  if [ -n "$gpxe_lkn" ]; then
153    # This is run in DRBL server
154    cp -af $gpxe_lkn $BOOT_ITEM_DIR/gpxe.lkn
155  fi
156  # Same reason, we have to use different name in isolinux
157  [ -e "$fdos_img_src" ] && cp -af $fdos_img_src $BOOT_ITEM_DIR/freedos.img
158  [ -e "$memtest86_file" ] && cp -af $memtest86_file $BOOT_ITEM_DIR/memtest
159
160  # Put the tag
161  # The VER_TAG is like drbl-live-xfce-20070315
162  VER_TAG="$(echo $real_target_iso | sed -e "s/.iso$//g")"
163  create_version_tag_in_live $ISOSYSLNX_TMP/DRBL-Live-Version "$VER_TAG"
164
165  # Excluding list for mkisofs
166  # We will create it like this:
167  # -x $stage1_iso_TMP/isolinux -x $stage1_iso_TMP/md5sum.txt -x $stage1_iso_TMP/casper/memtest
168  mkiso_exclude_list="isolinux syslinux md5sum.txt doc utils"
169  for i in $live_sys_files_dir_list; do
170    if [ -e "$stage1_iso_TMP/$i/memtest" ]; then
171      mkiso_exclude_list="$mkiso_exclude_list $i/memtest"
172      break
173    fi
174  done
175  mkiso_exclude_opt=""
176  for i in $mkiso_exclude_list; do
177    mkiso_exclude_opt="$mkiso_exclude_opt -x $stage1_iso_TMP/$i"
178  done
179
180  # Find the boot param $boot_param
181  get_live_boot_param $stage1_iso_TMP/isolinux
182  # generate the menu
183  # For isolinux
184  ocs-live-boot-menu -s -l $lang_answer --title "DRBL Live" -f 785 -n "$version_no" -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $pxelinux_bg_img --boot-param "$boot_param $live_extra_boot_param" isolinux $ISOSYSLNX_TMP/isolinux/
185  # For syslinux
186  ocs-live-boot-menu -s -l $lang_answer --title "DRBL Live" -f 785 -n "$version_no" -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $pxelinux_bg_img --boot-param "$boot_param $live_extra_boot_param" syslinux $ISOSYSLNX_TMP/syslinux/
187
188  echo "Preparing syslinux.exe, syslinux, makeboot.bat and makeboot.sh in dir utils... "
189  put_syslinux_makeboot_for_usb_flash $ISOSYSLNX_TMP
190 
191  # $sys_files_dir maybe /casper, /live or /isolinux. If it is isolinux, we can not list them twice otherwise mkisofs will go wrong.
192  if [ "$sys_files_dir" != "isolinux" ]; then
193    sys_files_dir_graft_point="/isolinux/=$ISOSYSLNX_TMP/isolinux/ /syslinux/=$ISOSYSLNX_TMP/syslinux/ /$sys_files_dir/=$ISOSYSLNX_TMP/$sys_files_dir/"
194  else
195    sys_files_dir_graft_point="/isolinux/=$ISOSYSLNX_TMP/isolinux/ /syslinux/=$ISOSYSLNX_TMP/syslinux/" 
196  fi
197  # create the iso file
198  genisoimage \
199   -A "DRBL Live CD" \
200   -V "DRBL-live" \
201   -publisher "DRBL/Clonezilla http://drbl.name http://clonezilla.org" \
202   -r -J -l \
203   -b isolinux/isolinux.bin -c isolinux/boot.cat \
204   -no-emul-boot -boot-load-size 4 -boot-info-table \
205   -x $stage1_iso_TMP/isolinux \
206   -x $stage1_iso_TMP/md5sum.txt \
207   $mkiso_exclude_opt \
208   -graft-points $stage1_iso_TMP \
209    $sys_files_dir_graft_point \
210    /COPYING=$DRBL_SCRIPT_PATH/doc/COPYING \
211    /DRBL-Live-Version=$ISOSYSLNX_TMP/DRBL-Live-Version \
212    /utils=$ISOSYSLNX_TMP/utils \
213   > $real_target_iso
214  RC_ISO=$?
215  if [ "$RC_ISO" -eq 0 ]; then
216    [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
217    echo "The $real_target_iso is created successfully!"
218    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
219  else
220    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
221    echo "The $real_target_iso is NOT created! Something went wrong!"
222    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
223  fi
224} # end of create_drbl_live_iso
225#
226create_drbl_live_zip() {
227  # create temp dir for usb flash drive
228  echo "$msg_delimiter_star_line"
229  echo "Creating DRBL server zip file..."
230  echo "$msg_delimiter_star_line"
231  #
232  # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
233  # Find the kernel and initrd in $stage1_iso_TMP/casper or $stage1_iso_TMP/live
234  # Ex: $stage1_iso_TMP/casper/vmlinuz1, /$stage1_iso_TMP/casper/initrd1.img
235  # $live_sys_files_dir_list is from drbl-ocs.conf.
236  # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
237  sys_files_dir=""
238  for i in $live_sys_files_dir_list; do
239    krnfile="$(find $stage1_iso_TMP/$i/ -maxdepth 1 -name "vmlinuz*" -print 2>/dev/null)"
240    if [ -n "$krnfile" ]; then
241      krnfile="$(basename $krnfile)"
242      sys_files_dir="$i"
243      irdfile="$(find $stage1_iso_TMP/$i/ -maxdepth 1 -name "initrd*" -print)"
244      irdfile="$(basename $irdfile)"
245      break
246    fi
247  done
248
249  if [ -z "$sys_files_dir" ]; then
250    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
251    echo "No system files from template live iso are found! Something went wrong!"
252    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
253    echo "$msg_program_stop"
254    exit 1
255  fi
256 
257  if [ -z "$krnfile" -o -z "$irdfile" ]; then
258     [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
259     echo "Kernel and initrd files NOT found in path $stage1_iso_TMP/$sys_files_dir/!"
260     echo "$msg_program_stop"
261     [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
262     exit 1
263  fi
264
265  WD="$(pwd)"
266  USB_TMP="$(mktemp -d /tmp/ocs-usb-dev.XXXXXX)"
267  mkdir -p $USB_TMP/$sys_files_dir
268  mkdir -p $USB_TMP/syslinux/ $USB_TMP/isolinux/
269  echo "Copying files to temp working directory... This might take some time..."
270  rsync -av --exclude isolinux --exclude md5sum.txt --exclude doc $stage1_iso_TMP/*  $USB_TMP/
271  cp -af $DRBL_SCRIPT_PATH/doc/COPYING $USB_TMP/
272  # For syslinux
273  cp -af $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $pxelinux_chain_file $USB_TMP/syslinux/
274  # For isolinux
275  cp -af $isolinux_file $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $pxelinux_chain_file $USB_TMP/isolinux/
276  # ref: http://syslinux.zytor.com/archives/2006-October/007440.html
277  # "-" will be regards as "_" if you want to use "-" for isolinux.
278  # In syslinux on vfat, etherboot.zlilo is too long, make it ever shorter as eb.zli
279  etherboot_zlilo="$($query_pkglist_cmd drbl-etherboot | grep -E "eb-.*-etherboot-pci.zlilo$")"
280  if [ -n "$etherboot_zlilo" ]; then
281    # we have to force it name as etherboot.zdsk, since isolinux only uses the "plain" ISO 9660 filenames, i.e. it does not support Rock Ridge or Joliet filenames.
282    # ref: http://syslinux.zytor.com/archives/2006-October/007440.html
283    # "-" will be regards as "_" if you want to use "-" for isolinux.
284    # In syslinux on vfat, etherboot.zlilo is too long, make it ever shorter as eb.zli
285    cp -af $etherboot_zlilo $USB_TMP/$sys_files_dir/eb.zli
286  fi
287  [ -e "$fdos_img_src" ] && cp -af $fdos_img_src $USB_TMP/$sys_files_dir/freedos.img
288  [ -e "$memtest86_file" ] && cp -af $memtest86_file $USB_TMP/$sys_files_dir/memtest
289  cp -af $stage1_iso_TMP/$sys_files_dir/{$krnfile,$irdfile} $USB_TMP/$sys_files_dir/
290  # Put the tag
291  # The VER_TAG is like drbl-live-xfce-20070315
292  VER_TAG="$(echo $real_target_zip | sed -e "s/.zip$//g")"
293  create_version_tag_in_live $USB_TMP/DRBL-Live-Version "$VER_TAG" 
294
295  # Find the boot param $boot_param
296  get_live_boot_param $stage1_iso_TMP/isolinux
297  # generate the menu
298  # For syslinux
299  ocs-live-boot-menu -s -l $lang_answer --title "DRBL Live" -f 785 -n "$version_no" -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $pxelinux_bg_img --boot-param "$boot_param $live_extra_boot_param noprompt" syslinux $USB_TMP/syslinux/
300  # For isolinux
301  ocs-live-boot-menu -s -l $lang_answer --title "DRBL Live" -f 785 -n "$version_no" -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $pxelinux_bg_img --boot-param "$boot_param $live_extra_boot_param noprompt" isolinux $USB_TMP/isolinux/
302
303  echo "Preparing syslinux.exe, syslinux, makeboot.bat and makeboot.sh in dir utils... "
304  put_syslinux_makeboot_for_usb_flash $USB_TMP
305  # just store it. since big files, like squash flie and opt_drbl.tgz are compressed, it's not necessary to compress it again.
306  [ -e "$WD/$real_target_zip" ] && rm -f $WD/$real_target_zip
307  (cd $USB_TMP; zip -0 -r $WD/$real_target_zip *)
308  echo "The created release file is $real_target_zip. You can extract all the files into your pendrive, and run makeboot.bat from pendrive on MS windows."
309  [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
310  echo "Warning: DO NOT RUN makeboot.bat from your local hard drive!! It is intended to be run from your USB device."
311  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
312 
313} # end of create_drbl_live_zip
314
315# default settings
316extra_pkgs=""
317pkg_list=""
318pkg_list_opt=""
319rm_tmp_iso="no"
320use_existing_stage1_iso="no"
321TARGET_MEDIA_FILE_DEF="both"
322# Parse command-line options
323while [ $# -gt 0 ]; do
324  case "$1" in
325    -l|--language)
326            shift
327            if [ -z "$(echo $1 |grep ^-.)" ]; then
328              # skip the -xx option, in case
329              specified_lang="$1"
330              shift
331            fi
332      [ -z "$specified_lang" ] && USAGE && exit 1
333            ;;
334    -b|--branch)
335            shift
336            if [ -z "$(echo $1 |grep ^-.)" ]; then
337              # skip the -xx option, in case
338              drbl_branch="$1"
339              shift
340            fi
341      [ -z "$drbl_branch" ] && USAGE && exit 1
342            ;;
343    -bt|--bootstrap)
344            shift
345            if [ -z "$(echo $1 |grep ^-.)" ]; then
346              # skip the -xx option, in case
347              bootstrap="$1"
348              shift
349            fi
350      [ -z "$bootstrap" ] && USAGE && exit 1
351            ;;
352    -c|--categories)
353            shift
354            if [ -z "$(echo $1 |grep ^-.)" ]; then
355              # skip the -xx option, in case
356              categories="$1"
357              shift
358            fi
359      [ -z "$categories" ] && USAGE && exit 1
360            ;;
361    -d|--debian-dist)
362            shift
363            if [ -z "$(echo $1 |grep ^-.)" ]; then
364              # skip the -xx option, in case
365              debian_dist="$1"
366              shift
367            fi
368      [ -z "$debian_dist" ] && USAGE && exit 1
369            ;;
370    -i|--assign-version-no)
371            shift
372            if [ -z "$(echo $1 |grep ^-.)" ]; then
373              # skip the -xx option, in case
374              version_no="$1"
375              shift
376            fi
377      [ -z "$version_no" ] && USAGE && exit 1
378            ;;
379    -k|--package)
380            shift
381            if [ -z "$(echo $1 |grep ^-.)" ]; then
382              # skip the -xx option, in case
383              extra_pkgs="$1"
384              shift
385            fi
386      [ -z "$extra_pkgs" ] && USAGE && exit 1
387            ;;
388    -n|--live-kernel-pkg)
389            shift
390            if [ -z "$(echo $1 |grep ^-.)" ]; then
391              # skip the -xx option, in case
392              live_kernel_ver="$1"
393              shift
394            fi
395      [ -z "$live_kernel_ver" ] && USAGE && exit 1
396            ;;
397    -e|--drbl-live-branch)
398            shift
399            if [ -z "$(echo $1 |grep ^-.)" ]; then
400              # skip the -xx option, in case
401              drbl_live_branch="$1"
402              shift
403            fi
404      [ -z "$drbl_live_branch" ] && USAGE && exit 1
405            ;;
406    -p|--packages-list)
407            shift
408            if [ -z "$(echo $1 |grep ^-.)" ]; then
409              # skip the -xx option, in case
410              pkg_list="$pkg_list $1"
411              shift
412            fi
413      [ -z "$pkg_list" ] && USAGE && exit 1
414            ;;
415    -f|--arch-flavor)
416            shift
417            if [ -z "$(echo $1 |grep ^-.)" ]; then
418              # skip the -xx option, in case
419              cpu_flavor="$1"
420              shift
421            fi
422      [ -z "$cpu_flavor" ] && USAGE && exit 1
423            ;;
424    -g|--drbl-repo-url)
425            shift
426            if [ -z "$(echo $1 |grep ^-.)" ]; then
427              # skip the -xx option, in case
428              DRBL_REPOSITORY_URL="$1"
429              shift
430            fi
431      [ -z "$DRBL_REPOSITORY_URL" ] && USAGE && exit 1
432            ;;
433    -m|--mirror-url)
434            shift
435            if [ -z "$(echo $1 |grep ^-.)" ]; then
436              # skip the -xx option, in case
437              mirror_url="$1"
438              shift
439            fi
440      [ -z "$mirror_url" ] && USAGE && exit 1
441            ;;
442    -s|--mirror-security-url)
443            shift
444            if [ -z "$(echo $1 |grep ^-.)" ]; then
445              # skip the -xx option, in case
446              mirror_security_url="$1"
447              shift
448            fi
449      [ -z "$mirror_security_url" ] && USAGE && exit 1
450            ;;
451    -t|--target-media-file)
452            shift
453            if [ -z "$(echo $1 |grep ^-.)" ]; then
454              # skip the -xx option, in case
455              target_media_file="$1"
456              shift
457            fi
458      [ -z "$target_media_file" ] && USAGE && exit 1
459            ;;
460    -r|--rm-tmp-iso)
461      rm_tmp_iso="yes"
462            shift ;;
463    -u|--use-existing-tmp-iso)
464            use_existing_stage1_iso="yes"
465            shift ;;
466    -v|--verbose)
467      verbose="on"
468            shift ;;
469    -x|--extra-boot-param)
470            shift
471            if [ -z "$(echo $1 |grep ^-.)" ]; then
472              # skip the -xx option, in case
473              live_extra_boot_param="$1"
474              shift
475            fi
476            shift
477      [ -z "$live_extra_boot_param" ] && USAGE && exit 1
478            ;;
479    -*)     echo "${0}: ${1}: invalid option" >&2
480            USAGE >& 2
481            exit 2 ;;
482    *)      break ;;
483  esac
484done
485
486#
487if [ "$use_existing_stage1_iso" = "no" ]; then
488  # if we use existing stage 1 iso file, then we do not have to check if lh exists. Otherwise we need make-live to create the stage 1 iso file
489  if ! type lh &>/dev/null; then
490    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
491    echo "This script only works in Debian Etch or later!"
492    echo "If you are running Debian Etch or later, use 'apt-get install live-helper' to install the live-helper (version $lh_ver_required or later), then run $0 again."
493    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
494    exit 1
495  fi
496  create_live_required_debian_based_prompt
497fi
498
499# we need zip to create the release file when target_mode is release_file
500if ! type zip &>/dev/null; then
501  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
502  echo "Command zip not found!"
503  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
504  echo "$msg_program_stop"
505  exit 1
506fi
507
508ask_and_load_lang_set $specified_lang
509
510[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
511echo "Creating DRBL live..." 
512[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
513
514rm -rf debian-live/.stage/
515
516# Apply default settings if not assigned
517[ -z "$debian_dist" ] && debian_dist="$DEBIAN_DIST_DEF"
518[ -z "$categories" ] && categories="$categories_default"
519[ -z "$DRBL_REPOSITORY_URL" ] && DRBL_REPOSITORY_URL="$DRBL_REPOSITORY_URL_def"
520[ -z "$mirror_url" ] && mirror_url="$debian_mirror_url_def"
521[ -z "$mirror_security_url" ] && mirror_security_url="$debian_mirror_security_url_def"
522[ -z "$cpu_flavor" ] && cpu_flavor="$cpu_flavor_default"
523[ -z "$bootstrap" ] && bootstrap=$bootstrap_default
524
525# Append the extra packages
526[ -n "$extra_pkgs" ] && pkgs="$pkgs $extra_pkgs"
527
528echo "The packages to be included in this live CD:"
529echo "$msg_delimiter_star_line"
530echo "$pkgs"
531echo "$msg_delimiter_star_line"
532if [ -n "$pkg_list" ]; then
533  pkg_list_opt="$pkg_list_opt --packages-list $pkg_list"
534  echo "The packages list to be included in this live CD:"
535  echo "$msg_delimiter_star_line"
536  echo "$pkg_list"
537  echo "$msg_delimiter_star_line"
538fi
539
540#
541echo "Using Debian $debian_dist..."
542echo "Using Debian repository from: $mirror_url"
543echo "Using Debian security repository from: $mirror_security_url"
544echo "Using DRBL repository from: $DRBL_REPOSITORY_URL"
545
546#
547case "$drbl_branch" in
548  t|testing)
549     echo "Using DRBL testing branch..."
550     LIVE_REPOSITORY_SECTIONS_drbl="stable testing"
551     ;;
552  u|unstable)
553     echo "Using DRBL unstable branch..."
554     LIVE_REPOSITORY_SECTIONS_drbl="stable testing unstable"
555     ;;
556  *)
557     echo "Using DRBL stable branch..."
558     LIVE_REPOSITORY_SECTIONS_drbl="stable live-stable"
559     ;;
560esac
561case "$drbl_live_branch" in
562  t|testing)
563     echo "Using DRBL Live testing branch..."
564     LIVE_REPOSITORY_SECTIONS_drbl="$LIVE_REPOSITORY_SECTIONS_drbl live-stable live-testing"
565     ;;
566  u|unstable)
567     echo "Using DRBL Live unstable branch..."
568     LIVE_REPOSITORY_SECTIONS_drbl="$LIVE_REPOSITORY_SECTIONS_drbl live-stable live-testing live-unstable"
569     ;;
570  e|experimental)
571     echo "Using DRBL Live experimental branch..."
572     LIVE_REPOSITORY_SECTIONS_drbl="$LIVE_REPOSITORY_SECTIONS_drbl live-stable live-testing live-unstable live-experimental"
573     ;;
574  *)
575     echo "Using DRBL live stable branch..."
576     LIVE_REPOSITORY_SECTIONS_drbl="$LIVE_REPOSITORY_SECTIONS_drbl live-stable"
577     ;;
578esac
579
580if [ -z "$pkg_list" ]; then
581  nametag="standard"
582else
583  # choose the first one, and strip space.
584  #nametag="$(echo $pkg_list | awk -F" " '{print $1}' | sed -e "s/ //g")"
585  # strip the spaces in the beginning and end, replace other space with -
586  nametag="$(echo $pkg_list | sed -e "s/^ *//g" -e "s/ *$//g" -e "s/ /-/g")"
587fi
588 
589# if version_no is not assigned, use date (Ex. 20070409)
590[ -z "$version_no" ] && version_no="$(date +%Y%m%d)"
591stage1_target_iso="hadoop-live-${nametag}-stage1-${version_no}.iso"
592real_target_iso="hadoop-live-${nametag}-${version_no}.iso"
593real_target_zip="hadoop-live-${nametag}-${version_no}.zip"
594[ -z "$target_media_file" ] && target_media_file="$TARGET_MEDIA_FILE_DEF"
595echo "$msg_delimiter_star_line"
596
597if [ "$debian_dist" = "squeeze" -o "$debian_dist" = "sid" ]; then
598  # From around Oct/2009, the dummy package name "grub" is actually grub-pc, therefore we force to use grub-legacy and assume that if grub2 boot loader is used in the restored GNU/Linux, grub2 is available in the restored GNU/Linux so therefore we can use chroot to run it.
599  pkgs="$(LC_ALL=C echo $pkgs | sed -r -e "s/grub[[:space:]]+/grub-legacy /")"
600  # Since with squeeze or sid, we can use uvesafb to replace vesafb, we need v86d. Check https://bugs.launchpad.net/ubuntu/+source/v86d/+bug/189621 for more details.
601fi
602
603if [ "$verbose" = "on" ]; then
604  pref="bash -x"
605  export CDEBOOTSTRAP_OPTIONS="$CDEBOOTSTRAP_OPTIONS -v --debug"
606fi
607
608if [ "$use_existing_stage1_iso" = "no" ]; then
609  if [ -d "debian-live" ]; then
610    echo "Found dir debian-live, clean stale debian-live files..."
611    chroot debian-live/chroot umount /dev/pts &>/dev/null || true
612    chroot debian-live/chroot umount /proc &>/dev/null || true
613    chroot debian-live/chroot umount /sys &>/dev/null || true
614    (
615      cd debian-live/
616      lh clean
617    )
618  fi
619  rm -rf debian-live
620  mkdir debian-live
621  (
622  cd debian-live
623
624  $pref lh config --archive-areas "$categories"
625  $pref lh config --mirror-binary $mirror_url --mirror-binary-security $mirror_security_url 
626  $pref lh config --mirror-bootstrap $mirror_url
627  $pref lh config --mirror-chroot $mirror_url --mirror-chroot-security $mirror_security_url
628  $pref lh config --bootstrap-flavour $debian_type --packages "$pkgs" $pkg_list_opt --bootappend ip=frommedia
629  $pref lh config --apt aptitude --apt-recommends false --binary-indices false --bootstrap $bootstrap --tasksel none
630  $pref lh config --volatile false
631  $pref lh config --initramfs live-initramfs
632  $pref lh config --username user --bootappend username=user
633  # Enable cache-indices, by doing this, "apt-get upgrade" won't be run in lh chroot_sources after hook since we might assign older package version when building.
634  $pref lh config --cache-indices true
635
636  # This decide_live_kernel_related_pkgs_from_debian function will output "kernel_related_pkgs" and "export MKSQUASHFS_OPTIONS"
637  decide_live_kernel_related_pkgs_from_debian
638  $pref lh config --distribution $debian_dist --linux-packages "$kernel_related_pkgs"
639
640  # We force to use the specific CPU kernel.
641  $pref lh config --linux-flavours $cpu_flavor
642
643  # No memtest from debian, we will use the one from drbl since it's newer.
644  $pref lh config --memtest none
645
646  # Put files to be included
647  mkdir -p config/chroot_local-includes/live-hook-dir
648  for i in $ocs_live_script_dir; do
649    cp -pr $i/* config/chroot_local-includes/live-hook-dir/
650  done
651  cp $DRBL_SCRIPT_PATH/conf/drbl*.conf config/chroot_local-includes/live-hook-dir/
652
653  # Put hook file to be run
654  mkdir -p config/chroot_local-hooks
655  cp $ocs_live_script_dir/$run_hook_script config/chroot_local-hooks/
656
657 
658  # prepare drbl source list
659  cat << AddDRBLRepository > config/chroot_sources/drbl.chroot
660  deb $DRBL_REPOSITORY_URL drbl $LIVE_REPOSITORY_SECTIONS_drbl
661AddDRBLRepository
662 
663  # prepare drbl key
664  LC_ALL=C wget -O config/chroot_sources/drbl.chroot.gpg $DRBL_GPG_KEY_URL
665
666
667  DISTRO=$(lsb_release -c | awk '{ print $2 }')
668
669  # prepare cloudera hadoop source list
670  cat << AddHadoopRepository > config/chroot_sources/hadoop.chroot
671  deb http://archive.cloudera.com/debian $DISTRO-cdh2 contrib
672AddHadoopRepository
673
674  # prepare cloudera key
675  LC_ALL=C wget -O config/chroot_sources/hadoop.chroot.gpg http://archive.cloudera.com/debian/archive.key
676
677  $pref lh build
678  )
679  mv -f debian-live/binary.iso $stage1_target_iso
680else
681  echo "Use existing temp iso file: $stage1_target_iso"
682fi
683  # clean the dir debian-live if $stage1_target_iso is already created
684  if [ -f "$stage1_target_iso" -a -d "debian-live" ]; then
685    echo "Removing working dir debian-live in background..."
686    rm -rf debian-live &
687  fi
688#
689[ ! -e "$stage1_target_iso" ] && echo "$stage1_target_iso does NOT exist!" && exit 1
690
691# mount the stage 1 iso file
692stage1_iso_TMP="$(mktemp -d /tmp/ocs-iso-tmp.XXXXXX)"
693trap "[ -d "$stage1_iso_TMP" ] && umount $stage1_iso_TMP &>/dev/null && clean_tmp_dirs_files" HUP INT QUIT TERM EXIT
694ISOSYSLNX_TMP="$(mktemp -d /tmp/isolnx-tmp.XXXXXX)"
695mount -o loop $stage1_target_iso $stage1_iso_TMP
696
697#
698case "$target_media_file" in
699  cd|CD|iso|ISO)
700     create_drbl_live_iso
701     ;;
702  usb|zip)
703     create_drbl_live_zip
704     ;;
705  b|both|BOTH)
706     create_drbl_live_iso
707     create_drbl_live_zip
708     ;;
709esac
710
711# unmount all iso file
712umount $stage1_iso_TMP &>/dev/null
713# Clean the tmp working directory
714echo "Cleaning tmp dirs..."
715clean_tmp_dirs_files
716
717#
718if type isohybrid &>/dev/null; then
719  if [ -e "$real_target_iso" ]; then
720    echo -n "Isohybriding $real_target_iso... "
721    isohybrid $real_target_iso
722    echo "done!"
723  fi
724fi
725#
726case "$target_media_file" in
727  cd|CD|iso|ISO)
728     [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
729     echo "$msg_burn_drbl_live_img_iso: $real_target_iso"
730     [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
731     ;;
732  usb|zip)
733     [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
734     echo "$msg_burn_drbl_live_img_zip: $real_target_zip"
735     [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
736     ;;
737  b|both|BOTH)
738     [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
739     echo "$msg_burn_drbl_live_img_iso: $real_target_iso"
740     echo "$msg_burn_drbl_live_img_zip: $real_target_zip"
741     [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
742     ;;
743esac
Note: See TracBrowser for help on using the repository browser.