-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcreate_kernel.sh
131 lines (107 loc) · 2.88 KB
/
create_kernel.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
#!/bin/bash
set -e
umask 0022
VERSION="`cat ./version.txt`"
if [ -r "update/vmlinuz.bin" ]; then
KERNEL="update/vmlinuz.bin"
else
KERNEL=""
fi
if [ -r "update/modules.squashfs" ]; then
MODULES_FS="update/modules.squashfs"
else
MODULE_FS=""
fi
if [ -r "update/mininit-syspart" ]; then
MININIT="update/mininit-syspart"
else
MININIT=""
fi
if [ -r "update/ubiboot-v20_mddr_512mb.bin" ]; then
BOOTLOADERS="update/ubiboot-v20_mddr_512mb.bin"
else
BOOTLOADERS=""
fi
# TODO: Reinstate this:
# X-OD-Manual=CHANGELOG
# Copy kernel and rootfs to update dir.
# We want to support symlinks for the kernel and rootfs images and if no
# copy is made, specifying the symlink will include the symlink in the OPK
# and specifying the real path might use a different name than the update
# script expects.
if [ "$KERNEL" ] ; then
DATE=`date -r "$KERNEL" +%F`
else
echo "ERROR: No kernel or rootfs found."
exit 1
fi
if [ "$KERNEL" ] ; then
chmod a-x "$KERNEL" "$MODULES_FS"
echo -n "Calculating SHA1 sum of kernel... "
sha1sum "$KERNEL" | cut -d' ' -f1 > "update/vmlinuz.bin.sha1"
echo "done"
echo -n "Calculating SHA1 sum of modules file-system... "
sha1sum "$MODULES_FS" | cut -d' ' -f1 > "update/modules.squashfs.sha1"
echo "done"
KERNEL="$KERNEL update/vmlinuz.bin.sha1"
MODULES_FS="$MODULES_FS update/modules.squashfs.sha1"
fi
if [ "$BOOTLOADERS" ] ; then
echo -n "Calculating SHA1 sum of bootloaders... "
sha1sum "$BOOTLOADERS" | cut -d' ' -f1 > "update/ubiboot-v20_mddr_512mb.bin.sha1"
echo "done"
BOOTLOADERS="$BOOTLOADERS update/ubiboot-v20_mddr_512mb.bin.sha1"
fi
if [ "$MININIT" ] ; then
echo -n "Calculating SHA1 sum of mininit-syspart... "
sha1sum "$MININIT" | cut -d' ' -f1 > "update/mininit-syspart.sha1"
echo "done"
MININIT="$MININIT update/mininit-syspart.sha1"
fi
echo "$DATE" > update/date.txt
echo "$VERSION" > update/version.txt
# Report metadata.
echo
echo "=========================="
echo "Bootloaders: $BOOTLOADERS"
echo "Mininit: $MININIT"
echo "Kernel: $KERNEL"
echo "Modules file system: $MODULES_FS"
echo "build date: $DATE"
echo "build version: $VERSION"
echo "=========================="
echo
# Write metadata.
cat > update/default.gcw0.desktop <<EOF
[Desktop Entry]
Name=Kernel Update $VERSION
Comment=POCKETGO2 ROGUE Update $DATE
Exec=update.sh
Icon=rogue
Terminal=true
Type=Application
StartupNotify=true
Categories=applications;
EOF
# Create OPK.
OPK_FILE=update/POCKETGO2-Kernel-update-$VERSION-$DATE.opk
mksquashfs \
update/default.gcw0.desktop \
update/rogue.png \
update/update.sh \
update/trimfat.py \
update/flash_partition.sh \
update/date.txt \
update/version.txt \
update/fsck.fat \
$BOOTLOADERS \
$MININIT \
$KERNEL \
$MODULES_FS \
$OPK_FILE \
-no-progress -noappend -comp gzip -all-root
echo
echo "=========================="
echo
echo "Updater OPK: $OPK_FILE"
echo