Files
emacs-windows-installer/build-readme.sh
corwin fbefcd90e6 build-readme.sh (add script): create .htaccess, sign files for publication
- made this script work with emacs-30 (by removing code, mostly)
- find somewhere to put it (here)
2025-08-03 20:52:24 +02:00

113 lines
3.5 KiB
Bash

#!/usr/bin/env bash
# generate clearsigned README documenting a "publication set" of Emacs binaries
## Copyright 2022 Corwin Brust <corwin@bru.st>
## This file is not part of GNU Emacs.
## 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, see <https://www.gnu.org/licenses/>.
# file names descriptions are take from a tab seperated "map" file
# regex/description pairings are taken from ~/emacs-build.README.map
DESC_MAP=~/emacs-build.README.map
# a post-script is added after sha1sums if this file exists
POSTFIX_FILE=~/emacs-upload_sha1sums.postfix
HTACCESS_SRC=~/emacs-upload.htaccess
# the target file is removed/replaced each run
TARGET_FILE=README
HTACCESS_TGT=.htaccess
# don't include sig files or our own log
rm -f $TARGET_FILE
# replace .htaccess from template
cp $HTACCESS_SRC $HTACCESS_TGT
echo 'Emacs Builds for Windows' >$TARGET_FILE
echo >>$TARGET_FILE
# list files having descriptions
( ls -1 | perl -Mstrict -e '
#!env perl
use strict;
use warnings;
# map file is the (first) command like argument, format:
# REGEX<tab>DESCRIPTION
open my $FH, q(<), shift or die $!;
my %desc = map { s/^\s+|\s+$//msg; split /\t/ } <$FH>;
close $FH;
my ($max, %len) = 0;
my @f = grep !!$_, map {
chomp;
my ($file,$desc) = $_;
for my $regex(keys %desc) {
next unless $file =~ /\A$regex\Z/;
$desc = $desc{$regex};
last;
}
if($desc) {
$desc{$file} = $desc; # ensure an exact match
$max = $len{$file} if $max < ($len{$file} = length($file));
$file # skip any without desc; calc longest of rest
}} <>; # stdin contains a list of filename
for (@f) {
printf STDERR qq(AddDescription "%s" %s\n), (map { s/"/\\"/g; $_} $desc{$_}), $_;
printf qq(%s..%s%s\n), $_, (q(.) x ($max - $len{$_})), $desc{$_}
}
' ${DESC_MAP}) >>$TARGET_FILE 2>>$HTACCESS_TGT
# golf
#ls -1 ~/emacs-upload/ | perl -e 'open $FH, q(<), shift or die $!; %desc = map { s/^\s+|\s+$//msg; split /\t/ } <$FH>; $max = 0; @f = map { chomp; $len{$_} = length($_) ; $max = $len{$_} if $max < $len{$_}; $_ } <>; printf "$_..%s$desc{$_}\n", q(.) x ($max-$len{$_}) for grep exists $desc{$_}, @f' ~/emacs-build.README.map
echo >>$TARGET_FILE
echo >>$TARGET_FILE
echo "sha1sums" >>$TARGET_FILE
echo >>$TARGET_FILE
for f in *.exe *.zip ; do
if [ -r "$f.sig" ] && gpg --verify "$f.sig" >/dev.null 2>&1; then
echo "verified $f.sig (skipped signing)"
else
echo "signing $f"
gpg --pinentry-mode=loopback \
--passphrase-file=$GPG_PPF \
--batch \
--yes \
-b $f
fi
ls -lh $f >>$TARGET_FILE;
sha1sum $f >>$TARGET_FILE;
ls -lh $f.sig >>$TARGET_FILE;
sha1sum $f.sig >>$TARGET_FILE;
done
if [ -r $POSTFIX_FILE ] ; then
cat $POSTFIX_FILE >>$TARGET_FILE
fi
# keep only the clearsigned version, if successful
#gpg --batch --yes --clearsign $TARGET_FILE \
gpg --pinentry-mode=loopback \
--passphrase-file=$GPG_PPF \
--batch \
--yes \
--clearsign $TARGET_FILE \
&& mv $TARGET_FILE.asc $TARGET_FILE
RV=$?
cd $OLD_PWD
exit $RV