Package: kbd
Followup-For: Bug #766240

Hello.
Please ignore 0002-0009 in the previous message
and read the attached new 0002-0008 instead.
Thanks.
>From 8bebfb7e6e43faa10e046a85c3e275195121e7eb Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Tue, 24 Feb 2026 14:14:36 +0100
Subject: [PATCH 2/8] Remove obsolete console-utilities virtual package

---
 debian/control | 2 --
 1 file changed, 2 deletions(-)

diff --git a/debian/control b/debian/control
index 73e53bf..89eeef0 100644
--- a/debian/control
+++ b/debian/control
@@ -14,8 +14,6 @@ Package: kbd
 Architecture: linux-any
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: console-setup | console-data
-Provides: console-utilities
-Conflicts: console-utilities
 Description: Linux console font and keytable utilities
  This package allows you to set up the Linux console, change the font,
  resize text mode virtual consoles and remap the keyboard.
-- 
2.47.3

>From 3fdf9a3f6d9ebefba5aea5d4e8c10934945b091f Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Tue, 24 Feb 2026 14:15:34 +0100
Subject: [PATCH 3/8] Wrap and sort build dependencies

---
 debian/control | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/debian/control b/debian/control
index 89eeef0..c5a1dca 100644
--- a/debian/control
+++ b/debian/control
@@ -3,8 +3,15 @@ Section: utils
 Priority: optional
 Maintainer: Console utilities maintainers <[email protected]>
 Uploaders: Michael Schutte <[email protected]>, Anton Zinoviev <[email protected]>
-Build-Depends: dpkg-dev (>= 1.16.1), debhelper-compat (= 13),
-    linuxdoc-tools, gettext, flex, bison, pkgconf, check
+Build-Depends:
+  bison,
+  check,
+  debhelper-compat (= 13),
+  dpkg-dev (>= 1.16.1),
+  flex,
+  gettext,
+  linuxdoc-tools,
+  pkgconf,
 Standards-Version: 4.1.5
 Homepage: https://kbd-project.org/
 Vcs-Git: https://salsa.debian.org/debian/kbd.git
-- 
2.47.3

>From 73ddf213b8854a56ec488fb902e124949095e5a2 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Tue, 24 Feb 2026 14:15:59 +0100
Subject: [PATCH 4/8] Remove obsolete version restriction on the dpkg-dev build
 dependency

---
 debian/control | 1 -
 1 file changed, 1 deletion(-)

diff --git a/debian/control b/debian/control
index c5a1dca..af8fc53 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,6 @@ Build-Depends:
   bison,
   check,
   debhelper-compat (= 13),
-  dpkg-dev (>= 1.16.1),
   flex,
   gettext,
   linuxdoc-tools,
-- 
2.47.3

>From 396c94b46c3328b708569a88fe606aee162bbc6e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Tue, 24 Feb 2026 14:17:50 +0100
Subject: [PATCH 5/8] Standards-Version 4.7.3

---
 debian/control | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/debian/control b/debian/control
index af8fc53..e59a5c9 100644
--- a/debian/control
+++ b/debian/control
@@ -1,6 +1,5 @@
 Source: kbd
 Section: utils
-Priority: optional
 Maintainer: Console utilities maintainers <[email protected]>
 Uploaders: Michael Schutte <[email protected]>, Anton Zinoviev <[email protected]>
 Build-Depends:
@@ -11,7 +10,7 @@ Build-Depends:
   gettext,
   linuxdoc-tools,
   pkgconf,
-Standards-Version: 4.1.5
+Standards-Version: 4.7.3
 Homepage: https://kbd-project.org/
 Vcs-Git: https://salsa.debian.org/debian/kbd.git
 Vcs-Browser: https://salsa.debian.org/debian/kbd
-- 
2.47.3

>From 50cce7c4f04e03dccf8106eaa27f1035a5fc5f1d Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Wed, 25 Feb 2026 04:45:32 +0100
Subject: [PATCH 6/8] Simplify debian/rules

Instal mk_modmap with a debhelper configuration file.

When debian/rules install files by itself, select the right place
directly instead of moving some later.

Build out of the source tree.  This simplifies the clean target, but
also makes it possible to build twice in a row (for deb and udeb).

I assume '-Os -g' was intending '-Os $(filter-out -O%,$(CFLAGS))'.
Set this during configuration instead of duplicating the setting for
each Make.

Delegate as much as possible to debhelper, which for example sets
CFLAGS and CC.
---
 debian/kbd.dirs    |  2 -
 debian/kbd.install |  5 +++
 debian/rules       | 98 +++++++++++++++++++---------------------------
 3 files changed, 46 insertions(+), 59 deletions(-)
 delete mode 100644 debian/kbd.dirs
 create mode 100644 debian/kbd.install

