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

Proposed by Andreas Hasenack on 2020-08-06
Status: Merged
Approved by: Andreas Hasenack on 2020-08-17
Approved revision: 6f3fbdb8ed9b84ed92aee611b03ae0bb96f4b7c4
Merged at revision: 6f3fbdb8ed9b84ed92aee611b03ae0bb96f4b7c4
Proposed branch: ~ahasenack/ubuntu/+source/base-files:focal-motd-news-config-split
Merge into: ubuntu/+source/base-files:ubuntu/focal-devel
Diff against target: 252 lines (+137/-11)
8 files modified
debian/base-files.maintscript (+1/-0)
debian/changelog (+33/-0)
debian/control (+14/-1)
debian/motd-news-config.install (+1/-0)
debian/motd-news-config.postinst (+55/-0)
debian/postinst.in (+13/-0)
debian/rules (+0/-1)
motd/50-motd-news (+20/-9)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  2020-08-06 Approve on 2020-08-17
Canonical Server Team 2020-08-06 Pending
Review via email: mp+388848@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 focal, with the following extra details:

- backport the switch to wget, and follow-up fixes that landed in groovy
- versions for breaks/replaces are the focal ones:

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

base-files 11ubuntu5.2:
  Breaks: ubuntu-server (<< 1.450.2)
  rm_conffile /etc/default/motd-news 11ubuntu5.2~ base-files

motd-news-config 11ubuntu5.2:
  Breaks/Replaces: base-files (<< 11ubuntu5.2)

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

Linked bugs have the SRU template filled out.

To post a comment you must log in.
Andreas Hasenack (ahasenack) wrote :

This is ready for review

Christian Ehrhardt  (paelzer) wrote :

I just realized that we will hit the base-files rm_conffile again and again - as the one in groovy has the groovy version listed. But that should be no problem - it will find the file already removed and be ok with it.

I re-read the changes and agree that they match what we got into Bionic and they LGTM.
+1

review: Approve
Andreas Hasenack (ahasenack) wrote :

Now that groovy has these packages, let me try a release upgrade just to be sure

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.

Christian Ehrhardt  (paelzer) wrote :

So many details, I'm glad for your thorough testing on this.
The additional change LGTM as well - re-approve.

I guess this needs to be added in Groovy as well then?

review: Approve
Andreas Hasenack (ahasenack) wrote :

It's uploaded to groovy already

On Mon, Aug 17, 2020, 03:34 Christian Ehrhardt  <
<email address hidden>> wrote:

> Review: Approve
>
> So many details, I'm glad for your thorough testing on this.
> The additional change LGTM as well - re-approve.
>
> I guess this needs to be added in Groovy as well then?
> --
>
> https://code.launchpad.net/~ahasenack/ubuntu/+source/base-files/+git/base-files/+merge/388848
> You are the owner of
> ~ahasenack/ubuntu/+source/base-files:focal-motd-news-config-split.
>
> Launchpad-Message-Rationale: Owner
> Launchpad-Message-For: ahasenack
> Launchpad-Notification-Type: code-review
> Launchpad-Branch:
> ~ahasenack/ubuntu/+source/base-files/+git/base-files:focal-motd-news-config-split
>

Andreas Hasenack (ahasenack) wrote :

I had to rebase to fix the commit message of commit 93ca11572a83a9c6efc8fd8dcfafb21cb4bbd207 which was mentioning the wrong ubuntu-server version to break on (the contents of the commit were correct, it was just the message):

commit 93ca11572a83a9c6efc8fd8dcfafb21cb4bbd207
Author: Andreas Hasenack <email address hidden>
Date: Tue Jul 28 15:36:04 2020 -0300

        - d/control: break on ubuntu-server << 1.453 to force an upgrade if
          it is installed, which will pull motd-news-config and the conffile
          back in

Became:

commit aea9fbc7ccacfe5e3e6cffd518a1b7fc98421d7f
Author: Andreas Hasenack <email address hidden>
Date: Tue Jul 28 15:36:04 2020 -0300

        - d/control: break on ubuntu-server << 1.450.2 to force an upgrade if
          it is installed, which will pull motd-news-config and the conffile
          back in

Andreas Hasenack (ahasenack) wrote :

Tagging and uploading 6f3fbdb8ed9b84ed92aee611b03ae0bb96f4b7c4

