Skip to content

Commit

Permalink
Add logic to retain DNS configuration for upgrade repo live-build hook
Browse files Browse the repository at this point in the history
  • Loading branch information
palash-gandhi committed Dec 24, 2024
1 parent 9066f85 commit cda567e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions live-build/config/hooks/configuration/81-upgrade-repository.binary
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ if [[ $(ls binary/lib/modules | wc -l) -gt 1 ]]; then
exit 1
fi

#
# In order for DNS to work when running Ansible chroot-ed in the
# "binary" directory, we have to copy the host's resolv.conf file into
# place, and then undo this change when we're done.
#

if [[ -e binary/etc/resolv.conf || -L binary/etc/resolv.conf ]]; then
mv binary/etc/resolv.conf binary/etc/resolv.conf.orig
fi

if [[ -e /etc/resolv.conf ]]; then
cp /etc/resolv.conf binary/etc/resolv.conf
fi

#
# Here, we generate a list of all of the packages that have been
# installed in the "binary" chroot directory, including package version,
Expand Down Expand Up @@ -142,3 +156,12 @@ rm -rf "binary/$DEBS_DIRECTORY"
tar -I pigz -cf "$ARTIFACT_NAME.debs.tar.gz" ./*.deb -C binary/packages .

rm -rf binary/packages


if [[ -e binary/etc/resolv.conf ]]; then
rm binary/etc/resolv.conf
fi

if [[ -e binary/etc/resolv.conf.orig || -L binary/etc/resolv.conf ]]; then
mv binary/etc/resolv.conf.orig binary/etc/resolv.conf
fi

0 comments on commit cda567e

Please sign in to comment.