Subversion Repositories livecd

Rev

Rev 16 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 beyerle@PS 1
#!/bin/bash
2
#
3
# run this script to create a LiveCD in /tmp/livecd.iso
4
# Your kernel image has to be in $ROOT/boot/vmlinuz or $ROOT/vmlinuz
5
# 
6
# Urs Beyerle, PSI:
7
# - add x86_64 support
8
# - add support to build for UP and SMP kernel
9
#   SMP kernel is added to LiveCD, if variable $SMP is set
16 beyerle@PS 10
# - copy System.map-* and config-* to CDDATA/boot
11
#   and copy /boot/grub/splash.xpm.gz to CDDATA/boot/grub
12
#   both needed for install LiveCD in local harddisk
23 beyerle@PS 13
# - config no longer sourced, we take ../livecd.conf
1 beyerle@PS 14
#
15
 
16
export LANG=C
17
 
18
ARCH=$( /bin/arch )
19
[ "$ARCH" != "x86_64" ] && ARCH=i686
20
 
21
# export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
22
export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/:.:./tools:../tools
23
 
24
CHANGEDIR="`dirname \`readlink -f $0\``"
25
echo "Changing current directory to $CHANGEDIR"
26
cd $CHANGEDIR
27
 
28
. liblinuxlive || exit 1
23 beyerle@PS 29
# . config || exit 1
30
. ../livecd.conf || exit 1
1 beyerle@PS 31
 
32
./install $ROOT
33
 
34
VMLINUZ=$ROOT/boot/vmlinuz
35
if [ -L "$VMLINUZ" ]; then VMLINUZ=`readlink -f $VMLINUZ`; fi
36
if [ "`ls $VMLINUZ 2>/dev/null`" = "" ]; then echo "cannot find $VMLINUZ"; exit 1; fi
37
 
38
if [ $SMP ]; then
39
    VMLINUZ_SMP=$ROOT/boot/vmlinuz${SMP}
40
    if [ -L "$VMLINUZ_SMP" ]; then VMLINUZ_SMP=`readlink -f $VMLINUZ_SMP`; fi
41
    if [ "`ls $VMLINUZ_SMP 2>/dev/null`" = "" ]; then echo "cannot find $VMLINUZ_SMP"; exit 1; fi
42
fi
43
 
44
header "Creating LiveCD from your Linux"
45
 
46
mkdir -p $CDDATA/base
47
mkdir -p $CDDATA/modules
48
mkdir -p $CDDATA/optional
49
mkdir -p $CDDATA/rootcopy
50
 
51
echo "copying livecd.conf to $CDDATA"
52
cp -a ../livecd.conf $CDDATA/
53
 
54
echo "copying cd-root to $CDDATA"
55
cp -R cd-root/* $CDDATA
56
if [ ! $SMP ]; then
57
    # delete line with "SMP kernel" in boot/splash.cfg
58
    sed -i "/SMP kernel/d" $CDDATA/boot/splash.cfg
59
    # delete 'or "smp" ' in  boot/help*.txt
60
    sed -i 's/or "smp" //' $CDDATA/boot/help*.txt
61
fi
62
 
63
# cp -R tools $CDDATA
64
cp -R info/* $CDDATA
65
 
16 beyerle@PS 66
# copy splash.xpm.gz to LiveCD
67
mkdir -p $CDDATA/boot/grub
68
cp -a $ROOT/boot/grub/splash.xpm.gz $CDDATA/boot/grub/
69
 
70
# copy kernel(s) to LiveCD
1 beyerle@PS 71
echo "using kernel from $VMLINUZ"
72
echo "and kernel modules from /lib/modules/$KERNEL"
16 beyerle@PS 73
cp -a $VMLINUZ $CDDATA/boot/vmlinuz
1 beyerle@PS 74
if [ $SMP ]; then 
75
    echo "using kernel from $VMLINUZ_SMP"
76
    echo "and kernel modules from /lib/modules/${KERNEL}smp"
16 beyerle@PS 77
    cp -a $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
1 beyerle@PS 78
fi
79
 
16 beyerle@PS 80
# copy System.map and config to LiveCD
81
cp -a $ROOT/boot/System.map-* $CDDATA/boot/
82
cp -a $ROOT/boot/config-* $CDDATA/boot/
83
 
1 beyerle@PS 84
BUILD_KERNELS="$KERNEL"
85
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
86
 
87
echo "creating initrd image..."
88
 
89
for BUILD_KERNEL in $BUILD_KERNELS; do
90
 
91
    cd initrd
23 beyerle@PS 92
    ./initrd_create $BUILD_KERNEL
1 beyerle@PS 93
    if [ "$?" -ne 0 ]; then exit; fi
94
    cd ..
95
    if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
23 beyerle@PS 96
	echo "add initrd.gz for kernel $BUILD_KERNEL"
1 beyerle@PS 97
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz        # UP Kernel
98
    else
23 beyerle@PS 99
	echo "add initrd${SMP}.gz for kernel $BUILD_KERNEL"
1 beyerle@PS 100
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz  # SMP Kernel
101
    fi
102
    rm initrd/$INITRDIMG.gz
103
 
104
done
105
 
106
echo "creating compressed images..."
107
 
108
# home not longer in the list, will be created on the fly
109
# opt -> /usr/opt
110
#
111
if [ "$ARCH" = "x86_64" ]; then
112
    dirs="bin etc lib lib64 root usr sbin var"
113
else
114
    dirs="bin etc lib root usr sbin var"
115
fi
116
 
117
for dir in $dirs; do
118
    if [ -d $ROOT/$dir ]; then
119
      echo "base/$dir.mo"
120
      create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
121
      if [ $? -ne 0 ]; then exit; fi
122
    fi
123
done
124
 
2 beyerle@PS 125
# remove any .svn folders from the CD
126
find $CDDATA -type d -name .svn -exec rm -f {} \;
127
 
1 beyerle@PS 128
echo "creating LiveCD ISO image..."
129
cd $CDDATA
130
./make_iso.sh /tmp/livecd.iso
131
 
132
cd /tmp
133
header "Your ISO is created in /tmp/livecd.iso"