2021-03-23 07:34:34 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-03-17 19:13:27 +03:00
|
|
|
set -o errexit
|
|
|
|
|
2021-03-23 07:34:34 +03:00
|
|
|
if [ ! "$1" ]; then
|
|
|
|
echo "This script requires either amd64 of arm64 as an argument"
|
|
|
|
exit 1
|
|
|
|
elif [ "$1" = "amd64" ]; then
|
|
|
|
PLATFORM="$1"
|
|
|
|
DIR_NAME="chia-blockchain-linux-x64"
|
|
|
|
else
|
|
|
|
PLATFORM="$1"
|
|
|
|
DIR_NAME="chia-blockchain-linux-arm64"
|
|
|
|
fi
|
2022-04-15 03:32:26 +03:00
|
|
|
export PLATFORM
|
2021-03-23 07:34:34 +03:00
|
|
|
|
|
|
|
# If the env variable NOTARIZE and the username and password variables are
|
|
|
|
# set, this will attempt to Notarize the signed DMG
|
|
|
|
|
|
|
|
if [ ! "$CHIA_INSTALLER_VERSION" ]; then
|
|
|
|
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
|
|
|
|
CHIA_INSTALLER_VERSION="0.0.0"
|
|
|
|
fi
|
|
|
|
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"
|
2022-04-15 03:32:26 +03:00
|
|
|
export CHIA_INSTALLER_VERSION
|
2021-03-23 07:34:34 +03:00
|
|
|
|
|
|
|
echo "Installing npm and electron packagers"
|
2022-01-20 03:52:20 +03:00
|
|
|
cd npm_linux_deb || exit
|
|
|
|
npm ci
|
|
|
|
PATH=$(npm bin):$PATH
|
|
|
|
cd .. || exit
|
2021-03-23 07:34:34 +03:00
|
|
|
|
|
|
|
echo "Create dist/"
|
|
|
|
rm -rf dist
|
|
|
|
mkdir dist
|
|
|
|
|
|
|
|
echo "Create executables with pyinstaller"
|
2021-04-05 05:30:34 +03:00
|
|
|
SPEC_FILE=$(python -c 'import chia; print(chia.PYINSTALLER_SPEC_PATH)')
|
2021-04-04 04:21:43 +03:00
|
|
|
pyinstaller --log-level=INFO "$SPEC_FILE"
|
|
|
|
LAST_EXIT_CODE=$?
|
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
|
|
|
echo >&2 "pyinstaller failed!"
|
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
|
|
|
|
2022-04-15 03:32:26 +03:00
|
|
|
# Builds CLI only .deb
|
|
|
|
# need j2 for templating the control file
|
|
|
|
pip install j2cli
|
|
|
|
CLI_DEB_BASE="chia-blockchain-cli_$CHIA_INSTALLER_VERSION-1_$PLATFORM"
|
|
|
|
mkdir -p "dist/$CLI_DEB_BASE/opt/chia"
|
2022-04-15 22:13:00 +03:00
|
|
|
mkdir -p "dist/$CLI_DEB_BASE/usr/bin"
|
2022-04-15 03:32:26 +03:00
|
|
|
mkdir -p "dist/$CLI_DEB_BASE/DEBIAN"
|
|
|
|
j2 -o "dist/$CLI_DEB_BASE/DEBIAN/control" assets/deb/control.j2
|
|
|
|
cp -r dist/daemon/* "dist/$CLI_DEB_BASE/opt/chia/"
|
2022-04-15 22:13:00 +03:00
|
|
|
ln -s ../../opt/chia/chia "dist/$CLI_DEB_BASE/usr/bin/chia"
|
2022-04-15 03:32:26 +03:00
|
|
|
dpkg-deb --build --root-owner-group "dist/$CLI_DEB_BASE"
|
|
|
|
# CLI only .deb done
|
|
|
|
|
2021-12-09 01:39:01 +03:00
|
|
|
cp -r dist/daemon ../chia-blockchain-gui/packages/gui
|
2021-03-23 07:34:34 +03:00
|
|
|
cd .. || exit
|
|
|
|
cd chia-blockchain-gui || exit
|
|
|
|
|
|
|
|
echo "npm build"
|
2021-12-09 01:39:01 +03:00
|
|
|
lerna clean -y
|
2022-01-20 03:52:20 +03:00
|
|
|
npm ci
|
2021-12-09 01:39:01 +03:00
|
|
|
# Audit fix does not currently work with Lerna. See https://github.com/lerna/lerna/issues/1663
|
|
|
|
# npm audit fix
|
2021-03-23 07:34:34 +03:00
|
|
|
npm run build
|
|
|
|
LAST_EXIT_CODE=$?
|
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
|
|
|
echo >&2 "npm run build failed!"
|
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
|
|
|
|
2021-12-09 01:39:01 +03:00
|
|
|
# Change to the gui package
|
|
|
|
cd packages/gui || exit
|
|
|
|
|
2021-07-30 03:32:23 +03:00
|
|
|
# sets the version for chia-blockchain in package.json
|
|
|
|
cp package.json package.json.orig
|
|
|
|
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json && mv temp.json package.json
|
|
|
|
|
2021-03-23 07:34:34 +03:00
|
|
|
electron-packager . chia-blockchain --asar.unpack="**/daemon/**" --platform=linux \
|
2021-04-06 00:43:20 +03:00
|
|
|
--icon=src/assets/img/Chia.icns --overwrite --app-bundle-id=net.chia.blockchain \
|
2021-12-09 01:39:01 +03:00
|
|
|
--appVersion=$CHIA_INSTALLER_VERSION --executable-name=chia-blockchain
|
2021-03-23 07:34:34 +03:00
|
|
|
LAST_EXIT_CODE=$?
|
2021-07-30 03:32:23 +03:00
|
|
|
|
|
|
|
# reset the package.json to the original
|
|
|
|
mv package.json.orig package.json
|
|
|
|
|
2021-03-23 07:34:34 +03:00
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
|
|
|
echo >&2 "electron-packager failed!"
|
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
|
|
|
|
2021-12-09 01:39:01 +03:00
|
|
|
mv $DIR_NAME ../../../build_scripts/dist/
|
|
|
|
cd ../../../build_scripts || exit
|
2021-03-23 07:34:34 +03:00
|
|
|
|
|
|
|
echo "Create chia-$CHIA_INSTALLER_VERSION.deb"
|
|
|
|
rm -rf final_installer
|
|
|
|
mkdir final_installer
|
2022-04-22 02:59:27 +03:00
|
|
|
electron-installer-debian --src "dist/$DIR_NAME/" \
|
|
|
|
--arch "$PLATFORM" \
|
|
|
|
--options.version "$CHIA_INSTALLER_VERSION" \
|
|
|
|
--config deb-options.json
|
2021-03-23 07:34:34 +03:00
|
|
|
LAST_EXIT_CODE=$?
|
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
|
|
|
echo >&2 "electron-installer-debian failed!"
|
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
|
|
|
|
2022-04-15 03:32:26 +03:00
|
|
|
# Move the cli only deb into final installers as well, so it gets uploaded as an artifact
|
|
|
|
mv "dist/$CLI_DEB_BASE.deb" final_installer/
|
|
|
|
|
2021-03-23 07:34:34 +03:00
|
|
|
ls final_installer/
|