diff options
author | Cyril Brulebois <kibi@debian.org> | 2016-10-30 22:10:27 (GMT) |
---|---|---|
committer | Cyril Brulebois <kibi@debian.org> | 2016-10-30 22:35:11 (GMT) |
commit | e8160a13b222caa3a3246f610398cda6ddc43bf0 (patch) | |
tree | 02aa26569e785e2d172ff74852810181783335e5 /functions | |
parent | c1a3ebd6aea8f49a47cb496e08e13dea41fa0d98 (diff) | |
download | debootstrap-e8160a13b222caa3a3246f610398cda6ddc43bf0.zip debootstrap-e8160a13b222caa3a3246f610398cda6ddc43bf0.tar.gz debootstrap-e8160a13b222caa3a3246f610398cda6ddc43bf0.tar.bz2 |
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.
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 44 |
1 files changed, 36 insertions, 8 deletions
@@ -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 () { |