Subversion Repositories livecd

Rev

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

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