Source: base-files Source-Version: 11 Severity: wishlist Tags: patch Hi!
This package requires both changes in Debian between freeze and non-freeze times, and also is one of the first ones that need modifications when creating a derivative. To make handling both these cases, I've prepared the attached patch which tries to parametrize everything that is changed in Debian during the release cycle so that it's easier to maintain. And so that derivatives can have an easier time deriving too. The new workflow for Debian would require only touching three variables in params/debian. For a derivative, it would require adding a new params/<vendor> file and changing the params/default symlink to point to that. This would massively reduce the amount of changes needed in derivatives, as seen in <http://deriv.debian.net/patches/b/base-files/>. I've tried to document all variables in params/debian so that they are easy to understand. I've also switched from #SUBST# to @SUBST@ as that works better within a Makefile. Let me know what you think, and whether you'd like to see anything changed? (BTW, I guess you do not manage this package under a VCS?) Thanks, Guillem
From f3bc14192d80a40c7376bced5e7af27f23de099c Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@debian.org> Date: Sun, 19 Jan 2020 01:10:40 +0100 Subject: [PATCH] Parametrize files This should help both Debian and its derivatives, as now all these should be able to do most of the work by just adding a new params/ file and updating the params/default symlink. We switch from #SUBST# to @SUBST@ as that works better within a Makefile. The intention here is that the only things that would normally need changing would be under params/. For a derivative a new params file would need to be added under params/ and the params/default symlink updated. --- debian/README | 10 ++--- debian/base-files.dirs | 1 + debian/base-files.docs | 2 - debian/base-files.links | 1 - debian/clean | 1 + debian/control | 8 ++-- debian/copyright.in | 6 +-- debian/current-md5sums-obsolete | 4 +- debian/gen-vendor.mk | 14 +++++++ debian/postinst.in | 4 +- debian/rules | 72 ++++++++++++++++++++++++++++----- etc/debian_version | 1 - etc/issue | 2 +- etc/issue.net | 2 +- etc/os-release | 16 +++++--- origins/debian | 3 -- params/debian | 68 +++++++++++++++++++++++++++++++ params/default | 1 + share/dot.bashrc | 2 +- share/info.dir | 2 +- share/motd | 4 +- 21 files changed, 180 insertions(+), 44 deletions(-) delete mode 100644 debian/base-files.docs create mode 100644 debian/gen-vendor.mk delete mode 100644 etc/debian_version delete mode 100644 origins/debian create mode 100644 params/debian create mode 120000 params/default diff --git a/debian/README b/debian/README index 1618655..5a51013 100644 --- a/debian/README +++ b/debian/README @@ -4,10 +4,10 @@ Frequently Asked Questions about base-files * Questions about /etc/issue and /etc/debian_version: Q. I upgraded my system to the testing distribution and now my /etc/issue -says "bullseye/sid". Should it not read "bullseye" or "testing"? +says "@OSCODENAME_TESTING@/sid". Should it not read "@OSCODENAME_TESTING@" or "testing"? Q. I upgraded my system to the unstable distribution and now my /etc/issue -says "bullseye/sid". Should it not read "sid" or "unstable"? +says "@OSCODENAME_TESTING@/sid". Should it not read "sid" or "unstable"? A. That would be nice, but it is not possible because of the way the testing distribution works. Packages uploaded for unstable reach @@ -17,9 +17,9 @@ testing. You should consider the testing and unstable distributions as two sides of the same coin. Since the base-files package in testing was initially uploaded for unstable, the only sensible /etc/issue to have is one that is both valid for testing and unstable, hence -"bullseye/sid" (or whatever is appropriate). +"@OSCODENAME_TESTING@/sid" (or whatever is appropriate). -Q. Why "bullseye/sid" and not "testing/unstable" as it used to be? +Q. Why "@OSCODENAME_TESTING@/sid" and not "testing/unstable" as it used to be? A. The codename is a little bit more informative, as the meaning of "testing" changes over time. @@ -31,7 +31,7 @@ not a reliable way to know that anymore. Looking at the contents of your /etc/apt/sources.list file is probably a much better way. Q. There is a new point release and I've just upgraded my system. -The /etc/debian_version file now says 10.x but /etc/issue still says 10. +The /etc/debian_version file now says @OSVERSION_ID_STABLE@.x but /etc/issue still says @OSVERSION_ID_STABLE@. Is this ok? A. Yes. The release managers asked me not to touch /etc/issue, as that's diff --git a/debian/base-files.dirs b/debian/base-files.dirs index b646146..67aa627 100644 --- a/debian/base-files.dirs +++ b/debian/base-files.dirs @@ -25,6 +25,7 @@ usr/share usr/share/base-files usr/share/common-licenses usr/share/dict +usr/share/doc/base-files usr/share/info usr/share/lintian/overrides usr/share/man diff --git a/debian/base-files.docs b/debian/base-files.docs deleted file mode 100644 index 3b7ab47..0000000 --- a/debian/base-files.docs +++ /dev/null @@ -1,2 +0,0 @@ -debian/README -debian/README.FHS diff --git a/debian/base-files.links b/debian/base-files.links index 3166652..2923156 100644 --- a/debian/base-files.links +++ b/debian/base-files.links @@ -1,4 +1,3 @@ -usr/share/doc/base-files/README usr/share/doc/base-files/FAQ usr/share/common-licenses/GFDL-1.3 usr/share/common-licenses/GFDL usr/share/common-licenses/LGPL-3 usr/share/common-licenses/LGPL usr/share/common-licenses/GPL-3 usr/share/common-licenses/GPL diff --git a/debian/clean b/debian/clean index 977e85d..076c22c 100644 --- a/debian/clean +++ b/debian/clean @@ -1,2 +1,3 @@ debian/postinst debian/copyright +debian/substvars diff --git a/debian/control b/debian/control index 3c6754f..3d2d46e 100644 --- a/debian/control +++ b/debian/control @@ -15,8 +15,8 @@ Priority: required Replaces: base, miscutils, dpkg (<= 1.15.0) Breaks: debian-security-support (<< 2019.04.25), initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~) Multi-Arch: foreign -Description: Debian base system miscellaneous files - This package contains the basic filesystem hierarchy of a Debian system, and - several important miscellaneous files, such as /etc/debian_version, +Description: ${vendorName} base system miscellaneous files + This package contains the basic filesystem hierarchy of a ${vendorName} system, and + several important miscellaneous files, such as /etc/${vendorVersionFileId}_version, /etc/host.conf, /etc/issue, /etc/motd, /etc/profile, and others, - and the text of several common licenses in use on Debian systems. + and the text of several common licenses in use on ${vendorName} systems. diff --git a/debian/copyright.in b/debian/copyright.in index 1d905d5..cd25685 100644 --- a/debian/copyright.in +++ b/debian/copyright.in @@ -1,6 +1,6 @@ -This is the Debian #OSNAME# prepackaged version of the Debian Base System +This is the @PRODUCT_NAME@ prepackaged version of the @VENDOR_NAME@ Base System Miscellaneous files. These files were written by Ian Murdock -<imurd...@debian.org> and Bruce Perens <br...@pixar.com>. +<imurd...@debian.org> and Bruce Perens <br...@pixar.com> for Debian. This package was first put together by Bruce Perens <br...@pixar.com>, from his own sources. @@ -24,5 +24,5 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -On Debian #OSNAME# systems, the complete text of the GNU General +On @PRODUCT_NAME@ systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/current-md5sums-obsolete b/debian/current-md5sums-obsolete index 5236dc4..ac7913b 100755 --- a/debian/current-md5sums-obsolete +++ b/debian/current-md5sums-obsolete @@ -1,3 +1,3 @@ #!/bin/sh -sed -e "s&#OSNAME#&GNU/Linux&" etc/motd | awk 'NR > 2' | md5sum -sed -e "s&#OSNAME#&GNU/Hurd&" etc/motd | awk 'NR > 2' | md5sum +sed -e "s&@OSNAME@&GNU/Linux&" etc/motd | awk 'NR > 2' | md5sum +sed -e "s&@OSNAME@&GNU/Hurd&" etc/motd | awk 'NR > 2' | md5sum diff --git a/debian/gen-vendor.mk b/debian/gen-vendor.mk new file mode 100644 index 0000000..a692c67 --- /dev/null +++ b/debian/gen-vendor.mk @@ -0,0 +1,14 @@ +include params/$(VENDOR_ID) + +gen_origin: + echo Vendor: $(VENDOR_NAME) > $(DESTDIR)/etc/dpkg/origins/$(VENDOR_ID) + echo Vendor-URL: $(VENDOR_URL_HOME) >> $(DESTDIR)/etc/dpkg/origins/$(VENDOR_ID) + echo Bugs: $(VENDOR_URL_BUGREPORT_NEW) >> $(DESTDIR)/etc/dpkg/origins/$(VENDOR_ID) +ifneq ($(VENDOR_ID_PARENT),) + echo Parent: $(VENDOR_NAME_PARENT) >> $(DESTDIR)/etc/dpkg/origins/$(VENDOR_ID) + $(MAKE) -f debian/gen-vendor.mk VENDOR_ID=$(VENDOR_ID_PARENT) DESTDIR=$(DESTDIR) +endif +ifneq ($(VENDOR_VERSION_FILE_ID),) + echo $(VENDOR_VERSION_FILE_VERSION) > $(DESTDIR)/etc/$(VENDOR_VERSION_FILE_ID)_version + echo "vendorVersionFileId=$(VENDOR_VERSION_FILE_ID)" >> debian/base-files.substvars +endif diff --git a/debian/postinst.in b/debian/postinst.in index 1d35ee1..70ed0f6 100644 --- a/debian/postinst.in +++ b/debian/postinst.in @@ -45,8 +45,8 @@ update_to_current_default() { } if [ ! -e /etc/dpkg/origins/default ]; then - if [ -e /etc/dpkg/origins/#VENDORFILE# ]; then - ln -sf #VENDORFILE# /etc/dpkg/origins/default + if [ -e /etc/dpkg/origins/@VENDOR_ID@ ]; then + ln -sf @VENDOR_ID@ /etc/dpkg/origins/default fi fi diff --git a/debian/rules b/debian/rules index 88db04b..38da601 100755 --- a/debian/rules +++ b/debian/rules @@ -8,7 +8,41 @@ ifeq ($(DEB_HOST_GNU_SYSTEM),gnu) OSNAME=GNU/Hurd endif -VENDORFILE = debian +VENDOR_ID = $(shell readlink params/default) + +include params/$(VENDOR_ID) + +PARAMS = +PARAMS += -e 's/@VENDOR_NAME@/$(VENDOR_NAME)/g' +PARAMS += -e "s/@VENDOR_ID@/$(VENDOR_ID)/g" +PARAMS += -e "s&@VENDOR_URL_HOME@&$(VENDOR_URL_HOME)&g" +PARAMS += -e "s&@VENDOR_URL_SUPPORT@&$(VENDOR_URL_SUPPORT)&g" +PARAMS += -e "s&@VENDOR_URL_BUGREPORT_WEB@&$(VENDOR_URL_BUGREPORT_WEB)&g" +PARAMS += -e "s/@VENDOR_CHROOT_ID@/$(VENDOR_CHROOT_ID)/g" +PARAMS += -e "s&@OSNAME@&$(OSNAME)&g" +PARAMS += -e "s&@OSCODENAME_TESTING@&$(OSCODENAME_TESTING)&g" +PARAMS += -e "s&@OSVERSION@&$(OSVERSION)&g" +PARAMS += -e "s/@OSVERSION_ID_STABLE@/$(OSVERSION_ID_STABLE)/g" +PARAMS += -e "s&@PRODUCT_NAME@&$(PRODUCT_NAME)&g" +PARAMS += -e "s&@PRODUCT_NAME_FULL@&$(PRODUCT_NAME_FULL)&g" +PARAMS += -e "s&@PRODUCT_NAME_LOGIN@&$(PRODUCT_NAME_LOGIN)&g" + +ifeq ($(VENDOR_ID_PARENT),) +PARAMS += -e "/^ID_LIKE=/d" +else +PARAMS += -e 's/@VENDOR_NAME_PARENT@/$(VENDOR_NAME_PARENT)/g' +PARAMS += -e "s/@VENDOR_ID_PARENT@/$(VENDOR_ID_PARENT)/g" +endif +ifeq ($(OSCODENAME),) +PARAMS += -e "/^VERSION_ID=/d" +PARAMS += -e "/^VERSION=/d" +PARAMS += -e "/^VERSION_CODENAME=/d" +else +PARAMS += -e "s/@OSVERSION_ID@/$(OSVERSION_ID)/g" +PARAMS += -e "s/@OSVERSION@/$(OSVERSION)/g" +PARAMS += -e "s/@OSCODENAME@/$(OSCODENAME)/g" +endif + DESTDIR = debian/base-files %: @@ -16,28 +50,40 @@ DESTDIR = debian/base-files override_dh_auto_build: sh debian/check-md5sum-etc profile - sed -e "s&#OSNAME#&$(OSNAME)&g" debian/copyright.in > debian/copyright - sed -e "s/#VENDORFILE#/$(VENDORFILE)/g" debian/postinst.in > debian/postinst + sed $(PARAMS) debian/copyright.in > debian/copyright + sed $(PARAMS) debian/postinst.in > debian/postinst override_dh_auto_install: install -p -m 644 etc/* $(DESTDIR)/etc install -p -m 755 motd/* $(DESTDIR)/etc/update-motd.d install -p -m 644 licenses/* $(DESTDIR)/usr/share/common-licenses - install -p -m 644 origins/* $(DESTDIR)/etc/dpkg/origins install -p -m 644 share/* $(DESTDIR)/usr/share/base-files ifeq ($(DEB_HOST_GNU_SYSTEM),gnu) rmdir $(DESTDIR)/sys endif - sed -e "s&#OSNAME#&$(OSNAME)&g" share/motd > $(DESTDIR)/usr/share/base-files/motd - sed -e "s&#OSNAME#&$(OSNAME)&g" share/info.dir > $(DESTDIR)/usr/share/base-files/info.dir - sed -e "s&#OSNAME#&$(OSNAME)&g" etc/issue > $(DESTDIR)/etc/issue - sed -e "s&#OSNAME#&$(OSNAME)&g" etc/issue.net > $(DESTDIR)/etc/issue.net - sed -e "s&#OSNAME#&$(OSNAME)&g" etc/os-release > $(DESTDIR)/etc/os-release + $(MAKE) -f debian/gen-vendor.mk VENDOR_ID=$(VENDOR_ID) DESTDIR=$(DESTDIR) + sed $(PARAMS) share/dot.bashrc > $(DESTDIR)/usr/share/base-files/dot.bashrc + sed $(PARAMS) share/motd > $(DESTDIR)/usr/share/base-files/motd + sed $(PARAMS) share/info.dir > $(DESTDIR)/usr/share/base-files/info.dir + sed $(PARAMS) etc/issue > $(DESTDIR)/etc/issue + sed $(PARAMS) etc/issue.net > $(DESTDIR)/etc/issue.net + sed $(PARAMS) etc/os-release > $(DESTDIR)/etc/os-release mv $(DESTDIR)/etc/os-release $(DESTDIR)/usr/lib/os-release ln -s ../usr/lib/os-release $(DESTDIR)/etc/os-release +# These are Debian specific files, not needed on derivatives. +ifeq ($(VENDOR_ID),debian) +override_dh_installdocs: + sed $(PARAMS) debian/README > $(DESTDIR)/usr/share/doc/base-files/README + dh_installdocs /usr/share/doc/base-files/README debian/README.FHS +endif + override_dh_link: +ifeq ($(VENDOR_ID),debian) + dh_link -X os-release usr/share/doc/base-files/README usr/share/doc/base-files/FAQ +else dh_link -X os-release +endif override_dh_compress: dh_compress -X README @@ -49,3 +95,11 @@ override_dh_fixperms: cd debian/base-files && chmod 1777 `cat ../1777-dirs` cd debian/base-files && chmod 2775 `cat ../2775-dirs` cd debian/base-files && chmod 700 root + +override_dh_gencontrol: + # Even though starting with dpkg 1.20.1 the vendor:Name substitution + # variables will be natively supported, we cannot use them, because we + # might be getting bootstrapped from another derivative. + echo "vendorName=$(VENDOR_NAME)" >> debian/substvars + echo "vendorName=$(VENDOR_NAME)" >> debian/base-files.substvars + dh_gencontrol diff --git a/etc/debian_version b/etc/debian_version deleted file mode 100644 index 37ad99e..0000000 --- a/etc/debian_version +++ /dev/null @@ -1 +0,0 @@ -bullseye/sid diff --git a/etc/issue b/etc/issue index 836683e..1e918f5 100644 --- a/etc/issue +++ b/etc/issue @@ -1,2 +1,2 @@ -Debian #OSNAME# bullseye/sid \n \l +@PRODUCT_NAME_LOGIN@ \n \l diff --git a/etc/issue.net b/etc/issue.net index 6c96e01..9da6795 100644 --- a/etc/issue.net +++ b/etc/issue.net @@ -1 +1 @@ -Debian #OSNAME# bullseye/sid +@PRODUCT_NAME_LOGIN@ diff --git a/etc/os-release b/etc/os-release index a6a47e9..6044428 100644 --- a/etc/os-release +++ b/etc/os-release @@ -1,6 +1,10 @@ -PRETTY_NAME="Debian #OSNAME# bullseye/sid" -NAME="Debian #OSNAME#" -ID=debian -HOME_URL="https://www.debian.org/" -SUPPORT_URL="https://www.debian.org/support" -BUG_REPORT_URL="https://bugs.debian.org/" +PRETTY_NAME="@PRODUCT_NAME_FULL@" +NAME="@PRODUCT_NAME@" +VERSION_ID="@OSVERSION_ID@" +VERSION="@OSVERSION@" +VERSION_CODENAME=@OSCODENAME@ +ID=@VENDOR_ID@ +ID_LIKE=@VENDOR_ID_PARENT@ +HOME_URL="@VENDOR_URL_HOME@" +SUPPORT_URL="@VENDOR_URL_SUPPORT@" +BUG_REPORT_URL="@VENDOR_URL_BUGREPORT_WEB@" diff --git a/origins/debian b/origins/debian deleted file mode 100644 index 3b623d2..0000000 --- a/origins/debian +++ /dev/null @@ -1,3 +0,0 @@ -Vendor: Debian -Vendor-URL: https://www.debian.org/ -Bugs: debbugs://bugs.debian.org diff --git a/params/debian b/params/debian new file mode 100644 index 0000000..4faaa7f --- /dev/null +++ b/params/debian @@ -0,0 +1,68 @@ +# The pretty name for this distribution vendor. +VENDOR_NAME = Debian +# The vendor parent name is the pretty name of the parent vendor distribution. +VENDOR_NAME_PARENT = +# The vendor parent ID is the identification of the parent vendor distribution +# as would be used in filenames. +VENDOR_ID_PARENT = + +VENDOR_URL_HOME = https://www.debian.org/ +VENDOR_URL_SUPPORT = https://www.debian.org/support +VENDOR_URL_BUGREPORT_WEB = https://bugs.debian.org/ +VENDOR_URL_BUGREPORT_NEW = debbugs://bugs.debian.org + +# This is used for the /etc/<vendor>_version, which is an interface, so +# consider whether this needs to be changed for a derivative. If your +# derivative does not need its own file, comment it out or set to empty. +VENDOR_VERSION_FILE_ID = debian + +# This is the name for <vendor>_chroot variable used in sh PS1. It is an +# interface, so consider whether this needs to be changed for a derivative. +# If your derivative does not need its own variable, leave it as is. +VENDOR_CHROOT_ID = debian + +## The following are only relevant for Debian, for other derivatives these +## can be commented out or set to empty: +# OSVERSION_ID_STABLE is the current stable major version before the freeze, +# and to the next major version during the freeze. +OSVERSION_ID_STABLE = 10 +# OSCODENAME_TESTING always refers to the testing release after the current +# stable. +OSCODENAME_TESTING = bullseye + +## The following are (in Debian) defined only for a stable release (during +## the freeze), derivatives might want to define them unconditionally: +# OSVERSION_ID is the version identifier, not including a patch level nor +# codenames, such as 10. +OSVERSION_ID = +# OSVERSION_FULL is the full version, including a patch level, such as 10.3. +# (This variables does not get substituted in output files.) +OSVERSION_FULL = +# OSCODENAME is the release codename, such as bullseye. +OSCODENAME = + +# OSVERSION is the version identifier, including the version number and +# possibly a release code name. +# LOGIN_VERSION is is the version identifier used during login. +# (This variable does not get substituted in output files.) +# VENDOR_VERSION_FILE_VERSION is the version identifier used for the the +# version vendor file (see VENDOR_VERSION_FILE_ID). + +ifeq ($(OSCODENAME),) +# Before the freeze: +OSVERSION = $(OSCODENAME_TESTING)/sid +LOGIN_VERSION = $(OSCODENAME_TESTING)/sid +VENDOR_VERSION_FILE_VERSION = $(OSCODENAME_TESTING)/sid +else +# During the freeze: +OSVERSION = $(OSVERSION_ID) ($(OSCODENAME)) +LOGIN_VERSION = $(OSVERSION_ID) +VENDOR_VERSION_FILE_VERSION = $(OSVERSION_FULL) +endif + +# PRODUCT_NAME_FULL is the full product name. +PRODUCT_NAME_FULL = $(VENDOR_NAME) $(OSNAME) $(OSVERSION) +# PRODUCT_NAME_LOGIN is the product name shown during login. +PRODUCT_NAME_LOGIN = $(VENDOR_NAME) $(OSNAME) $(LOGIN_VERSION) +# PRODUCT_NAME is the short product name. +PRODUCT_NAME = $(VENDOR_NAME) $(OSNAME) diff --git a/params/default b/params/default new file mode 120000 index 0000000..b2f7fd3 --- /dev/null +++ b/params/default @@ -0,0 +1 @@ +debian \ No newline at end of file diff --git a/share/dot.bashrc b/share/dot.bashrc index 5d3a56e..75d2978 100644 --- a/share/dot.bashrc +++ b/share/dot.bashrc @@ -2,7 +2,7 @@ # Note: PS1 and umask are already set in /etc/profile. You should not # need this unless you want different defaults for root. -# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ ' +# PS1='${@VENDOR_CHROOT_ID@_chroot:+($@VENDOR_CHROOT_ID@_chroot)}\h:\w\$ ' # umask 022 # You may uncomment the following lines if you want `ls' to be colorized: diff --git a/share/info.dir b/share/info.dir index 550533d..2a42998 100644 --- a/share/info.dir +++ b/share/info.dir @@ -11,7 +11,7 @@ File: dir Node: Top This is the top of the INFO tree it. --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- -In Debian #OSNAME#, Info `dir' entries are added with the command +In @PRODUCT_NAME@, Info `dir' entries are added with the command `install-info'. Please refer to install-info(8) for usage details. * Menu: The list of major topics begins on the next line. diff --git a/share/motd b/share/motd index 0120913..3bf6255 100644 --- a/share/motd +++ b/share/motd @@ -1,7 +1,7 @@ -The programs included with the Debian #OSNAME# system are free software; +The programs included with the @PRODUCT_NAME@ system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. -Debian #OSNAME# comes with ABSOLUTELY NO WARRANTY, to the extent +@PRODUCT_NAME@ comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. -- 2.26.1.301.g55bc3eb7cb9