mkgitrel: complete non-failing requests
[releases.git] / mkgitrel.cln
1 #! /bin/bash
2
3 # Copyright 2021-2023 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 scriptdir=$(dirname "$0")
25 . $scriptdir/mkgitrel.gcfg
26
27 success=:
28 for rel
29 do
30
31 . $scriptdir/mkgitrel.setprev &&
32
33 for up in linus stable; do
34   git rev-parse --verify -q $up/v$rup && break
35 done &&
36
37 git verify-tag $up/v$rup &&
38
39 { test -d scripts/v$rel ||
40   git worktree add --detach scripts/v$rel scripts/$cbr
41 } &&
42
43 case $(sed -n 's,^kver=\(.*\) extra=\(.*\),\1-gnu\2,p' \
44            scripts/v$rel/deblob-$cbr) in
45 "$cbr$(echo $rel | sed -n 's,.*\(-gnu\),\1,p')") ;;
46 *) echo $rel mismatches release implied by scripts/v$rel/deblob-$cbr >&2
47    echo "$cbr$(echo $rel | sed -n 's,.*\(-gnu\),\1,p')" vs \
48         $(sed -n 's,^kver=\(.*\) extra=\(.*\),\1-gnu\2,p' \
49            scripts/v$rel/deblob-$cbr) >&2
50    continue;;
51 esac &&
52
53 git worktree add --detach sources/v$rel $up/v$rup &&
54
55 git worktree add --detach logs/v$rel public/logs/v$prevn &&
56
57 (cd logs/v$rel && git rm -f linux-*) &&
58
59 if (cd sources/v$rel && ../../scripts/v$rel/deblob-$cbr) \
60        >& logs/v$rel/linux-libre-$rel.log; then
61   :
62 else
63   grep -i error logs/v$rel/linux-libre-$rel.log > linux-libre-$rel.check
64   success=false; continue
65 fi &&
66
67 (
68   cd sources/v$rel &&
69   git commit -m "GNU Linux-libre v$rel incremental" -a &&
70   git tag incr/v$rel
71 ) &&
72
73 . $scriptdir/mkgitrel.setdate &&
74
75 (
76   cd sources/v$rel &&
77   git reset --soft -q public/sources/v$prevn &&
78   git commit --amend --reset-author -S$key \
79       -m "GNU Linux-libre $rel" &&
80   git tag -m "GNU Linux-libre $rel" -s -u $key sources/v$rel &&
81
82   git reset --hard incr/v$rel^ &&
83   { git merge --no-commit incr/v$prevn || :; } &&
84   git diff incr/v$rel > ../../linux-libre-$rel.patckT &&
85   mv -v ../../linux-libre-$rel.patckT ../../linux-libre-$rel.patck
86  ) &&
87
88 git archive --format tar --prefix=linux-$rup/ -o linux-libre-$rel.tar sources/v$rel &&
89 gpg --armor --detach-sign linux-libre-$rel.tar &&
90 mv linux-libre-$rel.tar.asc logs/v$rel/linux-libre-$rel.tar.sign &&
91
92 for f in linux-libre-; do
93   if cmp logs/v$rel/$f$rel.log $reldir/$prevn/$f$prevn.log; then
94     ln -vf $reldir/$prevn/$f$prevn.log logs/v$rel/$f$rel.log &&
95     ln -vf $reldir/$prevn/$f$prevn.log.sign logs/v$rel/$f$rel.log.sign
96   else
97     gpg --armor --detach-sign logs/v$rel/$f$rel.log &&
98     mv -v logs/v$rel/$f$rel.log.asc logs/v$rel/$f$rel.log.sign
99   fi
100 done &&
101
102 (
103   cd logs/v$rel &&
104   git add linux* &&
105   git commit --amend --reset-author -S$key -m "GNU Linux-libre $rel logs" &&
106   git tag -m "GNU Linux-libre $rel logs" -s -u $key logs/v$rel
107 ) &&
108
109 git diff --src-prefix=linux-libre-$prev0/ --dst-prefix=linux-libre-$rel/ \
110   public/sources/v$prev0 sources/v$rel -- > patch-$prev0-$rel &&
111
112 if test "$prev0" != "$prevn"; then
113   git diff --src-prefix=linux-libre-$prevn/ --dst-prefix=linux-libre-$rel/ \
114     public/sources/v$prevn sources/v$rel -- > patch-$prevn-$rel
115 fi &&
116
117 { scripts/v$rel/deblob-check --use-awk linux-libre-$rel.tar ||
118     scripts/v$rel/deblob-check --use-awk -C linux-libre-$rel.tar \
119       > linux-libre-$rel.check ||
120     { success=false; continue; }; } &&
121
122 continue
123
124 echo something went wrong > linux-libre-$rel.check
125 success=false
126
127 done &&
128
129 : $success