Subversion Repositories livecd

Rev

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

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