diff --git a/debian/kbd.dirs b/debian/kbd.dirs
deleted file mode 100644
index ca882bb..0000000
--- a/debian/kbd.dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/sbin
diff --git a/debian/kbd.install b/debian/kbd.install
new file mode 100644
index 0000000..0cdd7f5
--- /dev/null
+++ b/debian/kbd.install
@@ -0,0 +1,5 @@
+data/keymaps/i386/mk_modmap             usr/bin
+
+docs/doc/iso8859.info                   usr/share/doc/kbd/charsets
+docs/doc/iso*.txt                       usr/share/doc/kbd/charsets
+docs/doc/cp*.txt                        usr/share/doc/kbd/charsets
diff --git a/debian/rules b/debian/rules
index 684a0b0..cea0c0e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,85 +1,69 @@
 #!/usr/bin/make -f
 
-TOPDIR = $(shell pwd)
-KBD = $(TOPDIR)/debian/kbd
-KBD_DOC = $(KBD)/usr/share/doc/kbd
-KBD_UDEB = $(TOPDIR)/debian/kbd-udeb
-
 # build these twice, once optimized for size (for kbd-udeb)
 UDEB_BINARIES = loadkeys kbd_mode setfont
 
 # non-standard binaries to build
-EXTRA_BINARIES = screendump setlogcons setvesablank
-CONTRIB_BINARIES = codepage splitfont vcstime
+# ./configure --enable-optional-progs would select several more.
+EXTRA_BINARIES_bin := screendump setlogcons
+EXTRA_BINARIES_sbin := setvesablank
+# Upstream provides no build system in contrib/, but dh_auto_build
+# exports variables like CFLAGS and CC so Make is fine.
+CONTRIB_BINARIES_bin := codepage splitfont
+CONTRIB_BINARIES_sbin := vcstime
 
 # we don’t want these in /usr/bin
-MOVE_TO_USR_SBIN = vcstime setvesablank kbdrate
-
-include /usr/share/dpkg/architecture.mk
-
-ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
-	CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc
-endif
+MOVE_TO_USR_SBIN := kbdrate
 
 %:
 	dh $@
 
 override_dh_auto_clean:
