> 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 unit, not starting it.
+ dpkg-maintscript-helper rm_conffile /etc/default/motd-news 11ubuntu11~ base-files -- configure 11ubuntu10
Removing obsolete conffile /etc/default/motd-news ...
Setting up motd-news-config (11ubuntu11) ...
+ [ -z ]
+ [ -e /etc/default/motd-news.dpkg-bak ]
+ [ -e /etc/default/motd-news.wasremoved ]
+ sed -i -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
+ exit 0
Processing triggers for plymouth-theme-ubuntu-text (0.9.4git20200323-0ubuntu6) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
install-info: warning: no info dir entry in `/usr/share/info/automake-history.info.gz'
Processing triggers for man-db (2.9.3-2) ...
Processing triggers for initramfs-tools (0.137ubuntu10) ...
/etc/default/motd-news isn't there at postinst time. Note how rm_conffile is run after, and correctly determines it's an obsolete conffile that can be removed
UPDATE
aha, it's dpkg-maintscripthelper. It renames /e/d/motd-news to motd-news.dpkg-remove in preparation for its removal in base-files.preinst, a script that does not exist in the src:base-files package, but since we are using dpkg-maintscripthelper, it's created at package build time.
> base-files. postinst: motd-news ]; then motd-news. wasremoved
> # user removed the full file, mark that to keep service disabled on conffile take over
> if [ -e /etc/default/
> touch /etc/default/
> 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: motd-news removed by hand "/etc/default/ motd-news" motd-news ]; then motd-news. wasremoved
(...)
# special case of having /etc/default/
# 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=
ls -la "$motd_config" || :
if [ ! -e /etc/default/
touch /etc/default/
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 files_11ubuntu1 1_amd64. deb ... news-config_ 11ubuntu11_ all.deb ... origins/ default ] dpkg/status ] update- notifier/ release- upgrade- available update- manager/ check-new- release ] to_current_ default profile /etc/profile 87021622dd9e21c 17ec26 1622dd9e21c17ec 26 /usr/share/ base-files/ profile. md5sums base-files/ profile /etc/profile to_current_ default dot.profile /root/.profile 2bb7d48aeb2f137 b828e4 d48aeb2f137b828 e4 /usr/share/ base-files/ dot.profile. md5sums /etc/default/ motd-news motd-news motd-news' : No such file or directory motd-news ] motd-news. wasremoved t-helper rm_conffile /etc/default/ motd-news 11ubuntu11~ base-files -- configure 11ubuntu10 motd-news ... motd-news. dpkg-bak ] motd-news. wasremoved ] 1/#Config file was removed for pkg:base-files - do not re-enable\ nENABLED= 0/ /etc/default/ motd-news motd-news. wasremoved theme-ubuntu- text (0.9.4git202003 23-0ubuntu6) ... info/automake- history. info.gz'
(Reading database ... 36078 files and directories currently installed.)
Preparing to unpack .../base-
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-
Unpacking motd-news-config (11ubuntu11) ...
Setting up base-files (11ubuntu11) ...
+ [ ! -e /etc/dpkg/
+ [ configure = configure ]
+ [ 11ubuntu10 = ]
+ [ ! -d /var/lib/dpkg ]
+ [ ! -f /var/lib/
+ [ ! -f /usr/info/dir ]
+ [ ! -f /usr/share/info/dir ]
+ [ configure = configure ]
+ [ 11ubuntu10 != ]
+ rm -f /var/lib/
+ [ -x /usr/lib/
+ update_
+ [ -f /etc/profile ]
+ md5sum /etc/profile
+ cut -f 1 -d
+ md5=9d5ee341492
+ grep -q 9d5ee3414928702
+ cmp -s /usr/share/
+ update_
+ [ -f /root/.profile ]
+ md5sum /root/.profile
+ cut -f 1 -d
+ md5=d68ce7c7d7d
+ grep -q d68ce7c7d7d2bb7
+ dpkg --compare-versions 11ubuntu10 lt-nl 7.7
+ motd_config=
+ ls -la /etc/default/
ls: cannot access '/etc/default/
+ :
+ [ ! -e /etc/default/
+ touch /etc/default/
+ [ 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 unit, not starting it.
+ dpkg-maintscrip
Removing obsolete conffile /etc/default/
Setting up motd-news-config (11ubuntu11) ...
+ [ -z ]
+ [ -e /etc/default/
+ [ -e /etc/default/
+ sed -i -e s/^ENABLED=
+ rm /etc/default/
+ exit 0
Processing triggers for plymouth-
update-initramfs: deferring update (trigger activated)
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
install-info: warning: no info dir entry in `/usr/share/
Processing triggers for man-db (2.9.3-2) ...
Processing triggers for initramfs-tools (0.137ubuntu10) ...
/etc/default/ motd-news isn't there at postinst time. Note how rm_conffile is run after, and correctly determines it's an obsolete conffile that can be removed
UPDATE
aha, it's dpkg-maintscrip thelper. It renames /e/d/motd-news to motd-news. dpkg-remove in preparation for its removal in base-files.preinst, a script that does not exist in the src:base-files package, but since we are using dpkg-maintscrip thelper, it's created at package build time.