-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·92 lines (74 loc) · 2.41 KB
/
package.sh
File metadata and controls
executable file
·92 lines (74 loc) · 2.41 KB
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
#!/bin/bash -e
# Setup environment for building inside Dockerized toolchain
export NVM_DIR="${HOME}/.nvm"
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
[ $(id -u) = 0 ] && umask 0
if [ -z "${ADDON_ARCH}" ]; then
# This means we're running locally. Fake out ADDON_ARCH.
# This happens when you run ./package.sh locally
UNAME=$(uname -s)
case "${UNAME}" in
Linux)
ADDON_ARCH=linux-arm64
;;
Darwin)
ADDON_ARCH=darwin-x64
;;
*)
echo "Unrecognized uname -s: ${UNAME}"
exit 1
;;
esac
echo "Faking ADDON_ARCH = ${ADDON_ARCH}"
else
echo "ADDON_ARCH = ${ADDON_ARCH}"
fi
echo "ADDON_ARCH = ${ADDON_ARCH}"
rm -rf node_modules
if [ -z "${ADDON_ARCH}" ]; then
TARFILE_SUFFIX=
else
NODE_VERSION="$(node --version)"
TARFILE_SUFFIX="-${ADDON_ARCH}-${NODE_VERSION/\.*/}"
fi
echo "TARFILE_SUFFIX: $TARFILE_SUFFIX"
#npm install -g pnpm
#pnpm install --frozen-lockfile
echo "doing npm rebuild. Node version is:"
node --version
echo "... and node version should be:"
echo $NODE_VERSION
echo ""
npm --yes rebuild
CPPFLAGS="-DPNG_ARM_NEON_OPT=0" npm --yes install --omit=dev
# small hack to allow metadata to be sent with internal gateway messages
if [ -f ./node_modules/gateway-addon/lib/property.js ]; then
sed -i 's/setValue(value) {/setValue(value, meta) {/g' ./node_modules/gateway-addon/lib/property.js
else
echo "ERROR, could not modify property.js"
exit 1
fi
echo "ls images:"
ls images
echo ""
curl -s https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep -m 1 '"url":' | cut -d : -f 2,3 | tr -d \" | sed 's/,*$//g' | xargs -n1 curl -s | grep tarball_url | cut -d : -f 2,3 | tr -d \" | sed 's/,*$//g' | xargs -n1 curl -L -o "z2m.tar.gz"
shasum --algorithm 256 manifest.json package.json package-lock.json *.js LICENSE README.md z2m.tar.gz > SHA256SUMS
find css images js node_modules views z2m.tar.gz \( -type f -o -type l \) -exec shasum --algorithm 256 {} \; >> SHA256SUMS
TARFILE=`npm pack`
echo "TARFILE after npm pack: $TARFILE"
tar xzf ${TARFILE}
rm ${TARFILE}
TARFILE_ARCH="${TARFILE/.tgz/${TARFILE_SUFFIX}.tgz}"
cp z2m.tar.gz ./package
cp package-lock.json ./package
cp -r node_modules ./package
cp -r images ./package
echo "TARFILE_ARCH: $TARFILE_ARCH"
echo ""
echo "ls package/images:"
ls package/images
echo ""
tar czf ${TARFILE_ARCH} package
shasum --algorithm 256 ${TARFILE_ARCH} > ${TARFILE_ARCH}.sha256sum
rm -rf SHA256SUMS package
exit 0