Add packaging scripts and gcc multiwrap

This commit is contained in:
Melon 2021-04-24 11:17:54 +01:00
parent dbc675584f
commit 54e25afc2f
3 changed files with 153 additions and 0 deletions

34
scripts/gcc_multiwrap.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
echo -e "\033[33mGCC Multiwrap\033[m"
j=0
y="$1"
for ((i=2; i<=$#; i++))
do
a="${!i}"
j=$i
if [ "$a" = "--" ]; then
break
fi
y="$y $a"
done
j=$((j+1))
w="${!j}"
j=$((j+1))
z="${!j}"
j=$(($j+1))
v=""
for ((i=$j; i<=$#; i++))
do
a="${!i}"
b=`basename "${!i:0:-2}"`
echo -e "\033[32mgcc $y -o \"$b.o\" -c \"$a\"\033[m"
gcc $y -o "$z/$b.o" -c "$a"
v="${v} ${z}${b}.o"
done
echo -e '\033[36mar cr '"$w"' '"$v"'\033[m'
ar cr "$w" $v

62
scripts/package-melonvpn.sh Executable file
View File

@ -0,0 +1,62 @@
#!/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"
cp dist/simple-vpn "$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"

57
scripts/package-melonvpngui.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
PROJECT_DIR=`dirname $SCRIPTPATH`
PROJECT_DAT=`cat $PROJECT_DIR/project-gui.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
LIBRARY_DIR="/usr/lib/melonvpn"
ICON_DIR="/usr/share/icons"
DESKTOP_DIR="/usr/share/applications"
LIBRARY_DIR=$(realpath -sm "$LIBRARY_DIR")
DESKTOP_DIR=$(realpath -sm "$DESKTOP_DIR")
PROJECT_DIR=$(realpath -sm "$PROJECT_DIR")
# paths in package
PACK="${PROJECT_DIR}/package/${PROJECT_NAM}_${PROJECT_VER}"
PACK_LIB=$(realpath -sm "$PACK/$LIBRARY_DIR")
PACK_ICO=$(realpath -sm "$PACK/$ICON_DIR")
PACK_DES=$(realpath -sm "$PACK/$DESKTOP_DIR")
PACK_DEB=$(realpath -sm "$PACK/DEBIAN")
mkdir -p "$PACK"
mkdir -p "$PACK_LIB"
mkdir -p "$PACK_ICO"
mkdir -p "$PACK_DES"
mkdir -p "$PACK_DEB"
# Copying files
echo "Copying icon files"
ICON_SCALE=$(realpath -sm "$PACK_ICO/hicolor/scalable/apps")
mkdir -p "$ICON_SCALE"
cp dist/melonvpn.svg "$ICON_SCALE"
cp dist/melonvpn.png "$PACK_LIB"
cp dist/statusmelonoff.png "$PACK_LIB"
cp dist/statusmelonon.png "$PACK_LIB"
echo "Copying setup files"
cp setup/melonvpn.desktop "$PACK_DES"
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"