mirror of
https://github.com/lxc/lxc-templates.git
synced 2025-01-05 13:20:17 +00:00
Handle suite mismatch, don't download packages if update failed
Signed-off-by: Tanya Degurechaff <34323200+TanyaEleventhGoddess@users.noreply.github.com>
This commit is contained in:
parent
92d4e109f1
commit
862a6098f0
@ -67,6 +67,16 @@ find_interpreter()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release_info() {
|
||||||
|
if wget "${1}/dists/${release}/Release" -O /dev/null --quiet 2> /dev/null; then
|
||||||
|
local release_file=$(wget "${1}/dists/${release}/Release" -O - --quiet 2> /dev/null)
|
||||||
|
distro_suite=${release_file#*Suite: }
|
||||||
|
distro_suite=${distro_suite%%$'\n'*}
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
configure_debian()
|
configure_debian()
|
||||||
{
|
{
|
||||||
rootfs=$1
|
rootfs=$1
|
||||||
@ -237,14 +247,26 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt_update_packages(){
|
||||||
|
local apt_update_args="update"
|
||||||
|
local lpath="${rootfs}/var/lib/apt/lists/$(echo "$MIRROR" | sed 's#.*://##;s#/#_#g')_dists_${release}_Release"
|
||||||
|
if [ -f "$lpath" ] && [ ! -z "$distro_suite" ]; then
|
||||||
|
local lsuite=$(cat "$lpath" | grep 'Suite:')
|
||||||
|
[ "${lsuite#Suite: }" != "$distro_suite" ] && apt_update_args="--allow-releaseinfo-change $apt_update_args"
|
||||||
|
fi
|
||||||
|
chroot "${rootfs}" apt-get $apt_update_args
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local rootfs="$1"; shift
|
local rootfs="$1"; shift
|
||||||
local packages="$*"
|
local packages="$*"
|
||||||
|
|
||||||
chroot "${rootfs}" apt-get update
|
if [ -n "${packages}" ] && apt_update_packages; then
|
||||||
if [ -n "${packages}" ]; then
|
|
||||||
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
||||||
|
elif [ -n "${packages}" ]; then
|
||||||
|
echo "Apt update failed, not downloading packages"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,10 +833,12 @@ fi
|
|||||||
release=${release:-stable}
|
release=${release:-stable}
|
||||||
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
||||||
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
||||||
if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then
|
if ! release_info "${MIRROR}"; then
|
||||||
echo "Invalid release ${release} (not found in mirror)"
|
echo "Invalid release ${release} (not found in mirror)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
release_info "${MIRROR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# detect rootfs
|
# detect rootfs
|
||||||
|
@ -67,6 +67,16 @@ find_interpreter()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release_info() {
|
||||||
|
if wget "${1}/dists/${release}/Release" -O /dev/null --quiet 2> /dev/null; then
|
||||||
|
local release_file=$(wget "${1}/dists/${release}/Release" -O - --quiet 2> /dev/null)
|
||||||
|
distro_suite=${release_file#*Suite: }
|
||||||
|
distro_suite=${distro_suite%%$'\n'*}
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
configure_devuan()
|
configure_devuan()
|
||||||
{
|
{
|
||||||
rootfs=$1
|
rootfs=$1
|
||||||
@ -240,14 +250,26 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt_update_packages(){
|
||||||
|
local apt_update_args="update"
|
||||||
|
local lpath="${rootfs}/var/lib/apt/lists/$(echo "$MIRROR" | sed 's#.*://##;s#/#_#g')_dists_${release}_Release"
|
||||||
|
if [ -f "$lpath" ] && [ ! -z "$distro_suite" ]; then
|
||||||
|
local lsuite=$(cat "$lpath" | grep 'Suite:')
|
||||||
|
[ "${lsuite#Suite: }" != "$distro_suite" ] && apt_update_args="--allow-releaseinfo-change $apt_update_args"
|
||||||
|
fi
|
||||||
|
chroot "${rootfs}" apt-get $apt_update_args
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local rootfs="$1"; shift
|
local rootfs="$1"; shift
|
||||||
local packages="$*"
|
local packages="$*"
|
||||||
|
|
||||||
chroot "${rootfs}" apt-get update
|
if [ -n "${packages}" ] && apt_update_packages; then
|
||||||
if [ -n "${packages}" ]; then
|
|
||||||
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
||||||
|
elif [ -n "${packages}" ]; then
|
||||||
|
echo "Apt update failed, not downloading packages"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,12 +777,14 @@ if [ -n "$authkey" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
release=${release:-stable}
|
release=${release:-stable}
|
||||||
permanent_releases=('stable' 'testing' 'ceres' 'unstable')
|
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
||||||
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
||||||
if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then
|
if ! release_info "${MIRROR}"; then
|
||||||
echo "Invalid release ${release} (not found in mirror)"
|
echo "Invalid release ${release} (not found in mirror)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
release_info "${MIRROR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# detect rootfs
|
# detect rootfs
|
||||||
|
Loading…
Reference in New Issue
Block a user