PATCH: net-retriever -- restructure to enable use for add-on udebs
This is intended as a first step towards full support for "add-on" udebs in the
installer: udebs which can be added in at install time from a non-standard source,
by manual invocation from the main menu.
This patch breaks net-retriever into two components. "net-retriever-core" contains
the elements which will be common to an ordinary net-retriever invocation and
a net-retriever invocation for add-on udebs. "net-retriever" then wraps this
with the remaining code so that it continues to behave as it always has.
I haven't actually tested this in a d-i situation, but manual testing hasn't
revealed any bugs, and I have gone over the code with a fine-toothed comb to
make sure that the standard invocation has unchanged behavior.
This patch only affects net-retriever; it doesn't contain the code to invoke it
for a non-standard source, it just makes it *possible* to do so via anna.
The following patch is intended to apply after the command
svn cp net-retriever net-retriever-core
Index: net-retriever-core
===================================================================
--- net-retriever-core (revision 40776)
+++ net-retriever-core (working copy)
@@ -10,25 +10,11 @@
exit 1
}
-db_get mirror/protocol
-protocol="$RET"
-db_get mirror/$protocol/hostname
-hostname="$RET"
-db_get mirror/$protocol/directory
-directory="$RET"
-db_get mirror/$protocol/proxy
-proxy="$RET"
-if [ -n "$proxy" ]; then
- if [ "$protocol" = http ]; then
- export http_proxy="$proxy"
- elif [ "$protocol" = ftp ]; then
- export ftp_proxy="$proxy"
- fi
-fi
-keyring=/usr/share/keyrings/archive.gpg
+base_url="$NET_RETRIEVER_URL"
+keyring="$NET_RETRIEVER_KEYRING"
fetch() {
- url="${protocol}://${hostname}${directory}/$1"
+ url="$base_url/$1"
iters=0
while [ $iters -lt 3 ]; do
if [ ! -e "$2" ]; then
@@ -106,7 +92,8 @@
fetch "dists/$codename/Release" "$Release" || exit $?
# If gpgv and a keyring are installed, authentication is
# mandatory.
- if type gpgv >/dev/null && [ -f "$keyring" ]; then
+ if [ "x$keyring" != x ] && type gpgv >/dev/null \
+ && [ -f "$keyring" ]; then
if ! fetch "dists/$codename/Release.gpg" "$Release.gpg"; then
error "dists/$codename/Release is unsigned."
fi
@@ -150,22 +137,7 @@
;;
xerror)
- T="retriever/net/error"
- db_set "$T" "Retry"
- db_input critical "$T" || true
-
- if ! db_go; then
- exit 2
- fi
- db_get "$T"
- if [ "$RET" = "Retry" ]; then
- exit 0
- elif [ "$RET" = "Change mirror" ]; then
- choose-mirror || true
- exit 0
- elif [ "$RET" = Cancel ]; then
- exit 2
- fi
+ exit 2
;;
*)
Index: debian/rules
===================================================================
--- debian/rules (revision 40776)
+++ debian/rules (working copy)
@@ -14,6 +14,8 @@
dh_clean -k
chmod +x net-retriever
dh_install net-retriever usr/lib/debian-installer/retriever
+ chmod +x net-retriever-core
+ dh_install net-retriever-core usr/lib/debian-installer/retriever
binary-arch: build install
Index: net-retriever
===================================================================
--- net-retriever (revision 40776)
+++ net-retriever (working copy)
@@ -2,14 +2,6 @@
. /usr/share/debconf/confmodule
-log() {
- logger -t net-retriever "$@"
-}
-error() {
- log "error: $@"
- exit 1
-}
-
db_get mirror/protocol
protocol="$RET"
db_get mirror/$protocol/hostname
@@ -25,131 +17,25 @@
export ftp_proxy="$proxy"
fi
fi
-keyring=/usr/share/keyrings/archive.gpg
+export NET_RETRIEVER_URL="${protocol}://${hostname}${directory}"
+export NET_RETRIEVER_KEYRING=/usr/share/keyrings/archive.gpg
-fetch() {
- url="${protocol}://${hostname}${directory}/$1"
- iters=0
- while [ $iters -lt 3 ]; do
- if [ ! -e "$2" ]; then
- wget -q "$url" -O "$2"
- return $?
- else
- # busybox wget can sometimes become confused while
- # resuming, so if it fails, restart
- if wget -c -q "$url" -O "$2"; then
- return 0
- else
- wget -q "$url" -O "$2"
- return $?
- fi
- fi
- iters=$(($iters + 1))
- done
-}
-
-checkmatch() {
- release="$1"
- packages="$2"
- pkgmd5="$3"
- pkgsize="$4"
-
- set -e
- sed -n '/^MD5Sum:$/ b LOOP; b; : PRINT; /:$/q; p; : LOOP; n; b PRINT' \
- "$release" | (
- while read md5 size file; do
- if [ "$file" = "$packages" ]; then
- if [ "$md5" != "$pkgmd5" ]; then
- error "MD5 mismatch for $packages ($md5 != $pkgmd5)."
- fi
- if [ "$size" != "$pkgsize" ]; then
- error "Size mismatch for $packages ($size != $pkgsize)."
- fi
- return 0
- fi
- done
- error "$packages not found in $release."
- )
- set +e
-}
-
-read_gpg_status() {
- while read prefix keyword rest; do
- [ "$prefix" = '[GNUPG:]' ] || continue
- if [ "$keyword" = VALIDSIG ]; then
- exit 0
- fi
- done
- exit 1
-}
-
cmd="$1"
shift
case "x$cmd" in
xretrieve)
- fetch "$@"
+ /usr/lib/debian-installer/retriever/net-retriever-core retrieve "$@"
exit $?
;;
xpackages)
- rm -f "$1"
- touch "$1"
-
- # Setting codename to a suite is not very nice, but can do no harm
- if ! db_get mirror/udeb/suite || [ -z "$RET" ]; then
- db_get mirror/codename
- fi
- codename="$RET"
-
- Release="/tmp/net-retriever-$$-Release"
- fetch "dists/$codename/Release" "$Release" || exit $?
- # If gpgv and a keyring are installed, authentication is
- # mandatory.
- if type gpgv >/dev/null && [ -f "$keyring" ]; then
- if ! fetch "dists/$codename/Release.gpg" "$Release.gpg"; then
- error "dists/$codename/Release is unsigned."
- fi
- if ! log-output -t net-retriever --pass-stdout \
- gpgv --status-fd 1 --keyring "$keyring" \
- --ignore-time-conflict \
- "$Release.gpg" "$Release" | read_gpg_status; then
- error "Bad signature on $Release."
- fi
- fi
-
- ARCH=`udpkg --print-architecture`
- components="`grep ^Components: $Release | cut -d' ' -f2-`"
- ret=1
- if [ -z "$components" ]; then
- error "No components listed in $Release."
- fi
- for comp in $components; do
- for ext in '.gz' ''; do
- pkgfile="$comp/debian-installer/binary-$ARCH/Packages$ext"
- line=`grep $pkgfile\$ $Release 2>/dev/null`
- if [ $? != 0 ]; then
- continue
- fi
- Packages="/tmp/net-retriever-$$-Packages"
- rm -f "$Packages"
- fetch "dists/$codename/$pkgfile" "$Packages" || continue
- checkmatch "$Release" "$pkgfile" \
- "$(md5sum "$Packages" | cut -d' ' -f1)" \
- "$(wc -c < "$Packages" | tr -d ' ')"
- if [ "$ext" = '' ]; then
- cat "$Packages" >> "$1"
- elif [ "$ext" = .gz ]; then
- zcat "$Packages" >> "$1"
- fi
- ret=0
- break
- done
- done
- exit $ret
+ /usr/lib/debian-installer/retriever/net-retriever-core packages "$@"
+ exit $?
;;
xerror)
+ # Override core behavior
T="retriever/net/error"
db_set "$T" "Retry"
db_input critical "$T" || true
--
Nathanael Nerode <neroden@fastmail.fm>
Theocracy, fascism, or absolute monarchy -- I don't care which it is, I don't like it.
Reply to: