From 9e265f9c7d97d2e9fbce8bd688e4a178e0087de2 Mon Sep 17 00:00:00 2001 From: MrMelon Date: Sun, 18 Apr 2021 11:26:31 +0100 Subject: [PATCH] Setup to create debian package --- .gitignore | 3 ++- Makefile | 26 ++++++++++++++++++++++ install | 3 --- project.json | 9 ++++++++ scripts/package-mclookup.sh | 43 +++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 Makefile delete mode 100755 install create mode 100644 project.json create mode 100755 scripts/package-mclookup.sh diff --git a/.gitignore b/.gitignore index 51db4cc..aaea3dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -go-mclookup +dist/ +package/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..21510bc --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ + + +all: + make build-main + +build-main: + mkdir -p dist/ && \ + go build -o dist/mclookup ./cmd/mclookup + +package: + ./scripts/package-mclookup.sh + +deb: + make clean && \ + make all && \ + make package + +clean: + rm -rf dist/ && \ + rm -rf package/ + + +.PHONY: run +run: + cd ./dist/ && \ + ./mclookup diff --git a/install b/install deleted file mode 100755 index 273f3b1..0000000 --- a/install +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -go build -o go-mclookup ./cmd/mclookup -sudo cp ./go-mclookup /usr/bin/mclookup diff --git a/project.json b/project.json new file mode 100644 index 0000000..a58830c --- /dev/null +++ b/project.json @@ -0,0 +1,9 @@ +{ + "Package": "mclookup", + "Version": "1.0-1", + "Section": "base", + "Priority": "optional", + "Architecture": "amd64", + "Maintainer": "MrMelon54 ", + "Description": "Lookup Minecraft usernames and UUIDs" +} diff --git a/scripts/package-mclookup.sh b/scripts/package-mclookup.sh new file mode 100755 index 0000000..4dd91ac --- /dev/null +++ b/scripts/package-mclookup.sh @@ -0,0 +1,43 @@ +#!/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" +INSTALL_DIR=$(realpath -sm "$INSTALL_DIR") + +echo "Using the following folders for install" +echo "PROJECT_DIR: $PROJECT_DIR" +echo "INSTALL_DIR: $INSTALL_DIR" + +PACK="${PROJECT_DIR}/package/${PROJECT_NAM}_${PROJECT_VER}" +PACK_BIN=$(realpath -sm "$PACK/$INSTALL_DIR") +PACK_DEB=$(realpath -sm "$PACK/DEBIAN") +mkdir -p "$PACK" +mkdir -p "$PACK_BIN" +mkdir -p "$PACK_DEB" + +# Copying files +echo "Copying binary files" +cp dist/mclookup "$PACK_BIN" + +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:"