39 lines
1.5 KiB
Makefile
39 lines
1.5 KiB
Makefile
PACKAGE := notifications-webhook
|
|
MODULE := send_notifications_webhook
|
|
SITE := usr/lib/python3/dist-packages
|
|
|
|
VERSION ?=
|
|
REVISION ?= 1
|
|
SRC_DIR ?= ../lib-send-notifications-webhook/src
|
|
|
|
BUILD_DIR := build
|
|
STAGE := $(BUILD_DIR)/$(PACKAGE)_$(VERSION)-$(REVISION)
|
|
DEB := $(BUILD_DIR)/$(PACKAGE)_$(VERSION)-$(REVISION)_all.deb
|
|
|
|
.PHONY: deb check clean
|
|
.DEFAULT_GOAL := deb
|
|
|
|
check:
|
|
@test -n "$(VERSION)" || { echo "VERSION is required"; exit 1; }
|
|
@test -d "$(SRC_DIR)/$(MODULE)" || { echo "$(SRC_DIR)/$(MODULE) not found"; exit 1; }
|
|
@test -f "$(SRC_DIR)/$(MODULE)/cli.py" || { echo "$(SRC_DIR)/$(MODULE)/cli.py not found (is it in the tag?)"; exit 1; }
|
|
|
|
deb: check
|
|
rm -rf $(STAGE)
|
|
mkdir -p $(STAGE)/DEBIAN $(STAGE)/$(SITE)
|
|
cp -r pkg/etc pkg/usr $(STAGE)/
|
|
cp -r $(SRC_DIR)/$(MODULE) $(STAGE)/$(SITE)/
|
|
find $(STAGE)/$(SITE) -name '__pycache__' -type d -prune -exec rm -rf {} +
|
|
find $(STAGE) -type d -exec chmod 0755 {} +
|
|
find $(STAGE)/$(SITE) -type f -exec chmod 0644 {} +
|
|
chmod 0755 $(STAGE)/usr/bin/send-notification
|
|
chmod 0640 $(STAGE)/etc/notifications-webhook/config
|
|
sed 's/@VERSION@/$(VERSION)-$(REVISION)/' pkg/DEBIAN/control > $(STAGE)/DEBIAN/control
|
|
echo "Installed-Size: $$(du -sk --exclude=DEBIAN $(STAGE) | cut -f1)" >> $(STAGE)/DEBIAN/control
|
|
install -m 0755 pkg/DEBIAN/postinst pkg/DEBIAN/prerm $(STAGE)/DEBIAN/
|
|
install -m 0644 pkg/DEBIAN/conffiles $(STAGE)/DEBIAN/
|
|
dpkg-deb --root-owner-group --build $(STAGE) $(DEB)
|
|
@echo "Built $(DEB)"
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|