jenkinsci / packaging

Native packaging for Jenkins
https://jenkins.io
42 stars 83 forks source link

Require Debian 10 / Ubuntu 20.04 or newer, include jenkins.tmpfiles #456

Closed TobiX closed 7 months ago

TobiX commented 7 months ago

This updates the debhelper compat level when building a Debian package from 10 to 13. This fixes #455, since the file introduced in #442 is picked up in the newer compat level.

This introces a new Pre-Depends (see the changelog for compat level 12) on init-system-helpers (>= 1.54~) which should be satisfiable in Debian >= 10 and Ubuntu >= 20.04, which should match Jenkins' support policy AFAICS.

Testing done

Build package using

make deb WAR=$PWD/jenkins.war MSI= CREDENTIAL=$PWD/credentials/test.mk

in the jenkinsciinfra/packaging:latest build image and installed in a debian:12 for verification that it still works and expected files are installed.

PS: I had to change the author in branding/test.mk to

export AUTHOR=Bogus Test (This is test only key) <noreply@jenkins-ci.org>

since debsign is using the package author field to find the secret GPG key...

Diffoscope report

Here is a difference between the package built without my change and with my change as reported by diffoscope:

Report ```diff --- target/debian/jenkinstest_2.440.2_all.old.deb +++ target/debian/jenkinstest_2.440.2_all.new.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2024-03-22 12:37:00.000000 debian-binary │ --rw-r--r-- 0 0 0 2792 2024-03-22 12:37:00.000000 control.tar.xz │ --rw-r--r-- 0 0 0 85780176 2024-03-22 12:37:00.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 3000 2024-03-22 12:37:00.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 85780336 2024-03-22 12:37:00.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── file list │ │ │ @@ -1,7 +1,7 @@ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./ │ │ │ -rw-r--r-- 0 root (0) root (0) 78 2024-03-22 12:37:00.000000 ./conffiles │ │ │ --rw-r--r-- 0 root (0) root (0) 889 2024-03-22 12:37:00.000000 ./control │ │ │ --rw-r--r-- 0 root (0) root (0) 399 2024-03-22 12:37:00.000000 ./md5sums │ │ │ --rwxr-xr-x 0 root (0) root (0) 4060 2024-03-22 12:37:00.000000 ./postinst │ │ │ --rwxr-xr-x 0 root (0) root (0) 1423 2024-03-22 12:37:00.000000 ./postrm │ │ │ --rwxr-xr-x 0 root (0) root (0) 237 2024-03-22 12:37:00.000000 ./prerm │ │ │ +-rw-r--r-- 0 root (0) root (0) 933 2024-03-22 12:37:00.000000 ./control │ │ │ +-rw-r--r-- 0 root (0) root (0) 469 2024-03-22 12:37:00.000000 ./md5sums │ │ │ +-rwxr-xr-x 0 root (0) root (0) 5028 2024-03-22 12:37:00.000000 ./postinst │ │ │ +-rwxr-xr-x 0 root (0) root (0) 1626 2024-03-22 12:37:00.000000 ./postrm │ │ │ +-rwxr-xr-x 0 root (0) root (0) 502 2024-03-22 12:37:00.000000 ./prerm │ │ ├── ./control │ │ │ @@ -1,12 +1,13 @@ │ │ │ Package: jenkinstest │ │ │ Version: 2.440.2 │ │ │ Architecture: all │ │ │ Maintainer: Bogus Test (This is test only key) │ │ │ -Installed-Size: 84529 │ │ │ +Installed-Size: 84533 │ │ │ +Pre-Depends: init-system-helpers (>= 1.54~) │ │ │ Depends: adduser, lsb-base (>= 3.2-14), net-tools, sysvinit-utils (>= 2.88dsf-50) │ │ │ Section: devel │ │ │ Priority: optional │ │ │ Homepage: http://test.jenkins.io/ │ │ │ Description: Jenkins is the leading open source automation server supported by a large and growing community of developers, testers, designers and other people interested in continuous integration, continuous delivery and modern software delivery practices. Built on the Java Virtual Machine (JVM), it provides more than 1,800 plugins that extend Jenkins to automate with practically any technology software delivery teams use. In 2022, Jenkins reached 300,000 known installations making it the most widely deployed automation server. │ │ │ . │ │ │ For more information, see https://www.jenkins.io. │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ │ │ │ ├── line order │ │ │ │ @@ -1,6 +1,7 @@ │ │ │ │ lib/systemd/system/jenkinstest.service │ │ │ │ usr/bin/jenkinstest │ │ │ │ +usr/lib/tmpfiles.d/jenkinstest.conf │ │ │ │ usr/share/doc/jenkinstest/changelog.gz │ │ │ │ usr/share/doc/jenkinstest/copyright │ │ │ │ usr/share/java/jenkinstest.war │ │ │ │ usr/share/jenkinstest/migrate │ │ ├── ./postinst │ │ │ @@ -71,15 +71,37 @@ │ │ │ exit 1 │ │ │ ;; │ │ │ esac │ │ │ │ │ │ # dh_installdeb will replace this with shell code automatically │ │ │ # generated by other debhelper scripts. │ │ │ │ │ │ -# Automatically added by dh_systemd_enable/13.6ubuntu1 │ │ │ +# Automatically added by dh_installtmpfiles/13.6ubuntu1 │ │ │ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then │ │ │ + # In case this system is running systemd, we need to ensure that all │ │ │ + # necessary tmpfiles (if any) are created before starting. │ │ │ + if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ] ; then │ │ │ + systemd-tmpfiles --create jenkinstest.conf >/dev/null || true │ │ │ + fi │ │ │ +fi │ │ │ +# End automatically added section │ │ │ +# Automatically added by dh_installinit/13.6ubuntu1 │ │ │ +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then │ │ │ + if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/jenkinstest" ]; then │ │ │ + update-rc.d jenkinstest defaults >/dev/null │ │ │ + if [ -n "$2" ]; then │ │ │ + _dh_action=restart │ │ │ + else │ │ │ + _dh_action=start │ │ │ + fi │ │ │ + invoke-rc.d --skip-systemd-native jenkinstest $_dh_action || exit 1 │ │ │ + fi │ │ │ +fi │ │ │ +# End automatically added section │ │ │ +# Automatically added by dh_installsystemd/13.6ubuntu1 │ │ │ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then │ │ │ # This will only remove masks created by d-s-h on package removal. │ │ │ deb-systemd-helper unmask 'jenkinstest.service' >/dev/null || true │ │ │ │ │ │ # was-enabled defaults to true, so new installations run enable. │ │ │ if deb-systemd-helper --quiet was-enabled 'jenkinstest.service'; then │ │ │ # Enables the unit on first installation, creates new │ │ │ @@ -88,23 +110,23 @@ │ │ │ else │ │ │ # Update the statefile to add new symlinks (if any), which need to be │ │ │ # cleaned up on purge. Also remove old symlinks. │ │ │ deb-systemd-helper update-state 'jenkinstest.service' >/dev/null || true │ │ │ fi │ │ │ fi │ │ │ # End automatically added section │ │ │ -# Automatically added by dh_installinit/13.6ubuntu1 │ │ │ +# Automatically added by dh_installsystemd/13.6ubuntu1 │ │ │ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then │ │ │ - if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/jenkinstest" ]; then │ │ │ - update-rc.d jenkinstest defaults >/dev/null │ │ │ + if [ -d /run/systemd/system ]; then │ │ │ + systemctl --system daemon-reload >/dev/null || true │ │ │ if [ -n "$2" ]; then │ │ │ _dh_action=restart │ │ │ else │ │ │ _dh_action=start │ │ │ fi │ │ │ - invoke-rc.d jenkinstest $_dh_action || exit 1 │ │ │ + deb-systemd-invoke $_dh_action 'jenkinstest.service' >/dev/null || true │ │ │ fi │ │ │ fi │ │ │ # End automatically added section │ │ │ │ │ │ │ │ │ exit 0 │ │ ├── ./postrm │ │ │ @@ -28,15 +28,20 @@ │ │ │ esac │ │ │ │ │ │ # Automatically added by dh_installinit/13.6ubuntu1 │ │ │ if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = "purge" ] ; then │ │ │ update-rc.d jenkinstest remove >/dev/null │ │ │ fi │ │ │ # End automatically added section │ │ │ -# Automatically added by dh_systemd_enable/13.6ubuntu1 │ │ │ +# Automatically added by dh_installsystemd/13.6ubuntu1 │ │ │ +if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then │ │ │ + systemctl --system daemon-reload >/dev/null || true │ │ │ +fi │ │ │ +# End automatically added section │ │ │ +# Automatically added by dh_installsystemd/13.6ubuntu1 │ │ │ if [ "$1" = "remove" ]; then │ │ │ if [ -x "/usr/bin/deb-systemd-helper" ]; then │ │ │ deb-systemd-helper mask 'jenkinstest.service' >/dev/null || true │ │ │ fi │ │ │ fi │ │ │ │ │ │ if [ "$1" = "purge" ]; then │ │ ├── ./prerm │ │ │ @@ -1,7 +1,12 @@ │ │ │ #!/bin/sh │ │ │ set -e │ │ │ +# Automatically added by dh_installsystemd/13.6ubuntu1 │ │ │ +if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then │ │ │ + deb-systemd-invoke stop 'jenkinstest.service' >/dev/null || true │ │ │ +fi │ │ │ +# End automatically added section │ │ │ # Automatically added by dh_installinit/13.6ubuntu1 │ │ │ if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -x "/etc/init.d/jenkinstest" ] ; then │ │ │ - invoke-rc.d jenkinstest stop || exit 1 │ │ │ + invoke-rc.d --skip-systemd-native jenkinstest stop || exit 1 │ │ │ fi │ │ │ # End automatically added section ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -9,14 +9,17 @@ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./lib/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./lib/systemd/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./lib/systemd/system/ │ │ │ -rw-r--r-- 0 root (0) root (0) 5648 2024-03-22 12:37:00.000000 ./lib/systemd/system/jenkinstest.service │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/bin/ │ │ │ -rwxr-xr-x 0 root (0) root (0) 4600 2024-03-22 12:37:00.000000 ./usr/bin/jenkinstest │ │ │ +drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/lib/ │ │ │ +drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/lib/tmpfiles.d/ │ │ │ +-rw-r--r-- 0 root (0) root (0) 38 2024-03-22 12:37:00.000000 ./usr/lib/tmpfiles.d/jenkinstest.conf │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/share/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/share/doc/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/share/doc/jenkinstest/ │ │ │ -rw-r--r-- 0 root (0) root (0) 180 2024-03-22 12:37:00.000000 ./usr/share/doc/jenkinstest/changelog.gz │ │ │ -rw-r--r-- 0 root (0) root (0) 1523 2024-03-22 12:37:00.000000 ./usr/share/doc/jenkinstest/copyright │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-03-22 12:37:00.000000 ./usr/share/java/ │ │ │ -rwxr-xr-x 0 root (0) root (0) 86482142 2024-03-22 12:37:00.000000 ./usr/share/java/jenkinstest.war ```

Formatted HTML report

PPS: For reproducibility I had to fudge the timestamp in the Debian changelog (which is used for all files in the package)

### Submitter checklist
- [ ] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [ ] Ensure that the pull request title represents the desired changelog entry
- [ ] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue
MarkEWaite commented 7 months ago

@kmartens27 don't miss including this in the weekly changelog and in the LTS changelog.