-	dh_auto_clean
-	[ ! -f Makefile ] || $(MAKE) clean
-	cd src/ && rm -f $(EXTRA_BINARIES) *-udeb
-	cd contrib/ && rm -f $(CONTRIB_BINARIES)
-	rm -f po/gr.po			# replaced by el.po
-	# cleanup modified or leftover files from previous build
-	! test -p tests/testsuite.dir/at-job-fifo || rm -f tests/testsuite.dir/at-job-fifo
-	rm -f po/*.gmo po/stamp-po
-	# force rebuilding of generated code
-	rm -f src/libkeymap/analyze.h src/libkeymap/analyze.c
+	rm -fr bld/
 
 override_dh_auto_configure:
-	dh_auto_configure -- \
+	dh_auto_configure -Bbld/deb -- $(common_configure_args)
+  ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES)))
+	DEB_CFLAGS_MAINT_APPEND=-Os dh_auto_configure -Bbld/udeb \
+	  --reload-all-buildenv-variables -- $(common_configure_args)
+  endif
+
+common_configure_args := \
 		--enable-nls \
 		--disable-libkeymap \
 		--disable-vlock
 
 override_dh_auto_build:
 ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES)))
-	$(MAKE) -C src/libkeymap CFLAGS="-Os -g" analyze.h
-	$(MAKE) -C src/libcommon CFLAGS="-Os -g"
-	$(MAKE) -C src/libkbdfile CFLAGS="-Os -g"
-	$(MAKE) -C src/libkeymap CFLAGS="-Os -g"
-	$(MAKE) -C src/libkfont CFLAGS="-Os -g"
-	$(MAKE) -C src/ CFLAGS="-Os -g" $(UDEB_BINARIES)
-	cd src/ && for ITEM in $(UDEB_BINARIES); do mv $$ITEM $$ITEM-udeb; done
-	$(MAKE) -C src/libkeymap clean
-	$(MAKE) -C src/libcommon clean
-	$(MAKE) -C src/libkbdfile clean
-	$(MAKE) -C src/libkfont clean
-	$(MAKE) -C src/ clean
+	dh_auto_build -Bbld/udeb/src/libcommon
+	dh_auto_build -Bbld/udeb/src/libkbdfile
+	dh_auto_build -Bbld/udeb/src/libkeymap
+	dh_auto_build -Bbld/udeb/src/libkfont
+	dh_auto_build -Bbld/udeb/src -- $(UDEB_BINARIES)
 endif
-	$(MAKE)
-	$(MAKE) -C src/ $(EXTRA_BINARIES)
-	$(MAKE) $(CROSS) CFLAGS="-O2 -g" -C contrib/ $(CONTRIB_BINARIES)
+	dh_auto_build -Bbld/deb
+	dh_auto_build -Bbld/deb/src -- $(EXTRA_BINARIES_bin) \
+	  $(EXTRA_BINARIES_sbin)
+	mkdir bld/contrib
+	dh_auto_build -Bbld/contrib -Smakefile -- VPATH=../../contrib \
+	  $(CONTRIB_BINARIES_bin) $(CONTRIB_BINARIES_sbin)
+
+override_dh_auto_test:
+	dh_auto_test -Bbld/deb
 
 override_dh_auto_install:
 # the kbd “core”
-	$(MAKE) DESTDIR=$(KBD) install-exec
-	$(MAKE) DESTDIR=$(KBD) -C po/ install
-	$(MAKE) DESTDIR=$(KBD) -C docs/man/ install
+	$(MAKE) -C bld/deb DESTDIR='$(CURDIR)'/debian/kbd install-exec
+	dh_auto_install -Bbld/deb/po --destdir=debian/kbd
+	dh_auto_install -Bbld/deb/docs/man --destdir=debian/kbd
 # some additional utilities
-	install -m755 $(addprefix src/,$(EXTRA_BINARIES)) $(KBD)/usr/bin/
-	install -m755 $(addprefix contrib/,$(CONTRIB_BINARIES)) $(KBD)/usr/bin/
-	install -m755 data/keymaps/i386/mk_modmap $(KBD)/usr/bin
+	dh_install -pkbd $(EXTRA_BINARIES_bin:%=bld/deb/src/%) \
+	  $(CONTRIB_BINARIES_bin:%=bld/contrib/%) usr/bin
+	dh_install -pkbd $(EXTRA_BINARIES_sbin:%=bld/deb/src/%) \
+	  $(CONTRIB_BINARIES_sbin:%=bld/contrib/%) usr/sbin
 # move everything where it belongs
-	mv $(addprefix debian/kbd/usr/bin/,$(MOVE_TO_USR_SBIN)) $(KBD)/usr/sbin/
+# The source file has been created by install-exec,
+# the destination directory usr/sbin by dh_install above.
+	mv $(MOVE_TO_USR_SBIN:%=debian/kbd/usr/bin/%) debian/kbd/usr/sbin
 # prepare udeb
-ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES)))
-	for ITEM in $(UDEB_BINARIES); do install -D -m755 src/$$ITEM-udeb $(KBD_UDEB)/usr/bin/$$ITEM; done
-endif
-# drop libtool files
-	find $(KBD) -name '*.la' -delete
-
-override_dh_installdocs:
-	dh_installdocs
-	install -d $(KBD_DOC)/charsets
-	cp docs/doc/iso8859.info docs/doc/iso*.txt docs/doc/cp*.txt $(KBD_DOC)/charsets
+	dh_install -pkbd-udeb $(UDEB_BINARIES:%=bld/udeb/src/%) usr/bin
-- 
2.47.3

>From 114534a6fac84a57ef43edc4462fdd157ab32f5a Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Tue, 24 Feb 2026 18:32:04 +0100
Subject: [PATCH 7/8] Enable hardening flags

---
 debian/rules | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/debian/rules b/debian/rules
index cea0c0e..e4a3f35 100755
--- a/debian/rules
+++ b/debian/rules
@@ -15,6 +15,8 @@ CONTRIB_BINARIES_sbin := vcstime
 # we don’t want these in /usr/bin
 MOVE_TO_USR_SBIN := kbdrate
 
+export DEB_BUILD_MAINT_OPTIONS := hardening=+all
+
 %:
 	dh $@
 
-- 
2.47.3

>From 4197efe2a568757f4e4e39f42afeb78e790ad7fa Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <[email protected]>
Date: Wed, 25 Feb 2026 05:24:19 +0100
Subject: [PATCH 8/8] Link libkeymap statically in udeb, dynamically in deb

---
 debian/rules | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/debian/rules b/debian/rules
index e4a3f35..b93a8d1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -24,15 +24,16 @@ override_dh_auto_clean:
 	rm -fr bld/
 
 override_dh_auto_configure:
-	dh_auto_configure -Bbld/deb -- $(common_configure_args)
+	dh_auto_configure -Bbld/deb -- $(common_configure_args) \
+	  --enable-libkeymap
   ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES)))
 	DEB_CFLAGS_MAINT_APPEND=-Os dh_auto_configure -Bbld/udeb \
-	  --reload-all-buildenv-variables -- $(common_configure_args)
+	  --reload-all-buildenv-variables -- $(common_configure_args) \
+	  --disable-libkeymap
   endif
 
 common_configure_args := \
 		--enable-nls \
-		--disable-libkeymap \
 		--disable-vlock
 
 override_dh_auto_build:
@@ -69,3 +70,7 @@ override_dh_auto_install:
 	mv $(MOVE_TO_USR_SBIN:%=debian/kbd/usr/bin/%) debian/kbd/usr/sbin
 # prepare udeb
 	dh_install -pkbd-udeb $(UDEB_BINARIES:%=bld/udeb/src/%) usr/bin
+# drop libtool files
+	rm debian/kbd/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.la
+# drop shared library development symbolic links
+	rm debian/kbd/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so
-- 
2.47.3

Reply via email to