Skip to content

Commit

Permalink
more stuff we don't need
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Sep 4, 2024
1 parent 705d856 commit d28ff99
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 88 deletions.
77 changes: 0 additions & 77 deletions debian/cloud-init.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,81 +7,4 @@ set -e
set -f # disable pathname expansion
db_capb escape # to support carriage return / multi-line values

fix_lp1889555() {
local oldver="$1" last_bad_ver="20.3-2-g371b392c-0ubuntu1"
dpkg --compare-versions "$oldver" le-nl "$last_bad_ver" || return 0

# if cloud-init's grub module did not run, then it did not break anything.
[ -f /var/lib/cloud/instance/sem/config_grub_dpkg ] || return 0

# Don't do anything unless we have grub
command -v grub-install > /dev/null || return 0

# Make sure that we are not chrooted.
[ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ] && return 0

# Check if we are in a container, i.e. LXC
if systemd-detect-virt --quiet --container || lxc-is-container 2>/dev/null; then
return 0
fi

# This bug only applies to NVMe devices
[ -e /dev/nvme0 ] || return 0

db_get grub-pc/install_devices && grub_cfg_dev=${RET} || return 0

# If the current setting is not the (potentially-incorrect) default we
# expect, this implies user intervention so leave things alone
[ "$grub_cfg_dev" = "/dev/sda" ] || return 0

correct_idev="$(python3 -c "import logging; from cloudinit.config.cc_grub_dpkg import fetch_idevs; print(fetch_idevs(logging.getLogger()))")" || return 0

# If correct_idev is the empty string, we failed to determine the correct
# install device; do nothing
[ -z "$correct_idev" ] && return 0

# If the correct_idev is already configured, do nothing
[ "$grub_cfg_dev" = "$correct_idev" ] && return 0

echo "Reconfiguring grub install device due to mismatch (LP: #1889555)"
echo " grub should use $correct_idev but is configured for $grub_cfg_dev"
db_set grub-pc/install_devices "$correct_idev"
db_set grub-pc/install_devices_empty "false"
}

rename_hook_hotplug_udev_rule() {
local oldver="$1" last_bad_ver="24.3~1g6e4153b3-0ubuntu1"
dpkg --compare-versions "$oldver" le-nl "$last_bad_ver" || return 0
# Avoids LP: #1946003 see commit: b519d861aff8b44a0610c176cb34adcbe28df144
if [ -f /etc/udev/rules.d/10-cloud-init-hook-hotplug.rules ]; then
mv -f /etc/udev/rules.d/10-cloud-init-hook-hotplug.rules \
/etc/udev/rules.d/90-cloud-init-hook-hotplug.rules
fi
}

update_maas_spelling(){
local oldver="$1" last_bad_ver="24.3~1g6e4153b3-0ubuntu1"
dpkg --compare-versions "$oldver" le-nl "$last_bad_ver" || return 0
if db_get cloud-init/datasources; then
values="$RET"
if [ "${values#*MaaS}" != "${values}" ]; then
# if db had old MAAS spelling, fix it.
values=$(echo "$values" | sed 's,MaaS,MAAS,g')
db_set cloud-init/datasources "$values"
fi
cat > /etc/cloud/cloud.cfg.d/90_dpkg.cfg <<EOF
# to update this file, run dpkg-reconfigure cloud-init
datasource_list: [ $values ]
EOF
fi
}

if [ "$1" = "configure" ]; then

update_maas_spelling "$2"
fix_lp1889555 "$2"
rename_hook_hotplug_udev_rule "$2"

fi

#DEBHELPER#
4 changes: 0 additions & 4 deletions debian/cloud-init.postrm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ set -e
case "$1" in
purge)
rm -f /etc/cloud/cloud.cfg.d/90_dpkg.cfg
rm -f /etc/apt/apt.conf.d/90cloud-init-pipelining
;;
remove)
rm -f /etc/cloud/cloud.cfg.d/90cloud-init-pipelining
;;
esac

Expand Down
2 changes: 1 addition & 1 deletion debian/cloud-init.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
cleanup_oci_network_lp1956788() {
# Remove vestigial /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
# from Oracle now that datasource honors system cfg above datasource cfg.
local oldver="$1" last_bad_ver="24.3~1g6e4153b3-0ubuntu1"
local oldver="$1" last_bad_ver="23.2-0ubuntu0"
dpkg --compare-versions "$oldver" le "$last_bad_ver" || return 0
grep DataSourceOracle /var/lib/cloud/instance/datasource > /dev/null 2>&1 || return 0
rm -f /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Expand Down
6 changes: 0 additions & 6 deletions debian/cloud-init.prerm

This file was deleted.

0 comments on commit d28ff99

Please sign in to comment.