Merge ~ahasenack/ubuntu/+source/base-files:groovy-motd-news-config-split into ubuntu/+source/base-files:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: de0f896184fa1b0569ccb57207748e7a24fc6b85
Merged at revision: de0f896184fa1b0569ccb57207748e7a24fc6b85
Proposed branch: ~ahasenack/ubuntu/+source/base-files:groovy-motd-news-config-split
Merge into: ubuntu/+source/base-files:ubuntu/devel
Diff against target: 169 lines (+106/-2)
7 files modified
debian/base-files.maintscript (+1/-0)
debian/changelog (+23/-0)
debian/control (+13/-1)
debian/motd-news-config.install (+1/-0)
debian/motd-news-config.postinst (+55/-0)
debian/postinst.in (+13/-0)
debian/rules (+0/-1)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Core Reviewers Pending
Review via email: mp+388835@code.launchpad.net

Description of the change

Another attempt at this motd-news-config split, after vorlon's feedback to make motd-news-config a base-files package instead of a new source.

PPA with test builds (no ~ppaN suffix because of the precise breaks/replaces I have all over the place): https://launchpad.net/~ahasenack/+archive/ubuntu/zomg-2/

The overall plan is to have motd-news only enabled on server systems after this upgrade. What it does:
- the /etc/default/motd-news config file is moved from base-files to motd-news-config, a new binary package built from base-files. If it has modifications, they are preserved via a postinst snippet
- ubuntu-server has a dependency on motd-news-config
- new base-files breaks old ubuntu-server, forcing an upgrade of ubuntu-server if it is installed

The versions used in these breaks/replaces have to be very precise for this to work, so between now and whenever these are uploaded, I'll check again.

For now in groovy we have:
base-files 11ubuntu10
ubuntu-meta 1.452

Therefore:
ubuntu-server 1.453:
Depends: motd-news-config

base-files 11ubuntu11:
Breaks/Replaces: ubuntu-server (<< 1.453)
rm_conffile /etc/default/motd-news 11ubuntu11~ base-files

motd-news-config 11ubuntu11:
Breaks/Replaces: base-files (<< 11ubuntu11)

For the PPA ubuntu-meta package, I committed directly to src:ubuntu-meta instead of running its ./update script, as I couldn't convince that script to use a branch of mine instead of the official ubuntu seeds repository. The seeds change is in https://code.launchpad.net/~ahasenack/ubuntu-seeds/+git/ubuntu-seeds/+merge/388403 and ready to land.

Here are the tests I've been running:
a) base-files installed, ubuntu-server installed, unmodified /e/d/motd-news
apt install base-files
- upgrades ubuntu-server
- installs motd-news-config
- /e/d/motd-news remains, motd-news remains enabled

b) base-files installed, ubuntu-server installed, modified /e/d/motd-news
apt install base-files
- upgrades ubuntu-server
- installs motd-news-config
- /e/d/motd-news remains with the original modification

c) base-files installed, ubuntu-server not installed, unmodified /e/d/motd-news
apt install base-files
- upgrades base-files
- removes /e/d/motd-news
- motd-news is disabled

d) base-files installed, ubuntu-server not installed, modified /e/d/motd-news
apt install base-files
- upgrades base-files
- /e/d/motd-news gets renamed to backup
- motd-news is disabled

e) removing motd-news-config will also remove ubuntu-server (since it's a depends, and not a recommends)

f) upgrading just ubuntu-server should pull motd-news-config in, and force-upgrade base-files

g) Removing motd-news-server leaves /e/d/motd-news around; purging motd-news-server removes the /e/d/motd-news config file

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Download full text (5.4 KiB)

Great testing as always.
I was not looking at re-running your tests, instead I wondered "what could happen" and a less surgical blunt user came to mind that just deleted /etc/default/motd-news which at first achieves the same thing (motd news is off)

I tested that on ubuntu-server and without ubuntu-server.

Without Ubuntu-server it is ok, the file does not come back and stays disabled.

But with Ubuntu-server installed there is nothing rm_conffile of base-files does.
Therefore no artifact is left, and due to that the default file is placed (again) and thereby re-enabling the service :-/

