Subversion Repositories livecd

Rev

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