What's cooking (2024/04 #09)
[alt-git.git] / RelSign
blobc7d6ce3177375582af78daa889420e46f05b7410
1 #!/bin/sh
3 if test "${GPG_TTY+set}" = set
4 then
5 WE_STARTED_AGENT=no
6 echo >&2 Reusing existing agent
7 else
8 WE_STARTED_AGENT=yes
10 GPG_TTY=$(tty) &&
11 export GPG_TTY &&
13 if AGENT=$(gpg-agent --daemon 2>/dev/null)
14 then
15 eval "$AGENT" &&
16 GPG_AGENT_PID=$(expr "$GPG_AGENT_INFO" : ".*:\([1-9][0-9]*\):[1-9][0-9]*$") &&
17 trap 'kill -0 2>/dev/null $GPG_AGENT_PID &&
18 kill $GPG_AGENT_PID' 0 1 2 3 15 &&
19 kill -0 "$GPG_AGENT_PID"
20 else
21 # agent is always on
22 gpgconf --kill gpg-agent
23 GPG_AGENT_PID=
24 fi || exit
27 gpg="gpg --use-agent --local-user 96AFE6CB!" || exit
29 formats='htmldocs manpages'
31 products () {
32 with_sig=: with_src=echo
33 case "$1" in
34 with-sig)
35 with_sig=echo
36 shift
38 only-sig)
39 with_sig=echo with_src=:
40 shift
42 esac
43 version=$1
44 $with_src "git-$version.tar.gz"
45 $with_sig "git-$version.tar.sig"
46 for fmt in $formats
48 $with_src "git-$fmt-$version.tar.gz"
49 $with_sig "git-$fmt-$version.tar.sig"
50 done
53 report () {
54 ls -l "git-$1.sign" $(products with-sig "$1")
58 failed=
59 for tar in git-[0-9]*.tar.gz
61 version=$(expr "$tar" : 'git-\(.*\)\.tar.gz$')
63 if test -f "git-$version.tar.sig"
64 then
65 can_skip=yes
66 for file in $(products with-sig "$version")
68 if ! test -f "$file"
69 then
70 can_skip=no
71 break
73 done
74 if test "$can_skip" = yes
75 then
76 report "$version"
77 continue
81 rm -f $(products only-sig $version)
83 files="$tar"
84 missing=
85 for fmt in $formats
87 doc="git-$fmt-$version.tar.gz"
88 if test -f "$doc"
89 then
90 files="$files $doc"
91 else
92 missing="$missing $doc"
94 done
95 case "$missing" in
96 ?*)
97 echo >&2 "Missing files: $missing"
98 failed="$failed $version"
99 continue
101 esac
102 sha1sum $files | $gpg --clearsign >git-$version.sign || {
103 failed="$failed $version"
104 continue
107 for file in $files
109 gzip -dc <"$file" >"${file%.gz}" &&
110 $gpg -b "${file%.gz}" || {
111 failed="$failed $version"
112 rm -f "${file%.gz}.sig"
114 rm -f "${file%.gz}"
115 done
117 case " $failed " in
118 *" $version "*)
119 continue
121 esac
123 report "$version"
124 done
126 if test "$WE_STARTED_AGENT" = yes
127 then
128 if test -n "$GPG_AGENT_PID"
129 then
130 kill "$GPG_AGENT_PID"
131 else
132 gpgconf --kill gpg-agent