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

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: c91565c6eb7c49f151ab7fff5a1cb9e350224e04
Merged at revision: c91565c6eb7c49f151ab7fff5a1cb9e350224e04
Proposed branch: ~ahasenack/ubuntu/+source/base-files:xenial-motd-news-config-split
Merge into: ubuntu/+source/base-files:ubuntu/xenial-devel
Diff against target: 362 lines (+197/-15)
10 files modified
debian/changelog (+35/-0)
debian/conffiles (+0/-1)
debian/control (+13/-1)
debian/motd-news-config.conffiles (+1/-0)
debian/motd-news-config.postinst (+50/-0)
debian/postinst.in (+19/-0)
debian/postrm (+6/-0)
debian/preinst (+34/-0)
debian/rules (+19/-4)
debian/update-motd.d/50-motd-news (+20/-9)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+389300@code.launchpad.net

Description of the change

Same as https://code.launchpad.net/~ahasenack/ubuntu/+source/base-files/+git/base-files/+merge/388835, but for xenial, with the following extra details:

- backport the switch to wget, and follow-up fixes that landed in groovy
- far from just a detail: the xenial package does not use debhelper, so I had to do many things by hand in d/rules
- versions for breaks/replaces are the xenial ones:

ubuntu-server 1.361.5:
  Depends: motd-news-config

base-files 9.4ubuntu4.13:
  Breaks: ubuntu-server (<< 1.361.5)
  rm_conffile /etc/default/motd-news 9.4ubuntu4.13~ base-files

motd-news-config 9.4ubuntu4.13:
  Breaks/Replaces: base-files (<< 9.4ubuntu4.13)

PPA: https://launchpad.net/~ahasenack/+archive/ubuntu/zomg-5/

The linked bugs have the SRU template filled out.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I pushed a change I found out while testing the groovy package: motd-news-config has to have priority set to optional, otherwise it will inherit base-files' which is "required" and do-release-upgrade will install it regardless of dependencies.

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

Change matches what we had in Groovy and soon Focal.
Additional change for priority is good as well.
Versions are good as well for an SRU and the bug LGTM as well.

The breaks and rm_conffile versions are adapted correctly, but we really need to land the meta change at the same time to avoid some updaters to remove packages or even ubuntu-server.

+1 to this in general, but I found one triviality to fix.
The changelog entries got carried over without line-wrap. So you violate the 80 chars in two lines and tools like lintian will hate it.

Fix is trivial enough, you don't need a re-review for the CL changes.

I was wondering at first why the different rm_conffile calls - but I see that adding debian/base-files.maintscript with the one line we need would have had no effect as he maintainer scripts have no #DEBHELPER# template and adding it int he SRU might change more than we want. I double checked if these three hooks should be enough - but they match the rm_conffile code well. This adds some noise, but the new lines LGTM - if your testing is good as well that should be fine.

+1 to this (condition, adapt the changelog)

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

> I was wondering at first why the different rm_conffile calls - but I see that
> adding debian/base-files.maintscript with the one line we need would have had
> no effect as he maintainer scripts have no #DEBHELPER# template

Not just that, debhelper isn't used at all in d/rules. I followed the dpkg-maintscript-helper manpage which says that for rm_conffile only preinst, postinst and postrm are used

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

changelog fixed

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

Tagging and uploading c91565c6eb7c49f151ab7fff5a1cb9e350224e04

$ git push pkg upload/9.4ubuntu4.13
Enumerating objects: 64, done.
Counting objects: 100% (64/64), done.
Delta compression using up to 4 threads
Compressing objects: 100% (49/49), done.
Writing objects: 100% (54/54), 8.46 KiB | 2.82 MiB/s, done.
Total 54 (delta 38), reused 7 (delta 4)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/base-files
 * [new tag] upload/9.4ubuntu4.13 -> upload/9.4ubuntu4.13

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

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

Also uploading https://code.launchpad.net/~ahasenack/ubuntu/+source/ubuntu-meta/+git/ubuntu-meta/+ref/xenial-ubuntu-server-motd-news

The seed change will also happen, but since it involves a new package, the update script from ubuntu-meta won't pick it up, so I have to add the dep manually.

Tagging and uploading d8fb428bfd5b6662e3408bdbb25121e844eb7c78 of that branch:

