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 |
|
|
|
30 |
. 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
|
|
|
66 |
cp -R info/* $CDDATA
|
|
|
67 |
|
16 |
beyerle@PS |
68 |
# copy splash.xpm.gz to LiveCD
|
|
|
69 |
mkdir -p $CDDATA/boot/grub
|
|
|
70 |
cp -a $ROOT/boot/grub/splash.xpm.gz $CDDATA/boot/grub/
|
|
|
71 |
|
|
|
72 |
# copy kernel(s) to LiveCD
|
1 |
beyerle@PS |
73 |
echo "using kernel from $VMLINUZ"
|
|
|
74 |
echo "and kernel modules from /lib/modules/$KERNEL"
|
16 |
beyerle@PS |
75 |
cp -a $VMLINUZ $CDDATA/boot/vmlinuz
|
1 |
beyerle@PS |
76 |
if [ $SMP ]; then
|
|
|
77 |
echo "using kernel from $VMLINUZ_SMP"
|
|
|
78 |
echo "and kernel modules from /lib/modules/${KERNEL}smp"
|
16 |
beyerle@PS |
79 |
cp -a $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
|
1 |
beyerle@PS |
80 |
fi
|
|
|
81 |
|
26 |
beyerle@PS |
82 |
# copy System.map, config, etc. to LiveCD /boot
|
16 |
beyerle@PS |
83 |
cp -a $ROOT/boot/System.map-* $CDDATA/boot/
|
26 |
beyerle@PS |
84 |
cp -a $ROOT/boot/config-* $CDDATA/boot/
|
|
|
85 |
cp -a $ROOT/boot/message* $CDDATA/boot/
|
|
|
86 |
cp -a $ROOT/boot/symvers-* $CDDATA/boot/ 2>/dev/null
|
16 |
beyerle@PS |
87 |
|
1 |
beyerle@PS |
88 |
BUILD_KERNELS="$KERNEL"
|
|
|
89 |
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
|
|
|
90 |
|
|
|
91 |
echo "creating initrd image..."
|
|
|
92 |
|
|
|
93 |
for BUILD_KERNEL in $BUILD_KERNELS; do
|
|
|
94 |
|
|
|
95 |
cd initrd
|
23 |
beyerle@PS |
96 |
./initrd_create $BUILD_KERNEL
|
1 |
beyerle@PS |
97 |
if [ "$?" -ne 0 ]; then exit; fi
|
|
|
98 |
cd ..
|
|
|
99 |
if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
|
23 |
beyerle@PS |
100 |
echo "add initrd.gz for kernel $BUILD_KERNEL"
|
1 |
beyerle@PS |
101 |
cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz # UP Kernel
|
|
|
102 |
else
|
23 |
beyerle@PS |
103 |
echo "add initrd${SMP}.gz for kernel $BUILD_KERNEL"
|
1 |
beyerle@PS |
104 |
cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz # SMP Kernel
|
|
|
105 |
fi
|
|
|
106 |
rm initrd/$INITRDIMG.gz
|
|
|
107 |
|
|
|
108 |
done
|
|
|
109 |
|
|
|
110 |
echo "creating compressed images..."
|
|
|
111 |
|
|
|
112 |
# home not longer in the list, will be created on the fly
|
|
|
113 |
# opt -> /usr/opt
|
|
|
114 |
#
|
|
|
115 |
if [ "$ARCH" = "x86_64" ]; then
|
|
|
116 |
dirs="bin etc lib lib64 root usr sbin var"
|
|
|
117 |
else
|
|
|
118 |
dirs="bin etc lib root usr sbin var"
|
|
|
119 |
fi
|
|
|
120 |
|
|
|
121 |
for dir in $dirs; do
|
|
|
122 |
if [ -d $ROOT/$dir ]; then
|
|
|
123 |
echo "base/$dir.mo"
|
|
|
124 |
create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
|
|
|
125 |
if [ $? -ne 0 ]; then exit; fi
|
|
|
126 |
fi
|
|
|
127 |
done
|
|
|
128 |
|
2 |
beyerle@PS |
129 |
# remove any .svn folders from the CD
|
|
|
130 |
find $CDDATA -type d -name .svn -exec rm -f {} \;
|
|
|
131 |
|
1 |
beyerle@PS |
132 |
echo "creating LiveCD ISO image..."
|
|
|
133 |
cd $CDDATA
|
|
|
134 |
./make_iso.sh /tmp/livecd.iso
|
|
|
135 |
|
|
|
136 |
cd /tmp
|
|
|
137 |
header "Your ISO is created in /tmp/livecd.iso"
|