Subversion Repositories livecd

Rev

Rev 130 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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