-
Notifications
You must be signed in to change notification settings - Fork 2
/
package.sh
executable file
·38 lines (32 loc) · 982 Bytes
/
package.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
#!/bin/bash
rm -rf node_modules
if [ -z "${ADDON_ARCH}" ]; then
TARFILE_SUFFIX=
else
NODE_VERSION="$(node --version)"
TARFILE_SUFFIX="-${ADDON_ARCH}-${NODE_VERSION/\.*/}"
fi
# For openwrt-linux-arm and linux-arm we need to cross compile.
if [[ "${ADDON_ARCH}" =~ "linux-arm" ]]; then
# We assume that CC and CXX are pointing to the cross compilers
npm install --ignore-scripts
npm rebuild --arch=armv6l --target_arch=arm
else
npm install
fi
npm run build
npm prune --production
npm cache clean --force
rm -f SHA256SUMS
sha256sum manifest.json package.json LICENSE README.md > SHA256SUMS
find dist node_modules -type f -exec sha256sum {} \; >> SHA256SUMS
TARFILE="$(npm pack)"
tar xzf ${TARFILE}
rm ${TARFILE}
TARFILE_ARCH="${TARFILE/.tgz/${TARFILE_SUFFIX}.tgz}"
cp -r node_modules ./package
tar czf ${TARFILE_ARCH} package
rm -rf package
echo "Created ${TARFILE_ARCH}"
sha256sum $TARFILE_ARCH > ${TARFILE_ARCH}.sha256sum
echo "Created ${TARFILE_ARCH}.sha256sum"