From e8160a13b222caa3a3246f610398cda6ddc43bf0 Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Sun, 30 Oct 2016 23:10:27 +0100 Subject: Fix InRelease support (Closes: #842591). The initial tr|sed|tr looked nice on paper but doesn't work within a d-i context, so let's switch to a shell-only implementation supplied by Ansgar Burchardt. --- debian/changelog | 9 +++++++++ functions | 44 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index c487179..4846a9f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +debootstrap (1.0.86) UNRELEASED; urgency=medium + + * Rework split_inline_sig by using shell built-ins instead of trying to + mix sed and tr together, which might work on regular systems but not + from inside the Debian Installer (Closes: #842591). Thanks to Ansgar + Burchardt for the proof of concept! + + -- Cyril Brulebois Sun, 30 Oct 2016 23:10:40 +0100 + debootstrap (1.0.85) unstable; urgency=medium [ Julien Cristau ] diff --git a/functions b/functions index 6d01e3f..578d72b 100644 --- a/functions +++ b/functions @@ -531,14 +531,42 @@ split_inline_sig () { local reldest="$2" local relsigdest="$3" - sed -n '/^-----BEGIN PGP SIGNATURE-----$/,/^-----END PGP SIGNATURE-----$/p' < \ - "$inreldest" > "$relsigdest" - # We assume \a does not appear in the Release file, and strip - # the last \n through the tr round-trip. - sed '/^-----BEGIN PGP SIGNED MESSAGE-----$/,/^$/ d - /^-----BEGIN PGP SIGNATURE-----$/,/^-----END PGP SIGNATURE-----$/ d - ' < "$inreldest" | - tr '\n' '\a' | sed 's/\a$//' | tr '\a' '\n' > "$reldest" + # Note: InRelease files are fun since one needs to remove the + # last newline from the PGP SIGNED MESSAGE part, while keeping + # the PGP SIGNATURE part intact. This shell implementation + # should work on most if not all systems, instead of trying to + # sed/tr/head, etc. + rm -f "$reldest" "$relsigdest" + nl="" + state=pre-begin + while IFS= read -r line; do + case "${state}" in + pre-begin) + if [ "x${line}" = "x-----BEGIN PGP SIGNED MESSAGE-----" ]; then + state=begin + fi + ;; + begin) + if [ "x${line}" = "x" ]; then + state=data + fi + ;; + data) + if [ "x${line}" = "x-----BEGIN PGP SIGNATURE-----" ]; then + printf "%s\n" "${line}" > "$relsigdest" + state=signature + else + printf "${nl}%s" "${line}" >> "$reldest" + nl="\n" + fi + ;; + signature) + printf "%s\n" "${line}" >> "$relsigdest" + if [ "x${line}" = "x-----END PGP SIGNATURE-----" ]; then + break + fi + esac + done < "$inreldest" } download_release_sig () { -- cgit v0.12