-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_zip.sh
125 lines (100 loc) · 3.24 KB
/
create_zip.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
#!/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.
#
. ./Version.inc
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 1 ]
then
echo "Usage $0 output-zip-file"
echo "The skin, plugins, dds and launch files under packfiles will be installed."
exit 255
fi
export ZIPFILE=$1
if [ "`id -u`" != "0" ]
then
echo "You have to be root to execute $0"
exit 255
fi
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"
echo "--- Building a new m1e binary packfile"
(cd .core; make pf)
# 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 master_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
sh create_os_packfile.sh
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."