Fix sarge sources.list to use archive.debian.org.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Wed, 5 Nov 2008 15:14:48 +0000 (16:14 +0100)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Wed, 5 Nov 2008 15:14:48 +0000 (16:14 +0100)
src/actions/main.queue
src/functions.sh

index d7b116f..3b93066 100644 (file)
@@ -1,5 +1,6 @@
 # Full upgrade
 true                           first_warning
+true                           fix_sarge_sources
 true                           check_my_version
 true                           check_apache_version
 true                           check_upgrade
index 6f85840..2399e2d 100644 (file)
@@ -323,6 +323,35 @@ Nakon toga ponovno pozovite ovu skriptu."
   fi
 }
 
+# update sarge urls in sources list
+fix_sarge_sources () {
+  local apt_sources='/etc/apt/sources.list'
+  local fixed_sources=$(mktemp /var/lib/carnet-upgrade/sources.list.XXXXXX)
+
+  # sarge (oldstable) was archived recently -> sources.list needs update
+  awk -v archive='http://archive.debian.org/debian' \
+      -v security='http://archive.debian.org/debian-security' \
+      '$3 == "sarge" && $2 ~ /[/]debian$/ { $2 = archive }
+       $3 == "sarge/updates" && $2 ~ /security\.debian\.org$/ { $2 = security }
+       { print }' $apt_sources > $fixed_sources
+
+  # did anything get updated
+  if ! cmp $apt_sources $fixed_sources >/dev/null; then
+      log "sources.list fixed to use archive.debian.org"
+
+      # backup current version
+      if [ ! -f "$apt_sources.$backup_ext.sarge" ]; then
+          cp -av $apt_sources "$apt_sources.$backup_ext.sarge"
+      fi
+
+      # install fixed version
+      cp -av $fixed_sources $apt_sources
+  fi
+
+  # delete temporary
+  rm -f $fixed_sources
+}
+
 # try to check if we are using the latest version of carnet-upgrade script
 check_my_version () {
   local packages latest_version