Improve packaging
This commit is contained in:
206
Makefile
206
Makefile
@@ -1,3 +1,4 @@
|
||||
# Package details
|
||||
PACKAGE_NAME := pgmon
|
||||
VERSION := 1.0
|
||||
|
||||
@@ -6,51 +7,41 @@ SCRIPT := src/$(PACKAGE_NAME).py
|
||||
# Where packages are built
|
||||
BUILD_DIR := build
|
||||
|
||||
# OS images used to build packages
|
||||
# These are created with: make docker
|
||||
# Targets are at the bottom of this file
|
||||
DEB_IMAGE := debian-package-builder
|
||||
RPM_IMAGE := rpm-package-builder
|
||||
EL7_IMAGE := el7-package-builder
|
||||
|
||||
# List of versions to test for each distro
|
||||
INSTALL_TEST_DEBIAN_RELEASES := 10 11
|
||||
INSTALL_TEST_REDHAT_RELEASES := 8 9
|
||||
INSTALL_TEST_REDHAT_OLD_RELEASES := 7
|
||||
INSTALL_TEST_UBUNTU_RELEASES := 20.04 22.04 24.04
|
||||
|
||||
# The default release to test for each distro (basically pick the last one in the list)
|
||||
INSTALL_TEST_DEBIAN_RELEASE := $(lastword $(INSTALL_TEST_DEBIAN_RELEASES))
|
||||
INSTALL_TEST_REDHAT_RELEASE := $(lastword $(INSTALL_TEST_REDHAT_RELEASES))
|
||||
INSTALL_TEST_REDHAT_OLD_RELEASE := $(lastword $(INSTALL_TEST_REDHAT_OLD_RELEASES))
|
||||
INSTALL_TEST_UBUNTU_RELEASE := $(lastword $(INSTALL_TEST_UBUNTU_RELEASES))
|
||||
|
||||
# List of distros we support
|
||||
SUPPORTED := ubuntu-20.04 \
|
||||
ubuntu-22.04 \
|
||||
ubuntu-24.04 \
|
||||
debian-10 \
|
||||
debian-11 \
|
||||
rockylinux-8 \
|
||||
rockylinux-9 \
|
||||
oraclelinux-7
|
||||
|
||||
##
|
||||
# These targets are the main ones to use for most things.
|
||||
##
|
||||
|
||||
.PHONY: all clean deb rpm test install install-tests
|
||||
.PHONY: all clean tgz test install
|
||||
|
||||
|
||||
# Build all packages
|
||||
.PHONY: package-all
|
||||
all: $(foreach distro_release, $(SUPPORTED), package-$(distro_release))
|
||||
|
||||
all: deb rpm
|
||||
|
||||
# Create a deb package
|
||||
deb:
|
||||
mkdir -p $(BUILD_DIR)/deb
|
||||
.PHONY: package-%
|
||||
package-%: PARTS=$(subst -, ,$*)
|
||||
package-%: DISTRO=$(word 1, $(PARTS))
|
||||
package-%: RELEASE=$(word 2, $(PARTS))
|
||||
package-%:
|
||||
mkdir -p $(BUILD_DIR)
|
||||
docker run --rm \
|
||||
-v .:/src:ro \
|
||||
-v ./$(BUILD_DIR)/deb:/output \
|
||||
-v ./$(BUILD_DIR):/output \
|
||||
--user $(shell id -u):$(shell id -g) \
|
||||
$(DEB_IMAGE)
|
||||
"$(DISTRO)-packager:$(RELEASE)"
|
||||
|
||||
# Create an rpm package
|
||||
rpm:
|
||||
mkdir -p $(BUILD_DIR)/rpm
|
||||
docker run --rm \
|
||||
-v .:/src:ro \
|
||||
-v ./$(BUILD_DIR)/rpm:/output \
|
||||
--user $(shell id -u):$(shell id -g) \
|
||||
$(RPM_IMAGE)
|
||||
|
||||
# Create a tarball
|
||||
tgz:
|
||||
@@ -95,56 +86,57 @@ install:
|
||||
|
||||
|
||||
# Run all of the install tests
|
||||
install-tests: all-debian-install-tests all-redhat-install-tests all-ubuntu-install-tests
|
||||
|
||||
.PHONY: all-debian-install-tests all-redhat-install-tests all-ubuntu-install-tests
|
||||
|
||||
# Run all of the Debian install tests
|
||||
all-debian-install-tests:
|
||||
$(foreach version, $(INSTALL_TEST_DEBIAN_RELEASES), $(MAKE) debian-install-test INSTALL_TEST_DEBIAN_RELEASE=$(version) ;)
|
||||
|
||||
# Run all of the RedHat install tests
|
||||
all-redhat-install-tests:
|
||||
$(foreach version, $(INSTALL_TEST_REDHAT_RELEASES), $(MAKE) redhat-install-test INSTALL_TEST_REDHAT_RELEASE=$(version) ;)
|
||||
|
||||
# Run all of the *old* RedHat install tests
|
||||
all-redhat-old-install-tests:
|
||||
$(foreach version, $(INSTALL_TEST_REDHAT_OLD_RELEASES), $(MAKE) redhat-old-install-test INSTALL_TEST_REDHAT_OLD_RELEASE=$(version) ;)
|
||||
|
||||
# Run all of the Ubuntu install tests
|
||||
all-ubuntu-install-tests:
|
||||
$(foreach version, $(INSTALL_TEST_REDHAT_RELEASES), $(MAKE) ubuntu-install-test INSTALL_TEST_REDHAT_RELEASE=$(version) ;)
|
||||
.PHONY: install-tests debian-%-install-test rockylinux-%-install-test ubuntu-%-install-test
|
||||
install-tests: $(foreach distro_release, $(SUPPORTED), $(distro_release)-install-test)
|
||||
|
||||
|
||||
.PHONY: debian-install-test redhat-install-test rhel-old-install-test ubuntu-install-test
|
||||
|
||||
# Run the specified (or latest) Debian install test
|
||||
debian-install-test:
|
||||
# Run a Debian install test
|
||||
debian-%-install-test:
|
||||
docker run --rm \
|
||||
-v ./$(BUILD_DIR)/deb:/output \
|
||||
debian:$(INSTALL_TEST_DEBIAN_RELEASE) \
|
||||
bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)_$(VERSION).deb'
|
||||
-v ./$(BUILD_DIR):/output \
|
||||
debian:$* \
|
||||
bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(VERSION)-debian-$*.deb'
|
||||
|
||||
# Run the specified (or latest) RedHat install test
|
||||
redhat-install-test:
|
||||
# Run a RedHat install test
|
||||
rockylinux-%-install-test:
|
||||
docker run --rm \
|
||||
-v ./$(BUILD_DIR)/rpm:/output \
|
||||
rockylinux:$(INSTALL_TEST_REDHAT_RELEASE) \
|
||||
bash -c 'dnf makecache && dnf install -y /output/$(PACKAGE_NAME)-$(VERSION).rpm'
|
||||
-v ./$(BUILD_DIR):/output \
|
||||
rockylinux:$* \
|
||||
bash -c 'dnf makecache && dnf install -y /output/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm'
|
||||
|
||||
# Run the specified (or latest) *old* RedHat install test
|
||||
rhel-old-install-test:
|
||||
# Run an Ubuntu install test
|
||||
ubuntu-%-install-test:
|
||||
docker run --rm \
|
||||
-v ./$(BUILD_DIR)/rpm:/output \
|
||||
rockylinux:$(INSTALL_TEST_REDHAT_OLD_RELEASE) \
|
||||
bash -c 'yum makecache && yum install -y /output/$(PACKAGE_NAME)-$(VERSION).el$(INSTALL_TEST_REDHAT_OLD_RELEASE).rpm'
|
||||
-v ./$(BUILD_DIR):/output \
|
||||
ubuntu:$* \
|
||||
bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)-$(VERSION)-ubuntu-$*.deb'
|
||||
|
||||
# Run the specified (or latest) Ubuntu install test
|
||||
ubuntu-install-test:
|
||||
# Run an OracleLinux install test (this is for EL7 since CentOS7 images no longer exist)
|
||||
oraclelinux-%-install-test:
|
||||
docker run --rm \
|
||||
-v ./$(BUILD_DIR)/deb:/output \
|
||||
ubuntu:$(INSTALL_TEST_UBUNTU_RELEASE) \
|
||||
bash -c 'apt-get update && apt-get install -y /output/$(PACKAGE_NAME)_$(VERSION).deb'
|
||||
-v ./$(BUILD_DIR):/output \
|
||||
oraclelinux:7 \
|
||||
bash -c 'yum makecache && yum install -y /output/$(PACKAGE_NAME)-$(VERSION)-1.el7.noarch.rpm'
|
||||
|
||||
##
|
||||
# Container targets
|
||||
#
|
||||
# These targets build the docker images used to create packages
|
||||
##
|
||||
|
||||
# Target to build packaging images for all supported releases
|
||||
.PHONY: all-package-images
|
||||
all-package-images: $(foreach distro_release, $(SUPPORTED), package-image-$(distro_release))
|
||||
|
||||
# Generic target for creating images that actually build the packages
|
||||
# The % is expected to be: distro-release
|
||||
# The build/.package-image-% target actually does the work and touches a state file to avoid excessive building
|
||||
.PHONY: package-image-%
|
||||
package-image-%: PARTS=$(subst -, ,$*)
|
||||
package-image-%: DISTRO=$(word 1, $(PARTS))
|
||||
package-image-%: RELEASE=$(word 2, $(PARTS))
|
||||
package-image-%:
|
||||
docker build -t "$(DISTRO)-packager:$(RELEASE)" --build-arg "RELEASE=$(RELEASE)" --build-arg "DISTRO=$(DISTRO)" -f docker/Dockerfile-$(DISTRO) .
|
||||
|
||||
|
||||
##
|
||||
@@ -155,48 +147,34 @@ ubuntu-install-test:
|
||||
# /output.
|
||||
##
|
||||
|
||||
.PHONY: package-deb package-rpm
|
||||
.PHONY: actually-package-debian-% actually-package-rockylinux-% actually-package-ubuntu-% actually-package-oraclelinux-%
|
||||
|
||||
# Debian package creation logic
|
||||
package-deb:
|
||||
$(MAKE) install DESTDIR=/output
|
||||
cp -r --preserve=mode DEBIAN /output/
|
||||
dpkg-deb -Zgzip --build /output /output/$(PACKAGE_NAME)_$(VERSION).deb
|
||||
# Debian package creation
|
||||
actually-package-debian-%:
|
||||
$(MAKE) install DESTDIR=/output/debian-$*
|
||||
cp -r --preserve=mode DEBIAN /output/debian-$*/
|
||||
dpkg-deb -Zgzip --build /output/debian-$* "/output/$(PACKAGE_NAME)-$(VERSION)-debian-$*.deb"
|
||||
|
||||
# RPM package creation logic
|
||||
package-rpm:
|
||||
mkdir -p /output/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
cp RPM/$(PACKAGE_NAME).spec /output/SPECS/
|
||||
rpmbuild --define '_topdir /output' \
|
||||
# RedHat package creation
|
||||
actually-package-rockylinux-%:
|
||||
mkdir -p /output/rockylinux-$*/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
cp RPM/$(PACKAGE_NAME).spec /output/rockylinux-$*/SPECS/
|
||||
rpmbuild --define '_topdir /output/rockylinux-$*' \
|
||||
--define 'version $(VERSION)' \
|
||||
-bb /output/SPECS/$(PACKAGE_NAME).spec
|
||||
cp /output/RPMS/noarch/*.rpm /output/
|
||||
-bb /output/rockylinux-$*/SPECS/$(PACKAGE_NAME).spec
|
||||
cp /output/rockylinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm /output/
|
||||
|
||||
# RPM package creation logic for old versions of RedHat (ie: 7)
|
||||
package-rpm-old:
|
||||
mkdir -p /output/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
cp RPM-OLD/$(PACKAGE_NAME).spec /output/SPECS/
|
||||
rpmbuild --define '_topdir /output' \
|
||||
# Ubuntu package creation
|
||||
actually-package-ubuntu-%:
|
||||
$(MAKE) install DESTDIR=/output/ubuntu-$*
|
||||
cp -r --preserve=mode DEBIAN /output/ubuntu-$*/
|
||||
dpkg-deb -Zgzip --build /output/ubuntu-$* "/output/$(PACKAGE_NAME)-$(VERSION)-ubuntu-$*.deb"
|
||||
|
||||
# OracleLinux package creation
|
||||
actually-package-oraclelinux-%:
|
||||
mkdir -p /output/oraclelinux-$*/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
cp RPM/$(PACKAGE_NAME)-el7.spec /output/oraclelinux-$*/SPECS/$(PACKAGE_NAME).spec
|
||||
rpmbuild --define '_topdir /output/oraclelinux-$*' \
|
||||
--define 'version $(VERSION)' \
|
||||
-bb /output/SPECS/$(PACKAGE_NAME).spec
|
||||
cp /output/RPMS/noarch/*.rpm /output/
|
||||
|
||||
|
||||
##
|
||||
# Container targets
|
||||
#
|
||||
# These targets build the docker images used to create packages
|
||||
##
|
||||
|
||||
.PHONY: docker deb-package-image rpm-package-image
|
||||
|
||||
docker: deb-package-image rpm-package-image
|
||||
|
||||
deb-package-image: docker/Dockerfile-deb
|
||||
docker build -t $(DEB_IMAGE) -f docker/Dockerfile-deb .
|
||||
|
||||
rpm-package-image: docker/Dockerfile-rpm
|
||||
docker build -t $(RPM_IMAGE) -f docker/Dockerfile-rpm .
|
||||
|
||||
el7-package-image: docker/Dockerfile-el7
|
||||
docker build -t $(EL7_IMAGE) -f docker/Dockerfile-el7 .
|
||||
-bb /output/oraclelinux-$*/SPECS/$(PACKAGE_NAME).spec
|
||||
cp /output/oraclelinux-$*/RPMS/noarch/$(PACKAGE_NAME)-$(VERSION)-1.el$*.noarch.rpm /output/
|
||||
|
||||
Reference in New Issue
Block a user