$ git push pkg upload/1.361.5
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.13 KiB | 46.00 KiB/s, done.
Total 9 (delta 5), reused 0 (delta 0)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/ubuntu-meta
 * [new tag] upload/1.361.5 -> upload/1.361.5

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

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

Seeds changed for xenial in 2c4f57772b95223c86ac23afeb7e8034488c95c7 after ok from steve.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 3be5a47..cf951ad 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,38 @@
6+base-files (9.4ubuntu4.13) xenial; urgency=medium
7+
8+ [ Andreas Hasenack ]
9+ * motd/50-motd-news: don't include uptime in the user-agent string
10+ (LP: #1886572)
11+ * Move the /etc/default/motd-news conffile to the motd-news-config
12+ package (LP: #1888575):
13+ - d/postinst.in, d/postrm, d/preinst: remove /etc/default/motd-news
14+ config file on base-files upgrade using dpkg-maintscript-helper
15+ - d/rules: install d/preinst
16+ - d/control: break on ubuntu-server << 1.361.5 to force an upgrade if
17+ it is installed, which will pull motd-news-config and the conffile
18+ back in
19+ - d/control: new motd-news-config package, carrying the
20+ configuration file for the /etc/update-motd.d/50-motd-news script.
21+ - d/motd-news-config.postinst:
22+ + handle the upgrade case where the motd-news config file was
23+ changed while it belonged to base-files
24+ + disable motd-news if the config file was removed by hand before
25+ the upgrade
26+ - d/postinst.in: signal the motd-news-config package if the
27+ motd-news config file was removed manually before the upgrade
28+ - d/conffiles: remove motd-news
29+ - d/rules, d/motd-news-config.conffiles: packaging motd-news-config
30+ without debhelper
31+
32+ [ Steve Langasek ]
33+ * motd/50-motd-news: use wget instead of curl, since wget is standard but
34+ curl is optional (LP: #1888572):
35+ - This changes the timeout behavior slightly because wget does not have
36+ an exact equivalent to curl's --max-time argument, we are using
37+ --timeout instead.
38+
39+ -- Andreas Hasenack <andreas@canonical.com> Mon, 17 Aug 2020 11:19:19 -0300
40+
41 base-files (9.4ubuntu4.12) xenial; urgency=medium
42
43 * /etc/issue, /etc/issue.net, /etc/lsb-release, /etc/os-release: Bump
44diff --git a/debian/conffiles b/debian/conffiles
45index 6600468..748ffb5 100644
46--- a/debian/conffiles
47+++ b/debian/conffiles
48@@ -1,5 +1,4 @@
49 /etc/debian_version
50-/etc/default/motd-news
51 /etc/dpkg/origins/debian
52 /etc/dpkg/origins/ubuntu
53 /etc/host.conf
54diff --git a/debian/control b/debian/control
55index 49ad4f0..a8c39a2 100644
56--- a/debian/control
57+++ b/debian/control
58@@ -12,7 +12,7 @@ Pre-Depends: awk
59 Essential: yes
60 Priority: required
61 Replaces: base, miscutils, dpkg (<= 1.15.0)
62-Breaks: initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~)
63+Breaks: initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~), ubuntu-server (<< 1.361.5)
64 Multi-Arch: foreign
65 Description: Debian base system miscellaneous files
66 This package contains the basic filesystem hierarchy of a Debian system, and
67@@ -25,3 +25,15 @@ Section: debian-installer
68 Architecture: all
69 Priority: extra
70 Description: LSB release information
71+
72+Package: motd-news-config
73+Architecture: all
74+Priority: optional
75+Breaks: base-files (<< 9.4ubuntu4.13)
76+Replaces: base-files (<< 9.4ubuntu4.13)
77+Depends: ${shlibs:Depends}, ${misc:Depends}
78+Description: Configuration for motd-news shipped in base-files
79+ This package contains the configuration read by the motd-news script
80+ shipped in the base-files package.
81+ .
82+ Install this package if you want motd-news to be enabled.
83diff --git a/debian/motd-news-config.conffiles b/debian/motd-news-config.conffiles
84new file mode 100644
85index 0000000..4109d03
86--- /dev/null
87+++ b/debian/motd-news-config.conffiles
88@@ -0,0 +1 @@
89+/etc/default/motd-news
90diff --git a/debian/motd-news-config.postinst b/debian/motd-news-config.postinst
91new file mode 100644
92index 0000000..419d326
93--- /dev/null
94+++ b/debian/motd-news-config.postinst
95@@ -0,0 +1,50 @@
96+#!/bin/sh
97+# postinst script for motd-news-config
98+#
99+# see: dh_installdeb(1)
100+
101+set -e
102+
103+# summary of how this script can be called:
104+# * <postinst> `configure' <most-recently-configured-version>
105+# * <old-postinst> `abort-upgrade' <new version>
106+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
107+# <new-version>
108+# * <postinst> `abort-remove'
109+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
110+# <failed-install-package> <version> `removing'
111+# <conflicting-package> <version>
112+# for details, see https://www.debian.org/doc/debian-policy/ or
113+# the debian-policy package
114+
115+
116+case "$1" in
117+ configure)
118+ # only run on new installs, $2 will be empty then
119+ if [ -z "$2" ]; then
120+ # /e/d/motd-news was moved from pkg:base-files to this package.
121+ # base-files runs rm_conffile which, if it was modified, leaves
122+ # /e/d/motd-news.dpkg-bak around. We want to preserve that *changed*
123+ # config file in this migration, and this is something that
124+ # rm_conffile is not handling. In that case, let's put the backup
125+ # file back in place
126+ if [ -e /etc/default/motd-news.dpkg-bak ]; then
127+ mv /etc/default/motd-news.dpkg-bak /etc/default/motd-news
128+ fi
129+ if [ -e /etc/default/motd-news.wasremoved ] && [ -e /etc/default/motd-news ]; then
130+ 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
131+ rm /etc/default/motd-news.wasremoved
132+ fi
133+ fi
134+ ;;
135+
136+ abort-upgrade|abort-remove|abort-deconfigure)
137+ ;;
138+
139+ *)
140+ echo "postinst called with unknown argument \`$1'" >&2
141+ exit 1
142+ ;;
143+esac
144+
145+exit 0
146diff --git a/debian/postinst.in b/debian/postinst.in
147index db85abf..89ddd29 100644
148--- a/debian/postinst.in
149+++ b/debian/postinst.in
150@@ -127,6 +127,19 @@ if [ "$1" = "configure" ] && [ "$2" != "" ]; then
151 fi
152 fi
153
154+# special case of having /etc/default/motd-news removed by hand
155+# signal the motd-news-config package that this happened, so that
156+# it does not put back the file with default contents which would
157+# re-enable motd-news
158+motd_news_config="/etc/default/motd-news"
159+if [ ! -e ${motd_news_config} ]; then
160+ if [ ! -e ${motd_news_config}.dpkg-remove ]; then
161+ if [ ! -e ${motd_news_config}.dpkg-backup ]; then
162+ touch ${motd_news_config}.wasremoved
163+ fi
164+ fi
165+fi
166+
167 # Manually inject expected maintainer script contents based on dh_systemd_*
168
169 # This will only remove masks created by d-s-h on package removal.
170@@ -147,3 +160,9 @@ if [ -d /run/systemd/system ]; then
171 systemctl --system daemon-reload >/dev/null || true
172 deb-systemd-invoke start motd-news.timer >/dev/null || true
173 fi
174+
175+if dpkg-maintscript-helper supports rm_conffile; then
176+ dpkg-maintscript-helper rm_conffile /etc/default/motd-news 9.4ubuntu4.13~ base-files -- "$@"
177+fi
178+
179+exit 0
180diff --git a/debian/postrm b/debian/postrm
181index a763f0d..5f1a281 100644
182--- a/debian/postrm
183+++ b/debian/postrm
184@@ -19,3 +19,9 @@ if [ "$1" = "purge" ]; then
185 deb-systemd-helper unmask 'motd-news.timer' >/dev/null || true
186 fi
187 fi
188+
189+if dpkg-maintscript-helper supports rm_conffile; then
190+ dpkg-maintscript-helper rm_conffile /etc/default/motd-news 9.4ubuntu4.13~ base-files -- "$@"
191+fi
192+
193+exit 0
194diff --git a/debian/preinst b/debian/preinst
195new file mode 100644
196index 0000000..6b96fc1
197--- /dev/null
198+++ b/debian/preinst
199@@ -0,0 +1,34 @@
200+#!/bin/sh
201+# preinst script for base-files
202+#
203+# see: dh_installdeb(1)
204+
205+set -e
206+
207+# summary of how this script can be called:
208+# * <new-preinst> `install'
209+# * <new-preinst> `install' <old-version>
210+# * <new-preinst> `upgrade' <old-version>
211+# * <old-preinst> `abort-upgrade' <new-version>
212+# for details, see https://www.debian.org/doc/debian-policy/ or
213+# the debian-policy package
214+
215+
216+case "$1" in
217+ install|upgrade)
218+ ;;
219+
220+ abort-upgrade)
221+ ;;
222+
223+ *)
224+ echo "preinst called with unknown argument \`$1'" >&2
225+ exit 1
226+ ;;
227+esac
228+
229+if dpkg-maintscript-helper supports rm_conffile; then
230+ dpkg-maintscript-helper rm_conffile /etc/default/motd-news 9.4ubuntu4.13~ base-files -- "$@"
231+fi
232+
233+exit 0
234diff --git a/debian/rules b/debian/rules
235index 0ca88d0..682cbf5 100755
236--- a/debian/rules
237+++ b/debian/rules
238@@ -25,10 +25,10 @@ build:
239 clean:
240 rm -f build
241 rm -f `find . -name "*~"`
242- rm -rf debian/tmp debian/lsb-release-udeb debian/files* core debian/substvars
243+ rm -rf debian/tmp debian/lsb-release-udeb debian/files* core debian/substvars debian/motd-news-config
244
245 binary-arch: build
246- rm -rf debian/tmp
247+ rm -rf debian/tmp debian/motd-news-config
248 install -d debian/tmp/DEBIAN $(docdir) debian/tmp/etc/dpkg/origins
249 install -p -m 644 origins/* debian/tmp/etc/dpkg/origins
250 cd debian/tmp && install -d usr/share/$(package)
251@@ -42,7 +42,7 @@ binary-arch: build
252 sed -e "s/#VENDORFILE#/$(VENDORFILE)/g" debian/postinst.in \
253 > debian/tmp/DEBIAN/postinst
254 chmod 755 debian/tmp/DEBIAN/postinst
255- install -m 755 debian/prerm debian/postrm debian/tmp/DEBIAN
256+ install -m 755 debian/prerm debian/postrm debian/preinst debian/tmp/DEBIAN
257 cd debian && install -m 644 conffiles tmp/DEBIAN
258 cd debian/tmp && install -d `cat ../directory-list`
259 install -p -m 644 share/* debian/tmp/usr/share/base-files
260@@ -55,7 +55,6 @@ binary-arch: build
261 ln -s README $(docdir)/FAQ
262 install -p -m 644 etc/* debian/tmp/etc
263 install -p -m 755 debian/update-motd.d/* debian/tmp/etc/update-motd.d
264- install -p -m 644 debian/motd-news debian/tmp/etc/default
265 install -p -m 644 debian/motd-news.service debian/tmp/lib/systemd/system/
266 install -p -m 644 debian/motd-news.timer debian/tmp/lib/systemd/system/
267 ifeq ($(DEB_HOST_GNU_SYSTEM),gnu)
268@@ -87,6 +86,22 @@ endif
269 xargs -0r touch -h --date='$(BUILD_DATE)'
270 dpkg-deb --build -Zgzip debian/tmp ..
271
272+ # motd-news-config packaging
273+ install -d debian/motd-news-config/DEBIAN debian/motd-news-config/usr/share/doc/motd-news-config
274+ install -d debian/motd-news-config/etc/default
275+ install -m 0644 $(docdir)/changelog.gz $(docdir)/copyright debian/motd-news-config/usr/share/doc/motd-news-config
276+ cp debian/motd-news-config.postinst debian/motd-news-config/DEBIAN/postinst
277+ chmod 0755 debian/motd-news-config/DEBIAN/postinst
278+ install -p -m 644 debian/motd-news debian/motd-news-config/etc/default
279+ cp debian/motd-news-config.conffiles debian/motd-news-config/DEBIAN/conffiles
280+ cd debian/motd-news-config && \
281+ find usr -type f ! -regex "DEBIAN/.*" -print0 |\
282+ LC_ALL=C sort -z | xargs -0r md5sum > DEBIAN/md5sums
283+ chmod 0644 debian/motd-news-config/DEBIAN/conffiles
284+ chmod 0644 debian/motd-news-config/DEBIAN/md5sums
285+ dpkg-gencontrol -pmotd-news-config -Pdebian/motd-news-config
286+ dpkg-deb --build -Zgzip debian/motd-news-config ..
287+
288 binary-indep: build
289 rm -rf debian/lsb-release-udeb
290 install -d debian/lsb-release-udeb/DEBIAN debian/lsb-release-udeb/etc
291diff --git a/debian/update-motd.d/50-motd-news b/debian/update-motd.d/50-motd-news
292index 08d7f0d..c9d142f 100644
293--- a/debian/update-motd.d/50-motd-news
294+++ b/debian/update-motd.d/50-motd-news
295@@ -1,10 +1,11 @@
296 #!/bin/sh
297 #
298 # 50-motd-news - print the live news from the Ubuntu wire
299-# Copyright (C) 2016-2017 Canonical Ltd.
300+# Copyright (C) 2016-2020 Canonical Ltd.
301 # Copyright (C) 2016-2017 Dustin Kirkland
302 #
303 # Authors: Dustin Kirkland <kirkland@canonical.com>
304+# Steve Langasek <steve.langasek@canonical.com>
305 #
306 # This program is free software; you can redistribute it and/or modify
307 # it under the terms of the GNU General Public License as published by
308@@ -64,6 +65,9 @@ fi
309 # If we've made it here, we've been given the --force argument,
310 # probably from the systemd motd-news.service. Let's update...
311
312+# Abort early if wget is missing
313+[ -x /usr/bin/wget ] || exit 0
314+
315 # Generate our temp files, clean up when done
316 NEWS=$(mktemp) || exit 1
317 ERR=$(mktemp) || exit 1
318@@ -73,8 +77,8 @@ trap "rm -f $NEWS $ERR $CLOUD" HUP INT QUIT ILL TRAP KILL BUS TERM
319 # Construct a user agent, similar to Firefox/Chrome/Safari/IE to
320 # ensure a proper, tailored, accurate message of the day
321
322-# Curl browser version, for debug purposes
323-curl_ver="$(dpkg -l curl | awk '$1 == "ii" { print($3); exit(0); }')"
324+# wget browser version, for debug purposes
325+wget_ver="$(dpkg -l wget | awk '$1 == "ii" { print($3); exit(0); }')"
326
327 # Distribution version, for messages releated to this Ubuntu release
328 . /etc/lsb-release
329@@ -97,12 +101,8 @@ if [ -x /usr/bin/cloud-id ]; then
330 fi
331 fi
332
333-# Some messages may only be pertinent before or after some amount of uptime
334-read up idle < /proc/uptime
335-uptime="uptime/$up/$idle"
336-
337 # Piece together the user agent
338-USER_AGENT="curl/$curl_ver $lsb $platform $cpu $uptime cloud_id/$cloud_id"
339+USER_AGENT="wget/$wget_ver $lsb $platform $cpu cloud_id/$cloud_id"
340
341 # Loop over any configured URLs
342 for u in $URLS; do
343@@ -121,7 +121,18 @@ for u in $URLS; do
344 # If we're forced, set the wait to much higher (1 minute)
345 [ "$FORCED" = "1" ] && WAIT=60
346 # Fetch and print the news motd
347- if curl --connect-timeout "$WAIT" --max-time "$WAIT" -A "$USER_AGENT" -o- "$u" >"$NEWS" 2>"$ERR"; then
348+ result=0
349+ not_found_is_ok=0
350+ wget --timeout "$WAIT" -U "$USER_AGENT" -O- --content-on-error "$u" >"$NEWS" 2>"$ERR" || result=$?
351+ # from wget's manpage: 8 Server issued an error response.
352+ if [ $result -eq 8 ]; then
353+ if grep -q "ERROR 404" "$ERR"; then
354+ # The server's 404 document is the generic, non cloud-specific, motd-news
355+ # content present in the index.txt file
356+ not_found_is_ok=1
357+ fi
358+ fi
359+ if [ $result -eq 0 ] || [ $not_found_is_ok -eq 1 ]; then
360 echo
361 # At most, 10 lines of text, remove control characters, print at most 80 characters per line
362 safe_print "$NEWS"

Subscribers

People subscribed via source and target branches