From 8fd57032e74da5da44cca1f531a693858e16449f Mon Sep 17 00:00:00 2001 From: James Campbell Date: Sun, 6 Jul 2025 03:28:16 -0400 Subject: [PATCH 1/3] 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 = {} From 3961aa34482bcc11c9520795cfe654576b08c216 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Sun, 6 Jul 2025 03:32:27 -0400 Subject: [PATCH 2/3] Add Gentoo ebuild for 1.0.4-rc1 --- GENTOO/pgmon-1.0.4-rc1.ebuild | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 GENTOO/pgmon-1.0.4-rc1.ebuild diff --git a/GENTOO/pgmon-1.0.4-rc1.ebuild b/GENTOO/pgmon-1.0.4-rc1.ebuild new file mode 100644 index 0000000..9d0e6a9 --- /dev/null +++ b/GENTOO/pgmon-1.0.4-rc1.ebuild @@ -0,0 +1,74 @@ +# Copyright 2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{6..13} ) + +inherit python-r1 systemd + +DESCRIPTION="PostgreSQL monitoring bridge" +HOMEPAGE="None" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="amd64" + +SRC_URI="https://code2.shh-dot-com.org/james/${PN}/releases/download/v${PV}/${P}.tar.bz2" + +IUSE="-systemd" + +DEPEND=" + ${PYTHON_DEPS} + dev-python/psycopg:2 + dev-python/pyyaml + dev-python/requests + app-admin/logrotate + " +RDEPEND="${DEPEND}" +BDEPEND="" + +#RESTRICT="fetch" + +#S="${WORKDIR}/${PN}" + +#pkg_nofetch() { +# einfo "Please download" +# einfo " - ${P}.tar.bz2" +# einfo "from ${HOMEPAGE} and place it in your DISTDIR directory." +# einfo "The file should be owned by portage:portage." +#} + +src_compile() { + true +} + +src_install() { + # Install init script + if ! use systemd ; then + newinitd "openrc/pgmon.initd" pgmon + newconfd "openrc/pgmon.confd" pgmon + fi + + # Install systemd unit + if use systemd ; then + systemd_dounit "systemd/pgmon.service" + fi + + # Install script + exeinto /usr/bin + newexe "src/pgmon.py" pgmon + + # Install default config + diropts -o root -g root -m 0755 + insinto /etc/pgmon + doins "sample-config/pgmon.yml" + doins "sample-config/pgmon-metrics.yml" + + # Install logrotate config + insinto /etc/logrotate.d + newins "logrotate/pgmon.logrotate" pgmon + + # Install man page + doman manpages/pgmon.1 +} From 5afc940df877739ee4f5d7bc58e9ab95c04d3602 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Sun, 6 Jul 2025 03:35:00 -0400 Subject: [PATCH 3/3] Bump release version to 1.0.4 --- GENTOO/{pgmon-1.0.4-rc1.ebuild => pgmon-1.0.4.ebuild} | 0 src/pgmon.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename GENTOO/{pgmon-1.0.4-rc1.ebuild => pgmon-1.0.4.ebuild} (100%) diff --git a/GENTOO/pgmon-1.0.4-rc1.ebuild b/GENTOO/pgmon-1.0.4.ebuild similarity index 100% rename from GENTOO/pgmon-1.0.4-rc1.ebuild rename to GENTOO/pgmon-1.0.4.ebuild diff --git a/src/pgmon.py b/src/pgmon.py index bb755a3..2b72169 100755 --- a/src/pgmon.py +++ b/src/pgmon.py @@ -29,7 +29,7 @@ import re from decimal import Decimal -VERSION = "1.0.4-rc1" +VERSION = "1.0.4" # Configuration config = {}