diff options
author | Jonathan Wright | 2021-02-02 20:57:30 +0000 |
---|---|---|
committer | Jonathan Wright | 2021-02-02 20:58:23 +0000 |
commit | 36c1541ce243e12cbe9b6cc8bbdd661a244fa9cb (patch) | |
tree | 33e79e9b9f358cb3a602f7525aefbcfba8dfb10d | |
parent | 8a03394d7b03a7ccb08bac8eb13ee445ee2cbfd3 (diff) | |
download | aur-36c1541ce243e12cbe9b6cc8bbdd661a244fa9cb.tar.gz |
Replace the build script with a Makefile
-rw-r--r-- | Makefile | 83 | ||||
-rwxr-xr-x | build | 19 |
2 files changed, 83 insertions, 19 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..3721b908155b --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +MAKEFLAGS += --warn-undefined-variables +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c +.DEFAULT_GOAL := push +.ONESHELL: + +# Simple ANSI colours +CC_YELLOW=\033[0;33m +CC_WHITE=\033[1;37m +CC_END=\033[0m + +# Get the version information +current_pkgver=$(shell cat PKGBUILD | awk -F = '/^pkgver/ { print $$2 }') +use_pkgver=$(current_pkgver) +current_pkgrel=$(shell cat PKGBUILD | awk -F = '/^pkgrel/ { print $$2 }') +use_pkgrel=$(current_pkgrel) + +ifneq ($(strip $(pkgver)),) + use_pkgver=$(pkgver) +endif + +ifdef ($(string $(pkgrel)),) + use_pkgrel=$(pkgrel) +else + ifeq ($(pkgver),$(current_pkgver)) + use_pkgrel=$(current_pkgrel)+1 + else + use_pkgrel=1 + endif +endif + +.PHONY: help +help: ## Show this help message + @grep '.*:.*##' Makefile | grep -v grep | sort | sed 's/:.* ##/:/g' | column -t -s : + +.PHONY: clean +clean: ## Clean the current workspace + @echo -e "${CC_YELLOW}==>${CC_WHITE} Cleaning up old package files${CC_END}" + rm -f *.pkg.tar.{xz,zst} *.zip{,.part} + @echo -e "${CC_YELLOW}==>${CC_WHITE} Cleaning up old working directories${CC_END}" + rm -rf ./pkg ./src + +.PHONY: pull +pull: clean ## Pull changes from the AUR + @echo -e "${CC_YELLOW}==>${CC_WHITE} Check for, and pull, changes from AUR${CC_END}" + git pull --ff-only + +.PHONY: update-version +update-version: pull ## Update the package version in PKGBUILD (use pkgver and pkgrel) + @echo -e "${CC_YELLOW}==>${CC_WHITE} Update the package to $(use_pkgver)-$(use_pkgrel)" + sed -i -e 's/^pkgver=.*$$/pkgver=$(use_pkgver)/' -e 's/^pkgrel=.*$$/pkgrel=$(use_pkgrel)/' PKGBUILD + +.PHONY: update-pkgbuild +update-pkgbuild: update-version ## Update the checksums in the PKGBUILD + @echo -e "${CC_YELLOW}==>${CC_WHITE} Update the checksums in PKGBUILD${CC_END}" + updpkgsums + +.PHONY: build +build: update-pkgbuild ## Build the package (as a test) + @echo -e "${CC_YELLOW}==>${CC_WHITE} Build the package as a test${CC_END}" + makepkg -s + +.PHONY: update-srcinfo +update-srcinfo: build ## Update the .SRCINFO file + @echo -e "${CC_YELLOW}==>${CC_WHITE} Update the .SRCINFO file${CC_END}" + makepkg --printsrcinfo > .SRCINFO + +.PHONY: commit +commit: update-pkgbuild update-srcinfo ## Commit the changes to the repository + @echo -e "${CC_YELLOW}==>${CC_WHITE} Commit the PKGBUILD and .SRCINFO files${CC_END}" + git add PKGBUILD .SRCINFO + git commit -m "Bump package to $$( + cat .SRCINFO \ + | awk -F ' = ' \ + ' /\s+pkgver/ { version=$$2 } + /\s+pkgrel/ { release=$$2 } + END { printf "%s-%s", version, release }' + )" + +.PHONY: push +push: commit ## Push the changes back to up the AUR + @echo -e "${CC_YELLOW}==>${CC_WHITE} Push the changes up to the AUR${CC_END}" + git push diff --git a/build b/build deleted file mode 100755 index a39eeba8d8c5..000000000000 --- a/build +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -make_srcinfo () { - makepkg --printsrcinfo > .SRCINFO -} - -build () { - updpkgsums && makepkg -s "${@}" -} - -clean () { - rm -rf *.pkg.tar.xz *.pkg.tar.zst *.zip ; rm -rf ./pkg ./src ; true -} - -main () { - clean && build "${@}" && make_srcinfo -} - -main "$@" |