Subversion Repositories livecd

Rev

Go to most recent revision | Details | 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 livecd.conf to $CDDATA"
47
cp -a ../livecd.conf $CDDATA/
48
 
49
echo "copying cd-root to $CDDATA"
50
cp -R cd-root/* $CDDATA
51
if [ ! $SMP ]; then
52
    # delete line with "SMP kernel" in boot/splash.cfg
53
    sed -i "/SMP kernel/d" $CDDATA/boot/splash.cfg
54
    # delete 'or "smp" ' in  boot/help*.txt
55
    sed -i 's/or "smp" //' $CDDATA/boot/help*.txt
56
fi
57
 
58
# cp -R tools $CDDATA
59
cp -R info/* $CDDATA
60
 
61
echo "using kernel from $VMLINUZ"
62
echo "and kernel modules from /lib/modules/$KERNEL"
63
cp $VMLINUZ $CDDATA/boot/vmlinuz
64
if [ $SMP ]; then 
65
    echo "using kernel from $VMLINUZ_SMP"
66
    echo "and kernel modules from /lib/modules/${KERNEL}smp"
67
    cp $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
68
fi
69
 
70
BUILD_KERNELS="$KERNEL"
71
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
72
 
73
echo "creating initrd image..."
74
 
75
for BUILD_KERNEL in $BUILD_KERNELS; do
76
 
77
    echo "add kernel $BUILD_KERNEL"
78
    # Set KERNEL=$BUILD_KERNEL in config
79
    sed -i "s|^KERNEL=.*|KERNEL=$BUILD_KERNEL|" config
80
 
81
    cd initrd
82
    ./initrd_create
83
    if [ "$?" -ne 0 ]; then exit; fi
84
    cd ..
85
 
86
    if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
87
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz        # UP Kernel
88
    else
89
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz  # SMP Kernel
90
    fi
91
    rm initrd/$INITRDIMG.gz
92
 
93
done
94
 
95
echo "creating compressed images..."
96
 
97
# home not longer in the list, will be created on the fly
98
# opt -> /usr/opt
99
#
100
if [ "$ARCH" = "x86_64" ]; then
101
    dirs="bin etc lib lib64 root usr sbin var"
102
else
103
    dirs="bin etc lib root usr sbin var"
104
fi
105
 
106
for dir in $dirs; do
107
    if [ -d $ROOT/$dir ]; then
108
      echo "base/$dir.mo"
109
      create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
110
      if [ $? -ne 0 ]; then exit; fi
111
    fi
112
done
113
 
114
echo "creating LiveCD ISO image..."
115
cd $CDDATA
116
./make_iso.sh /tmp/livecd.iso
117
 
118
cd /tmp
119
header "Your ISO is created in /tmp/livecd.iso"