11739c8d85ba632d79a421bb348963f6683f4b62
[grml-live.git] / remaster / grml-live-remaster
1 #!/bin/sh
2 # Filename:      grml-live-remaster
3 # Purpose:       remaster a grml from the live cd
4 # Authors:       grml-team (grml.org), (c) Michael Schierl <schierlm@gmx.de>, (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: Fri Dec 28 00:59:13 CET 2007 [mika]
8 ################################################################################
9 # DISCLAIMER:
10 # this script currently lacks lots of error checking code... any help welcome...
11 ################################################################################
12
13 set -e # exit on any error
14
15 VERSION='0.0.1'
16
17 # source core functions {{{
18 . /etc/grml/lsb-functions
19 . /etc/grml/script-functions
20 # }}}
21
22 # make sure we have what we need {{{
23 check4progs mkisofs mksquashfs || exit 1
24 check4root || exit 1
25 # }}}
26
27 if [ x"$1" == x ]; then
28    echo "$0 - version $VERSION"
29    echo ""
30    echo "Usage: $0 destination.iso"
31    echo "  destination.iso should point to a path that is on a hard disk,"
32    echo "  you might want to mount some swap partitions or swap files"
33    echo "  first, because grml-live-remaster will need a lot ot RAM."
34    echo ""
35    echo "Please report bugs and feature requests: http://grml.org/bugs/"
36    exit -1
37 fi
38
39 if [ ! -d /remaster ]; then
40    mkdir -p /remaster/chroot /remaster/tmp /remaster/cdrom
41    mount -t tmpfs tmpfs /remaster/tmp
42    echo "#:# edit the following two lines to change the boot message" \
43            >/remaster/msg
44    echo "#:#" >>/remaster/msg
45    sed 1,2d /live/image/boot/isolinux/boot.msg >>/remaster/msg
46 fi
47
48 mount -t squashfs /live/image/live/grml.squashfs /remaster/cdrom -o ro,loop
49 mount -t aufs aufs /remaster/chroot -o br:/remaster/tmp=rw:/remaster/cdrom=rr
50
51 for i in dev proc root sys tmp; do
52     mount --bind /$i /remaster/chroot/$i
53 done
54
55 echo "Now edit the contents of the live CD in this chrooted shell:"
56 chroot /remaster/chroot
57
58 for i in dev proc root sys tmp; do
59         umount /remaster/chroot/$i
60 done
61
62 $EDITOR /remaster/msg
63
64 mkdir /remaster/iso
65 for i in /live/image/*; do
66     if [ ! $i == /live/image/live ]; then
67        cp -R $i /remaster/iso
68     fi
69 done
70
71 rm /remaster/iso/boot/isolinux/boot.msg
72 sed 3,4d /live/image/boot/isolinux/boot.msg \
73         >/remaster/iso/boot/isolinux/boot.msg
74 sed 1,2d /remaster/msg >>/remaster/iso/boot/isolinux/boot.msg
75
76 mkdir /remaster/iso/live
77 mksquashfs /remaster/chroot /remaster/iso/live/grml.squashfs
78 umount /remaster/chroot /remaster/cdrom
79
80 mkisofs -b boot/isolinux/isolinux.bin -no-emul-boot -c boot/isolinux/boot.cat \
81         -boot-info-table -l -r -J -o "$1" /remaster/iso
82 rm -R /remaster/iso
83
84 echo ""
85 echo "ISO generation complete:"
86 ls --color -l "$1"
87 echo "If you want to customize your ISO, just call grml-live-remaster again."
88
89 ## END OF FILE #################################################################
90 # vim: ai filetype=sh expandtab