make sure python and gawk are available
[releases.git] / mkgitrel.cln
index 865a813197484578b8d22d168d94820341930ba5..b2fd4df2db32fce50eca8ae1f001599753113657 100755 (executable)
@@ -1,36 +1,40 @@
 #! /bin/bash
 
-reldir=$HOME/linux-libre/releases
-
-key=474402C8C582DAFBE389C427BCB7CF877E7D47A7
+# Copyright 2021-2023 Alexandre Oliva <lxoliva@fsfla.org>
+#
+# This program is part of GNU Linux-libre, a GNU project that
+# publishes scripts to clean up Linux so as to make it suitable for
+# use in the GNU Project and in Free System Distributions.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+# USA
+
+scriptdir=$(dirname "$0")
+. $scriptdir/mkgitrel.gcfg
+
+force= && case $1 in --force) force=$1; shift;; esac
 
 success=:
 for rel
 do
 
-rup=$(echo "$rel" | sed 's,-gnu[0-9]*$,,')
-cbr=$(echo "$rup" | sed 's,\(\.\|-rc\)[0-9]*$,,')
-
-if test -d $reldir/$rel; then
-  echo $reldir/$rel exists >&2
-  continue
-fi
-
-if test -h $reldir/LATEST-$cbr.0; then
-  prev0=$(readlink $reldir/LATEST-$cbr.0)
-  prevn=$(readlink $reldir/LATEST-$cbr.N)
-elif test -h $reldir/LATEST-$rup.N; then
-  cbr=$rup
-  prev0=$(readlink $reldir/LATEST-$cbr.0)
-  prevn=$(readlink $reldir/LATEST-$cbr.N)
-else
-  echo Neither $reldir/LATEST-$cbr.0 nor $reldir/LATEST-$rup.N exist >&2
-  exit 1
-fi
+. $scriptdir/mkgitrel.setprev &&
 
 for up in linus stable; do
   git rev-parse --verify -q $up/v$rup && break
-done
+done &&
 
 git verify-tag $up/v$rup &&
 
@@ -54,18 +58,24 @@ git worktree add --detach logs/v$rel public/logs/v$prevn &&
 
 (cd logs/v$rel && git rm -f linux-*) &&
 
+if (cd sources/v$rel && ../../scripts/v$rel/deblob-$cbr $force) \
+       >& logs/v$rel/linux-libre-$rel.log &&
+   { test -z "$force" ||
+       test $(grep -i error logs/v$rel/linux-libre-$rel.log |
+               grep -c -v force) = 0; }; then
+  :
+else
+  grep -i error logs/v$rel/linux-libre-$rel.log > linux-libre-$rel.check
+  success=false; continue
+fi &&
+
 (
   cd sources/v$rel &&
-  ../../scripts/v$rel/deblob-$cbr >& ../../logs/v$rel/linux-libre-$rel.log &&
   git commit -m "GNU Linux-libre v$rel incremental" -a &&
   git tag incr/v$rel
 ) &&
 
-DATE=$(git cat-file -p incr/v$rel |
-       gawk '/^(author|tagger)/ {
-               print strftime(PROCINFO["strftime"], $(NF-1))
-             }') &&
-export GIT_COMMITTER_DATE=$DATE GIT_AUTHOR_DATE=$DATE &&
+. $scriptdir/mkgitrel.setdate &&
 
 (
   cd sources/v$rel &&
@@ -109,11 +119,22 @@ if test "$prev0" != "$prevn"; then
     public/sources/v$prevn sources/v$rel -- > patch-$prevn-$rel
 fi &&
 
-{ scripts/v$rel/deblob-check --use-awk linux-libre-$rel.tar ||
+{ { test -z "$force" &&
+      scripts/v$rel/deblob-check --use-awk linux-libre-$rel.tar; } ||
     scripts/v$rel/deblob-check --use-awk -C linux-libre-$rel.tar \
       > linux-libre-$rel.check ||
-    { success=false; continue; }; }
+    { success=false; continue; }; } &&
+
+if test -n "$force"; then
+  echo aborting, --force is for testing only >> linux-libre-$rel.check
+  success=false
+fi &&
+
+continue
+
+echo something went wrong > linux-libre-$rel.check
+success=false
 
 done &&
 
-$success
+$success