mkgitrel.cln: run single check pass and refuse --force releases
[releases.git] / mkgitrel.pre
1 #! /bin/bash
2
3 # pre-check to stop early in case of typos and other mistakes
4 #
5 # Copyright 2021-2023 Alexandre Oliva <lxoliva@fsfla.org>
6 #
7 # This program is part of GNU Linux-libre, a GNU project that
8 # publishes scripts to clean up Linux so as to make it suitable for
9 # use in the GNU Project and in Free System Distributions.
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 # General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
24 # USA
25
26 scriptdir=$(dirname "$0")
27 . $scriptdir/mkgitrel.gcfg
28
29 success=:
30 for rel
31 do
32
33 . $scriptdir/mkgitrel.setprev &&
34
35   case $rel in
36   v*)
37     echo $rel starts with v, that is unexpected >&2
38     success=false
39     ;;
40   *.*-gnu*)
41     if test -d scripts/v$rel &&
42        git -C scripts/v$rel status | grep -q Untracked; then
43       echo scripts/v$rel exists and contains untracked files >&2
44       success=false
45     fi
46     ;;
47   *)
48     echo $rel does not end with -gnu, that is unexpected >&2
49     success=false
50     ;;
51   esac &&
52
53 if for up in linus stable; do
54      git rev-parse --verify -q $up/v$rup && break
55    done &&
56    git verify-tag $up/v$rup; then
57   :
58 else
59   echo could not find a $rup tag on which to base this release >&2
60   success=false
61   continue
62 fi &&
63
64 for d in sources/v$rel logs/v$rel; do
65   if test -d $d; then
66     echo directory $d already exists, it needs to be cleaned up first >&2
67     success=false
68   fi
69 done &&
70
71 for d in $reldir/$rel; do
72   if test -d $d; then
73     echo directory $d already exists, cannot proceed >&2
74     success=false
75   fi
76 done &&
77
78 for d in sources logs scripts incr; do
79   if git rev-parse --verify -q $d/v$rel >&2; then
80     echo tag $d/v$rel already exists, it needs to be cleaned up first >&2
81     success=false
82   elif git rev-parse --verify -q public/$d/v$rel >&2; then
83     echo tag public/$d/v$rel already exists, cannot proceed >&2
84     success=false
85   fi
86 done &&
87
88 for f in linux-libre-$rel.check linux-libre-$rel.patck; do
89   if test -f $f; then
90     echo warning: file $f already exists >&2
91   fi
92 done &&
93
94 { test -d scripts/v$rel ||
95   git worktree add --detach scripts/v$rel scripts/$cbr
96 } &&
97
98 case $(sed -n 's,^kver=\(.*\) extra=\(.*\),\1-gnu\2,p' \
99            scripts/v$rel/deblob-$cbr) in
100 "$cbr$(echo $rel | sed -n 's,.*\(-gnu\),\1,p')") ;;
101 *) echo $rel mismatches release implied by scripts/v$rel/deblob-$cbr >&2
102    echo "$cbr$(echo $rel | sed -n 's,.*\(-gnu\),\1,p')" vs \
103         $(sed -n 's,^kver=\(.*\) extra=\(.*\),\1-gnu\2,p' \
104            scripts/v$rel/deblob-$cbr) >&2
105    continue;;
106 esac &&
107
108 for f in scripts/v$rel/.* scripts/v$rel/*; do
109   case $f in
110   scripts/"v$rel"/. | \
111   scripts/"v$rel"/.. | \
112   scripts/"v$rel"/.git | \
113   scripts/"v$rel"/COPYING | \
114   scripts/"v$rel"/deblob-"$cbr" | \
115   scripts/"v$rel"/deblob-check) ;;
116   *) echo unexpected file $f exists >&2
117      success=false;;
118   esac
119 done &&
120
121 continue
122
123 success=false
124
125 done &&
126
127 $success