# Working (default)

root@g2:~# bash -x /etc/update-motd.d/50-motd-news
+ '[' -r /etc/default/motd-news ']'
+ . /etc/default/motd-news
++ ENABLED=1
++ URLS=https://motd.ubuntu.com
++ WAIT=5
+ '[' 1 = 1 ']'
+ '[' -n https://motd.ubuntu.com ']'
+ '[' -n 5 ']'
+ '[' -n '' ']'
+ CACHE=/var/cache/motd-news
+ '[' '' = --force ']'
+ '[' '' '!=' 1 ']'
+ '[' -r /var/cache/motd-news ']'
++ id -u
+ '[' 0 -eq 0 ']'
+ :
+ exit 0

# Remove file (disabled)

root@g2:~# rm /etc/default/motd-news
root@g2:~# bash -x /etc/update-motd.d/50-motd-news
+ '[' -r /etc/default/motd-news ']'
+ '[' '' = 1 ']'
+ exit 0

# Upgrade re-enables

root@g2:~# add-apt-repository ppa:ahasenack/zomg-2

 More info: https://launchpad.net/~ahasenack/+archive/ubuntu/zomg-2
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu groovy-backports InRelease
Get:4 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy InRelease [17.5 kB]
Hit:5 http://security.ubuntu.com/ubuntu groovy-security InRelease
Get:6 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main amd64 Packages [3772 B]
Get:7 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main Translation-en [1056 B]
Fetched 22.3 kB in 1s (27.7 kB/s)
Reading package lists... Done
root@g2:~#
root@g2:~#
root@g2:~# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
  motd-news-config
The following packages will be upgraded:
  base-files ubuntu-minimal ubuntu-server ubuntu-standard
4 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 262 kB of archives.
After this operation, 45.1 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main amd64 ubuntu-server amd64 1.453 [46.8 kB]
Get:2 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main amd64 base-files amd64 11ubuntu11 [88.6 kB]
Get:3 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main amd64 motd-news-config all 11ubuntu11 [32.5 kB]
Get:4 http://ppa.launchpad.net/ahasenack/zomg-2/ubuntu groovy/main amd64 ubuntu-minimal amd64 1.453 [46.9 ...

Read more...

review: Needs Information
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

> What do you think, does this require a bit more maintscript magic to be covered as well?

Heh, the config file is coming back because now it belongs to another package, which was never installed before (motd-news-config).

Do you have any idea what this maintscript magic would look like?

Is there a sane way motd-news-config could tell that the file was supposed to be there, but isn't? And then what would it do, place the new one in there with ENABLED set to 0?

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

How to do it:

What to do:
I wondered about that myself - there will be no perfect answer - but I think after placing the default file on install AND detecting this case of a formerly removed config-file the following should do it.

motd-news-config.postinst:
if [ -e /etc/default/motd-news.wasremoved ]; then
    sed -e 's/ENABLED=1/#Config file was removed for pkg:base-files - do not re-enable\nENABLED=0/' /etc/default/motd-news
    rm /etc/default/motd-news.wasremoved
fi

You'd need to check if that orders right to have motd-news.postinst (the one of the new version) executed before motd-news-config.postinst - if it does then before the #DEBHELPER# section something like.

base-files.postinst:
# user removed the full file, mark that to keep service disabled on conffile take over
if [ -e /etc/default/motd-news ]; then
    touch /etc/default/motd-news.wasremoved
fi

The above is untested, but this is what I'd have thought might help to avoid this issue.
Did you get any other feedback if/how to handle that situation?

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

what I meant for ordering: The new base-files.postinst will be called with "configure $oldver" before the install fully completes - just if this happens before moted-news.config.postinst is the question that I'm unsure about and worth a test.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

> Did you get any other feedback if/how to handle that situation?

xnox said "it's hard", steve didn't comment yet. Will ping again today.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :
Download full text (4.4 KiB)

> base-files.postinst:
> # user removed the full file, mark that to keep service disabled on conffile take over
> if [ -e /etc/default/motd-news ]; then
> touch /etc/default/motd-news.wasremoved
> fi

