summaryrefslogtreecommitdiffstats
path: root/t/templates/deb-make-builder
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
commit75808db17caf8b960b351e3408e74142f4c85aac (patch)
tree7989e9c09a4240248bf4658a22208a0a52d991c4 /t/templates/deb-make-builder
parentInitial commit. (diff)
downloadlintian-75808db17caf8b960b351e3408e74142f4c85aac.tar.xz
lintian-75808db17caf8b960b351e3408e74142f4c85aac.zip
Adding upstream version 2.117.0.upstream/2.117.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/templates/deb-make-builder')
-rw-r--r--t/templates/deb-make-builder/Makefile.in121
-rw-r--r--t/templates/deb-make-builder/control-members2
-rw-r--r--t/templates/deb-make-builder/deb-members3
-rw-r--r--t/templates/deb-make-builder/fill-values.d/deb-make-builder.values2
-rw-r--r--t/templates/deb-make-builder/members/debian-binary1
-rwxr-xr-xt/templates/deb-make-builder/tar-control13
-rwxr-xr-xt/templates/deb-make-builder/tar-data7
7 files changed, 149 insertions, 0 deletions
diff --git a/t/templates/deb-make-builder/Makefile.in b/t/templates/deb-make-builder/Makefile.in
new file mode 100644
index 0000000..3a89ab2
--- /dev/null
+++ b/t/templates/deb-make-builder/Makefile.in
@@ -0,0 +1,121 @@
+ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+
+name = [% $source %]
+
+package = $(name).deb
+
+datadir = $(ROOT_DIR)/root
+controldir = $(ROOT_DIR)/DEBIAN
+
+builddir = build
+debiandir = $(builddir)/DEBIAN
+rootdir = $(builddir)/root
+docdir = $(rootdir)/usr/share/doc/$(name)
+
+mandatorydir = $(ROOT_DIR)/doc
+changelogfile = $(mandatorydir)/changelog
+copyrightfile = $(mandatorydir)/copyright
+
+version = [% $version %]
+
+ifeq "$(findstring -, $(version))" ""
+changelogtarget = $(docdir)/changelog
+else
+changelogtarget = $(docdir)/changelog.Debian
+endif
+
+pre_build = $(ROOT_DIR)/pre-build
+pre_data = $(ROOT_DIR)/pre-data
+tar_data = $(ROOT_DIR)/tar-data
+pre_control = $(ROOT_DIR)/pre-control
+tar_control = $(ROOT_DIR)/tar-control
+post_build = $(ROOT_DIR)/post-build
+
+deb_member_source_path = $(ROOT_DIR)/members
+deb_member_build_path = members
+
+debmembers = $(shell tr '\n' ' ' < $(ROOT_DIR)/deb-members)
+controlmembers = $(shell tr '\n' ' ' < $(ROOT_DIR)/control-members)
+
+$(package): fix-perm
+ -mkdir -p $(deb_member_build_path)
+ if [ -d $(deb_member_source_path) \
+ -a $(deb_member_source_path) != $(deb_member_build_path) ] ; then \
+ cp -rp $(deb_member_source_path)/. $(deb_member_build_path) ; \
+ fi
+
+ -mkdir -p $(rootdir)
+ if [ -d $(datadir) ] ; then \
+ cp -rp $(datadir)/. $(rootdir) ; \
+ fi
+
+ if [ -x $(pre_build) ] ; then \
+ $(pre_build) "$(rootdir)" "$(name)" ; \
+ fi
+
+ -mkdir -p $(docdir)
+ -if [ -f $(changelogfile) ] ; then \
+ install --mode 0644 $(changelogfile) $(changelogtarget) ; \
+ gzip -9nf $(changelogtarget) ; \
+ fi
+ if [ -f $(copyrightfile) ] ; then \
+ install --mode 0644 $(copyrightfile) $(docdir) ; \
+ fi
+
+ # pass package name to pre-data script
+ if [ -x $(pre_data) ] ; then \
+ $(pre_data) "$(rootdir)" "$(name)" ; \
+ fi
+
+ if [ -x $(tar_data) ] ; then \
+ $(tar_data) "$(rootdir)" ; \
+ fi
+
+ -mkdir $(debiandir)
+ if [ -d $(controldir) ] ; then \
+ cp -rp $(controldir)/. $(debiandir) ; \
+ fi
+
+ # prevents 'control-file-has-bad-permissions' on CI runners with strange umasks
+ find $(debiandir) -type d -exec chmod 0755 \{\} +
+ find $(debiandir) -type f -exec chmod 0644 \{\} +
+
+ (cd $(rootdir); find . -type f -a -! -ipath etc -exec md5sum -- \{\} +) > $(debiandir)/md5sums
+
+ # pass package name to pre-control script
+ if [ -x $(pre_control) ] ; then \
+ $(pre_control) "$(debiandir)" "$(name)" ; \
+ fi
+ if [ -x $(tar_control) ] ; then \
+ $(tar_control) "$(debiandir)" "$(controlmembers)" ; \
+ fi
+
+ ar rc $(package) $(debmembers)
+
+ # pass package name to post-build script
+ if [ -x $(post_build) ] ; then \
+ $(post_build) "$(name)" ; \
+ fi
+
+
+.PHONY: clean
+clean:
+ rm -f $(package)
+ rm -rf $(builddir)
+
+# If root/ exists, it is because the test ships with it. Since the
+# test may have been checked out (or unpacked) with a "whack umask"
+# (anything but 0022), we reset the permissions to a reasonable
+# default.
+#
+# The contents of the deb usually is not what is tested by this suite
+# (t/tests is preferred for this), so the below merely handles the
+# AVERAGE CASE. Tests that need special permissions (anything but
+# 0644 for files and 0755 for dirs) require manually setting the
+# permissions.
+.PHONY: fix-perm
+fix-perm:
+ if [ -d $(datadir) ] ; then \
+ find $(datadir) -type d | xargs -r chmod 0755 ; \
+ find $(datadir) -type f | xargs -r chmod 0644 ; \
+ fi
diff --git a/t/templates/deb-make-builder/control-members b/t/templates/deb-make-builder/control-members
new file mode 100644
index 0000000..cf97afe
--- /dev/null
+++ b/t/templates/deb-make-builder/control-members
@@ -0,0 +1,2 @@
+control
+md5sums
diff --git a/t/templates/deb-make-builder/deb-members b/t/templates/deb-make-builder/deb-members
new file mode 100644
index 0000000..57c72d4
--- /dev/null
+++ b/t/templates/deb-make-builder/deb-members
@@ -0,0 +1,3 @@
+members/debian-binary
+members/control.tar.gz
+members/data.tar.gz
diff --git a/t/templates/deb-make-builder/fill-values.d/deb-make-builder.values b/t/templates/deb-make-builder/fill-values.d/deb-make-builder.values
new file mode 100644
index 0000000..610b6f6
--- /dev/null
+++ b/t/templates/deb-make-builder/fill-values.d/deb-make-builder.values
@@ -0,0 +1,2 @@
+Build-Product: [% $source %].deb
+Build-Command: fakeroot make --trace -f [% $source_path %]/Makefile DEFAULT_DH_COMPAT=[% $dh_compat_level %]
diff --git a/t/templates/deb-make-builder/members/debian-binary b/t/templates/deb-make-builder/members/debian-binary
new file mode 100644
index 0000000..cd5ac03
--- /dev/null
+++ b/t/templates/deb-make-builder/members/debian-binary
@@ -0,0 +1 @@
+2.0
diff --git a/t/templates/deb-make-builder/tar-control b/t/templates/deb-make-builder/tar-control
new file mode 100755
index 0000000..feb065b
--- /dev/null
+++ b/t/templates/deb-make-builder/tar-control
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+debiandir="$1"
+controlmembers="$2"
+
+tar --create \
+ --owner=root:0 --group=root:0 \
+ --file members/control.tar.gz \
+ --gzip \
+ --directory "$debiandir" \
+ $controlmembers
diff --git a/t/templates/deb-make-builder/tar-data b/t/templates/deb-make-builder/tar-data
new file mode 100755
index 0000000..fcb7dc3
--- /dev/null
+++ b/t/templates/deb-make-builder/tar-data
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+rootdir="$1"
+
+tar --create --file members/data.tar.gz --gzip --directory "$rootdir" .