1
0
mirror of https://github.com/lxc/lxc-templates.git synced 2025-02-26 03:23:42 +00:00

Merge pull request #33 from TanyaEleventhGoddess/master

Fix indentation and correct issues with suite mismatch
This commit is contained in:
Stéphane Graber 2020-07-14 23:17:21 -04:00 committed by GitHub
commit f841a6f7f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 413 additions and 359 deletions

View File

@ -67,6 +67,16 @@ find_interpreter()
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()
{
rootfs=$1
@ -237,14 +247,26 @@ EOF
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()
{
local rootfs="$1"; shift
local packages="$*"
chroot "${rootfs}" apt-get update
if [ -n "${packages}" ]; then
if [ -n "${packages}" ] && apt_update_packages; then
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
elif [ -n "${packages}" ]; then
echo "Apt update failed, not downloading packages"
fi
}
@ -344,12 +366,14 @@ download_debian()
$init,\
ifupdown,\
locales,\
ca-certificates,\
dialog,\
isc-dhcp-client,\
netbase,\
net-tools,\
$iproute,\
openssh-server
openssh-server,\
apt-transport-https
cache=$1
arch=$2
@ -811,10 +835,12 @@ fi
release=${release:-stable}
permanent_releases=('stable' 'testing' 'sid' 'unstable')
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)"
exit 1
fi
else
release_info "${MIRROR}"
fi
# detect rootfs

View File

@ -67,6 +67,16 @@ find_interpreter()
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()
{
rootfs=$1
@ -240,14 +250,26 @@ EOF
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()
{
local rootfs="$1"; shift
local packages="$*"
chroot "${rootfs}" apt-get update
if [ -n "${packages}" ]; then
if [ -n "${packages}" ] && apt_update_packages; then
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
elif [ -n "${packages}" ]; then
echo "Apt update failed, not downloading packages"
fi
}
@ -298,12 +320,14 @@ download_devuan()
init,\
ifupdown,\
locales,\
ca-certificates,\
dialog,\
isc-dhcp-client,\
netbase,\
net-tools,\
iproute2,\
openssh-server
openssh-server,\
apt-transport-https
cache=$1
arch=$2
@ -755,12 +779,14 @@ if [ -n "$authkey" ]; then
fi
release=${release:-stable}
permanent_releases=('stable' 'testing' 'ceres' 'unstable')
permanent_releases=('stable' 'testing' 'sid' 'unstable')
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)"
exit 1
fi
else
release_info "${MIRROR}"
fi
# detect rootfs

View File

@ -326,13 +326,15 @@ download_kali()
$init,\
ifupdown,\
locales,\
ca-certificates,\
dialog,\
isc-dhcp-client,\
netbase,\
net-tools,\
$iproute,\
openssh-server,\
kali-archive-keyring
kali-archive-keyring,\
apt-transport-https
cache=$1
arch=$2