Skip to content

Commit

Permalink
Trying updated apt service masking on Ubuntu 20.04+ to reduce build f…
Browse files Browse the repository at this point in the history
…ailures.
  • Loading branch information
ladar committed Oct 30, 2023
1 parent 1e2486e commit 0f69edf
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 112 deletions.
37 changes: 34 additions & 3 deletions scripts/ubuntu2004/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,40 @@ printf "APT::Periodic::Enable \"0\";\n" >> /etc/apt/apt.conf.d/10periodic
printf "APT::Acquire::Retries \"0\";\n" >> /etc/apt/apt.conf.d/20retries

fi
# Keep the daily apt updater from deadlocking our installs.
systemctl stop apt-daily.service apt-daily.timer
systemctl stop snapd.service snapd.socket

# Stop the active services/timers.
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active update-notifier-download.timer && systemctl stop update-notifier-download.timer

systemctl --quiet is-active apt-news.service && systemctl stop apt-news.service
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service

systemctl --quiet is-active snapd.service && systemctl stop snapd.service

systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active packagekit-offline-update.service && systemctl stop packagekit.service

systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-download.service && systemctl stop update-notifier-download.service

# Disable them so they don't restart.
systemctl --quiet is-enabled apt-daily.timer && systemctl disable apt-daily.timer
systemctl --quiet is-enabled apt-daily-upgrade.timer && systemctl disable apt-daily-upgrade.timer
systemctl --quiet is-enabled update-notifier-download.timer && systemctl disable update-notifier-download.timer

systemctl --quiet is-enabled apt-news.service && systemctl mask apt-news.service
systemctl --quiet is-enabled apt-daily.service && systemctl mask apt-daily.service
systemctl --quiet is-enabled apt-daily-upgrade.service && systemctl mask apt-daily-upgrade.service

systemctl --quiet is-enabled packagekit.service && systemctl mask packagekit.service
systemctl --quiet is-enabled packagekit-offline-update.service && systemctl mask packagekit-offline-update.service

systemctl --quiet is-enabled snapd.service && systemctl mask snapd.service

systemctl --quiet is-enabled unattended-upgrades.service && systemctl mask unattended-upgrades.service
systemctl --quiet is-enabled update-notifier-download.service && systemctl mask update-notifier-download.service

