|
| 1 | +.POSIX: |
| 2 | +.SUFFIXES: |
| 3 | + |
| 4 | +NAME=pushprox-updater |
| 5 | +# the 0- is prepended until a version of this repo is tagged |
| 6 | +VERSION=0-$(shell git describe --always --match v[0-9]* HEAD | cut -c2-) |
| 7 | +OUT_DIR=build |
| 8 | +PACKAGE_DIR=$(OUT_DIR)/$(NAME)-$(VERSION) |
| 9 | + |
| 10 | +$(PACKAGE_DIR)/: \ |
| 11 | + $(PACKAGE_DIR)/DEBIAN/ \ |
| 12 | + $(PACKAGE_DIR)/lib/systemd/system/$(NAME).service \ |
| 13 | + $(PACKAGE_DIR)/lib/systemd/system/$(NAME).timer \ |
| 14 | + $(PACKAGE_DIR)/usr/bin/pushprox-updater \ |
| 15 | + |
| 16 | + @touch "$@" |
| 17 | + |
| 18 | +$(PACKAGE_DIR)/DEBIAN/: \ |
| 19 | + $(PACKAGE_DIR)/DEBIAN/conffile \ |
| 20 | + $(PACKAGE_DIR)/DEBIAN/control \ |
| 21 | + $(PACKAGE_DIR)/DEBIAN/postinst \ |
| 22 | + $(PACKAGE_DIR)/DEBIAN/postrm \ |
| 23 | + $(PACKAGE_DIR)/DEBIAN/prerm \ |
| 24 | + |
| 25 | + @touch "$@" |
| 26 | + |
| 27 | +$(PACKAGE_DIR)/DEBIAN/control: debian/control |
| 28 | + (cat debian/control && echo -n 'Version: ' && echo "${VERSION}") > "$@" |
| 29 | + |
| 30 | +$(PACKAGE_DIR)/DEBIAN/%: debian/% |
| 31 | + @mkdir -p "$(dir $@)" |
| 32 | + cp -p "debian/$*" "$@" |
| 33 | + |
| 34 | +$(PACKAGE_DIR)/lib/systemd/system/%: % |
| 35 | + @mkdir -p $(PACKAGE_DIR)/lib/systemd/system |
| 36 | + cp -r "$<" "$@" |
| 37 | + |
| 38 | +$(PACKAGE_DIR)/usr/bin/pushprox-updater: update.sh |
| 39 | + @mkdir -p "$(dir $@)" |
| 40 | + cp -p "$<" "$@" |
| 41 | + |
| 42 | +.PHONY: deb |
| 43 | +deb: $(PACKAGE_DIR).deb |
| 44 | + |
| 45 | +$(PACKAGE_DIR).deb: $(PACKAGE_DIR)/ |
| 46 | + chmod 755 $(PACKAGE_DIR)/DEBIAN/postinst |
| 47 | + chmod 755 $(PACKAGE_DIR)/DEBIAN/postrm |
| 48 | + chmod 755 $(PACKAGE_DIR)/DEBIAN/prerm |
| 49 | + fakeroot dpkg-deb --build "${PACKAGE_DIR}" |
| 50 | + |
| 51 | +.PHONY: release |
| 52 | +release: clean $(PACKAGE_DIR).deb |
| 53 | + hub release create --attach="$(PACKAGE_DIR).deb" "$(VERSION)" |
| 54 | + |
| 55 | +.PHONY: clean |
| 56 | +clean: |
| 57 | + rm -rf "$(OUT_DIR)" |
0 commit comments