From 70e292420508f94a80381a0c30c70c1233c5620d Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Sat, 25 Nov 2023 01:04:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20mommy=20cleans=20up=20her=20make?= =?UTF-8?q?file~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 3 ++ .github/workflows/ci.yml | 8 ++-- GNUmakefile | 74 +++++++++++++++----------------- README.md | 4 +- pkg/{rpm => fpm}/mommy.spec.rpkg | 0 pkg/fpm/rpkg.conf | 2 + pkg/{rpm => fpm}/rpkg.macros | 0 pkg/rpm/rpkg.conf | 2 - 8 files changed, 46 insertions(+), 47 deletions(-) rename pkg/{rpm => fpm}/mommy.spec.rpkg (100%) create mode 100644 pkg/fpm/rpkg.conf rename pkg/{rpm => fpm}/rpkg.macros (100%) delete mode 100644 pkg/rpm/rpkg.conf diff --git a/.editorconfig b/.editorconfig index de212fc..0e568e0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,3 +18,6 @@ indent_size = 2 [GNUmakefile] indent_style = tab + +[debian.rules] +indent_style = tab diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f06a832..e21a34c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,7 +212,7 @@ jobs: - name: Checkout mommy uses: actions/checkout@v4 with: - # Checkout to subdirectory is required for 'pkg/rpm/rpkg.conf' to correctly determine '${git_props:root}' + # Checkout to subdirectory is required for 'pkg/fpm/rpkg.conf' to correctly determine '${git_props:root}' path: mommy - name: Test script working-directory: ./mommy/ @@ -247,7 +247,7 @@ jobs: working-directory: ./mommy/ run: | echo "::group::Build" - rpkg -p ./pkg/rpm local # build srpm + rpkg -p ./pkg/fpm local # build srpm rpmbuild --rebuild /tmp/rpkg/mommy-*/*.rpm echo "::endgroup::" @@ -348,8 +348,8 @@ jobs: echo "::endgroup::" echo "::group::Install ShellSpec" - git clone --depth=1 https://github.com/shellspec/shellspec.git - gmake -C shellspec install + git clone --depth=1 https://github.com/shellspec/shellspec.git /tmp/shellspec + gmake -C /tmp/shellspec install echo "::endgroup::" echo "::group::Install additional shells" diff --git a/GNUmakefile b/GNUmakefile index f2e1a46..35e7743 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,23 +1,29 @@ +## Configuration +# Variables are passed to sub-makes because of 'export'. Additionally, sub-makes never override their super-makes +# because of assignment using '?='. + +export + # Build file locations -build_dir := build/ -dist_dir := dist/ +build_dir ?= build/ +dist_dir ?= dist/ # Install locations -prefix := /usr/ -bin_prefix := $(prefix)/bin/ -man_prefix := $(prefix)/share/man/ -fish_prefix := $(prefix)/share/fish/vendor_completions.d/ -zsh_prefix := $(prefix)/share/zsh/site-functions/ +prefix ?= /usr/ +bin_prefix ?= $(prefix)/bin/ +man_prefix ?= $(prefix)/share/man/ +fish_prefix ?= $(prefix)/share/fish/vendor_completions.d/ +zsh_prefix ?= $(prefix)/share/zsh/site-functions/ # Other locations -shellspec_bin := shellspec +shellspec_bin ?= shellspec # Extracted values -version := $(shell head -n 1 version) -date := $(shell tail -n 1 version) +version ?= $(shell head -n 1 version) +date ?= $(shell tail -n 1 version) -comment := $(shell grep -- "--description" .fpm | tr -d "\"" | cut -d " " -f 2-) -maintainer := $(shell grep -- "--maintainer" .fpm | tr -d "\"" | cut -d " " -f 2-) +comment ?= $(shell grep -- "--description" .fpm | tr -d "\"" | cut -d " " -f 2-) +maintainer ?= $(shell grep -- "--maintainer" .fpm | tr -d "\"" | cut -d " " -f 2-) ## Meta @@ -56,7 +62,8 @@ build: @mkdir -p "$(build_dir)/completions/zsh/"; cp src/main/completions/zsh/_mommy "$(build_dir)/completions/zsh/" @# Insert version information - @sed -i".bak" "s/%%VERSION_NUMBER%%/$(version)/g;s/%%VERSION_DATE%%/$(date)/g" \ + @sed -i".bak" \ + "s/%%VERSION_NUMBER%%/$(version)/g;s/%%VERSION_DATE%%/$(date)/g" \ "$(build_dir)/bin/mommy" \ "$(build_dir)/man/man1/mommy.1" @rm -f "$(build_dir)/bin/mommy.bak" "$(build_dir)/man/man1/mommy.1.bak" @@ -83,6 +90,8 @@ install: build install/%: install @# + +## Uninstallation # Remove installed files .PHONY: uninstall uninstall: @@ -97,11 +106,11 @@ uninstall/%: uninstall @# -## Build packages +## Build distributable packages .PHONY: dist/% -# Invoke fpm on built files to create `fpm_target` type output -# For valid `fpm_target`s, see https://fpm.readthedocs.io/en/latest/packaging-types.html +# Invoke fpm on built files to create 'fpm_target' type output +# For valid 'fpm_target's, see https://fpm.readthedocs.io/en/latest/packaging-types.html .PHONY: fpm fpm: build ifndef fpm_target @@ -122,39 +131,28 @@ dist/generic: prefix = $(build_dir)/generic/mommy-$(version)/usr/ dist/generic: @rm -rf "$(build_dir)/generic/" - @$(MAKE) prefix="$(prefix)" install + @$(MAKE) install @mkdir -p "$(dist_dir)" @tar -C "$(build_dir)/generic/" -czf "$(dist_dir)/mommy-$(version)+generic.tar.gz" ./ -# Build Debian package with fpm -dist/deb: zsh_prefix = $(prefix)/share/zsh/vendor-completions/ -dist/deb: - @$(MAKE) fpm_target=deb zsh_prefix="$(zsh_prefix)" fpm - -# Build AlpineLinux / Debian / ArchLinux / RedHat package with fpm -dist/apk dist/pacman dist/rpm: +# Build AlpineLinux / Debian / FreeBSD / ArchLinux / RedHat package with fpm +%/deb: zsh_prefix = $(prefix)/share/zsh/vendor-completions/ +%/freebsd: prefix = /usr/local/ +dist/apk dist/deb dist/freebsd dist/pacman dist/rpm: @$(MAKE) fpm_target="$(@:dist/%=%)" fpm # Build macOS package with fpm %/osxpkg: prefix = /usr/local/ -dist/osxpkg: - @$(MAKE) fpm_target=osxpkg prefix="$(prefix)" fpm - - @# `installer` program requires `pkg` extension +%/osxpkg: fpm_target = osxpkg +dist/osxpkg: fpm + @# 'installer' program requires 'pkg' extension @mv "$(dist_dir)/"*".osxpkg" "$(dist_dir)/mommy-$(version)+osx.pkg" -# Build FreeBSD package with fpm -%/freebsd: prefix = /usr/local/ -dist/freebsd: - @$(MAKE) fpm_target=freebsd prefix="$(prefix)" fpm - # Build NetBSD package manually %/netbsd: prefix = $(build_dir)/netbsd/usr/pkg/ %/netbsd: man_prefix = $(prefix)/man/ -dist/netbsd: - @$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install - +dist/netbsd: install @cd "$(build_dir)/netbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS @echo "$(comment)" > "$(build_dir)/netbsd/+COMMENT" @@ -185,9 +183,7 @@ dist/netbsd: # Build OpenBSD package manually %/openbsd: prefix = $(build_dir)/openbsd/usr/local/ %/openbsd: man_prefix = $(prefix)/man/ -dist/openbsd: - @$(MAKE) prefix="$(prefix)" man_prefix="$(man_prefix)" install - +dist/openbsd: install @cd "$(build_dir)/openbsd"; find . -type f | sed -e "s/^/.\//" > +CONTENTS @echo "$(comment)" > "$(build_dir)/openbsd/+COMMENT" diff --git a/README.md b/README.md index d86564a..3c5045e 100644 --- a/README.md +++ b/README.md @@ -672,7 +672,7 @@ unfortunately, packages for macos, netbsd, and openbsd cannot be built on system a service builds mommy on-demand on each release, and makes the created packages available for all users. currently, this happens only for fedora/epel at [copr](https://copr.fedorainfracloud.org/coprs/fwdekker/mommy/). the relevant build files are hosted in -[mommy's `pkg/rpm/` directory](https://github.com/FWDekker/mommy/tree/main/pkg/rpm/)~ +[mommy's `pkg/fpm/` directory](https://github.com/FWDekker/mommy/tree/main/pkg/fpm/)~
@@ -697,7 +697,7 @@ every merge into `main` automatically build and releases a new version~ * **before merging into `main`** * update `version`~ - * update `pkg/rpm/mommy.spec.rpkg` if changes were made to the packaging~ + * update `pkg/fpm/mommy.spec.rpkg` if changes were made to the packaging~ * update release number~ * update change log~ * update `CHANGELOG.md`~ diff --git a/pkg/rpm/mommy.spec.rpkg b/pkg/fpm/mommy.spec.rpkg similarity index 100% rename from pkg/rpm/mommy.spec.rpkg rename to pkg/fpm/mommy.spec.rpkg diff --git a/pkg/fpm/rpkg.conf b/pkg/fpm/rpkg.conf new file mode 100644 index 0000000..b6d6904 --- /dev/null +++ b/pkg/fpm/rpkg.conf @@ -0,0 +1,2 @@ +[rpkg] +user_macros = "${git_props:root}/pkg/fpm/rpkg.macros" diff --git a/pkg/rpm/rpkg.macros b/pkg/fpm/rpkg.macros similarity index 100% rename from pkg/rpm/rpkg.macros rename to pkg/fpm/rpkg.macros diff --git a/pkg/rpm/rpkg.conf b/pkg/rpm/rpkg.conf deleted file mode 100644 index 0128fdb..0000000 --- a/pkg/rpm/rpkg.conf +++ /dev/null @@ -1,2 +0,0 @@ -[rpkg] -user_macros = "${git_props:root}/pkg/rpm/rpkg.macros"