aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile70
1 files changed, 49 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index adaa8a4..917c26c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
#!/usr/bin/env make
-# SPDX-FileCopyrightText: 2022 Patrick Spek <p.spek@tyil.nl>
+# SPDX-FileCopyrightText: 2023 Patrick Spek <p.spek@tyil.nl>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -9,9 +9,12 @@ ETCDIR=/etc
# Variables for building (binary) packages
PREFIX=
-PKG_VERSION=0.0.0
+PKG_VERSION=2.1.0
PKG_WORKDIR:=$(or $(PKG_WORKDIR),$(shell mktemp -d))
PKG_ROOT:=$(PKG_WORKDIR)/bashtard-$(PKG_VERSION)
+SOURCE_DATE_EPOCH:=$(shell git show -s --format=%ct)
+
+rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
all:
: # No build step required, use `make install` to install this program
@@ -49,28 +52,53 @@ man:
pkg-debian:
# Create the directories to work with
- mkdir -pv "$(PKG_ROOT)"
-
- # Create an original, and use it for building
- tar czf "$(PKG_WORKDIR)/bashtard_$(PKG_VERSION).orig.tar.gz" .
- cd "$(PKG_WORKDIR)" && tar xzf "bashtard_$(PKG_VERSION).orig.tar.gz" -C "$(PKG_ROOT)"
-
- # Move Debian packaging info
- mv -v "$(PKG_ROOT)/etc/debian" "$(PKG_ROOT)/debian"
-
- # Make all Bash files +x to please Lintian
- find "$(PKG_ROOT)" -iname "*.bash" -exec chmod +x {} \;
-
- # Build the Debian package
- cd "$(PKG_ROOT)" && dpkg-source --build .
- cd "$(PKG_ROOT)" && dpkg-buildpackage
-
- # TODO: Remove lintian, that's a manual step
- lintian --no-tag-display-limit "$(PKG_WORKDIR)/bashtard_$(PKG_VERSION)-1_amd64.deb"
+ mkdir -pv -- "$(PKG_ROOT)/usr"
+
+ # Install into the workdir
+ $(MAKE) PREFIX="$(PKG_ROOT)" install
+ $(MAKE) PREFIX="$(PKG_ROOT)" man
+
+ # Copy Debian's control file
+ mkdir -pv -- "$(PKG_ROOT)/DEBIAN"
+ printf "Version: %s\n" "$(PKG_VERSION)" > "$(PKG_ROOT)/DEBIAN/control"
+ grep -v '^\#' ./etc/debian/control >> "$(PKG_ROOT)/DEBIAN/control"
+
+ # Include the changelog
+ mkdir -pv -- "$(PKG_ROOT)/usr/share/doc/bashtard"
+ gzip -9n < CHANGELOG.md > "$(PKG_ROOT)/usr/share/doc/bashtard/changelog.gz"
+
+ # Include license
+ cp -v -- LICENSES/AGPL-3.0-or-later.txt "$(PKG_ROOT)/usr/share/doc/bashtard/copyright"
+
+ # Debian wants all .bash files to be +x
+ find "$(PKG_ROOT)" -type f -iname "*.bash" | xargs chmod +x
+
+ # Generate the .deb file
+ mkdir -pv -- "dist"
+ dpkg-deb -b "$(PKG_ROOT)" "dist/bashtard-$(PKG_VERSION).deb"
+
+pkg-targz:
+ mkdir -pv -- "dist"
+ tar \
+ --exclude dist \
+ --group=0 \
+ --mtime="@$(SOURCE_DATE_EPOCH)" \
+ --numeric-owner \
+ --owner=0 \
+ --pax-option="exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" \
+ --sort=name \
+ --transform "s@^./@bashtard-$(PKG_VERSION)/@" \
+ --exclude-vcs \
+ --exclude-vcs-ignores \
+ -cvzf "dist/bashtard-$(PKG_VERSION).tar.gz" .
qa:
+ # Check licenses
reuse lint
- shellcheck -x bin/bashtard **/*.bash
+
+ # Check code
+ shellcheck -s sh bin/bashtard
+ shellcheck -s bash $(call rwildcard,.,*.bash)
share:
mkdir -pv -- "$(PREFIX)$(DESTDIR)/share/bashtard"