spqlios basic wrapper

This commit is contained in:
Jean-Philippe Bossuat
2025-01-26 12:26:44 +01:00
parent 7e9a9501b5
commit 06e4e58b2d
201 changed files with 30406 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# this script generates one tag if there is a version change in manifest.yaml
cd `dirname $0`/..
if [ "v$1" = "v-y" ]; then
echo "production mode!";
fi
changes=`git diff HEAD~1..HEAD -- manifest.yaml | grep 'version:'`
oldversion=$(echo "$changes" | grep '^-version:' | cut '-d ' -f2)
version=$(echo "$changes" | grep '^+version:' | cut '-d ' -f2)
echo "Versions: $oldversion --> $version"
if [ "v$oldversion" = "v$version" ]; then
echo "Same version - nothing to do"; exit 0;
fi
if [ "v$1" = "v-y" ]; then
git config user.name github-actions
git config user.email github-actions@github.com
git tag -a "v$version" -m "Version $version"
git push origin "v$version"
else
cat <<EOF
# the script would do:
git tag -a "v$version" -m "Version $version"
git push origin "v$version"
EOF
fi

102
spqlios/lib/scripts/ci-pkg Normal file
View File

@@ -0,0 +1,102 @@
#!/bin/sh
# ONLY USE A PREFIX YOU ARE CONFIDENT YOU CAN WIPE OUT ENTIRELY
CI_INSTALL_PREFIX=/opt/spqlios
CI_REPO_URL=https://spq-dav.algonics.net/ci
WORKDIR=`pwd`
if [ "x$DESTDIR" = "x" ]; then
DESTDIR=/
else
mkdir -p $DESTDIR
DESTDIR=`realpath $DESTDIR`
fi
DIR=`dirname "$0"`
cd $DIR/..
DIR=`pwd`
FULL_UNAME=`uname -a | tr '[A-Z]' '[a-z]'`
HOST=`echo $FULL_UNAME | sed 's/ .*//'`
ARCH=none
case "$HOST" in
*linux*)
DISTRIB=`lsb_release -c | awk '{print $2}' | tr '[A-Z]' '[a-z]'`
HOST=linux-$DISTRIB
;;
*darwin*)
HOST=darwin
;;
*mingw*|*msys*)
DISTRIB=`echo $MSYSTEM | tr '[A-Z]' '[a-z]'`
HOST=msys64-$DISTRIB
;;
*)
echo "Host unknown: $HOST";
exit 1
esac
case "$FULL_UNAME" in
*x86_64*)
ARCH=x86_64
;;
*aarch64*)
ARCH=aarch64
;;
*arm64*)
ARCH=arm64
;;
*)
echo "Architecture unknown: $FULL_UNAME";
exit 1
esac
UNAME="$HOST-$ARCH"
CMH=
if [ -d lib/spqlios/.git ]; then
CMH=`git submodule status | sed 's/\(..........\).*/\1/'`
else
CMH=`git rev-parse HEAD | sed 's/\(..........\).*/\1/'`
fi
FNAME=spqlios-arithmetic-$CMH-$UNAME.tar.gz
cat <<EOF
================= CI MINI-PACKAGER ==================
Work Dir: WORKDIR=$WORKDIR
Spq Dir: DIR=$DIR
Install Root: DESTDIR=$DESTDIR
Install Prefix: CI_INSTALL_PREFIX=$CI_INSTALL_PREFIX
Archive Name: FNAME=$FNAME
CI WebDav: CI_REPO_URL=$CI_REPO_URL
=====================================================
EOF
if [ "x$1" = "xcreate" ]; then
rm -rf dist
cmake -B build -S . -DCMAKE_INSTALL_PREFIX="$CI_INSTALL_PREFIX" -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON -DWARNING_PARANOID=ON -DDEVMODE_INSTALL=ON || exit 1
cmake --build build || exit 1
rm -rf "$DIR/dist" 2>/dev/null
rm -f "$DIR/$FNAME" 2>/dev/null
DESTDIR="$DIR/dist" cmake --install build || exit 1
if [ -d "$DIR/dist$CI_INSTALL_PREFIX" ]; then
tar -C "$DIR/dist" -cvzf "$DIR/$FNAME" .
else
# fix since msys can mess up the paths
REAL_DEST=`find "$DIR/dist" -type d -exec test -d "{}$CI_INSTALL_PREFIX" \; -print`
echo "REAL_DEST: $REAL_DEST"
[ -d "$REAL_DEST$CI_INSTALL_PREFIX" ] && tar -C "$REAL_DEST" -cvzf "$DIR/$FNAME" .
fi
[ -f "$DIR/$FNAME" ] || { echo "failed to create $DIR/$FNAME"; exit 1; }
[ "x$CI_CREDS" = "x" ] && { echo "CI_CREDS is not set: not uploading"; exit 1; }
curl -u "$CI_CREDS" -T "$DIR/$FNAME" "$CI_REPO_URL/$FNAME"
fi
if [ "x$1" = "xinstall" ]; then
[ "x$CI_CREDS" = "x" ] && { echo "CI_CREDS is not set: not downloading"; exit 1; }
# cleaning
rm -rf "$DESTDIR$CI_INSTALL_PREFIX"/* 2>/dev/null
rm -f "$DIR/$FNAME" 2>/dev/null
# downloading
curl -u "$CI_CREDS" -o "$DIR/$FNAME" "$CI_REPO_URL/$FNAME"
[ -f "$DIR/$FNAME" ] || { echo "failed to download $DIR/$FNAME"; exit 0; }
# installing
mkdir -p $DESTDIR
tar -C "$DESTDIR" -xvzf "$DIR/$FNAME"
exit 0
fi

View File

@@ -0,0 +1,181 @@
#!/usr/bin/perl
##
## This script will help update manifest.yaml and Changelog.md before a release
## Any merge to master that changes the version line in manifest.yaml
## is considered as a new release.
##
## When ready to make a release, please run ./scripts/prepare-release
## and commit push the final result!
use File::Basename;
use Cwd 'abs_path';
# find its way to the root of git's repository
my $scriptsdirname = dirname(abs_path(__FILE__));
chdir "$scriptsdirname/..";
print "✓ Entering directory:".`pwd`;
# ensures that the current branch is ahead of origin/main
my $diff= `git diff`;
chop $diff;
if ($diff =~ /./) {
die("ERROR: Please commit all the changes before calling the prepare-release script.");
} else {
print("✓ All changes are comitted.\n");
}
system("git fetch origin");
my $vcount = `git rev-list --left-right --count origin/main...HEAD`;
$vcount =~ /^([0-9]+)[ \t]*([0-9]+)$/;
if ($2>0) {
die("ERROR: the current HEAD is not ahead of origin/main\n. Please use git merge origin/main.");
} else {
print("✓ Current HEAD is up to date with origin/main.\n");
}
mkdir ".changes";
my $currentbranch = `git rev-parse --abbrev-ref HEAD`;
chop $currentbranch;
$currentbranch =~ s/[^a-zA-Z._-]+/-/g;
my $changefile=".changes/$currentbranch.md";
my $origmanifestfile=".changes/$currentbranch--manifest.yaml";
my $origchangelogfile=".changes/$currentbranch--Changelog.md";
my $exit_code=system("wget -O $origmanifestfile https://raw.githubusercontent.com/tfhe/spqlios-fft/main/manifest.yaml");
if ($exit_code!=0 or ! -f $origmanifestfile) {
die("ERROR: failed to download manifest.yaml");
}
$exit_code=system("wget -O $origchangelogfile https://raw.githubusercontent.com/tfhe/spqlios-fft/main/Changelog.md");
if ($exit_code!=0 or ! -f $origchangelogfile) {
die("ERROR: failed to download Changelog.md");
}
# read the current version (from origin/main manifest)
my $vmajor = 0;
my $vminor = 0;
my $vpatch = 0;
my $versionline = `grep '^version: ' $origmanifestfile | cut -d" " -f2`;
chop $versionline;
if (not $versionline =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
die("ERROR: invalid version in manifest file: $versionline\n");
} else {
$vmajor = int($1);
$vminor = int($2);
$vpatch = int($3);
}
print "Version in manifest file: $vmajor.$vminor.$vpatch\n";
if (not -f $changefile) {
## create a changes file
open F,">$changefile";
print F "# Changefile for branch $currentbranch\n\n";
print F "## Type of release (major,minor,patch)?\n\n";
print F "releasetype: patch\n\n";
print F "## What has changed (please edit)?\n\n";
print F "- This has changed.\n";
close F;
}
system("editor $changefile");
# compute the new version
my $nvmajor;
my $nvminor;
my $nvpatch;
my $changelog;
my $recordchangelog=0;
open F,"$changefile";
while ($line=<F>) {
chop $line;
if ($recordchangelog) {
($line =~ /^$/) and next;
$changelog .= "$line\n";
next;
}
if ($line =~ /^releasetype *: *patch *$/) {
$nvmajor=$vmajor;
$nvminor=$vminor;
$nvpatch=$vpatch+1;
}
if ($line =~ /^releasetype *: *minor *$/) {
$nvmajor=$vmajor;
$nvminor=$vminor+1;
$nvpatch=0;
}
if ($line =~ /^releasetype *: *major *$/) {
$nvmajor=$vmajor+1;
$nvminor=0;
$nvpatch=0;
}
if ($line =~ /^## What has changed/) {
$recordchangelog=1;
}
}
close F;
print "New version: $nvmajor.$nvminor.$nvpatch\n";
print "Changes:\n$changelog";
# updating manifest.yaml
open F,"manifest.yaml";
open G,">.changes/manifest.yaml";
while ($line=<F>) {
if ($line =~ /^version *: */) {
print G "version: $nvmajor.$nvminor.$nvpatch\n";
next;
}
print G $line;
}
close F;
close G;
# updating Changelog.md
open F,"$origchangelogfile";
open G,">.changes/Changelog.md";
print G <<EOF
# Changelog
All notable changes to this project will be documented in this file.
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
EOF
;
print G "## [$nvmajor.$nvminor.$nvpatch] - ".`date '+%Y-%m-%d'`."\n";
print G "$changelog\n";
my $skip_section=1;
while ($line=<F>) {
if ($line =~ /^## +\[([0-9]+)\.([0-9]+)\.([0-9]+)\] +/) {
if ($1>$nvmajor) {
die("ERROR: found larger version $1.$2.$3 in the Changelog.md\n");
} elsif ($1<$nvmajor) {
$skip_section=0;
} elsif ($2>$nvminor) {
die("ERROR: found larger version $1.$2.$3 in the Changelog.md\n");
} elsif ($2<$nvminor) {
$skip_section=0;
} elsif ($3>$nvpatch) {
die("ERROR: found larger version $1.$2.$3 in the Changelog.md\n");
} elsif ($2<$nvpatch) {
$skip_section=0;
} else {
$skip_section=1;
}
}
($skip_section) and next;
print G $line;
}
close F;
close G;
print "-------------------------------------\n";
print "THIS WILL BE UPDATED:\n";
print "-------------------------------------\n";
system("diff -u manifest.yaml .changes/manifest.yaml");
system("diff -u Changelog.md .changes/Changelog.md");
print "-------------------------------------\n";
print "To proceed: press <enter> otherwise <CTRL+C>\n";
my $bla;
$bla=<STDIN>;
system("cp -vf .changes/manifest.yaml manifest.yaml");
system("cp -vf .changes/Changelog.md Changelog.md");
system("git commit -a -m \"Update version and changelog.\"");
system("git push");
print("✓ Changes have been committed and pushed!\n");
print("✓ A new release will be created when this branch is merged to main.\n");