diff --git a/.github/workflows/build_deb.yml b/.github/workflows/build_deb.yml new file mode 100644 index 00000000..063fa33f --- /dev/null +++ b/.github/workflows/build_deb.yml @@ -0,0 +1,22 @@ +name: Build deb + +on: + push: + branches: ['master'] + tags: ['**'] + pull_request: + branches: ['**'] + +jobs: + build_deb: + strategy: + matrix: + ubuntu_version: ["22.04", "24.04"] + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-deb-native.yml@v43 + with: + go_version: "1.20" + artifact_name: "gpbackup-deb-ubuntu${{ matrix.ubuntu_version }}" + build_command: "make deb" + runner: "ubuntu-${{ matrix.ubuntu_version }}" + test_docker: "ubuntu:${{ matrix.ubuntu_version }}" + add_greengage_repo: true diff --git a/Makefile b/Makefile index 1fd0d0c8..6e408ed8 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,22 @@ install : fi; \ rm /tmp/seg_hosts +# Packaging +DATE_RFC := $(shell date -R) +DISTRO_CODENAME := $(shell lsb_release -sc 2>/dev/null || echo unstable) +DEB_VERSION := $(shell echo "$(GIT_VERSION)" | sed 's/^v//') +DEB_MAINTAINER := Greengage + +debian/changelog : + @echo "=== Generating debian/changelog ===" + @printf 'gpbackup (%s) %s; urgency=medium\n\n * Build from %s\n\n -- %s %s\n' \ + "$(DEB_VERSION)" "$(DISTRO_CODENAME)" "$(GIT_VERSION)" "$(DEB_MAINTAINER)" "$(DATE_RFC)" > $@ + +changelog : debian/changelog + +deb : debian/changelog + dpkg-buildpackage -us -uc -b + clean : # Build artifacts rm -f $(BIN_DIR)/$(BACKUP) $(BACKUP) $(BIN_DIR)/$(RESTORE) $(RESTORE) $(BIN_DIR)/$(HELPER) $(HELPER) diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..b1bd38b6 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +13 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..956b1601 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: gpbackup +Maintainer: Greengage +Section: database +Build-Depends: debhelper (>= 13), + build-essential +Standards-Version: 4.6.0 + +Package: gpbackup +Architecture: any +Depends: ${shlibs:Depends}, + greengage6 | greengage7 +Description: Greengage Backup and Restore utilities + gpbackup and gprestore are Go utilities for performing Greengage Database + backups and restores. gpbackup_helper is used with the --single-data-file flag. diff --git a/debian/gpbackup.install.in b/debian/gpbackup.install.in new file mode 100644 index 00000000..a3e5b72b --- /dev/null +++ b/debian/gpbackup.install.in @@ -0,0 +1,3 @@ +@GPBACKUP_HOME_REL@/bin/gpbackup +@GPBACKUP_HOME_REL@/bin/gprestore +@GPBACKUP_HOME_REL@/bin/gpbackup_helper diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..479d425a --- /dev/null +++ b/debian/postinst @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +GPBACKUP_BIN=/opt/greengagedb/gpbackup/bin + +for gphome in /opt/greengagedb/greengage*/; do + [ -d "${gphome}bin" ] || continue + for binary in gpbackup gprestore gpbackup_helper; do + ln -sf "${GPBACKUP_BIN}/${binary}" "${gphome}bin/${binary}" + done +done diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 00000000..d9033ca7 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +for gphome in /opt/greengagedb/greengage*/; do + [ -d "${gphome}bin" ] || continue + for binary in gpbackup gprestore gpbackup_helper; do + rm -f "${gphome}bin/${binary}" + done +done diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..45a6253f --- /dev/null +++ b/debian/rules @@ -0,0 +1,42 @@ +#!/usr/bin/make -f + +DH_VERBOSE = 1 + +GPBACKUP_HOME ?= /opt/greengagedb/gpbackup +GPBACKUP_HOME_REL := $(GPBACKUP_HOME:/%=%) + +export DH_OPTIONS := $(DH_OPTIONS) +export DEB_BUILD_OPTIONS = nocheck +export PATH := /usr/local/go/bin:$(PATH) +export CGO_ENABLED = 1 +export GOPATH ?= $(HOME)/go + +BUILD_DIR := $(CURDIR)/_build + +%: + dh $@ + +override_dh_auto_clean: + @echo "Skipping clean" + +override_dh_auto_configure: + @echo "=== Generating .install files ===" + sed 's|@GPBACKUP_HOME_REL@|$(GPBACKUP_HOME_REL)|g' debian/gpbackup.install.in > debian/gpbackup.install + +override_dh_auto_build: + @echo "=== Building gpbackup binaries ===" + mkdir -p $(BUILD_DIR) + $(MAKE) build BIN_DIR=$(BUILD_DIR) + +override_dh_auto_install: + @echo "=== Installing gpbackup binaries ===" + install -D -m 755 $(BUILD_DIR)/gpbackup $(CURDIR)/debian/tmp/$(GPBACKUP_HOME_REL)/bin/gpbackup + install -D -m 755 $(BUILD_DIR)/gprestore $(CURDIR)/debian/tmp/$(GPBACKUP_HOME_REL)/bin/gprestore + install -D -m 755 $(BUILD_DIR)/gpbackup_helper $(CURDIR)/debian/tmp/$(GPBACKUP_HOME_REL)/bin/gpbackup_helper + +override_dh_dwz: + @echo "Skipping debug symbols compression (not working properly with Golang)" + +override_dh_gencontrol: + @echo "=== Generating control files ===" + dh_gencontrol