mkgitrel.cln: run single check pass and refuse --force releases
[releases.git] / check-release
1 #! /bin/bash
2
3 # Copyright 2021 Alexandre Oliva <lxoliva@fsfla.org>
4 #
5 # This program is part of GNU Linux-libre, a GNU project that
6 # publishes scripts to clean up Linux so as to make it suitable for
7 # use in the GNU Project and in Free System Distributions.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22 # USA
23
24
25 # This is a one-shot script that we used when transitioning to
26 # git-based releases.  IIRC it double-checked scripts and tarballs
27 # against the preexisting git repo from Jason Self, and added our own
28 # signatures.
29
30
31 archive=$HOME/linux-libre/releases # $(ls -d /media/p0?/linux-libre-releases)
32 key=474402C8C582DAFBE389C427BCB7CF877E7D47A7
33 pubase=public/logs/v5.6-gnu
34 tmp=. # /tmp/prep
35
36 success=:
37
38 for tag
39 do
40   rel=${tag##jxself/v}
41   rup=${rel%%-[gl][ni][ub]*}
42
43   git rev-parse --verify -q incr/v$rel &&
44   git rev-parse --verify -q public/sources/v$rel &&
45   git rev-parse --verify -q public/logs/v$rel &&
46   continue
47
48  (if test ! -d $archive/$rel; then
49     echo $archive/$rel/ does not exist >& 2
50     exit 1
51   fi &&
52
53   tb=$archive/$rel/linux-libre-$rel &&
54   tar=$tb.tar.bz2 &&
55   trd=linux-$rup &&
56
57   tagid=$(git rev-parse $tag) &&
58   noteid=$(echo $tagid | sed 's,^..,&/,') &&
59   git rev-parse --verify -q stable/v$rup &&
60
61   DATE=$(git cat-file -p $tagid |
62              gawk '/^(author|tagger)/ {
63                         print strftime(PROCINFO["strftime"], $(NF-1))
64                    }') &&
65   export GIT_COMMITTER_DATE=$DATE GIT_AUTHOR_DATE=$DATE &&
66
67   test -f $tb.log &&
68   test -f notes/logs/$noteid &&
69   test -f notes/tars/$noteid &&
70   diff -b $tb.log notes/logs/$noteid &&
71
72   git archive --format tar --prefix=linux-libre-$rel/ $tag |
73   gpg -q --verify notes/tars/$noteid - &&
74
75   git worktree add --detach log-$rel $pubase &&
76
77   cd log-$rel &&
78   git rm -f linux* &&
79   cp -p $tb.log $tb.tar.sign . &&
80   cp ../notes/tars/$noteid $(basename $tb).git.tar.sign &&
81   git add linux* &&
82   git commit --amend --reset-author -S$key -m "GNU Linux-libre $rel logs" &&
83   cd .. &&
84
85   gpg -q --verify $tar.sign &&
86
87   git worktree add --detach $tmp/$trd master &&
88   rm -f $tmp/$trd/* &&
89
90  (cd $tmp/$trd &&
91   git reset -q $tag &&
92   tar -xf $tar -C .. &&
93
94   if git status -su | grep .; then
95     exit 1
96   fi &&
97
98   git reset --soft stable/v$rup &&
99   git commit -m "GNU Linux-libre $rel incremental" &&
100
101   git tag -f incr/v$rel &&
102
103   git fetch file://$(pwd) refs/tags/$tag:refs/tags/public/sources/v$rel
104  ) &&
105
106   git worktree remove $tmp/$trd &&
107
108   cd log-$rel &&
109   git tag -f -m "GNU Linux-libre $rel logs" -s -u $key public/logs/v$rel &&
110   cd .. &&
111   git worktree remove log-$rel
112
113  ) || { echo $tag failed >&2; success=false; }
114 done
115
116 $success