Skip to content

Instantly share code, notes, and snippets.

@sublimino
Last active May 1, 2017 15:48
Show Gist options
  • Save sublimino/7fdcfac9bb3d8c582ab1ee8a618e86b6 to your computer and use it in GitHub Desktop.
Save sublimino/7fdcfac9bb3d8c582ab1ee8a618e86b6 to your computer and use it in GitHub Desktop.
update-debian-to-testing.sh
#!/bin/bash
set -euo pipefail
OUTFILE=/tmp/fastest-sources.list
ARCHITECTURES=$(printf "$(
dpkg --print-architecture
dpkg --print-foreign-architectures
)")
NS_ARCH_OPTIONS=$(echo "${ARCHITECTURES}" | sed -E 's#(.*)#--arch \1#' | tr '\n' ' ')
cp -a /etc/apt/sources.list ~/sources.list.bak
sudo apt install apt-listbugs apt-listchanges netselect-apt -t testing
sudo netselect-apt testing ${NS_ARCH_OPTIONS} --outfile "${OUTFILE}" --nonfree --sources
SOURCES=$(sed -E '/^#|^$/d' "${OUTFILE}")
(
for REPO in testing unstable; do
echo "${SOURCES}" | sed "s#testing#${REPO}#" | sed -E "s/^(deb(-src)?)/\1 [arch=$(printf "${ARCHITECTURES}" | tr '\n' ',')]/"
echo
done
echo "deb http://security.debian.org/ testing/updates main contrib non-free"
echo "deb-src http://security.debian.org/ testing/updates main contrib non-free"
) | sudo tee /etc/apt/sources.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment