Add script to build debian package

Signed-off-by: Marek Küthe <m.k@mk16.de>
This commit is contained in:
Marek Küthe 2024-01-31 14:32:32 +01:00
parent 38781e39fe
commit 1f50a3b2ee
No known key found for this signature in database
4 changed files with 69 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Binary output
meshnamed
# Debian package
deb/meshname.deb
deb/package/

40
deb/build.sh Executable file
View File

@ -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!"

8
deb/control.template Normal file
View File

@ -0,0 +1,8 @@
Package: meshname
Version: 0.2.0
Architecture: %ARCHITECTURE%
Section: net
Priority: optional
Homepage: https://github.com/zhoreeq/meshname
Maintainer: George <zhoreeq@protonmail.com>
Description: Distributed naming system for IPv6 mesh networks

15
deb/copyright Normal file
View File

@ -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 <zhoreeq@protonmail.com>
Files: *
Copyright: George <zhoreeq@protonmail.com>
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.