Skip to content

Commit

Permalink
DLPX-92566 Third-party source list file prevented upgrade (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
palash-gandhi authored Dec 2, 2024
1 parent 51cac43 commit 856987e
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions upgrade/upgrade-scripts/execute
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,19 @@ if [[ -n "$CURRENT_VERSION" ]]; then
"$ROOTFS_CONTAINER" "$ROOTFS_CONTAINER@execute-upgrade.$UNIQUE"
fi

if [[ -f /etc/apt/sources.list ]]; then
mv /etc/apt/sources.list /etc/apt/sources.list.orig ||
die "failed to save /etc/apt/sources.list"
fi
#
# Delete the central /etc/apt/sources.list and also all files in
# /etc/apt/sources.list.d/ because only the Delphix repository
# from the upgrade image must be used to install/upgrade packages.
#
rm -f /etc/apt/sources.list
rm -f /etc/apt/sources.list.d/*

#
# Create a new sources.list that only contains the Delphix repository from
# the image. This ensures packages are only sourced from the upgrade
# image.
#
cat <<EOF >/etc/apt/sources.list ||
deb [trusted=yes] file://$IMAGE_PATH focal delphix
EOF
Expand Down Expand Up @@ -453,6 +461,14 @@ dpkg-query -Wf '${Conffiles}\n' | awk '$3 == "obsolete" {print $1}' |
die "failed to reinstall package '$package'"
done || die "failed to remove obsolete package configuration files"

#
# Now that all the packages have been installed, delete the newly created
# central /etc/apt/sources.list and also empty out the /etc/apt/sources.list.d/ directory
# again in case packages added their own sources.
#
rm -f /etc/apt/sources.list
rm -f /etc/apt/sources.list.d/*

#
# Due to https://github.com/influxdata/telegraf/issues/14052, telegraf must be masked after
# packages are upgraded. The telegraf package removes /etc/systemd/system/telegraf.service thus
Expand Down Expand Up @@ -486,19 +502,6 @@ zcat "/usr/share/doc/delphix-entire-$opt_p/packages.list.gz" | sed 's/=/ /' |
"'$installed' '=' '$version'"
done || die "verification of package versions failed"

if [[ -f /etc/apt/sources.list.orig ]]; then
mv /etc/apt/sources.list.orig /etc/apt/sources.list ||
die "failed to restore /etc/apt/sources.list"
else
#
# If "/etc/apt/sources.list.orig" does not exist, then it likely
# means the system didn't have a "/etc/apt/sources.list" file to
# begin with; so we restore that state by simply removing our
# dynamically generated "sources.list" file (generated earlier).
#
rm /etc/apt/sources.list
fi

#
# As mentioned in an earlier comment, when $CURRENT_VERSION is not set,
# we're assuming we're running the intial "execute" for a not-in-place
Expand Down

0 comments on commit 856987e

Please sign in to comment.