]> xenbits.xensource.com Git - people/dariof/xen-tools.git/commitdiff
Use apt-config dump to determine Dom0's APT proxy settings.
authorAxel Beckert <abe@deuxchevaux.org>
Tue, 3 Aug 2010 13:59:10 +0000 (15:59 +0200)
committerAxel Beckert <abe@deuxchevaux.org>
Tue, 3 Aug 2010 13:59:10 +0000 (15:59 +0200)
This is the official way, needs no own parsing (therefore less
fault-prone) and shorter. Also fixes Debian bug #560011 -- the manual
parsing did not catch all syntax variants.

Also add some comments before /etc/apt/sources.list generation in the
Ubuntu hooks.

hooks/dapper/20-setup-apt
hooks/debian/20-setup-apt
hooks/edgy/20-setup-apt
hooks/intrepid/20-setup-apt
hooks/karmic/20-setup-apt

index 475f8c6a1bc7055f00e73b07432ec9658f341052..4fdd008cc9a0ec793d4851a76a48fe3aba2b1d19 100755 (executable)
@@ -30,28 +30,17 @@ logMessage Script $0 starting
 
 #
 # Attempt to auto-magically detect the use of a Proxy for apt-get, and
-# replicate that setup in our new guest.
+# replicate that setup in our new guest via apt-config dump and save
+# the setting to the proxy guess file.
 #
-#
-#  Process any of the present apt-conf setup lines.
-#
-for i in /etc/apt/apt.conf /etc/apt/apt.conf.d/* ; do 
-
-    #
-    # If the file exists.  (Need this in case the literal glob fails.)
-    #
-    if [ -e $i ] ; then
-
-        #
-        # Save the matching line(s) to the proxy guess file.
-        #
-        logMessage The use of a proxy detected.
-        grep -i HTTP::Proxy $i >> ${prefix}/etc/apt/apt.conf.d/proxy-guess
-    fi
-done
-
+logMessage The use of a proxy detected.
+apt-config dump | grep -i Acquire::HTTP::Proxy \
+    > ${prefix}/etc/apt/apt.conf.d/proxy-guess
 
 
+#
+# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
+#
 cat <<E_O_APT > ${prefix}/etc/apt/sources.list
 #
 #  /etc/apt/sources.list
index 7f9dcfc20e91cd61c134d3d2a961f185beaa33cd..446cd670b37886e7d9dde8eedf787b4037d1e0ba 100755 (executable)
@@ -29,26 +29,12 @@ logMessage Script $0 starting
 
 #
 # Attempt to auto-magically detect the use of a Proxy for apt-get, and
-# replicate that setup in our new guest.
+# replicate that setup in our new guest via apt-config dump and save
+# the setting to the proxy guess file.
 #
-#
-#  Process any of the present apt-conf setup lines.
-#
-for i in /etc/apt/apt.conf /etc/apt/apt.conf.d/* ; do 
-
-    #
-    # If the file exists.  (Need this in case the literal glob fails.)
-    #
-    if [ -e $i ] ; then
-
-        #
-        # Save the matching line(s) to the proxy guess file.
-        #
-        logMessage The use of a proxy detected.
-        grep -i HTTP::Proxy $i >> ${prefix}/etc/apt/apt.conf.d/proxy-guess
-    fi
-done
-
+logMessage The use of a proxy detected.
+apt-config dump | grep -i Acquire::HTTP::Proxy \
+    > ${prefix}/etc/apt/apt.conf.d/proxy-guess
 
 
 #
index a0e185f5f9edbd4ca76eaff010042f6d93cfb46a..4463ed5e5fd8d48536d7ab44e073a291f2a4b6f2 100755 (executable)
@@ -30,30 +30,17 @@ logMessage Script $0 starting
 
 #
 # Attempt to auto-magically detect the use of a Proxy for apt-get, and
-# replicate that setup in our new guest.
+# replicate that setup in our new guest via apt-config dump and save
+# the setting to the proxy guess file.
 #
-#
-#  Process any of the present apt-conf setup lines.
-#
-for i in /etc/apt/apt.conf $(run-parts --list /etc/apt/apt.conf.d) ; do
-
-
-    #
-    # If the file exists.  (Need this in case the literal glob fails.)
-    #
-    if [ -e $i ] ; then
-
-        #
-        # Save the matching line(s) to the proxy guess file.
-        #
-        logMessage The use of a proxy detected.
-
-        grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
-    fi
-done
-
+logMessage The use of a proxy detected.
+apt-config dump | grep -i Acquire::HTTP::Proxy \
+    > ${prefix}/etc/apt/apt.conf.d/proxy-guess
 
 
+#
+# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
+#
 cat <<E_O_APT > ${prefix}/etc/apt/sources.list
 #
 #  /etc/apt/sources.list
index a0e185f5f9edbd4ca76eaff010042f6d93cfb46a..4463ed5e5fd8d48536d7ab44e073a291f2a4b6f2 100755 (executable)
@@ -30,30 +30,17 @@ logMessage Script $0 starting
 
 #
 # Attempt to auto-magically detect the use of a Proxy for apt-get, and
-# replicate that setup in our new guest.
+# replicate that setup in our new guest via apt-config dump and save
+# the setting to the proxy guess file.
 #
-#
-#  Process any of the present apt-conf setup lines.
-#
-for i in /etc/apt/apt.conf $(run-parts --list /etc/apt/apt.conf.d) ; do
-
-
-    #
-    # If the file exists.  (Need this in case the literal glob fails.)
-    #
-    if [ -e $i ] ; then
-
-        #
-        # Save the matching line(s) to the proxy guess file.
-        #
-        logMessage The use of a proxy detected.
-
-        grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
-    fi
-done
-
+logMessage The use of a proxy detected.
+apt-config dump | grep -i Acquire::HTTP::Proxy \
+    > ${prefix}/etc/apt/apt.conf.d/proxy-guess
 
 
+#
+# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
+#
 cat <<E_O_APT > ${prefix}/etc/apt/sources.list
 #
 #  /etc/apt/sources.list
index a0e185f5f9edbd4ca76eaff010042f6d93cfb46a..4463ed5e5fd8d48536d7ab44e073a291f2a4b6f2 100755 (executable)
@@ -30,30 +30,17 @@ logMessage Script $0 starting
 
 #
 # Attempt to auto-magically detect the use of a Proxy for apt-get, and
-# replicate that setup in our new guest.
+# replicate that setup in our new guest via apt-config dump and save
+# the setting to the proxy guess file.
 #
-#
-#  Process any of the present apt-conf setup lines.
-#
-for i in /etc/apt/apt.conf $(run-parts --list /etc/apt/apt.conf.d) ; do
-
-
-    #
-    # If the file exists.  (Need this in case the literal glob fails.)
-    #
-    if [ -e $i ] ; then
-
-        #
-        # Save the matching line(s) to the proxy guess file.
-        #
-        logMessage The use of a proxy detected.
-
-        grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
-    fi
-done
-
+logMessage The use of a proxy detected.
+apt-config dump | grep -i Acquire::HTTP::Proxy \
+    > ${prefix}/etc/apt/apt.conf.d/proxy-guess
 
 
+#
+# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
+#
 cat <<E_O_APT > ${prefix}/etc/apt/sources.list
 #
 #  /etc/apt/sources.list