|
|
@ -33,7 +33,58 @@ fi |
|
|
|
|
|
|
|
## We can now do the ``apt-get update`` safely... |
|
|
|
|
|
|
|
apt-get update |
|
|
|
apt:update() { |
|
|
|
tried=() |
|
|
|
backup= |
|
|
|
|
|
|
|
while ! out=$(apt-get update 2>&1); do |
|
|
|
echo "Failed to 'apt-get update', looking for fixes..." |
|
|
|
old_tried_length="${#tried[@]}" |
|
|
|
failed_fetch=$(printf "%s" "$out" | egrep "^E: Failed to fetch .*404\s+Not Found") |
|
|
|
failed_release=$(printf "%s" "$out" | egrep "^[EW]: The repository '.*' does (no longer|not) have a Release file.$") |
|
|
|
if [[ " ${tried[*]} " != *" stretch-updates-fix "* ]] && |
|
|
|
[[ "$failed_fetch" == *" http://archive.debian.org/dists/stretch/updates/"* ]]; then |
|
|
|
tried+=("stretch-updates-fix") |
|
|
|
[ -z "$backup" ] && { |
|
|
|
backup=1 |
|
|
|
echo "Backup old /etc/apt/sources.list" |
|
|
|
cp -v /etc/apt/sources.list{,.myc-update} |
|
|
|
} |
|
|
|
echo "Applying stretch-updates-fix" |
|
|
|
sed -ri 's%^(\s*deb(-src)? http://archive.debian.org/? stretch/updates .*)$%# \1%g' /etc/apt/sources.list |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [[ " ${tried[*]} " != *" stretch-archive-fix "* ]] && |
|
|
|
[[ "$failed_release" == *"'http://deb.debian.org/debian stretch"* ]]; then |
|
|
|
tried+=("stretch-archive-fix") |
|
|
|
[ -z "$backup" ] && { |
|
|
|
backup=1 |
|
|
|
echo "Backup old /etc/apt/sources.list" |
|
|
|
cp -v /etc/apt/sources.list{,.myc-update} |
|
|
|
} |
|
|
|
echo "Applying stretch-archive-fix" |
|
|
|
sed -i 's,http://deb.debian.org,http://archive.debian.org,g; |
|
|
|
s,http://security.debian.org,http://archive.debian.org,g; |
|
|
|
s,\(.*stretch-updates\),#\1,' \ |
|
|
|
/etc/apt/sources.list |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ "$old_tried_length" == "${#tried[@]}" ]]; then |
|
|
|
echo "Failing 'apt-get update'. Couldn't fix it automatically. Stopping." |
|
|
|
if [ -n "$backup" ]; then |
|
|
|
mv -v /etc/apt/sources.list{,.myc-update-fix} |
|
|
|
mv -v /etc/apt/sources.list{.myc-update,} |
|
|
|
fi |
|
|
|
printf "%s\n" "$out" | sed -r 's/^/ | /g' |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
done |
|
|
|
echo "Successful 'apt-get update'." |
|
|
|
} |
|
|
|
|
|
|
|
apt:update || exit 1 |
|
|
|
|
|
|
|
apt-get -y install bash-completion wget bzip2 git-core \ |
|
|
|
less tmux mosh \ |
|
|
|
sudo git vim file gawk </dev/null |
|
|
|