From 8fd57032e74da5da44cca1f531a693858e16449f Mon Sep 17 00:00:00 2001 From: James Campbell Date: Sun, 6 Jul 2025 03:28:16 -0400 Subject: [PATCH] Update Makefile to support rc versions, bump version * Support packaging RC versions for deb and rpm packages * Bump version to 1.0.4-rc1 --- Makefile | 51 +++++++++++++++++++++++++++++++--------------- RPM/pgmon-el7.spec | 2 +- RPM/pgmon.spec | 2 +- src/pgmon.py | 2 +- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index ad1de2e..95ae465 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,22 @@ PACKAGE_NAME := pgmon SCRIPT := src/$(PACKAGE_NAME).py -VERSION := $(shell grep -m 1 '^VERSION = ' "$(SCRIPT)" | sed -ne 's/.*"\(.*\)".*/\1/p') +# Figure out the version components +# Note: The release is for RPM packages, where prerelease releases are written as 0. +FULL_VERSION := $(shell grep -m 1 '^VERSION = ' "$(SCRIPT)" | sed -ne 's/.*"\(.*\)".*/\1/p') +VERSION := $(shell echo $(FULL_VERSION) | sed -n 's/\(.*\)\(-rc.*\|$$\)/\1/p') +RELEASE := $(shell echo $(FULL_VERSION) | sed -n 's/.*-rc\([0-9]\+\)$$/\1/p') + +ifeq ($(RELEASE),) +RPM_RELEASE := 1 +RPM_VERSION := $(VERSION)-$(RPM_RELEASE) +DEB_VERSION := $(VERSION) +else +RPM_RELEASE := 0.$(RELEASE) +RPM_VERSION := $(VERSION)-$(RPM_RELEASE) +DEB_VERSION := $(VERSION)~rc$(RELEASE) +endif + # Where packages are built BUILD_DIR := build @@ -23,8 +38,12 @@ SUPPORTED := ubuntu-20.04 \ # These targets are the main ones to use for most things. ## -.PHONY: package-all clean tgz test query-tests install-common install-openrc install-systemd +.PHONY: all clean tgz test query-tests install-common install-openrc install-systemd +all: package-all + +version: + @echo "full version=$(FULL_VERSION) version=$(VERSION) rel=$(RELEASE) rpm=$(RPM_VERSION) deb=$(DEB_VERSION)" # Build all packages .PHONY: package-all @@ -34,7 +53,7 @@ package-all: $(foreach distro_release, $(SUPPORTED), package-$(distro_release)) .PHONY: package-gentoo package-gentoo: mkdir -p $(BUILD_DIR)/gentoo - tar --transform "s,^,$(PACKAGE_NAME)-$(VERSION)/," -acjf $(BUILD_DIR)/gentoo/$(PACKAGE_NAME)-$(VERSION).tar.bz2 --exclude .gitignore $(shell git ls-tree --full-tree --name-only -r HEAD) + tar --transform "s,^,$(PACKAGE_NAME)-$(FULL_VERSION)/," -acjf $(BUILD_DIR)/gentoo/$(PACKAGE_NAME)-$(FULL_VERSION).tar.bz2 --exclude .gitignore $(shell git ls-tree --full-tree --name-only -r HEAD) # Create a deb package @@ -55,7 +74,7 @@ tgz: rm -rf $(BUILD_DIR)/tgz/root mkdir -p $(BUILD_DIR)/tgz/root $(MAKE) install-openrc DESTDIR=$(BUILD_DIR)/tgz/root - tar -cz -f $(BUILD_DIR)/tgz/$(PACKAGE_NAME)-$(VERSION).tgz -C $(BUILD_DIR)/tgz/root . + tar -cz -f $(BUILD_DIR)/tgz/$(PACKAGE_NAME)-$(FULL_VERSION).tgz -C $(BUILD_DIR)/tgz/root . # Clean up the build directory clean: @@ -129,28 +148,28 @@ debian-%-install-test: docker run --rm \ -v ./$(BUILD_DIR):/output \ debian:$* \ - bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(VERSION)-debian-$*.deb' + bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(DEB_VERSION)-debian-$*.deb' # Run a RedHat install test rockylinux-%-install-test: docker run --rm \ -v ./$(BUILD_DIR):/output \ rockylinux:$* \ - bash -c 'dnf makecache && dnf install -y /output/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm' + bash -c 'dnf makecache && dnf install -y /output/$(PACKAGE_NAME)-$(RPM_VERSION).el$*.noarch.rpm' # Run an Ubuntu install test ubuntu-%-install-test: docker run --rm \ -v ./$(BUILD_DIR):/output \ ubuntu:$* \ - bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(VERSION)-ubuntu-$*.deb' + bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(DEB_VERSION)-ubuntu-$*.deb' # Run an OracleLinux install test (this is for EL7 since CentOS7 images no longer exist) oraclelinux-%-install-test: docker run --rm \ -v ./$(BUILD_DIR):/output \ oraclelinux:7 \ - bash -c 'yum makecache && yum install -y /output/$(PACKAGE_NAME)-$(VERSION)-1.el7.noarch.rpm' + bash -c 'yum makecache && yum install -y /output/$(PACKAGE_NAME)-$(RPM_VERSION).el7.noarch.rpm' # Run a Gentoo install test gentoo-install-test: @@ -192,28 +211,28 @@ package-image-%: actually-package-debian-%: $(MAKE) install-systemd DESTDIR=/output/debian-$* cp -r --preserve=mode DEBIAN /output/debian-$*/ - dpkg-deb -Zgzip --build /output/debian-$* "/output/$(PACKAGE_NAME)-$(VERSION)-debian-$*.deb" + dpkg-deb -Zgzip --build /output/debian-$* "/output/$(PACKAGE_NAME)-$(DEB_VERSION)-debian-$*.deb" # RedHat package creation actually-package-rockylinux-%: mkdir -p /output/rockylinux-$*/{BUILD,RPMS,SOURCES,SPECS,SRPMS} - sed -e "s/@@VERSION@@/$(VERSION)/g" RPM/$(PACKAGE_NAME).spec > /output/rockylinux-$*/SPECS/$(PACKAGE_NAME).spec + sed -e "s/@@VERSION@@/$(VERSION)/g" -e "s/@@RELEASE@@/$(RPM_RELEASE)/g" RPM/$(PACKAGE_NAME).spec > /output/rockylinux-$*/SPECS/$(PACKAGE_NAME).spec rpmbuild --define '_topdir /output/rockylinux-$*' \ - --define 'version $(VERSION)' \ + --define 'version $(RPM_VERSION)' \ -bb /output/rockylinux-$*/SPECS/$(PACKAGE_NAME).spec - cp /output/rockylinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm /output/ + cp /output/rockylinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(RPM_VERSION).el$*.noarch.rpm /output/ # Ubuntu package creation actually-package-ubuntu-%: $(MAKE) install-systemd DESTDIR=/output/ubuntu-$* cp -r --preserve=mode DEBIAN /output/ubuntu-$*/ - dpkg-deb -Zgzip --build /output/ubuntu-$* "/output/$(PACKAGE_NAME)-$(VERSION)-ubuntu-$*.deb" + dpkg-deb -Zgzip --build /output/ubuntu-$* "/output/$(PACKAGE_NAME)-$(DEB_VERSION)-ubuntu-$*.deb" # OracleLinux package creation actually-package-oraclelinux-%: mkdir -p /output/oraclelinux-$*/{BUILD,RPMS,SOURCES,SPECS,SRPMS} - sed -e "s/@@VERSION@@/$(VERSION)/g" RPM/$(PACKAGE_NAME)-el7.spec > /output/oraclelinux-$*/SPECS/$(PACKAGE_NAME).spec + sed -e "s/@@VERSION@@/$(VERSION)/g" -e "s/@@RELEASE@@/$(RPM_RELEASE)/g" RPM/$(PACKAGE_NAME)-el7.spec > /output/oraclelinux-$*/SPECS/$(PACKAGE_NAME).spec rpmbuild --define '_topdir /output/oraclelinux-$*' \ - --define 'version $(VERSION)' \ + --define 'version $(RPM_VERSION)' \ -bb /output/oraclelinux-$*/SPECS/$(PACKAGE_NAME).spec - cp /output/oraclelinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm /output/ + cp /output/oraclelinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(RPM_VERSION).el$*.noarch.rpm /output/ diff --git a/RPM/pgmon-el7.spec b/RPM/pgmon-el7.spec index 3b880c2..68ee750 100644 --- a/RPM/pgmon-el7.spec +++ b/RPM/pgmon-el7.spec @@ -1,6 +1,6 @@ Name: pgmon Version: @@VERSION@@ -Release: 1%{?dist} +Release: @@RELEASE@@%{?dist} Summary: A bridge to sit between monitoring tools and PostgreSQL License: MIT diff --git a/RPM/pgmon.spec b/RPM/pgmon.spec index 5f7facf..469b584 100644 --- a/RPM/pgmon.spec +++ b/RPM/pgmon.spec @@ -1,6 +1,6 @@ Name: pgmon Version: @@VERSION@@ -Release: 1%{?dist} +Release: @@RELEASE@@%{?dist} Summary: A bridge to sit between monitoring tools and PostgreSQL License: MIT diff --git a/src/pgmon.py b/src/pgmon.py index d184a67..bb755a3 100755 --- a/src/pgmon.py +++ b/src/pgmon.py @@ -29,7 +29,7 @@ import re from decimal import Decimal -VERSION = "1.0.3" +VERSION = "1.0.4-rc1" # Configuration config = {}