Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 22a56c7

Browse files
committed
Replace gulp with script for package creation
To remove dev dependencies from the final packages, they need to be removed from the package creation process first. This commit does that by replacing gulp with an external script during that process.
1 parent 291b3b4 commit 22a56c7

File tree

2 files changed

+63
-8
lines changed

2 files changed

+63
-8
lines changed

doc/linux-packaging.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ Make sure you can build the `node.js` client from source code (i.e. you can succ
77
#### Debian/Ubuntu (deb package format)
88

99
1. Make sure you have `dpkg`, `jq` and `fakeroot` installed (otherwise, install them with `apt`).
10-
2. Run `PACKAGING=1 yarn`.
11-
3. Run `PACKAGING=1 yarn build`.
12-
4. Then run `yarn run build-deb`.
13-
5. The deb package will be located in the `dist/` directory.
10+
2. Run `yarn`.
11+
3. Run `yarn build`.
12+
4. Run `PACKAGING=1 yarn --production`.
13+
5. Then run `./packaging/build-package.sh deb`.
14+
6. The deb package will be located in the `dist/` directory.
1415

1516
Note: creating deb packages only has been tested extensively on Ubuntu and Debian.
1617

1718
#### Fedora/CentOS/RHEL (RPM package format)
1819

1920
1. Make sure you have `rpm-build` installed (otherwise, install it with `yum` or `dnf`).
20-
2. Run `PACKAGING=1 yarn`
21-
3. Run `PACKAGING=1 yarn build`.
22-
4. Then run `yarn run build-rpm`.
23-
5. The RPM package will be located in the `dist/` directory.
21+
2. Run `yarn`
22+
3. Run `yarn build`.
23+
4. Run `PACKAGING=1 yarn --production`.
24+
5. Then run `./packaging/build-package.sh rpm`.
25+
6. The RPM package will be located in the `dist/` directory.
2426

2527
Note: creating RPM packages only has been tested extensively on Fedora.

packaging/build-package.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Check that at least one parameter (type of package to build) has been specified
6+
if [[ -z $1 ]];
7+
then
8+
echo "Error: must specify if building a deb or rpm package"
9+
exit 1
10+
fi
11+
12+
NODE_BIN=$(which node)
13+
HOME_PATH=$(dirname "$0")/..
14+
15+
# Make sure we start from the right path
16+
cd ${HOME_PATH}
17+
18+
# Create the directories where all files will be copied
19+
mkdir packaging/BUILD/{fakeroot/etc/nimiq/,modules/,lib/,build/}
20+
21+
# Copy files that need to go verbatim into the package
22+
cp dist/VERSION ${NODE_BIN} packaging/BUILD/
23+
cp -r clients/nodejs/node-ui packaging/BUILD/
24+
cp clients/nodejs/sample.conf packaging/BUILD/fakeroot/etc/nimiq/
25+
cp package.json packaging/BUILD/
26+
cp -r node_modules packaging/BUILD/
27+
cp dist/node.* dist/worker-* dist/web.* packaging/BUILD/lib/
28+
cp build/Release/nimiq_*.node packaging/BUILD/build
29+
mv packaging/BUILD/fakeroot/etc/nimiq/sample.conf packaging/BUILD/fakeroot/etc/nimiq/nimiq.conf
30+
31+
# Copy files that need to be modified from their original form
32+
for i in $(ls clients/nodejs/ | grep 'js$');
33+
do sed 's|../../dist/node.js|./lib/node.js|' clients/nodejs/${i} > packaging/BUILD/${i}
34+
done
35+
36+
for i in $(ls clients/nodejs/modules/);
37+
do sed 's|../../../dist/|../lib/|' clients/nodejs/modules/${i} > packaging/BUILD/modules/${i}
38+
done
39+
40+
# Format-specific steps to finally build the binary package
41+
if [ "$1" == "deb" ]
42+
then
43+
sed 's|node "$SCRIPT_PATH/index.js"|/usr/share/nimiq/app/node "/usr/share/nimiq/app/index.js"|' clients/nodejs/nimiq > packaging/BUILD/nimiq
44+
cd packaging/BUILD
45+
../../node_modules/.bin/node-deb --no-default-package-dependencies -- node *.js VERSION build/ lib/ modules/ node-ui/
46+
mv *.deb ../../dist/
47+
elif [ "$1" == "rpm" ]
48+
then
49+
sed 's|node "$SCRIPT_PATH/index.js"|/usr/share/nimiq/node "/usr/share/nimiq/index.js"|' clients/nodejs/nimiq > packaging/BUILD/nimiq
50+
cd packaging
51+
rpmbuild -bb SPECS/nimiq.spec
52+
mv RPMS/x86_64/*.rpm ../dist
53+
fi

0 commit comments

Comments
 (0)