From f91214d1b0c5de0ba6ef3debf39e2632adae9ec5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 25 Jul 2022 16:45:41 +0200 Subject: [PATCH] Better git versioning --- packaging/gitversion | 22 +++++++++++++++++++ packaging/packages/preserves-tools/.gitignore | 1 + packaging/packages/preserves-tools/APKBUILD | 4 ++-- .../preserves-tools/Makefile.external | 2 ++ .../packages/syndicate-server/.gitignore | 1 + packaging/packages/syndicate-server/APKBUILD | 4 ++-- .../syndicate-server/Makefile.external | 1 + packaging/packages/synit-config/.gitignore | 1 + packaging/packages/synit-config/APKBUILD | 6 ++--- .../packages/synit-config/Makefile.external | 1 + packaging/packages/synit-pid1/.gitignore | 1 + packaging/packages/synit-pid1/APKBUILD | 4 ++-- .../packages/synit-pid1/Makefile.external | 1 + packaging/packages/synit-splash/.gitignore | 1 + packaging/packages/synit-splash/APKBUILD | 4 ++-- .../packages/synit-splash/Makefile.external | 6 +++++ 16 files changed, 48 insertions(+), 12 deletions(-) create mode 100755 packaging/gitversion create mode 100644 packaging/packages/synit-splash/.gitignore create mode 100644 packaging/packages/synit-splash/Makefile.external diff --git a/packaging/gitversion b/packaging/gitversion new file mode 100755 index 0000000..09ed02a --- /dev/null +++ b/packaging/gitversion @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import subprocess +import sys +import time + +def x(cmd): + return subprocess.check_output(cmd, shell=True) + +uncommitted = x('git status --porcelain=v1 -- .') +dirty = len(uncommitted) > 0 + +if dirty: + commithash = x('git --no-pager log -n 1 --pretty=tformat:"%h" -- .').strip() + timestamp = int(time.time()) +else: + (commithash, timestamp) = x('git --no-pager log -n 1 --pretty=tformat:"%h %ct" -- .').strip().split() + timestamp = int(timestamp) + +commithash = commithash.decode('utf-8') +timestamp = time.strftime("%Y%m%d%H%M%S", time.gmtime(timestamp)) +print(f'_git{timestamp}') diff --git a/packaging/packages/preserves-tools/.gitignore b/packaging/packages/preserves-tools/.gitignore index 575ea79..fcf8a44 100644 --- a/packaging/packages/preserves-tools/.gitignore +++ b/packaging/packages/preserves-tools/.gitignore @@ -1,3 +1,4 @@ +GITVERSION VERSION buildlog.* preserves-tool.aarch64 diff --git a/packaging/packages/preserves-tools/APKBUILD b/packaging/packages/preserves-tools/APKBUILD index ee672f5..3555614 100644 --- a/packaging/packages/preserves-tools/APKBUILD +++ b/packaging/packages/preserves-tools/APKBUILD @@ -1,8 +1,8 @@ # Contributor: Tony Garnock-Jones # Maintainer: Tony Garnock-Jones pkgname=preserves-tools -pkgver=$(cat VERSION) -pkgrel=$(date '+%Y%m%d%H%M%S') +pkgver=$(cat VERSION)$(cat GITVERSION) +pkgrel=0 pkgdesc="Command-line tools for working with Preserves documents" url="https://preserves.dev/" arch="all" diff --git a/packaging/packages/preserves-tools/Makefile.external b/packaging/packages/preserves-tools/Makefile.external index 5b0d9ce..2906d49 100644 --- a/packaging/packages/preserves-tools/Makefile.external +++ b/packaging/packages/preserves-tools/Makefile.external @@ -9,6 +9,8 @@ prepare: preserves miniclean | preserves-tool convert --output-format unquoted \ --select '. "packages" / [. "name" = "preserves-tools"] . "version"' \ > VERSION + rm -f preserves/implementations/rust/rust-toolchain + (cd preserves; ../../../gitversion) > GITVERSION preserves: git clone https://gitlab.com/preserves/preserves diff --git a/packaging/packages/syndicate-server/.gitignore b/packaging/packages/syndicate-server/.gitignore index b226ba7..f224f6f 100644 --- a/packaging/packages/syndicate-server/.gitignore +++ b/packaging/packages/syndicate-server/.gitignore @@ -1,3 +1,4 @@ +GITVERSION VERSION buildlog.* protocols/ diff --git a/packaging/packages/syndicate-server/APKBUILD b/packaging/packages/syndicate-server/APKBUILD index d03ffa7..5f47d4e 100644 --- a/packaging/packages/syndicate-server/APKBUILD +++ b/packaging/packages/syndicate-server/APKBUILD @@ -1,8 +1,8 @@ # Contributor: Tony Garnock-Jones # Maintainer: Tony Garnock-Jones pkgname=syndicate-server -pkgver=$(cat VERSION) -pkgrel=$(date '+%Y%m%d%H%M%S') +pkgver=$(cat VERSION)$(cat GITVERSION) +pkgrel=0 pkgdesc="Syndicate server" url="https://syndicate-lang.org/" arch="all" diff --git a/packaging/packages/syndicate-server/Makefile.external b/packaging/packages/syndicate-server/Makefile.external index c2e130d..8d2273b 100644 --- a/packaging/packages/syndicate-server/Makefile.external +++ b/packaging/packages/syndicate-server/Makefile.external @@ -8,6 +8,7 @@ prepare: syndicate-rs miniclean --select '. "packages" / [. "name" = "syndicate-server"] . "version"' \ > VERSION rsync -a syndicate-rs/syndicate-server/protocols . + (cd syndicate-rs; ../../../gitversion) > GITVERSION syndicate-rs: git clone https://git.syndicate-lang.org/syndicate-lang/syndicate-rs diff --git a/packaging/packages/synit-config/.gitignore b/packaging/packages/synit-config/.gitignore index e9d0fcf..e3b8af7 100644 --- a/packaging/packages/synit-config/.gitignore +++ b/packaging/packages/synit-config/.gitignore @@ -1,2 +1,3 @@ +GITVERSION protocols/ __pycache__/ diff --git a/packaging/packages/synit-config/APKBUILD b/packaging/packages/synit-config/APKBUILD index a74c096..2ab3797 100644 --- a/packaging/packages/synit-config/APKBUILD +++ b/packaging/packages/synit-config/APKBUILD @@ -1,10 +1,8 @@ # Contributor: Tony Garnock-Jones # Maintainer: Tony Garnock-Jones pkgname=synit-config -pkgver=0.0.6 -pkgrel=$(date '+%Y%m%d%H%M%S') -# pkgver=0.0.5 -# pkgrel=1 +pkgver=0.0.6$(cat GITVERSION) +pkgrel=0 pkgdesc="synit system layer configuration" url="https://synit.org/" arch="noarch" diff --git a/packaging/packages/synit-config/Makefile.external b/packaging/packages/synit-config/Makefile.external index a1cb6ec..fa68b78 100644 --- a/packaging/packages/synit-config/Makefile.external +++ b/packaging/packages/synit-config/Makefile.external @@ -2,6 +2,7 @@ prepare: rsync -a ../../../protocols . + ../../gitversion > GITVERSION clean: rm -rf protocols diff --git a/packaging/packages/synit-pid1/.gitignore b/packaging/packages/synit-pid1/.gitignore index 2087df3..5a95c20 100644 --- a/packaging/packages/synit-pid1/.gitignore +++ b/packaging/packages/synit-pid1/.gitignore @@ -1,3 +1,4 @@ +GITVERSION VERSION buildlog.* synit-pid1.aarch64 diff --git a/packaging/packages/synit-pid1/APKBUILD b/packaging/packages/synit-pid1/APKBUILD index 59a44ad..5c934b1 100644 --- a/packaging/packages/synit-pid1/APKBUILD +++ b/packaging/packages/synit-pid1/APKBUILD @@ -1,8 +1,8 @@ # Contributor: Tony Garnock-Jones # Maintainer: Tony Garnock-Jones pkgname=synit-pid1 -pkgver=$(cat VERSION) -pkgrel=$(date '+%Y%m%d%H%M%S') +pkgver=$(cat VERSION)$(cat GITVERSION) +pkgrel=0 pkgdesc="synit pid 1 program" url="https://synit.org/" arch="all" diff --git a/packaging/packages/synit-pid1/Makefile.external b/packaging/packages/synit-pid1/Makefile.external index c49ee95..6368cf7 100644 --- a/packaging/packages/synit-pid1/Makefile.external +++ b/packaging/packages/synit-pid1/Makefile.external @@ -6,6 +6,7 @@ prepare: miniclean (cd ../../../synit-pid1 && cargo metadata --format-version 1) | \ preserves-tool convert --output-format unquoted \ --select '. "packages" / [. "name" = "synit-pid1"] . "version"' > VERSION + (cd ../../../synit-pid1; ../packaging/gitversion) > GITVERSION miniclean: rm -f synit-pid1.$(ARCH) diff --git a/packaging/packages/synit-splash/.gitignore b/packaging/packages/synit-splash/.gitignore new file mode 100644 index 0000000..fc5f6ce --- /dev/null +++ b/packaging/packages/synit-splash/.gitignore @@ -0,0 +1 @@ +GITVERSION diff --git a/packaging/packages/synit-splash/APKBUILD b/packaging/packages/synit-splash/APKBUILD index 4852117..941b381 100644 --- a/packaging/packages/synit-splash/APKBUILD +++ b/packaging/packages/synit-splash/APKBUILD @@ -1,8 +1,8 @@ # Contributor: Tony Garnock-Jones # Maintainer: Tony Garnock-Jones pkgname=synit-splash -pkgver=0.0.1 -pkgrel=5 +pkgver=0.0.2$(cat GITVERSION) +pkgrel=0 pkgdesc="synit loading splash screen" url="https://synit.org/" arch="noarch" diff --git a/packaging/packages/synit-splash/Makefile.external b/packaging/packages/synit-splash/Makefile.external new file mode 100644 index 0000000..4054c38 --- /dev/null +++ b/packaging/packages/synit-splash/Makefile.external @@ -0,0 +1,6 @@ +# -*- makefile -*- + +prepare: + ../../gitversion > GITVERSION + +clean: