From 0cb5b9300a3193c9bd10e86ebce1b8c541cf8481 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 7 Sep 2020 09:47:32 +0200 Subject: [PATCH 1/3] hooks: update motd handling and remove 50-motd-news The base-files package grew a new /etc/update-motd.d/50-motd-news script during the lifetime of Core 16. This script wants to write to the non-writable /var/cache/motd-news location and also needs curl to work. So it fails and that leads to breaking the /etc/update-motd.d/00-header script. This commit disables the script and also adds a check to ensure that no new files are added to /etc/update-motd.d without us noticing. --- live-build/hooks/14-set-motd.chroot | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/live-build/hooks/14-set-motd.chroot b/live-build/hooks/14-set-motd.chroot index f8b0cc3..fd8545a 100644 --- a/live-build/hooks/14-set-motd.chroot +++ b/live-build/hooks/14-set-motd.chroot @@ -20,3 +20,18 @@ EOF # in particular the 'help' message but leave the 'Welcome' # string which is autogenerated based on uname -a and such. rm /etc/update-motd.d/10-help-text + +# Ensure there is no motd-news. If that file is there the +# /etc/update-motd.d/50-motd-news script will try to fetch news from +# motd.ubuntu.com but will fail and cause /etc/update-motd.d/00-header +# not to run. +# +# See also: https://github.com/snapcore/core18/pull/168 +! test -e /etc/default/motd-news + +# fail if anything in update-motd.d changed so that we can inspect/update +if [ "$(find /etc/update-motd.d/ -type f | wc -l)" != 2 ]; then + echo "The /etc/update-motd.d/ directory content changed, please inspect:" + ls -l /etc/update-motd.d + exit 1 +fi From dcc74472303eabd2c19ba770aa476369cd9bd7f3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 7 Sep 2020 10:58:33 +0200 Subject: [PATCH 2/3] hooks: remove /etc/default/motd-news.wasremoved The update to base-files in LP:1888575 leaves an empty /etc/default/motd-news.wasremoved file around. This file is not needed and also misleading because the file was never around so it was never removed. See https://bugs.launchpad.net/ubuntu/+source/base-files/+bug/1888575/comments/21 for more details. This commit just removes this (empty) file. --- live-build/hooks/14-set-motd.chroot | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/live-build/hooks/14-set-motd.chroot b/live-build/hooks/14-set-motd.chroot index fd8545a..b1d5797 100644 --- a/live-build/hooks/14-set-motd.chroot +++ b/live-build/hooks/14-set-motd.chroot @@ -21,6 +21,13 @@ EOF # string which is autogenerated based on uname -a and such. rm /etc/update-motd.d/10-help-text +# fail if anything in update-motd.d changed so that we can inspect/update +if [ "$(find /etc/update-motd.d/ -type f | wc -l)" != 2 ]; then + echo "The /etc/update-motd.d/ directory content changed, please inspect:" + ls -l /etc/update-motd.d + exit 1 +fi + # Ensure there is no motd-news. If that file is there the # /etc/update-motd.d/50-motd-news script will try to fetch news from # motd.ubuntu.com but will fail and cause /etc/update-motd.d/00-header @@ -28,10 +35,7 @@ rm /etc/update-motd.d/10-help-text # # See also: https://github.com/snapcore/core18/pull/168 ! test -e /etc/default/motd-news - -# fail if anything in update-motd.d changed so that we can inspect/update -if [ "$(find /etc/update-motd.d/ -type f | wc -l)" != 2 ]; then - echo "The /etc/update-motd.d/ directory content changed, please inspect:" - ls -l /etc/update-motd.d - exit 1 -fi +# the base-files split in LP:1888575 leaves a /etc/default/motd-news.wasremoved +# For details, see +# https://bugs.launchpad.net/ubuntu/+source/base-files/+bug/1888575/comments/21 +rm -f /etc/default/motd-news.wasremoved From d6926507eaa7576190f39f4ad86be031d6b948ce Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 8 Sep 2020 17:58:52 +0200 Subject: [PATCH 3/3] hooks: rework /etc/update-motd.d/ test to be more precise (thanks to Samuele) --- live-build/hooks/14-set-motd.chroot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/live-build/hooks/14-set-motd.chroot b/live-build/hooks/14-set-motd.chroot index b1d5797..4c9fbbd 100644 --- a/live-build/hooks/14-set-motd.chroot +++ b/live-build/hooks/14-set-motd.chroot @@ -22,7 +22,8 @@ EOF rm /etc/update-motd.d/10-help-text # fail if anything in update-motd.d changed so that we can inspect/update -if [ "$(find /etc/update-motd.d/ -type f | wc -l)" != 2 ]; then +needle="00-header 50-motd-news" +if [ "$(find /etc/update-motd.d/ | sort |cut -f4 -d/ | xargs echo)" = "$needle" ]; then echo "The /etc/update-motd.d/ directory content changed, please inspect:" ls -l /etc/update-motd.d exit 1