From 0e77456f1fcf8b085413218c403283578d96fe13 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 29 May 2023 14:44:24 +0200 Subject: [PATCH] expand repoid to 16 chars and avoid querying git for it twice i.e., just reuse GITVERSION, and FWIW, the current ID length git auto chooses is 9 chars, suggesting that 8 really was getting to small. With 16 we got now 64 bits, that's plenty for the next few years. Document the format also (roughly) in the API schema Signed-off-by: Thomas Lamprecht --- Makefile | 7 ++----- PVE/API2.pm | 2 ++ PVE/Makefile | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0cc56ad8..e49c3683 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,7 @@ DESTDIR= SUBDIRS = aplinfo PVE bin www services configs network-hooks test -GITVERSION:=$(shell git rev-parse HEAD) - -# possibly set via debian/rules(.env) -REPOID?=$(shell git rev-parse --short=8 HEAD) +GITVERSION:=$(shell git rev-parse --short=16 HEAD) DEB=$(PACKAGE)_$(VERSION)_$(DEB_BUILD_ARCH).deb @@ -36,7 +33,7 @@ $(DEB): mkdir dest rsync -a * dest echo "git clone git://git.proxmox.com/git/pve-manager.git\\ngit checkout $(GITVERSION)" > dest/debian/SOURCE - echo "REPOID_GENERATED=$(REPOID)" > dest/debian/rules.env + echo "REPOID_GENERATED=$(GITVERSION)" > dest/debian/rules.env cd dest; dpkg-buildpackage -b -us -uc lintian $(DEB) diff --git a/PVE/API2.pm b/PVE/API2.pm index 6703b941..42941fd2 100644 --- a/PVE/API2.pm +++ b/PVE/API2.pm @@ -104,6 +104,8 @@ __PACKAGE__->register_method ({ }, repoid => { type => 'string', + # length 8 is old (< 8.0) short-id, 16 is new short id, 40 is sha1 and 64 is sha256 + pattern => '[0-9a-fA-F]{8,64}', description => 'The short git revision from which this version was build.', }, console => { diff --git a/PVE/Makefile b/PVE/Makefile index 9a67db74..660de4d0 100644 --- a/PVE/Makefile +++ b/PVE/Makefile @@ -19,8 +19,9 @@ PERLSOURCE = \ all: pvecfg.pm $(SUBDIRS) set -e && for i in $(SUBDIRS); do $(MAKE) -C $$i; done +REPOID ?= $(or $(GITVERSION), $(shell git rev-parse --short=16 HEAD), unknown) pvecfg.pm: pvecfg.pm.in - sed -e s/@VERSION@/$(VERSION)/ -e s/@PVERELEASE@/$(PVERELEASE)/ -e s/@PACKAGE@/$(PACKAGE)/ -e s/@REPOID@/$(REPOID)/ $< >$@.tmp + sed 's/@VERSION@/$(VERSION)/;s/@PVERELEASE@/$(PVERELEASE)/;s/@PACKAGE@/$(PACKAGE)/;s/@REPOID@/$(REPOID)/' $< >$@.tmp mv $@.tmp $@ %: -- 2.39.5