-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathZ-compile
executable file
·119 lines (101 loc) · 4.69 KB
/
Z-compile
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
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <release-name> <minor-version>"
echo "Example: $0 junwei 3.58"
exit
fi
. ./0-vars
FULLFILEUNCOMPRESSED=$HDDROOTFSPATH
if [ $LINKSTATION -eq 1 ]; then
AUTOFILE=linkstation_series-$VERSIONDOT-$1.zip
FW_INFO=$FINALOUTPUTAUTO/fw_info2.xml
else
AUTOFILE=cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip
FW_INFO=/dev/null
fi
echo $0 running...
echo " Cleaning up old versions"
rm -f $HDDROOTFSPATH/hddrootfs.img
rm -f $RESOURCES/hddrootfs.buffalo.updated
echo " Update firmware revision"
DAT="`date "+%Y/%m/%d %H:%M:%S"`"
sed -i "s/^VERSION=$VERSIONDOT.*\$/VERSION=$VERSIONDOT-$1/" $SRC/etc/linkstation_release
sed -i "s/^SUBVERSION=.*\$/SUBVERSION=HDD $2/" $SRC/etc/linkstation_release
sed -i "s,^BUILDDATE=.*\$,BUILDDATE=$DAT," $SRC/etc/linkstation_release
sed -i "s/^VERSION=$VERSIONDOT.*\$/VERSION=$VERSIONDOT-$1-$2\r/" $HDDROOTFSPATH/linkstation_version.ini
sed -i "s,^ROOTFS=.*\$,ROOTFS=$DAT\r," $HDDROOTFSPATH/linkstation_version.ini
sed -i "s/^VERSION=$VERSIONDOT.*\$/VERSION=$VERSIONDOT-$1-$2\r/" $HDDROOTFSPATH/linkstation_version.txt
sed -i "s,^ROOTFS=.*\$,ROOTFS=$DAT\r," $HDDROOTFSPATH/linkstation_version.txt
echo " Compressing hddrootfs.buffalo.updated"
tar -C $SRC -cf $RESOURCES/hddrootfs.buffalo.updated.tar .
gzip -9 $RESOURCES/hddrootfs.buffalo.updated.tar
mv $RESOURCES/hddrootfs.buffalo.updated.tar.gz $RESOURCES/hddrootfs.buffalo.updated
echo " Encrypting to hddrootfs.img"
zip -9 -q -j -e $HDDROOTFSPATH/hddrootfs.img $RESOURCES/hddrootfs.buffalo.updated -P "`cat $RESOURCES/password$VERSION`"
echo " Copying hddrootfs.buffalo.updated to autoupdate folder and preparing other autoupdate files"
rm -rf $TMPFOLDER
mkdir $TMPFOLDER
if [ $LINKSTATION -eq 1 ]; then
#unzip -q -o -d $TMPFOLDER -P "`cat $RESOURCES/password$VERSION`" $FULLFILEUNCOMPRESSED/hddrootfs.img
cp $RESOURCES/hddrootfs.buffalo.updated $TMPFOLDER
unzip -q -o -d $TMPFOLDER -P "`cat $RESOURCES/initrd$VERSION`" $FULLFILEUNCOMPRESSED/initrd.img
unzip -q -o -d $TMPFOLDER -P "`cat $RESOURCES/u-boot$VERSION`" $FULLFILEUNCOMPRESSED/u-boot.img
unzip -q -o -d $TMPFOLDER -P "`cat $RESOURCES/uimage$VERSION`" $FULLFILEUNCOMPRESSED/uImage.img
fi
echo " Clean up hddrootfs.buffalo.updated"
rm -f $RESOURCES/hddrootfs.buffalo.updated
if [ $LINKSTATION -ne 1 ]; then
echo " Creating full firmware zip cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip"
cd $FIRMWARESHELL
zip -q -r ../cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip .
cd $FIRMWARESHELLBACKOUT
if [ -d "$FINALOUTPUTFULL" ]; then
echo " Moving full firmware to final place at $FINALOUTPUTFULL"
mv $RESOURCES/cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip $FINALOUTPUTFULL
else
echo "**$FINALOUTPUTFULL does not exist, keeping firmware at $RESOURCES/cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip"
echo "**Consider settings \$FINALOUTPUTFULL in $0"
fi
echo "DONE cloudstor-firmware-build-$VERSIONDOT-$SUBVERSION-$1.zip"
exit
fi
echo " Create autoupdate file $AUTOFILE"
cd $TMPFOLDER
zip -9 -q -r $AUTOFILE .
cd $TMPFOLDERBACKOUT
echo " Creating full firmware zip ls_series-$VERSION-$1.zip"
cd $FIRMWARESHELL
zip -q -r ../ls_series-$VERSION-$1.zip .
cd $FIRMWARESHELLBACKOUT
if [ -d "$FINALOUTPUTAUTO" ]; then
echo " Moving autoupdate to final place at $FINALOUTPUTAUTO"
mv $TMPFOLDER/$AUTOFILE $FINALOUTPUTAUTO
SIZE="`stat -c%s $FINALOUTPUTAUTO/$AUTOFILE`"
MD5="`md5sum $FINALOUTPUTAUTO/$AUTOFILE | cut -c-32`"
else
echo "**$FINALOUTPUTAUTO does not exist, keeping autoupdate firmware at $TMPFOLDER/$AUTOFILE"
echo "**Consider setting \$FINALOUTPUTAUTO in $0"
SIZE="`stat -c%s $TMPFOLDER/$AUTOFILE`"
MD5="`md5sum $TMPFOLDER/$AUTOFILE | cut -c-32`"
fi
if [ -d "$FINALOUTPUTFULL" ]; then
echo " Moving full firmware to final place at $FINALOUTPUTFULL"
mv $RESOURCES/ls_series-$VERSION-$1.zip $FINALOUTPUTFULL
else
echo "**$FINALOUTPUTFULL does not exist, keeping firmware at $RESOURCES/ls_series-$VERSION-$1.zip"
echo "**Consider settings \$FINALOUTPUTFULL in $0"
fi
if [ -f "$FW_INFO" ]; then
echo " Adding changes to fw_info"
sed -i '/^\s*<size>$/,/^\s*<\/size>$/ {/size/ !{s/^\(\s*\)[0-9]*$/\1'"$SIZE"'/}}' $FW_INFO
sed -i '/^\s*<checksum/,/^\s*<\/checksum>$/ {/checksum/ !{s/^\(\s*\)[a-zA-Z0-9]*$/\1'"$MD5"'/}}' $FW_INFO
sed -i '/^\s*<version/,/^\s*<\/version>$/ {/version/ !{s/^\(\s*\)[-\.0-9]*$/\1'"$VERSIONDOT-$2"'/}}' $FW_INFO
sed -i '/^\s*<name/,/^\s*<\/name>$/ {/name/ !{s/^\(\s*\).*$/\1LinkStation Series Firmware Updater Ver.'"$VERSIONDOT $1"'/}}' $FW_INFO
else
echo "**$FW_INFO doesn't exist."
echo "**Consider setting \$FW_INFO in $0"
fi
echo "DONE ls_series-$VERSION-$1.zip"
echo "DONE $AUTOFILE"
echo "AutoUpdate FILESIZE: $SIZE"
echo "AutoUpdate MD5SUM: $MD5"