melonvpn/scripts/package-melonvpn.sh

62 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
PROJECT_DIR=`dirname $SCRIPTPATH`
PROJECT_DAT=`cat $PROJECT_DIR/project.json`
PROJECT_NAM=`echo $PROJECT_DAT | jq .Package -r`
PROJECT_VER=`echo $PROJECT_DAT | jq .Version -r`
echo
echo "Packaging $PROJECT_NAM v$PROJECT_VER"
echo
INSTALL_DIR="/usr/bin"
SERVICE_DIR="/etc/systemd/system"
SHARE_DIR="/usr/share/melonvpn"
PROJECT_DIR=$(realpath -sm "$PROJECT_DIR")
INSTALL_DIR=$(realpath -sm "$INSTALL_DIR")
SERVICE_DIR=$(realpath -sm "$SERVICE_DIR")
SHARE_DIR=$(realpath -sm "$SHARE_DIR")
# paths in the package
PACK="${PROJECT_DIR}/package/${PROJECT_NAM}_${PROJECT_VER}"
PACK_BIN=$(realpath -sm "$PACK/$INSTALL_DIR")
PACK_SER=$(realpath -sm "$PACK/$SERVICE_DIR")
PACK_SHA=$(realpath -sm "$PACK/$SHARE_DIR")
PACK_DEB=$(realpath -sm "$PACK/DEBIAN")
mkdir -p "$PACK"
mkdir -p "$PACK_BIN"
mkdir -p "$PACK_SER"
mkdir -p "$PACK_SHA"
mkdir -p "$PACK_DEB"
# Copying files
echo "Copying binary files"
# /usr/bin/
cp dist/melonvpn "$PACK_BIN"
# /usr/share/
cp dist/melonvpndaemon "$PACK_SHA"
cp dist/melonvpnrefreshpeers "$PACK_SHA"
echo "Copying setup files"
# service
cp setup/melonvpndaemon.service "$PACK_SER"
echo "Generating meta data"
PACK_CON=$(realpath -sm "$PACK_DEB/control")
echo "" > "$PACK_CON"
for row in $(echo "$PROJECT_DAT" | jq -r 'keys[]'); do
value=`echo "$PROJECT_DAT" | jq -r ".[\"$row\"]"`
echo "$row: $value" >> "$PACK_CON"
done
echo "Building package"
dpkg-deb --build "$PACK"
echo "Signing package"
dpkg-sig -k OnPointCoding --sign repo "$PACK.deb"
echo "Package complete"