Subversion Repositories livecd

Rev

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

Rev 1 Rev 2
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"
46
echo "copying livecd.conf to $CDDATA"
47
cp -a ../livecd.conf $CDDATA/
47
cp -a ../livecd.conf $CDDATA/
48
 
48
 
49
echo "copying cd-root to $CDDATA"
49
echo "copying cd-root to $CDDATA"
50
cp -R cd-root/* $CDDATA
50
cp -R cd-root/* $CDDATA
51
if [ ! $SMP ]; then
51
if [ ! $SMP ]; then
52
    # delete line with "SMP kernel" in boot/splash.cfg
52
    # delete line with "SMP kernel" in boot/splash.cfg
53
    sed -i "/SMP kernel/d" $CDDATA/boot/splash.cfg
53
    sed -i "/SMP kernel/d" $CDDATA/boot/splash.cfg
54
    # delete 'or "smp" ' in  boot/help*.txt
54
    # delete 'or "smp" ' in  boot/help*.txt
55
    sed -i 's/or "smp" //' $CDDATA/boot/help*.txt
55
    sed -i 's/or "smp" //' $CDDATA/boot/help*.txt
56
fi
56
fi
57
 
57
 
58
# cp -R tools $CDDATA
58
# cp -R tools $CDDATA
59
cp -R info/* $CDDATA
59
cp -R info/* $CDDATA
60
 
60
 
61
echo "using kernel from $VMLINUZ"
61
echo "using kernel from $VMLINUZ"
62
echo "and kernel modules from /lib/modules/$KERNEL"
62
echo "and kernel modules from /lib/modules/$KERNEL"
63
cp $VMLINUZ $CDDATA/boot/vmlinuz
63
cp $VMLINUZ $CDDATA/boot/vmlinuz
64
if [ $SMP ]; then 
64
if [ $SMP ]; then 
65
    echo "using kernel from $VMLINUZ_SMP"
65
    echo "using kernel from $VMLINUZ_SMP"
66
    echo "and kernel modules from /lib/modules/${KERNEL}smp"
66
    echo "and kernel modules from /lib/modules/${KERNEL}smp"
67
    cp $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
67
    cp $VMLINUZ_SMP $CDDATA/boot/vmlinuz${SMP}
68
fi
68
fi
69
 
69
 
70
BUILD_KERNELS="$KERNEL"
70
BUILD_KERNELS="$KERNEL"
71
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
71
[ $SMP ] && BUILD_KERNELS="$BUILD_KERNELS ${KERNEL}smp"
72
 
72
 
73
echo "creating initrd image..."
73
echo "creating initrd image..."
74
 
74
 
75
for BUILD_KERNEL in $BUILD_KERNELS; do
75
for BUILD_KERNEL in $BUILD_KERNELS; do
76
 
76
 
77
    echo "add kernel $BUILD_KERNEL"
77
    echo "add kernel $BUILD_KERNEL"
78
    # Set KERNEL=$BUILD_KERNEL in config
78
    # Set KERNEL=$BUILD_KERNEL in config
79
    sed -i "s|^KERNEL=.*|KERNEL=$BUILD_KERNEL|" config
79
    sed -i "s|^KERNEL=.*|KERNEL=$BUILD_KERNEL|" config
80
 
80
 
81
    cd initrd
81
    cd initrd
82
    ./initrd_create
82
    ./initrd_create
83
    if [ "$?" -ne 0 ]; then exit; fi
83
    if [ "$?" -ne 0 ]; then exit; fi
84
    cd ..
84
    cd ..
85
 
85
 
86
    if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
86
    if [ "$BUILD_KERNEL" = "$KERNEL" ]; then
87
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz        # UP Kernel
87
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd.gz        # UP Kernel
88
    else
88
    else
89
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz  # SMP Kernel
89
	cp initrd/$INITRDIMG.gz $CDDATA/boot/initrd${SMP}.gz  # SMP Kernel
90
    fi
90
    fi
91
    rm initrd/$INITRDIMG.gz
91
    rm initrd/$INITRDIMG.gz
92
 
92
 
93
done
93
done
94
 
94
 
95
echo "creating compressed images..."
95
echo "creating compressed images..."
96
 
96
 
97
# home not longer in the list, will be created on the fly
97
# home not longer in the list, will be created on the fly
98
# opt -> /usr/opt
98
# opt -> /usr/opt
99
#
99
#
100
if [ "$ARCH" = "x86_64" ]; then
100
if [ "$ARCH" = "x86_64" ]; then
101
    dirs="bin etc lib lib64 root usr sbin var"
101
    dirs="bin etc lib lib64 root usr sbin var"
102
else
102
else
103
    dirs="bin etc lib root usr sbin var"
103
    dirs="bin etc lib root usr sbin var"
104
fi
104
fi
105
 
105
 
106
for dir in $dirs; do
106
for dir in $dirs; do
107
    if [ -d $ROOT/$dir ]; then
107
    if [ -d $ROOT/$dir ]; then
108
      echo "base/$dir.mo"
108
      echo "base/$dir.mo"
109
      create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
109
      create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
110
      if [ $? -ne 0 ]; then exit; fi
110
      if [ $? -ne 0 ]; then exit; fi
111
    fi
111
    fi
112
done
112
done
113
 
113
 
-
 
114
# remove any .svn folders from the CD
-
 
115
find $CDDATA -type d -name .svn -exec rm -f {} \;
-
 
116
 
114
echo "creating LiveCD ISO image..."
117
echo "creating LiveCD ISO image..."
115
cd $CDDATA
118
cd $CDDATA
116
./make_iso.sh /tmp/livecd.iso
119
./make_iso.sh /tmp/livecd.iso
117
 
120
 
118
cd /tmp
121
cd /tmp
119
header "Your ISO is created in /tmp/livecd.iso"
122
header "Your ISO is created in /tmp/livecd.iso"