@@ -27,6 +27,7 @@ usage() {
2727 echo " compile compile go project"
2828 echo " package create spk"
2929 echo " dev runs '_cp', 'compile' and 'package' commands"
30+ echo " clean|clear remove all *spk files"
3031 echo " "
3132}
3233
@@ -40,6 +41,10 @@ _cp() {
4041 # cp -r node_modules/codemirror/theme/monokai.css package/ui/codemirror/theme/
4142}
4243
44+ clean () {
45+ rm -v ./* .spk
46+ }
47+
4348# # Update node_modules
4449update () {
4550 if command -v yarn > /dev/null; then
@@ -87,24 +92,31 @@ compileAll() {
8792 dependencies
8893
8994 # # match arches to go build arches:
90- arch =" arm arm64 386 amd64 ppc64"
91- for ARCH in ${arch} ; do
92- compile " $ARCH "
95+ arches =" arm arm64 386 amd64 ppc64"
96+ os_min_ver=6.1-14715
97+ for arch in ${arches} ; do
9398 supported_arches=" "
94- case " $ARCH " in
99+ case " $arch " in
95100 " arm" )
96- supported_arches=" $ARM5_ARCHES $ARM7_ARCHES "
97- package " $ARCH " " ipq806x northstarplus" " 1.1"
98-
99- supported_arches=$( echo " $supported_arches " | sed ' s/ ipq806x//' | sed ' s/ northstarplus//' )
101+ compile " $arch " " 5"
102+ package " $arch " _v5 " $ARM5_ARCHES " " $os_min_ver "
103+
104+ compile " $arch " " 7"
105+ ARM7_ARCHES=$( echo " $ARM7_ARCHES " | sed ' s/ ipq806x//' | sed ' s/ northstarplus//' )
106+ package " $arch " _v7 " $ARM7_ARCHES " " $os_min_ver "
107+ # SRM
108+ package " $arch " _v7 " ipq806x northstarplus" " 1.1.6-6931"
100109 ;;
101- " arm64" )
110+ " arm64" ) # ARMv8
111+ compile " $arch "
102112 supported_arches=" $ARM8_ARCHES "
103113 ;;
104114 " 386" )
115+ compile " $arch "
105116 supported_arches=" $x86_ARCHES "
106117 ;;
107118 " amd64" )
119+ compile " $arch "
108120 supported_arches=" $x64_ARCHES "
109121 ;;
110122 " ppc64" )
@@ -115,26 +127,27 @@ compileAll() {
115127 exit 1
116128 ;;
117129 esac
118- OS_MIN_VER=6.1-14715
119- package " $ARCH " " $supported_arches " " $OS_MIN_VER "
130+ package " $arch " " $supported_arches " " $os_min_ver "
120131 done
121132}
122133
123134# # Step 2 compile
124135compile () {
125- ARCH=" ${1:- " " } "
136+ _ARCH=" ${1:- " " } "
137+ _GOARM=" ${2:- " " } "
126138 if command -v go > /dev/null; then
127139 gofmt -s -w -- package/src/synoedit/* .go
128140 cd package || exit
129141 export GOPATH=$PWD
130142 cd src/synoedit || exit
131143 echo " go compiling ..."
132- if [ -z " $ARCH " ]; then
144+ if [ -z " $_ARCH " ]; then
133145 go build -ldflags=" -s -w" -o ../../ui/index.cgi
134146 # go build -ldflags "-s -w" -o package/ui/index.cgi -- package/src/synoedit/*.go
135147 else
136148 # env GOOS=linux GOARCH="$ARCH" go build -ldflags "-s -w" -o package/ui/index.cgi -- package/src/*.go
137- env CGO_ENABLED=0 GOOS=linux GOARCH=" $ARCH " go build -ldflags " -s -w" -o ../../ui/index.cgi
149+ echo " GOARCH=$_ARCH GOARM=$_GOARM "
150+ env CGO_ENABLED=0 GOOS=linux GOARCH=" $_ARCH " GOARM=" $_GOARM " go build -ldflags " -s -w" -o ../../ui/index.cgi
138151 fi
139152 cd ../../.. || edit
140153 else
@@ -156,9 +169,9 @@ compress() { # not recommended, slows down launch time ~0.8s
156169
157170# # Step 3 Compress package and create spk
158171package () {
159- ARCH =${1:- native}
160- SUPP_ARCH =${2:- noarch}
161- OS_MIN_VER =${3:- 6.1-14715}
172+ _arch =${1:- native}
173+ _supported_arches =${2:- noarch}
174+ _os_min_ver =${3:- 6.1-14715}
162175 # sha1sum="$(shell command -v sha1sum 2>/dev/null || command -v gsha1sum 2>/dev/null)"
163176 # sha256sum="$(shell command -v sha256sum 2>/dev/null || command -v gsha256sum 2>/dev/null)"
164177 md5sum=" $( shell command -v md5sum 2> /dev/null || command -v gmd5sum 2> /dev/null) "
@@ -176,13 +189,13 @@ package() {
176189 # # Create checksum
177190 checksum=$( $md5sum package.tgz | awk ' {print $1}' )
178191 sed -i ' ' -e " s/checksum=.*/checksum=\" ${checksum} \" /" INFO
179- sed -i ' ' -e " s/arch=.*/arch=\" ${SUPP_ARCH } \" /" INFO
180- sed -i ' ' -e " s/os_min_ver=.*/os_min_ver=\" ${OS_MIN_VER } \" /" INFO
192+ sed -i ' ' -e " s/arch=.*/arch=\" ${_supported_arches } \" /" INFO
193+ sed -i ' ' -e " s/os_min_ver=.*/os_min_ver=\" ${_os_min_ver } \" /" INFO
181194 # pkg_get_spk_platform
182195 # pkg_get_spk_family
183196
184197 # # Create spk
185- tar cpf synoedit-" $ARCH " -" $OS_MIN_VER " .spk \
198+ tar cpf synoedit-" $_arch " -" $_os_min_ver " .spk \
186199 --exclude=' node_modules' \
187200 --exclude=' *.afdesign' \
188201 --exclude=' *.afphoto' \
@@ -219,6 +232,8 @@ elif [ "$CMD" = "dev" ]; then
219232 _cp
220233 compile
221234 package
235+ elif [ " $CMD " = " clean" ] || [ " $CMD " = " clear" ]; then
236+ clean
222237else
223238 usage
224239fi
0 commit comments