Debian Codegraph @

scripts/debuerreotype-gpgv-ignore-expiration-config

raw
1 #!/usr/bin/env bash
2 set -Eeuo pipefail
3
4 thisDir="$(dirname "$(readlink -vf "$BASH_SOURCE")")"
5 source "$thisDir/.constants.sh" \
6 '<target-dir>' \
7 'rootfs'
8
9 eval "$dgetopt"
10 while true; do
11 flag="$1"; shift
12 dgetopt-case "$flag"
13 case "$flag" in
14 --) break ;;
15 *) eusage "unknown flag '$flag'" ;;
16 esac
17 done
18
19 targetDir="${1:-}"; shift || eusage 'missing target-dir'
20 [ -n "$targetDir" ]
21
22 aptVersion="$("$thisDir/.apt-version.sh" "$targetDir")"
23 # if we're on APT 0.6 or lower, this isn't relevant
24 # (added in 0.7.21 / 0.7.20.2+lenny1; https://salsa.debian.org/apt-team/apt/commit/0b77f4775db7bc45964e0337b8978a170b3f0483)
25 if dpkg --compare-versions "$aptVersion" '<<' '0.7.20~'; then
26 echo >&2 "note: skipping $self: APT version ($aptVersion) too old to be relevant"
27 exit
28 fi
29
30 sourceFile="$thisDir/.gpgv-ignore-expiration.sh"
31 targetPath='/usr/local/bin/.debuerreotype-gpgv-ignore-expiration'
32 targetFile="$targetDir$targetPath"
33 cp -T "$sourceFile" "$targetFile"
34 chmod 0755 "$targetFile"
35
36 # APT 1.1+ changed to use "apt-key verify" instead of invoking "gpgv" directly
37 # (https://salsa.debian.org/apt-team/apt/commit/12841e8320aa499554ac50b102b222900bb1b879)
38 aptConfigKey='Apt::Key::gpgvcommand'
39 case "$aptVersion" in
40 0.* | 1.0*) aptConfigKey='Dir::Bin::gpg' ;;
41 esac
42
43 cat > "$targetDir/etc/apt/apt.conf.d/debuerreotype-gpgv-ignore-expiration" <<-EOF
44 # For the sake of EOL releases (whose archive keys have often expired), we need
45 # a fake "gpgv" substitute that will essentially ignore *just* key expiration.
46 # (So we get *some* signature validation instead of using something like
47 # "--allow-unauthenticated" or "--force-yes" which disable security entirely
48 # instead.)
49
50 $aptConfigKey "$targetPath";
51 EOF
52 chmod 0644 "$targetDir/etc/apt/apt.conf.d/debuerreotype-gpgv-ignore-expiration"
53 "$thisDir/.fix-apt-comments.sh" "$aptVersion" "$targetDir/etc/apt/apt.conf.d/debuerreotype-gpgv-ignore-expiration"