Subversion Repositories livecd

Rev

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

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