Subversion Repositories livecd

Rev

Rev 8 | 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
10
#
11
 
12
export LANG=C
13
 
14
ARCH=$( /bin/arch )
15
[ "$ARCH" != "x86_64" ] && ARCH=i686
16
 
17
# export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
18
export PATH=/usr/sbin:/usr/bin:/sbin:/bin:/:.:./tools:../tools
19
 
20
CHANGEDIR="`dirname \`readlink -f $0\``"
21
echo "Changing current directory to $CHANGEDIR"
22
cd $CHANGEDIR
23
 
24
. liblinuxlive || exit 1
25
. config || exit 1
26
 
27
./install $ROOT
28
 
29
VMLINUZ=$ROOT/boot/vmlinuz
30
if [ -L "$VMLINUZ" ]; then VMLINUZ=`readlink -f $VMLINUZ`; fi
31
if [ "`ls $VMLINUZ 2>/dev/null`" = "" ]; then echo "cannot find $VMLINUZ"; exit 1; fi
32
 
33
if [ $SMP ]; then
34
    VMLINUZ_SMP=$ROOT/boot/vmlinuz${SMP}
35
    if [ -L "$VMLINUZ_SMP" ]; then VMLINUZ_SMP=`readlink -f $VMLINUZ_SMP`; fi
36
    if [ "`ls $VMLINUZ_SMP 2>/dev/null`" = "" ]; then echo "cannot find $VMLINUZ_SMP"; exit 1; fi
37
fi
38
 
39
header "Creating LiveCD from your Linux"
40
 
41
mkdir -p $CDDATA/base
42
mkdir -p $CDDATA/modules
43
mkdir -p $CDDATA/optional
44
mkdir -p $CDDATA/rootcopy
45
 
46
echo "copying cd-root to $CDDATA"
47
cp -R cd-root/* $CDDATA
48
if [ ! $SMP ]; then
49
    # delete line with "SMP kernel" in boot/splash.cfg
50
    sed -i "/SMP kernel/d" $CDDATA/boot/splash.cfg
51
    # delete 'or "smp" ' in  boot/help*.txt
52
    sed -i 's/or "smp" //' $CDDATA/boot/help*.txt
53
fi
54
 
55
# cp -R tools $CDDATA
56
cp -R info/* $CDDATA
57
 
58
echo "using kernel from $VMLINUZ"
59
echo "and kernel modules from /lib/modules/$KERNEL"
60
cp $VMLINUZ $CDDATA/boot/vmlinuz
61
if [ $SMP ]; then 
62
    echo "using kernel from $VMLINUZ_SMP"
63
    echo "and kernel modules from /lib/modules/${KERNEL}smp"
64
    cp $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
65
fi
66
 
67
BUILD_KERNELS="$KERNEL"
68
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
69
 
70
echo "creating initrd image..."
71
 
72
for BUILD_KERNEL in $BUILD_KERNELS; do
73
 
74
    echo "add kernel $BUILD_KERNEL"
75
    # Set KERNEL=$BUILD_KERNEL in config
76
    sed -i "s|^KERNEL=.*|KERNEL=$BUILD_KERNEL|" config
77
 
78
    cd initrd
79
    ./initrd_create
80
    if [ "$?" -ne 0 ]; then exit; fi
81
    cd ..
82
 
83
    if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
84
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz        # UP Kernel
85
    else
86
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz  # SMP Kernel
87
    fi
88
    rm initrd/$INITRDIMG.gz
89
 
90
done
91
 
92
echo "creating compressed images..."
93
 
94
# home not longer in the list, will be created on the fly
95
# opt -> /usr/opt
96
#
97
if [ "$ARCH" = "x86_64" ]; then
98
    dirs="bin etc lib lib64 root usr sbin var"
99
else
100
    dirs="bin etc lib root usr sbin var"
101
fi
102
 
103
for dir in $dirs; do
104
    if [ -d $ROOT/$dir ]; then
105
      echo "base/$dir.mo"
106
      create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
107
      if [ $? -ne 0 ]; then exit; fi
108
    fi
109
done
110
 
111
echo "creating LiveCD ISO image..."
112
cd $CDDATA
113
./make_iso.sh /tmp/livecd.iso
114
 
115
cd /tmp
116
header "Your ISO is created in /tmp/livecd.iso"