Subversion Repositories livecd

Rev

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