Subversion Repositories livecd

Rev

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

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