# Update the package database.
retry apt-get --assume-yes -o Dpkg::Options::="--force-confnew" update; error
Expand Down
14 changes: 10 additions & 4 deletions scripts/ubuntu2004/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ error() {
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true

# Keep the daily apt updater from deadlocking our installs.
systemctl stop apt-daily.service apt-daily.timer
systemctl stop snapd.service snapd.socket snapd.refresh.timer

# We should be able to run the following, but removing popularity-contest also removes the ubuntu-standard
# package. The latter package contents are trivial, as it only contains a copyright notice, but its
# presence signifies that the system is a "standard" Ubuntu installation, so we leave it be.
Expand All @@ -34,3 +30,13 @@ apt-get --assume-yes purge; error
# Removethe random seed so a unique value is used the first time the box is booted.
systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service
[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed

# *Unmask anything we might have masked in the apt module.
[ "$(systemctl is-enabled apt-news.service)" == "masked" ] && systemctl unmask apt-news.service
[ "$(systemctl is-enabled apt-daily.service)" == "masked" ] && systemctl unmask apt-daily.service
# [ "$(systemctl is-enabled apt-daily-upgrade.service)" == "masked" ] && systemctl unmask apt-daily-upgrade.service

[ "$(systemctl is-enabled packagekit.service)" == "masked" ] && systemctl unmask packagekit.service
[ "$(systemctl is-enabled packagekit-offline-update.service)" == "masked" ] && systemctl unmask packagekit-offline-update.service

[ "$(systemctl is-enabled snapd.service)" == "masked" ] && systemctl unmask snapd.service
22 changes: 17 additions & 5 deletions scripts/ubuntu2010/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,38 @@ EOF

fi

# Keep the daily apt updater from deadlocking our the upgrade/install commands we are about to run.
# systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket

# Stop the active services/timers.
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active update-notifier-download.timer && systemctl stop update-notifier-download.timer

systemctl --quiet is-active apt-news.service && systemctl stop apt-news.service
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service

systemctl --quiet is-active snapd.service && systemctl stop snapd.service

systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active packagekit-offline-update.service && systemctl stop packagekit.service

systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-download.service && systemctl stop update-notifier-download.service

# Disable them so they don't restart.
systemctl --quiet is-enabled apt-daily.timer && systemctl disable apt-daily.timer
systemctl --quiet is-enabled apt-daily-upgrade.timer && systemctl disable apt-daily-upgrade.timer
systemctl --quiet is-enabled update-notifier-download.timer && systemctl disable update-notifier-download.timer
systemctl --quiet is-enabled unattended-upgrades.service && systemctl disable unattended-upgrades.service

systemctl --quiet is-enabled apt-news.service && systemctl mask apt-news.service
systemctl --quiet is-enabled apt-daily.service && systemctl mask apt-daily.service
systemctl --quiet is-enabled apt-daily-upgrade.service && systemctl mask apt-daily-upgrade.service

systemctl --quiet is-enabled packagekit.service && systemctl mask packagekit.service
systemctl --quiet is-enabled packagekit-offline-update.service && systemctl mask packagekit-offline-update.service

systemctl --quiet is-enabled snapd.service && systemctl mask snapd.service

systemctl --quiet is-enabled unattended-upgrades.service && systemctl mask unattended-upgrades.service
systemctl --quiet is-enabled update-notifier-download.service && systemctl mask update-notifier-download.service

# Truncate the sources list in order to force a status purge.
Expand Down
19 changes: 9 additions & 10 deletions scripts/ubuntu2010/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ error() {
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true

# Keep the daily apt updater from deadlocking our cleanup commands.
systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service
systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-donwload.service && systemctl stop update-notifier-donwload.service

# Remove cloud init packages.
dpkg -l eatmydata &>/dev/null && apt-get --assume-yes purge eatmydata
dpkg -l libeatmydata1 &>/dev/null && apt-get --assume-yes purge libeatmydata1
Expand Down Expand Up @@ -67,3 +57,12 @@ sed -i '/old-releases.ubuntu.com/d' /etc/hosts
systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service
[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed

# *Unmask anything we might have masked in the apt module.
[ "$(systemctl is-enabled apt-news.service)" == "masked" ] && systemctl unmask apt-news.service
[ "$(systemctl is-enabled apt-daily.service)" == "masked" ] && systemctl unmask apt-daily.service
# [ "$(systemctl is-enabled apt-daily-upgrade.service)" == "masked" ] && systemctl unmask apt-daily-upgrade.service

[ "$(systemctl is-enabled packagekit.service)" == "masked" ] && systemctl unmask packagekit.service
[ "$(systemctl is-enabled packagekit-offline-update.service)" == "masked" ] && systemctl unmask packagekit-offline-update.service

[ "$(systemctl is-enabled snapd.service)" == "masked" ] && systemctl unmask snapd.service
22 changes: 17 additions & 5 deletions scripts/ubuntu2104/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,38 @@ EOF

fi

# Keep the daily apt updater from deadlocking our the upgrade/install commands we are about to run.
# systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket

# Stop the active services/timers.
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active update-notifier-download.timer && systemctl stop update-notifier-download.timer

systemctl --quiet is-active apt-news.service && systemctl stop apt-news.service
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service

systemctl --quiet is-active snapd.service && systemctl stop snapd.service

systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active packagekit-offline-update.service && systemctl stop packagekit.service

systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-download.service && systemctl stop update-notifier-download.service

# Disable them so they don't restart.
systemctl --quiet is-enabled apt-daily.timer && systemctl disable apt-daily.timer
systemctl --quiet is-enabled apt-daily-upgrade.timer && systemctl disable apt-daily-upgrade.timer
systemctl --quiet is-enabled update-notifier-download.timer && systemctl disable update-notifier-download.timer
systemctl --quiet is-enabled unattended-upgrades.service && systemctl disable unattended-upgrades.service

systemctl --quiet is-enabled apt-news.service && systemctl mask apt-news.service
systemctl --quiet is-enabled apt-daily.service && systemctl mask apt-daily.service
systemctl --quiet is-enabled apt-daily-upgrade.service && systemctl mask apt-daily-upgrade.service

systemctl --quiet is-enabled packagekit.service && systemctl mask packagekit.service
systemctl --quiet is-enabled packagekit-offline-update.service && systemctl mask packagekit-offline-update.service

systemctl --quiet is-enabled snapd.service && systemctl mask snapd.service

systemctl --quiet is-enabled unattended-upgrades.service && systemctl mask unattended-upgrades.service
systemctl --quiet is-enabled update-notifier-download.service && systemctl mask update-notifier-download.service

# Truncate the sources list in order to force a status purge.
Expand Down
19 changes: 9 additions & 10 deletions scripts/ubuntu2104/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ error() {
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true

# Keep the daily apt updater from deadlocking our cleanup commands.
systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service
systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-donwload.service && systemctl stop update-notifier-donwload.service

# Remove cloud init packages.
dpkg -l eatmydata &>/dev/null && apt-get --assume-yes purge eatmydata
dpkg -l libeatmydata1 &>/dev/null && apt-get --assume-yes purge libeatmydata1
Expand Down Expand Up @@ -67,3 +57,12 @@ sed -i '/old-releases.ubuntu.com/d' /etc/hosts
systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service
[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed

# *Unmask anything we might have masked in the apt module.
[ "$(systemctl is-enabled apt-news.service)" == "masked" ] && systemctl unmask apt-news.service
[ "$(systemctl is-enabled apt-daily.service)" == "masked" ] && systemctl unmask apt-daily.service
# [ "$(systemctl is-enabled apt-daily-upgrade.service)" == "masked" ] && systemctl unmask apt-daily-upgrade.service

[ "$(systemctl is-enabled packagekit.service)" == "masked" ] && systemctl unmask packagekit.service
[ "$(systemctl is-enabled packagekit-offline-update.service)" == "masked" ] && systemctl unmask packagekit-offline-update.service

[ "$(systemctl is-enabled snapd.service)" == "masked" ] && systemctl unmask snapd.service
23 changes: 18 additions & 5 deletions scripts/ubuntu2110/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,41 @@ EOF

fi

# Keep the daily apt updater from deadlocking our the upgrade/install commands we are about to run.
# systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket

# Stop the active services/timers.
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active update-notifier-download.timer && systemctl stop update-notifier-download.timer

systemctl --quiet is-active apt-news.service && systemctl stop apt-news.service
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service

systemctl --quiet is-active snapd.service && systemctl stop snapd.service

systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active packagekit-offline-update.service && systemctl stop packagekit.service

systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-download.service && systemctl stop update-notifier-download.service

# Disable them so they don't restart.
systemctl --quiet is-enabled apt-daily.timer && systemctl disable apt-daily.timer
systemctl --quiet is-enabled apt-daily-upgrade.timer && systemctl disable apt-daily-upgrade.timer
systemctl --quiet is-enabled update-notifier-download.timer && systemctl disable update-notifier-download.timer
systemctl --quiet is-enabled unattended-upgrades.service && systemctl disable unattended-upgrades.service

systemctl --quiet is-enabled apt-news.service && systemctl mask apt-news.service
systemctl --quiet is-enabled apt-daily.service && systemctl mask apt-daily.service
systemctl --quiet is-enabled apt-daily-upgrade.service && systemctl mask apt-daily-upgrade.service

systemctl --quiet is-enabled packagekit.service && systemctl mask packagekit.service
systemctl --quiet is-enabled packagekit-offline-update.service && systemctl mask packagekit-offline-update.service

systemctl --quiet is-enabled snapd.service && systemctl mask snapd.service

systemctl --quiet is-enabled unattended-upgrades.service && systemctl mask unattended-upgrades.service
systemctl --quiet is-enabled update-notifier-download.service && systemctl mask update-notifier-download.service


# Truncate the sources list in order to force a status purge.
# truncate --size=0 /etc/apt/sources.list

Expand Down
19 changes: 9 additions & 10 deletions scripts/ubuntu2110/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ error() {
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true

# Keep the daily apt updater from deadlocking our cleanup commands.
systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket
systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service
systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer
systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service
systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer
systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service
systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service
systemctl --quiet is-active update-notifier-donwload.service && systemctl stop update-notifier-donwload.service

# Remove cloud init packages.
dpkg -l eatmydata &>/dev/null && apt-get --assume-yes purge eatmydata
dpkg -l libeatmydata1 &>/dev/null && apt-get --assume-yes purge libeatmydata1
Expand Down Expand Up @@ -67,3 +57,12 @@ sed -i '/old-releases.ubuntu.com/d' /etc/hosts
systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service
[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed

# *Unmask anything we might have masked in the apt module.
[ "$(systemctl is-enabled apt-news.service)" == "masked" ] && systemctl unmask apt-news.service
[ "$(systemctl is-enabled apt-daily.service)" == "masked" ] && systemctl unmask apt-daily.service
# [ "$(systemctl is-enabled apt-daily-upgrade.service)" == "masked" ] && systemctl unmask apt-daily-upgrade.service

[ "$(systemctl is-enabled packagekit.service)" == "masked" ] && systemctl unmask packagekit.service
[ "$(systemctl is-enabled packagekit-offline-update.service)" == "masked" ] && systemctl unmask packagekit-offline-update.service

[ "$(systemctl is-enabled snapd.service)" == "masked" ] && systemctl unmask snapd.service
Loading

0 comments on commit 0f69edf

Please sign in to comment.