-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_upgrade.sh
133 lines (110 loc) · 3.59 KB
/
create_upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh
#
# All rights reserved. Reproduction, modification, use or disclosure
# to third parties without express authority is forbidden.
# Copyright Magden LLC, California, USA, 2004, 2005, 2006, 2007.
#
# Create a self extractable image that can be dragged and dropped to an USB stick.
# When an M1 with a functional boot loader (and nothing else required) is booted
# It will read the linux and initrd from the USB stick and install OS and all packfiles.
#
export TARGET=jway
#export KERNEL_VERSION=2.6.21.5
#export KERNEL_VERSION=2.6.23.14
#export KERNEL_VERSION=2.6.24
export KERNEL_VERSION=2.6.25.4
export ZIPDIR=ziptmp
if [ $# -lt 4 ]
then
echo "Usage $0 serial output-zip-file {pack1 pack1_ver} {pack2 pack2_ver} ..."
echo "packx will be extracted from database as [packx]_upgrade/packx_ver"
echo "and will be installed as packx/packx_ver."
exit 255
fi
if [ "`id -u`" != "0" ]
then
echo "You have to be root to execute $0"
exit 255
fi
SERIAL=$1
shift
ZIPFILE=$1
shift
LOG=create_zip.log
echo "$0 "'date' > $LOG
echo "--- Log file can be found in create_master.log"
echo "--- Using kernel version ${KERNEL_VERSION}-${TARGET}"
echo "--- Output zip file is $ZIPFILE"
rm -f packfiles/*
while [ "$#" -gt "1" ]
do
PACK=$1
shift
PACK_VER=$1
shift
echo "Creating packfile for [email protected]/${PACK}/${PACK_VER}"
./bin/db2pf -s ${SERIAL} -P -k magden -S .m1 -i [email protected]/${PACK}_upgrade/${PACK_VER} -o packfiles/u_${PACK}_${PACK_VER}_${SERIAL}.pfl -O [email protected]/${PACK}/${PACK_VER}
done
# Reset old directory.
rm -rf /mnt/loopback > /dev/null
mkdir /mnt/loopback > /dev/null 2>&1
rm -rf ${ZIPDIR} > /dev/null
mkdir ${ZIPDIR} > /dev/null 2>&1
#
# Setup the partition and install syslinux boot strap.
#
# Install linux images.
if [ ! -f kernel/linux-${KERNEL_VERSION}-${TARGET}/vmlinux ]
then
echo "--- No kernel has been built."
echo "--- Do:"
echo "--- cd kernel; make; make install"
echo "--- and try again."
exit 255
fi
echo "--- Creating initrd file system"
dd if=/dev/zero of=initrd.tmp count=7500 bs=1024 >> $LOG 2>&1
sync
sync
sync
# Mount it
losetup /dev/loop0 initrd.tmp >> $LOG 2>&1
mke2fs /dev/loop0 >> $LOG 2>&1
/sbin/tune2fs -c0 -i0 /dev/loop0 >> $LOG 2>&1
mount /dev/loop0 /mnt/loopback >> $LOG
# Copy linuxrc script, which does the install
cp upgrade_linuxrc /mnt/loopback/linuxrc
chmod 777 /mnt/loopback/linuxrc
echo "--- Installing linux images."
#
# Copy bzImage and initrd to /mnt
#
cp kernel/linux-${KERNEL_VERSION}-${TARGET}/arch/i386/boot/bzImage ${ZIPDIR}/linux
#Install linux modules
echo "--- Installing modules and other kernel components in initrd."
cp -a images-${KERNEL_VERSION}-${TARGET}/* /mnt/loopback/
#
# Install root file system in initrd
#
echo "--- Installing master file system skeleton image into initrd."
MASTER_SKELETON=$PWD/master_skeleton.tgz
(cd /mnt/loopback; tar xzpf $MASTER_SKELETON)
echo "--- Populating root file system with busybox build into initrd"
BUSYBOX_PATH=$PWD/busybox/busybox_image.tgz
(cd /mnt/loopback; tar xpf $BUSYBOX_PATH)
# Add packfile unpacker app.
cp ./bin/pf2fs /mnt/loopback/bin
echo "--- Creating master grub used to install bootstrap on target."
mkdir -p /mnt/loopback/boot/grub
cp grub/* /mnt/loopback/boot/grub
mkdir /mnt/loopback/fat
# Unmount loopback disk
umount /mnt/loopback >> $LOG
losetup -d /dev/loop0 >> $LOG
echo "--- Copying initrd to zip target."
gzip -c initrd.tmp > ${ZIPDIR}/initrd
echo "--- Copying all pack files to zip target."
cp packfiles/*.pfl ${ZIPDIR}
echo "--- Building zip file at ${ZIPFILE}"
(cd ${ZIPDIR}; zip -r ../${ZIPFILE} *)
echo "Done."