I'm assuming you meant "! -e" in the check above, i.e.:
- before rm_conffile kicks in (#DEBHELPER#)
- if /e/d/motd-news isn't there, then it's because the user removed it

I have this in debian/postinst.in:
(...)
# special case of having /etc/default/motd-news removed by hand
# signal the motd-news-config package that this happened, so that
# it does not put back the file with default contents which would
# re-enable motd-news
motd_config="/etc/default/motd-news"
ls -la "$motd_config" || :
if [ ! -e /etc/default/motd-news ]; then
  touch /etc/default/motd-news.wasremoved
fi

#DEBHELPER#

The "ls -la" is a debug statement.

I start with only base-files 11ubuntu10 installed (the current groovy version), and an unmodified /etc/default/motd-news file. Here is dpkg -i of the new base-files and new motd-news-config:

$ sudo dpkg -i ../*.deb 2>&1 | tee ../dpkg-i.log
(Reading database ... 36078 files and directories currently installed.)
Preparing to unpack .../base-files_11ubuntu11_amd64.deb ...
Warning: Stopping motd-news.service, but it can still be activated by:
  motd-news.timer
Unpacking base-files (11ubuntu11) over (11ubuntu10) ...
Selecting previously unselected package motd-news-config.
Preparing to unpack .../motd-news-config_11ubuntu11_all.deb ...
Unpacking motd-news-config (11ubuntu11) ...
Setting up base-files (11ubuntu11) ...
+ [ ! -e /etc/dpkg/origins/default ]
+ [ configure = configure ]
+ [ 11ubuntu10 = ]
+ [ ! -d /var/lib/dpkg ]
+ [ ! -f /var/lib/dpkg/status ]
+ [ ! -f /usr/info/dir ]
+ [ ! -f /usr/share/info/dir ]
+ [ configure = configure ]
+ [ 11ubuntu10 != ]
+ rm -f /var/lib/update-notifier/release-upgrade-available
+ [ -x /usr/lib/update-manager/check-new-release ]
+ update_to_current_default profile /etc/profile
+ [ -f /etc/profile ]
+ md5sum /etc/profile
+ cut -f 1 -d
+ md5=9d5ee34149287021622dd9e21c17ec26
+ grep -q 9d5ee34149287021622dd9e21c17ec26 /usr/share/base-files/profile.md5sums
+ cmp -s /usr/share/base-files/profile /etc/profile
+ update_to_current_default dot.profile /root/.profile
+ [ -f /root/.profile ]
+ md5sum /root/.profile
+ cut -f 1 -d
+ md5=d68ce7c7d7d2bb7d48aeb2f137b828e4
+ grep -q d68ce7c7d7d2bb7d48aeb2f137b828e4 /usr/share/base-files/dot.profile.md5sums
+ dpkg --compare-versions 11ubuntu10 lt-nl 7.7
+ motd_config=/etc/default/motd-news
+ ls -la /etc/default/motd-news
ls: cannot access '/etc/default/motd-news': No such file or directory
+ :
+ [ ! -e /etc/default/motd-news ]
+ touch /etc/default/motd-news.wasremoved
+ [ configure = configure ]
+ deb-systemd-helper unmask motd-news.timer
+ deb-systemd-helper --quiet was-enabled motd-news.timer
+ deb-systemd-helper enable motd-news.timer
+ [ configure = configure ]
+ [ -d /run/systemd/system ]
+ systemctl --system daemon-reload
+ deb-systemd-invoke start motd-news.timer
+ [ configure = configure ]
+ [ -d /run/systemd/system ]
+ systemctl --system daemon-reload
+ deb-systemd-invoke start motd-news.service
motd-news.service is a disabled or a static uni...

Read more...

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Ok, handling those two cases as well now (.dpkg-remove and .dpkg-bak), pushed. I'll have to create a new ppa (guess: zomg-3), as I don't want to complicate testing by using ~ppaN suffixes, given all the exact breaks/replaces I have in these packages.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Had a typo in postinst, preparing zomg-4...

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I added these two extra tests:
h) base-files installed, ubuntu-server installed, removed /e/d/motd-news
- apt install base-files
- upgrades base-files, upgrades ubuntu-server, installs motd-news-config
- /e/d/motd-news is installed with ENABLED=0

i) base-files installed, ubuntu-server NOT installed, removed e/d/motd-news
- apt install base-files
- base-files is upgraded
- no /e/d/motd-news is installed, motd-news remains disabled

Packages from zomg-4 passed all, but (i) left a lingering /etc/default/motd-news.wasremoved. Investigating.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Ok, it's because the removal is done in motd-news-config's postinst, but since there was no motd-news-config package installed (because there was no ubuntu-server installed before), nothing removed the .wasremoved file :/

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Should I add a check to see if ubuntu-server is installed before touching that .wasremoved file? Like dpkg -s ubuntu-server, and only if it's installed and the other conditions match, create the .wasremoved file? This is getting complicated...

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Ok, Steve came back and said:
<vorlon> ahasenack: hi, managing to reply before you drop off IRC for the day; I think the corner case in question is acceptable to not address, but needs to be called out in the SRU
<vorlon> (as "regression potential")

I then mentioned the attempt above at fixing this corner case, and he analyzed the changes, and said:
<vorlon> ahasenack: yeah, so I'm vaguely inclined to leave this corner case unfixed but called out in the SRU, rather than add additional complicated maintscript handling; but I wouldn't block the SRU if you do add the maintscript stuff

I fear that this complicated handling in maintainerscripts might introduce more bugs. Let's try without it, and call out the corner case you found in the bug?

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I pushed 6aaff4e6f2930bb3351f6adc72e3bd46b0c8ca78 for the extra ubuntu-devel presence check, to try to fix the /etc/default/motd-news.wasremoved leftover, but I'm not very fond of calling dpkg -l inside a maintainer script, and am ready to drop that.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

While it isn't common dpkg -l should be safe as it is "essential: Yes".
The line you added isn't super complex and should get the issue of the lingering file solved.

The only thing I'm wondering is - would at this stage the first entry of dpkg -l being "Desired state" already be "i" for motd-news-config itself.

If it isn't then keep things as-is and at least I'm +1 on it.
But if it is "i" then checking directly for motd-news-config ready more logically and would cover any awkward dependency messing that prevents it from being installed despite ubuntu-server being present (none come to mind right now, but you know to be on the safe side).

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

To be clear - (if you prefer that) I'd also be ok to leave "6aaff4e6" out and list it in regression risk. But I see no big risk in keeping "6aaff4e6" either.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I feel like walking a fine line and risking introducing worse regressions than the ones I'm trying to handle :)

About dpkg -l, I've seen at least two ways to check if a package is installed. In postfix[1], we have:
nis_status=$(dpkg -l nis 2>/dev/null | sed -n '$p')
if [ "X$nis_status" != "X${nis_status#i}" ] && [ -x /usr/bin/ypcat ] &&
 /usr/bin/ypcat mail.aliases >/dev/null 2>&1; then
     alias_maps="hash:/etc/aliases, nis:mail.aliases"

In openssl[2], dpkg -s is used:

dpkg -s <list-of-packages-space-separated> 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')

While testing the "dpkg -l ubuntu-server" idea, I was at first grepping for ^ii, but turns out ubuntu-server is in a iU state (installed, unpacked), so I switched to ^i. I haven't checked the motd-news-config state yet.

The other thing that bothers me in this fine line I'm walking is that this latest testing was on groovy, but I have to do this all the way back to xenial, and in xenial debhelper isn't even used.

1. https://git.launchpad.net/ubuntu/+source/postfix/tree/debian/postfix.postinst#n321
2. https://git.launchpad.net/ubuntu/+source/openssl/tree/debian/libssl1.1.postinst#n83

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I filled in the SRU template in the base-files bug, and slightly changed the wording we add to /e/d/motd-news when the config file isn't there during the upgrade. I also added an extra check for the presence of the file before sedding it, just to be safe.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Am going to test this one last time in zomg-5

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Repeated the groovy tests with the zomg-5 ppa, all worked as expected from (a) to (i), where in (i) the /etc/default/motd-news.wasremoved zero-sized file remains.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Tagging and uploading de0f896184fa1b0569ccb57207748e7a24fc6b85

$ git push pkg upload/11ubuntu11
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 4 threads
Compressing objects: 100% (38/38), done.
Writing objects: 100% (39/39), 5.97 KiB | 381.00 KiB/s, done.
Total 39 (delta 26), reused 0 (delta 0)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/base-files
 * [new tag] upload/11ubuntu11 -> upload/11ubuntu11

$ dput ubuntu ../base-files_11ubuntu11_source.changes
Checking signature on .changes
gpg: ../base-files_11ubuntu11_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../base-files_11ubuntu11.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading base-files_11ubuntu11.dsc: done.
  Uploading base-files_11ubuntu11.tar.xz: done.
  Uploading base-files_11ubuntu11_source.buildinfo: done.
  Uploading base-files_11ubuntu11_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/base-files.maintscript b/debian/base-files.maintscript
2new file mode 100644
3index 0000000..9972f51
4--- /dev/null
5+++ b/debian/base-files.maintscript
6@@ -0,0 +1 @@
7+rm_conffile /etc/default/motd-news 11ubuntu11~ base-files
8diff --git a/debian/changelog b/debian/changelog
9index c72b59f..6d9813e 100644
10--- a/debian/changelog
11+++ b/debian/changelog
12@@ -1,3 +1,26 @@
13+base-files (11ubuntu11) groovy; urgency=medium
14+
15+ * Move the /etc/default/motd-news conffile to the motd-news-config
16+ package (LP: #1888575):
17+ - d/base-files.maintscript: remove /etc/default/motd-news config file
18+ on upgrade
19+ - d/control: break on ubuntu-server << 1.453 to force an upgrade if
20+ it is installed, which will pull motd-news-config and the conffile
21+ back in
22+ - d/motd-news-config.postinst:
23+ + handle the upgrade case where the motd-news config file was
24+ changed while it belonged to base-files
25+ + disable motd-news if the config file was removed by hand before
26+ the upgrade
27+ - d/postinst.in: signal the motd-news-config package if the
28+ motd-news config file was removed manually before the upgrade
29+ - d/control: new motd-news-config package, carrying the
30+ configuration file for the /etc/update-motd.d/50-motd-news script.
31+ - d/rules, d/motd-news-config.install: /e/d/motd-news is in the
32+ motd-news-config package now
33+
34+ -- Andreas Hasenack <andreas@canonical.com> Mon, 10 Aug 2020 21:02:37 +0000
35+
36 base-files (11ubuntu10) groovy; urgency=medium
37
38 * motd/50-motd-news: use the actual wget version variable in the
39diff --git a/debian/control b/debian/control
40index c90938a..d6b9138 100644
41--- a/debian/control
42+++ b/debian/control
43@@ -14,7 +14,8 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, libcrypt1 (>= 1:4.4.10-10ubuntu3)
44 Essential: yes
45 Priority: required
46 Replaces: base, miscutils, dpkg (<= 1.15.0)
47-Breaks: debian-security-support (<< 2019.04.25), initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~)
48+Breaks: debian-security-support (<< 2019.04.25), initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~),
49+ ubuntu-server (<< 1.453)
50 Multi-Arch: foreign
51 Description: Debian base system miscellaneous files
52 This package contains the basic filesystem hierarchy of a Debian system, and
53@@ -28,3 +29,14 @@ Section: debian-installer
54 Architecture: all
55 Priority: extra
56 Description: LSB release information
57+
58+Package: motd-news-config
59+Architecture: all
60+Breaks: base-files (<< 11ubuntu11)
61+Replaces: base-files (<< 11ubuntu11)
62+Depends: ${shlibs:Depends}, ${misc:Depends}
63+Description: Configuration for motd-news shipped in base-files
64+ This package contains the configuration read by the motd-news script
65+ shipped in the base-files package.
66+ .
67+ Install this package if you want motd-news to be enabled.
68diff --git a/debian/motd-news-config.install b/debian/motd-news-config.install
69new file mode 100644
70index 0000000..876b3b8
71--- /dev/null
72+++ b/debian/motd-news-config.install
73@@ -0,0 +1 @@
74+debian/motd-news etc/default
75diff --git a/debian/motd-news-config.postinst b/debian/motd-news-config.postinst
76new file mode 100644
77index 0000000..a73427f
78--- /dev/null
79+++ b/debian/motd-news-config.postinst
80@@ -0,0 +1,55 @@
81+#!/bin/sh
82+# postinst script for motd-news-config
83+#
84+# see: dh_installdeb(1)
85+
86+set -e
87+
88+# summary of how this script can be called:
89+# * <postinst> `configure' <most-recently-configured-version>
90+# * <old-postinst> `abort-upgrade' <new version>
91+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
92+# <new-version>
93+# * <postinst> `abort-remove'
94+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
95+# <failed-install-package> <version> `removing'
96+# <conflicting-package> <version>
97+# for details, see https://www.debian.org/doc/debian-policy/ or
98+# the debian-policy package
99+
100+
101+case "$1" in
102+ configure)
103+ # only run on new installs, $2 will be empty then
104+ if [ -z "$2" ]; then
105+ # /e/d/motd-news was moved from pkg:base-files to this package.
106+ # base-files runs rm_conffile which, if it was modified, leaves
107+ # /e/d/motd-news.dpkg-bak around. We want to preserve that *changed*
108+ # config file in this migration, and this is something that
109+ # rm_conffile is not handling. In that case, let's put the backup
110+ # file back in place
111+ if [ -e /etc/default/motd-news.dpkg-bak ]; then
112+ mv /etc/default/motd-news.dpkg-bak /etc/default/motd-news
113+ fi
114+ if [ -e /etc/default/motd-news.wasremoved ] && [ -e /etc/default/motd-news ]; then
115+ sed -i -e 's/^ENABLED=1/# Changed by motd-news-config.postinst:\n# config file was manually removed - disable the service\nENABLED=0/' /etc/default/motd-news
116+ rm /etc/default/motd-news.wasremoved
117+ fi
118+ fi
119+ ;;
120+
121+ abort-upgrade|abort-remove|abort-deconfigure)
122+ ;;
123+
124+ *)
125+ echo "postinst called with unknown argument \`$1'" >&2
126+ exit 1
127+ ;;
128+esac
129+
130+# dh_installdeb will replace this with shell code automatically
131+# generated by other debhelper scripts.
132+
133+#DEBHELPER#
134+
135+exit 0
136diff --git a/debian/postinst.in b/debian/postinst.in
137index 69435e3..c347a62 100644
138--- a/debian/postinst.in
139+++ b/debian/postinst.in
140@@ -125,4 +125,17 @@ if [ "$1" = "configure" ] && [ "$2" != "" ]; then
141 fi
142 fi
143
144+# special case of having /etc/default/motd-news removed by hand
145+# signal the motd-news-config package that this happened, so that
146+# it does not put back the file with default contents which would
147+# re-enable motd-news
148+motd_news_config="/etc/default/motd-news"
149+if [ ! -e ${motd_news_config} ]; then
150+ if [ ! -e ${motd_news_config}.dpkg-remove ]; then
151+ if [ ! -e ${motd_news_config}.dpkg-backup ]; then
152+ touch ${motd_news_config}.wasremoved
153+ fi
154+ fi
155+fi
156+
157 #DEBHELPER#
158diff --git a/debian/rules b/debian/rules
159index 9f0f164..4340bf7 100755
160--- a/debian/rules
161+++ b/debian/rules
162@@ -25,7 +25,6 @@ override_dh_auto_build: locale-check
163 override_dh_auto_install:
164 install -p -m 644 etc/* $(DESTDIR)/etc
165 install -p -m 755 motd/* $(DESTDIR)/etc/update-motd.d
166- install -p -m 644 debian/motd-news $(DESTDIR)/etc/default
167 install -p -m 644 debian/motd-news.service $(DESTDIR)/lib/systemd/system/
168 install -p -m 644 debian/motd-news.timer $(DESTDIR)/lib/systemd/system/
169 install -p -m 644 licenses/* $(DESTDIR)/usr/share/common-licenses

Subscribers

People subscribed via source and target branches