From 1f50a3b2eeadb3ccda08b2471b163632c813b497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20K=C3=BCthe?= Date: Wed, 31 Jan 2024 14:32:32 +0100 Subject: [PATCH] Add script to build debian package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Küthe --- .gitignore | 6 ++++++ deb/build.sh | 40 ++++++++++++++++++++++++++++++++++++++++ deb/control.template | 8 ++++++++ deb/copyright | 15 +++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100755 deb/build.sh create mode 100644 deb/control.template create mode 100644 deb/copyright diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..774b8b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Binary output +meshnamed + +# Debian package +deb/meshname.deb +deb/package/ diff --git a/deb/build.sh b/deb/build.sh new file mode 100755 index 0000000..89194ee --- /dev/null +++ b/deb/build.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +die () { + >&2 echo "$1" + exit 1 +} + + +( + # Remove previous package construction + rm -rf package || die "Failed to remove old packages" +) + +( + # Remove already built programs, build and test what you have built + cd ".." || die "Failed to change directory" + GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" \ + make clean all test || die "Failed to build and test project" +) + +# Install all necessary files in the package structure +install -Dm755 "../meshnamed" "package/usr/bin/meshnamed" || die "Failed to copy meshnamed" +install -Dm644 "../meshnamed.service" "package/usr/lib/systemd/system/meshnamed.service" || die "Failed to copy meshnamed service" +install -Dm644 "control.template" "package/DEBIAN/control" || die "Failed to copy control template" +install -Dm644 "copyright" "package/usr/share/doc/meshname/copyright" || die "Failed to copy copyright file" +install -Dm644 "../protocol.md" "package/usr/share/doc/meshname/protocol.md" + +# Fix the path in the systemd-service file +sed -i "s|/usr/local/bin/meshname|/usr/bin/meshname|g" "package/usr/lib/systemd/system/meshnamed.service" || die "Failed to patch service file" + +# Set the current architecture for the package +ARCH="$(dpkg --print-architecture)" +[ "$ARCH" ] || die "Failed to get architecture string" +sed "s/%ARCHITECTURE%/$ARCH/" -i package/DEBIAN/control || die "Failed to replace architecture in control template" + +# Build the actual package +echo "Building package..." +dpkg-deb --root-owner-group --build package meshname.deb || die "Failed to build package" + +echo "Package $(dpkg-deb --show meshname.deb | sed "s/\t/ /") successful built!" diff --git a/deb/control.template b/deb/control.template new file mode 100644 index 0000000..b234052 --- /dev/null +++ b/deb/control.template @@ -0,0 +1,8 @@ +Package: meshname +Version: 0.2.0 +Architecture: %ARCHITECTURE% +Section: net +Priority: optional +Homepage: https://github.com/zhoreeq/meshname +Maintainer: George +Description: Distributed naming system for IPv6 mesh networks diff --git a/deb/copyright b/deb/copyright new file mode 100644 index 0000000..2f6c61e --- /dev/null +++ b/deb/copyright @@ -0,0 +1,15 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://github.com/zhoreeq/meshname/blob/master/LICENSE +Upstream-Name: meshname +Upstream-Contact: George + +Files: * +Copyright: George +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.