What's cooking (2018/05 #01)
[alt-git.git] / RelSign
blob132413d7d295f111d719b492f03cc08eaa85e3fb
1 #!/bin/sh
3 # Use agent
4 GPG_TTY=$(tty) &&
5 export GPG_TTY &&
7 if AGENT=$(gpg-agent --daemon 2>/dev/null)
8 then
9 eval "$AGENT" &&
10 GPG_AGENT_PID=$(expr "$GPG_AGENT_INFO" : ".*:\([1-9][0-9]*\):[1-9][0-9]*$") &&
11 trap 'kill -0 2>/dev/null $GPG_AGENT_PID && kill $GPG_AGENT_PID' 0 1 2 3 15 &&
12 kill -0 "$GPG_AGENT_PID"
13 else
14 # agent is always on
15 gpgconf --kill gpg-agent
16 GPG_AGENT_PID=
17 fi &&
18 gpg="gpg --use-agent --local-user 96AFE6CB!" || exit
20 formats='htmldocs manpages'
22 products () {
23 with_sig=: with_src=echo
24 case "$1" in
25 with-sig)
26 with_sig=echo
27 shift
29 only-sig)
30 with_sig=echo with_src=:
31 shift
33 esac
34 version=$1
35 $with_src "git-$version.tar.gz"
36 $with_sig "git-$version.tar.sig"
37 for fmt in $formats
39 $with_src "git-$fmt-$version.tar.gz"
40 $with_sig "git-$fmt-$version.tar.sig"
41 done
44 report () {
45 ls -l "git-$1.sign" $(products with-sig "$1")
49 failed=
50 for tar in git-[0-9]*.tar.gz
52 version=$(expr "$tar" : 'git-\(.*\)\.tar.gz$')
54 if test -f "git-$version.tar.sig"
55 then
56 can_skip=yes
57 for file in $(products with-sig "$version")
59 if ! test -f "$file"
60 then
61 can_skip=no
62 break
64 done
65 if test "$can_skip" = yes
66 then
67 report "$version"
68 continue
72 rm -f $(products only-sig $version)
74 files="$tar"
75 missing=
76 for fmt in $formats
78 doc="git-$fmt-$version.tar.gz"
79 if test -f "$doc"
80 then
81 files="$files $doc"
82 else
83 missing="$missing $doc"
85 done
86 case "$missing" in
87 ?*)
88 echo >&2 "Missing files: $missing"
89 failed="$failed $version"
90 continue
92 esac
93 sha1sum $files | $gpg --clearsign >git-$version.sign || {
94 failed="$failed $version"
95 continue
98 for file in $files
100 gzip -dc <"$file" >"${file%.gz}" &&
101 $gpg -b "${file%.gz}" || {
102 failed="$failed $version"
103 rm -f "${file%.gz}.sig"
105 rm -f "${file%.gz}"
106 done
108 case " $failed " in
109 *" $version "*)
110 continue
112 esac
114 report "$version"
115 done
117 if test -n "$GPG_AGENT_PID"
118 then
119 kill "$GPG_AGENT_PID"
120 else
121 gpgconf --kill gpg-agent