The code works on those distributions now; there was still nothing to install. This adds the two packages and, more to the point, somewhere for them to live that hands out updates - a package a user has to notice a new version of and download again is not much better than a checkout. Both are built from `make install` and nothing else. A packaging script that lists the installed files a second time is a second description of the layout, and the two drift the first time a file moves; here the Makefile stays the only place that says where anything goes. The .deb is staged and wrapped with dpkg-deb, the .rpm goes through a spec whose %install is the same make invocation. Both are architecture-independent, so one file each covers Debian, Ubuntu and their derivatives on one side and Fedora, RHEL and openSUSE on the other. The version is not written down twice either. The Makefile has it, the control file and the spec take it as a placeholder, and check-version.sh refuses a tag that disagrees - otherwise a v1.0.4 release quietly ships a program that reports 1.0.3. The release workflow builds both in a Debian and a Fedora container, signs the RPM where there is a native rpm-sign, attaches both to the GitHub release, and then adds them to an APT and a DNF repository on gh-pages, regenerating the indexes over every version ever published so that pinning and going back to one still work. Missing the signing key is not an error: it builds, it says in the log that the repositories were left alone, and the packages are still on the release. There is also a check workflow, which is the first time shellcheck actually runs on this. Neither package carries a maintainer script. The units are enabled per user by the program itself, so there is nothing for a package to do as root - and nothing it could do about the changes in a user's home either, which is why both descriptions say to run `disable` before removing. packaging/README.md has the two things that cannot be automated: making the signing key, and pointing Pages at the branch.
134 lines
4.4 KiB
Makefile
134 lines
4.4 KiB
Makefile
# middleclick-autoscroll - build and install
|
|
#
|
|
# Everything here is plain shell; "building" only means compiling the gettext
|
|
# catalogs and rendering the man page. Both targets degrade to a no-op when
|
|
# msgfmt/scdoc are missing, so the tree stays usable for development without
|
|
# the build dependencies installed.
|
|
|
|
# Overridable so a packager can pass the version it is actually building
|
|
# (`make VERSION=$pkgver`). The literal below is the fallback for builds
|
|
# straight from a checkout, and is what a release tag has to carry.
|
|
VERSION ?= 1.0.3
|
|
|
|
PREFIX ?= /usr
|
|
DESTDIR ?=
|
|
BINDIR ?= $(PREFIX)/bin
|
|
DATADIR ?= $(PREFIX)/share
|
|
LIBDIR ?= $(DATADIR)/middleclick-autoscroll/lib
|
|
LOCALEDIR ?= $(DATADIR)/locale
|
|
MANDIR ?= $(DATADIR)/man
|
|
|
|
# Where systemd looks for user units. For a normal install into /usr this is
|
|
# asked of systemd itself, because the answer is not the same everywhere - a
|
|
# distribution that still keeps /lib separate from /usr/lib says so here - and
|
|
# only guessed at when there is no systemd installed to ask.
|
|
#
|
|
# A build with a prefix of its own keeps the units under that prefix instead.
|
|
# systemd searches $(PREFIX)/lib/systemd/user as well, and a file outside the
|
|
# prefix it was asked for is not this build's to place.
|
|
ifeq ($(PREFIX),/usr)
|
|
USERUNITDIR ?= $(shell pkg-config --variable=systemduserunitdir systemd 2>/dev/null || echo /usr/lib/systemd/user)
|
|
else
|
|
USERUNITDIR ?= $(PREFIX)/lib/systemd/user
|
|
endif
|
|
|
|
LINGUAS := de
|
|
MOFILES := $(patsubst %,po/%.mo,$(LINGUAS))
|
|
MANPAGE := doc/middleclick-autoscroll.1
|
|
|
|
LIBS := $(wildcard src/lib/*.sh)
|
|
|
|
MSGFMT := $(shell command -v msgfmt 2>/dev/null)
|
|
SCDOC := $(shell command -v scdoc 2>/dev/null)
|
|
|
|
.PHONY: all build install uninstall check clean version
|
|
|
|
all: build
|
|
|
|
build: $(MOFILES) $(MANPAGE)
|
|
|
|
# The one place the version is written down, for everything that has to agree
|
|
# with it: the packaging scripts, and the release workflow checking that the
|
|
# tag it was handed says the same thing.
|
|
version:
|
|
@echo $(VERSION)
|
|
|
|
po/%.mo: po/%.po
|
|
ifdef MSGFMT
|
|
$(MSGFMT) --check --output-file=$@ $<
|
|
else
|
|
@echo "msgfmt not found - skipping $@"
|
|
endif
|
|
|
|
$(MANPAGE): doc/middleclick-autoscroll.1.scd
|
|
ifdef SCDOC
|
|
$(SCDOC) < $< > $@
|
|
else
|
|
@echo "scdoc not found - skipping $@"
|
|
endif
|
|
|
|
# Syntax-check every shell file, and run shellcheck when it is available.
|
|
check:
|
|
@set -e; for f in src/middleclick-autoscroll $(LIBS); do \
|
|
bash -n "$$f" && echo "ok $$f"; \
|
|
done
|
|
@if command -v shellcheck >/dev/null 2>&1; then \
|
|
shellcheck -x -e SC1090,SC1091 src/middleclick-autoscroll $(LIBS); \
|
|
echo "ok shellcheck"; \
|
|
else \
|
|
echo "shellcheck not found - skipped"; \
|
|
fi
|
|
@if command -v desktop-file-validate >/dev/null 2>&1; then \
|
|
echo "ok desktop-file-validate (nothing to check)"; \
|
|
fi
|
|
|
|
install: build
|
|
# executable
|
|
install -Dm755 src/middleclick-autoscroll \
|
|
"$(DESTDIR)$(BINDIR)/middleclick-autoscroll"
|
|
|
|
# shell libraries
|
|
install -d "$(DESTDIR)$(LIBDIR)"
|
|
install -Dm644 -t "$(DESTDIR)$(LIBDIR)" $(LIBS)
|
|
|
|
# the version and the resolved paths are baked in at install time
|
|
sed -i -e 's|@VERSION@|$(VERSION)|g' \
|
|
-e 's|@LIBDIR@|$(LIBDIR)|g' \
|
|
-e 's|@LOCALEDIR@|$(LOCALEDIR)|g' \
|
|
"$(DESTDIR)$(BINDIR)/middleclick-autoscroll" \
|
|
"$(DESTDIR)$(LIBDIR)"/*.sh
|
|
|
|
# user units: the watcher, and the one-shot it starts
|
|
install -Dm644 res/systemd/middleclick-autoscroll.service \
|
|
"$(DESTDIR)$(USERUNITDIR)/middleclick-autoscroll.service"
|
|
install -Dm644 res/systemd/middleclick-autoscroll.path \
|
|
"$(DESTDIR)$(USERUNITDIR)/middleclick-autoscroll.path"
|
|
sed -i -e 's|@BINDIR@|$(BINDIR)|g' \
|
|
"$(DESTDIR)$(USERUNITDIR)/middleclick-autoscroll.service"
|
|
|
|
# translations
|
|
@for l in $(LINGUAS); do \
|
|
if [ -f "po/$$l.mo" ]; then \
|
|
install -Dm644 "po/$$l.mo" \
|
|
"$(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES/middleclick-autoscroll.mo"; \
|
|
fi; \
|
|
done
|
|
|
|
# documentation
|
|
@if [ -f $(MANPAGE) ]; then \
|
|
install -Dm644 $(MANPAGE) "$(DESTDIR)$(MANDIR)/man1/middleclick-autoscroll.1"; \
|
|
fi
|
|
install -Dm644 README.md \
|
|
"$(DESTDIR)$(DATADIR)/doc/middleclick-autoscroll/README.md"
|
|
|
|
uninstall:
|
|
rm -f "$(DESTDIR)$(BINDIR)/middleclick-autoscroll"
|
|
rm -rf "$(DESTDIR)$(DATADIR)/middleclick-autoscroll"
|
|
rm -f "$(DESTDIR)$(USERUNITDIR)/middleclick-autoscroll.service"
|
|
rm -f "$(DESTDIR)$(USERUNITDIR)/middleclick-autoscroll.path"
|
|
rm -f "$(DESTDIR)$(MANDIR)/man1/middleclick-autoscroll.1"
|
|
rm -rf "$(DESTDIR)$(DATADIR)/doc/middleclick-autoscroll"
|
|
|
|
clean:
|
|
rm -f po/*.mo $(MANPAGE)
|