Subversion Repositories livecd

Rev

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

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