$ git push pkg upload/11ubuntu5.2
Enumerating objects: 50, done.
Counting objects: 100% (50/50), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31/31), done.
Writing objects: 100% (42/42), 6.75 KiB | 3.38 MiB/s, done.
Total 42 (delta 28), reused 12 (delta 10)
remote: Checking connectivity: 42, done.
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/base-files
 * [new tag] upload/11ubuntu5.2 -> upload/11ubuntu5.2

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

Andreas Hasenack (ahasenack) wrote :

Also uploading https://code.launchpad.net/~ahasenack/ubuntu/+source/ubuntu-meta/+git/ubuntu-meta/+ref/focal-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 53462aae9d19ec2e1d19f233d02514c27e09af1d of that branch:
$ git push pkg upload/1.450.2
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.19 KiB | 41.00 KiB/s, done.
Total 9 (delta 5), reused 0 (delta 0)
remote: Checking connectivity: 9, done.
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/ubuntu-meta
 * [new tag] upload/1.450.2 -> upload/1.450.2

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

Andreas Hasenack (ahasenack) wrote :

Seeds changed for focal in 113992ddf60c5573fc23ca173a6c4ca44058a943 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/base-files.maintscript b/debian/base-files.maintscript
2new file mode 100644
3index 0000000..a0cdd9a
4--- /dev/null
5+++ b/debian/base-files.maintscript
6@@ -0,0 +1 @@
7+rm_conffile /etc/default/motd-news 11ubuntu5.2~ base-files
8diff --git a/debian/changelog b/debian/changelog
9index 601311f..40b6cd2 100644
10--- a/debian/changelog
11+++ b/debian/changelog
12@@ -1,3 +1,36 @@
13+base-files (11ubuntu5.2) focal; urgency=medium
14+
15+ [ Andreas Hasenack ]
16+ * motd/50-motd-news: don't include uptime in the user-agent string
17+ (LP: #1886572)
18+ * Move the /etc/default/motd-news conffile to the motd-news-config
19+ package (LP: #1888575):
20+ - d/base-files.maintscript: remove /etc/default/motd-news config file
21+ on upgrade
22+ - d/control: break on ubuntu-server << 1.450.2 to force an upgrade if
23+ it is installed, which will pull motd-news-config and the conffile
24+ back in
25+ - d/motd-news-config.postinst:
26+ + handle the upgrade case where the motd-news config file was
27+ changed while it belonged to base-files
28+ + disable motd-news if the config file was removed by hand before
29+ the upgrade
30+ - d/postinst.in: signal the motd-news-config package if the
31+ motd-news config file was removed manually before the upgrade
32+ - d/control: new motd-news-config package, carrying the
33+ configuration file for the /etc/update-motd.d/50-motd-news script.
34+ - d/rules, d/motd-news-config.install: /e/d/motd-news is in the
35+ motd-news-config package now
36+
37+ [ Steve Langasek ]
38+ * motd/50-motd-news: use wget instead of curl, since wget is standard but
39+ curl is optional (LP: #1888572):
40+ - This changes the timeout behavior slightly because wget does not have
41+ an exact equivalent to curl's --max-time argument, we are using
42+ --timeout instead.
43+
44+ -- Andreas Hasenack <andreas@canonical.com> Mon, 17 Aug 2020 10:31:58 -0300
45+
46 base-files (11ubuntu5.1) focal; urgency=medium
47
48 * /etc/issue, /etc/issue.net, /etc/lsb-release, /etc/os-release: Bump
49diff --git a/debian/control b/debian/control
50index c90938a..d172bc1 100644
51--- a/debian/control
52+++ b/debian/control
53@@ -14,7 +14,8 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, libcrypt1 (>= 1:4.4.10-10ubuntu3)
54 Essential: yes
55 Priority: required
56 Replaces: base, miscutils, dpkg (<= 1.15.0)
57-Breaks: debian-security-support (<< 2019.04.25), initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~)
58+Breaks: debian-security-support (<< 2019.04.25), initscripts (<< 2.88dsf-13.3), sendfile (<< 2.1b.20080616-5.2~),
59+ ubuntu-server (<< 1.450.2)
60 Multi-Arch: foreign
61 Description: Debian base system miscellaneous files
62 This package contains the basic filesystem hierarchy of a Debian system, and
63@@ -28,3 +29,15 @@ Section: debian-installer
64 Architecture: all
65 Priority: extra
66 Description: LSB release information
67+
68+Package: motd-news-config
69+Architecture: all
70+Priority: optional
71+Breaks: base-files (<< 11ubuntu5.2)
72+Replaces: base-files (<< 11ubuntu5.2)
73+Depends: ${shlibs:Depends}, ${misc:Depends}
74+Description: Configuration for motd-news shipped in base-files
75+ This package contains the configuration read by the motd-news script
76+ shipped in the base-files package.
77+ .
78+ Install this package if you want motd-news to be enabled.
79diff --git a/debian/motd-news-config.install b/debian/motd-news-config.install
80new file mode 100644
81index 0000000..876b3b8
82--- /dev/null
83+++ b/debian/motd-news-config.install
84@@ -0,0 +1 @@
85+debian/motd-news etc/default
86diff --git a/debian/motd-news-config.postinst b/debian/motd-news-config.postinst
87new file mode 100644
88index 0000000..a73427f
89--- /dev/null
90+++ b/debian/motd-news-config.postinst
91@@ -0,0 +1,55 @@
92+#!/bin/sh
93+# postinst script for motd-news-config
94+#
95+# see: dh_installdeb(1)
96+
97+set -e
98+
99+# summary of how this script can be called:
100+# * <postinst> `configure' <most-recently-configured-version>
101+# * <old-postinst> `abort-upgrade' <new version>
102+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
103+# <new-version>
104+# * <postinst> `abort-remove'
105+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
106+# <failed-install-package> <version> `removing'
107+# <conflicting-package> <version>
108+# for details, see https://www.debian.org/doc/debian-policy/ or
109+# the debian-policy package
110+
111+
112+case "$1" in
113+ configure)
114+ # only run on new installs, $2 will be empty then
115+ if [ -z "$2" ]; then
116+ # /e/d/motd-news was moved from pkg:base-files to this package.
117+ # base-files runs rm_conffile which, if it was modified, leaves
118+ # /e/d/motd-news.dpkg-bak around. We want to preserve that *changed*
119+ # config file in this migration, and this is something that
120+ # rm_conffile is not handling. In that case, let's put the backup
121+ # file back in place
122+ if [ -e /etc/default/motd-news.dpkg-bak ]; then
123+ mv /etc/default/motd-news.dpkg-bak /etc/default/motd-news
124+ fi
125+ if [ -e /etc/default/motd-news.wasremoved ] && [ -e /etc/default/motd-news ]; then
126+ 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
127+ rm /etc/default/motd-news.wasremoved
128+ fi
129+ fi
130+ ;;
131+
132+ abort-upgrade|abort-remove|abort-deconfigure)
133+ ;;
134+
135+ *)
136+ echo "postinst called with unknown argument \`$1'" >&2
137+ exit 1
138+ ;;
139+esac
140+
141+# dh_installdeb will replace this with shell code automatically
142+# generated by other debhelper scripts.
143+
144+#DEBHELPER#
145+
146+exit 0
147diff --git a/debian/postinst.in b/debian/postinst.in
148index 69435e3..c347a62 100644
149--- a/debian/postinst.in
150+++ b/debian/postinst.in
151@@ -125,4 +125,17 @@ if [ "$1" = "configure" ] && [ "$2" != "" ]; then
152 fi
153 fi
154
155+# special case of having /etc/default/motd-news removed by hand
156+# signal the motd-news-config package that this happened, so that
157+# it does not put back the file with default contents which would
158+# re-enable motd-news
159+motd_news_config="/etc/default/motd-news"
160+if [ ! -e ${motd_news_config} ]; then
161+ if [ ! -e ${motd_news_config}.dpkg-remove ]; then
162+ if [ ! -e ${motd_news_config}.dpkg-backup ]; then
163+ touch ${motd_news_config}.wasremoved
164+ fi
165+ fi
166+fi
167+
168 #DEBHELPER#
169diff --git a/debian/rules b/debian/rules
170index 9f0f164..4340bf7 100755
171--- a/debian/rules
172+++ b/debian/rules
173@@ -25,7 +25,6 @@ override_dh_auto_build: locale-check
174 override_dh_auto_install:
175 install -p -m 644 etc/* $(DESTDIR)/etc
176 install -p -m 755 motd/* $(DESTDIR)/etc/update-motd.d
177- install -p -m 644 debian/motd-news $(DESTDIR)/etc/default
178 install -p -m 644 debian/motd-news.service $(DESTDIR)/lib/systemd/system/
179 install -p -m 644 debian/motd-news.timer $(DESTDIR)/lib/systemd/system/
180 install -p -m 644 licenses/* $(DESTDIR)/usr/share/common-licenses
181diff --git a/motd/50-motd-news b/motd/50-motd-news
182index 912e768..4b0b56a 100644
183--- a/motd/50-motd-news
184+++ b/motd/50-motd-news
185@@ -1,10 +1,11 @@
186 #!/bin/sh
187 #
188 # 50-motd-news - print the live news from the Ubuntu wire
189-# Copyright (C) 2016-2017 Canonical Ltd.
190+# Copyright (C) 2016-2020 Canonical Ltd.
191 # Copyright (C) 2016-2017 Dustin Kirkland
192 #
193 # Authors: Dustin Kirkland <kirkland@canonical.com>
194+# Steve Langasek <steve.langasek@canonical.com>
195 #
196 # This program is free software; you can redistribute it and/or modify
197 # it under the terms of the GNU General Public License as published by
198@@ -64,6 +65,9 @@ fi
199 # If we've made it here, we've been given the --force argument,
200 # probably from the systemd motd-news.service. Let's update...
201
202+# Abort early if wget is missing
203+[ -x /usr/bin/wget ] || exit 0
204+
205 # Generate our temp files, clean up when done
206 NEWS=$(mktemp) || exit 1
207 ERR=$(mktemp) || exit 1
208@@ -73,8 +77,8 @@ trap "rm -f $NEWS $ERR $CLOUD" HUP INT QUIT ILL TRAP KILL BUS TERM
209 # Construct a user agent, similar to Firefox/Chrome/Safari/IE to
210 # ensure a proper, tailored, accurate message of the day
211
212-# Curl browser version, for debug purposes
213-curl_ver="$(dpkg -l curl | awk '$1 == "ii" { print($3); exit(0); }')"
214+# wget browser version, for debug purposes
215+wget_ver="$(dpkg -l wget | awk '$1 == "ii" { print($3); exit(0); }')"
216
217 # Distribution version, for messages releated to this Ubuntu release
218 . /etc/lsb-release
219@@ -97,12 +101,8 @@ if [ -x /usr/bin/cloud-id ]; then
220 fi
221 fi
222
223-# Some messages may only be pertinent before or after some amount of uptime
224-read up idle < /proc/uptime
225-uptime="uptime/$up/$idle"
226-
227 # Piece together the user agent
228-USER_AGENT="curl/$curl_ver $lsb $platform $cpu $uptime cloud_id/$cloud_id"
229+USER_AGENT="wget/$wget_ver $lsb $platform $cpu cloud_id/$cloud_id"
230
231 # Loop over any configured URLs
232 for u in $URLS; do
233@@ -121,7 +121,18 @@ for u in $URLS; do
234 # If we're forced, set the wait to much higher (1 minute)
235 [ "$FORCED" = "1" ] && WAIT=60
236 # Fetch and print the news motd
237- if curl --connect-timeout "$WAIT" --max-time "$WAIT" -A "$USER_AGENT" -o- "$u" >"$NEWS" 2>"$ERR"; then
238+ result=0
239+ not_found_is_ok=0
240+ wget --timeout "$WAIT" -U "$USER_AGENT" -O- --content-on-error "$u" >"$NEWS" 2>"$ERR" || result=$?
241+ # from wget's manpage: 8 Server issued an error response.
242+ if [ $result -eq 8 ]; then
243+ if grep -q "ERROR 404" "$ERR"; then
244+ # The server's 404 document is the generic, non cloud-specific, motd-news
245+ # content present in the index.txt file
246+ not_found_is_ok=1
247+ fi
248+ fi
249+ if [ $result -eq 0 ] || [ $not_found_is_ok -eq 1 ]; then
250 echo
251 # At most, 10 lines of text, remove control characters, print at most 80 characters per line
252 safe_print "$NEWS"

Subscribers

People subscribed via source and target branches