build-arm.sh 2.71 KB
Newer Older
Cédric Moreau's avatar
Cédric Moreau committed
1
2
3
4
5
6
#!/bin/bash

# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

7

Cédric Moreau's avatar
Cédric Moreau committed
8
# Prepare
9
NODE_VERSION=8.9.1
Cédric Moreau's avatar
Cédric Moreau committed
10
ARCH="`uname -m | sed -e \"s/86_//\"`"
11
NVER="v$NODE_VERSION"
12
DUNITER_TAG=$1
Cédric Moreau's avatar
Cédric Moreau committed
13
14
15
16
17
18
19

# Folders
INITIAL_DIRECTORY=`pwd`
ROOT="/tmp/build_duniter"
DOWNLOADS="$ROOT/downloads"
RELEASES="$ROOT/releases"

20
21
22
23
24
nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}

echo "Version de NodeJS : `node -v`"

Cédric Moreau's avatar
Cédric Moreau committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -----------
# Clean sources + releases
# -----------
rm -rf "$ROOT"

mkdir -p "$DOWNLOADS"

# -----------
# Downloads
# -----------

cd "$DOWNLOADS"

if [ ! -d "$DOWNLOADS/duniter" ]; then
39
  mv "$INITIAL_DIRECTORY/duniter-source" duniter
Cédric Moreau's avatar
Cédric Moreau committed
40
41
42
43
44
45
46
47
48
  cd duniter
  git checkout "v${DUNITER_TAG}"
  cd ..
fi

DUNITER_VER="$DUNITER_TAG"
DUNITER_DEB_VER=" $DUNITER_TAG"
DUNITER_TAG="v$DUNITER_TAG"

49
50
51
52
echo "Arch: $ARCH"
echo "Nver: $NVER"
echo "DuniterVer: $DUNITER_VER"
echo "DebianVer: $DUNITER_DEB_VER"
Cédric Moreau's avatar
Cédric Moreau committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

if [ ! -f "$DOWNLOADS/node-${NVER}-linux-${ARCH}.tar.gz" ]; then
  # Download Node.js and package it with the sources
  wget http://nodejs.org/dist/${NVER}/node-${NVER}-linux-${ARCH}.tar.gz
  tar xzf node-${NVER}-linux-${ARCH}.tar.gz
fi

rm -rf "$RELEASES"
mkdir -p "$RELEASES"

cp -r "$DOWNLOADS/duniter" "$RELEASES/duniter"
cd ${RELEASES}/duniter

echo "Copying Nodejs"
cp -R "$DOWNLOADS/node-${NVER}-linux-${ARCH}" node

69
70
71
npm install

npm install duniter-ui@1.6.x --save --production
Cédric Moreau's avatar
Cédric Moreau committed
72
73
74
75
76
77
78
79
80
81
82
83
84
SRC=`pwd`
echo $SRC

# Clean unused UI modules
rm -Rf node_modules/duniter-ui/node_modules

# Because we are building in a VM, Node.js could not detect that the target is ARM. So we move the modules' binaries accordingly.
#mv node_modules/naclb/lib/binding/Release/node-v48-linux-x64 node_modules/naclb/lib/binding/Release/node-v48-linux-arm
#mv node_modules/wotb/lib/binding/Release/node-v48-linux-x64 node_modules/wotb/lib/binding/Release/node-v48-linux-arm
#mv node_modules/scryptb/lib/binding/Release/node-v48-linux-x64 node_modules/scryptb/lib/binding/Release/node-v48-linux-arm
#mv node_modules/sqlite3/lib/binding/Release/node-v48-linux-x64 node_modules/sqlite3/lib/binding/Release/node-v48-linux-arm

cd ..
Cédric Moreau's avatar
Cédric Moreau committed
85
86
mkdir -p duniter_release
cp -R ${SRC}/* duniter_release/
Cédric Moreau's avatar
Cédric Moreau committed
87
88

# Creating DEB packaging
89
mv duniter_release/release/extra/debian/package duniter-${ARCH}
Cédric Moreau's avatar
Cédric Moreau committed
90
91
92
93
mkdir -p duniter-${ARCH}/opt/duniter/
chmod 755 duniter-${ARCH}/DEBIAN/post*
chmod 755 duniter-${ARCH}/DEBIAN/pre*
sed -i "s/Version:.*/Version:$DUNITER_DEB_VER/g" duniter-${ARCH}/DEBIAN/control
Cédric Moreau's avatar
Cédric Moreau committed
94
cd duniter_release
Cédric Moreau's avatar
Cédric Moreau committed
95
96
97
98
pwd
rm -Rf .git
echo "Zipping..."
zip -qr ../duniter-desktop.nw *
Cédric Moreau's avatar
Cédric Moreau committed
99
100
cd ../
mv duniter-desktop.nw duniter-${ARCH}/opt/duniter/
Cédric Moreau's avatar
Cédric Moreau committed
101
102
echo "Making package package"
fakeroot dpkg-deb --build duniter-${ARCH}
103
mv duniter-${ARCH}.deb "$INITIAL_DIRECTORY/duniter-server-v${DUNITER_VER}-linux-${ARCH}.deb"