changed makefile so it doesnt intefere with arch package build process

This commit is contained in:
Pascal Jäger
2021-11-02 16:18:04 +01:00
committed by Antynea
parent 66a218356a
commit 3b0d0c4ff7
+87 -88
View File
@@ -1,89 +1,88 @@
PKGNAME ?= grub-btrfs PKGNAME ?= grub-btrfs
PREFIX ?= /usr PREFIX ?= /usr
INITCPIO ?= false INITCPIO ?= false
SYSTEMD ?= true
SHARE_DIR = $(DESTDIR)$(PREFIX)/share OPENRC ?= false
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
OPENRC = $(shell strings /sbin/init | grep -q "sysvinit" && echo true || echo false) SHARE_DIR = $(DESTDIR)$(PREFIX)/share
SYSTEMD = $(shell test -d /run/systemd/system && echo true || echo false) LIB_DIR = $(DESTDIR)$(PREFIX)/lib
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
.PHONY: install uninstall help
install: .PHONY: install uninstall help
@if test "$(shell id -u)" != 0; then \
echo "You are not root, run this target as root please."; \ install:
exit 1; \ @if test "$(shell id -u)" != 0; then \
fi echo "You are not root, run this target as root please."; \
@install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs exit 1; \
@install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config fi
@# Systemd detected on system, install systemd service @install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs
@if [[ $(SYSTEMD) = true ]]; then \ @install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config
install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path; \ @# Systemd init system
install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service; \ @if test "$(SYSTEMD)" = true; then \
fi install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path; \
@# OpenRC detected on system, install OpenRC daemon install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service; \
@if [[ $(OPENRC) = true ]]; then \ fi
install -Dm744 -t "$(BIN_DIR)/" grub-btrfs-openrc; \ @# OpenRC init system
install -Dm744 -t "$(DESTDIR)/etc/init.d/" grub-btrfsd; \ @if test "$(OPENRC)" = true; then \
fi install -Dm744 -t "$(BIN_DIR)/" grub-btrfs-openrc; \
@# Arch Linux like distros only : install -Dm744 -t "$(DESTDIR)/etc/init.d/" grub-btrfsd; \
@if test "$(INITCPIO)" = true; then \ fi
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \ @# Arch Linux like distros only :
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \ @if test "$(INITCPIO)" = true; then \
fi install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md fi
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md" @install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
uninstall: @install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
@if test "$(shell id -u)" != 0; then \
echo "You are not root, run this target as root please."; \ uninstall:
exit 1; \ @if test "$(shell id -u)" != 0; then \
fi echo "You are not root, run this target as root please."; \
@grub_dirname="$$(grep -oP '^[[:space:]]*GRUB_BTRFS_GRUB_DIRNAME=\K.*' "$(DESTDIR)/etc/default/grub-btrfs/config" | sed "s|\s*#.*||;s|(\s*\(.\+\)\s*)|\1|;s|['\"]||g")"; \ exit 1; \
rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg" fi
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config" @grub_dirname="$$(grep -oP '^[[:space:]]*GRUB_BTRFS_GRUB_DIRNAME=\K.*' "$(DESTDIR)/etc/default/grub-btrfs/config" | sed "s|\s*#.*||;s|(\s*\(.\+\)\s*)|\1|;s|['\"]||g")"; \
@rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs" rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
@if [[ $(SYSTEMD) = true ]]; then \ @rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path; \ @rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs"
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.service; \ @rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path;
fi @rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.service;
@# OpenRC detected on system, install OpenRC daemon @rm -f "$(BIN_DIR)/grub-btrfs.openrcbin;
@if [[ $(OPENRC) = true ]]; then \ @rm -f "$(DESTDIR)/etc/init.d/grub-btrfs.openrc;
rm -f "$(BIN_DIR)/grub-btrfs.openrcbin; \ @rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
rm -f "$(DESTDIR)/etc/init.d/grub-btrfs.openrc; \ @rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
fi @# Arch Linux UNlike distros only :
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" @if test "$(INITCPIO)" != true && test -d "$(LIB_DIR)/initcpio"; then \
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs" rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \
@# Arch Linux UNlike distros only : rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \
@if test "$(INITCPIO)" != true && test -d "$(LIB_DIR)/initcpio"; then \ rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \ fi
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \ @rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/README.md"
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \ @rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
fi @rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/README.md" @rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/doc/$(PKGNAME)/" || :
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md" @rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/licenses/$(PKGNAME)/" || :
@rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE" @rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" || :
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/doc/$(PKGNAME)/" || :
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/licenses/$(PKGNAME)/" || : help:
@rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" || : @echo
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
help: @echo
@echo @echo " actions: install"
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]" @echo " uninstall"
@echo @echo " help"
@echo " actions: install" @echo
@echo " uninstall" @echo " parameter | type | description | defaults"
@echo " help" @echo " ----------+------+--------------------------------+----------------------------"
@echo @echo " DESTDIR | path | install destination | <unset>"
@echo " parameter | type | description | defaults" @echo " PREFIX | path | system tree prefix | '/usr'"
@echo " ----------+------+--------------------------------+----------------------------" @echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
@echo " DESTDIR | path | install destination | <unset>" @echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
@echo " PREFIX | path | system tree prefix | '/usr'" @echo " PKGNAME | name | name of the ditributed package | 'grub-btrfs'"
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'" @echo " INITCPIO | bool | include mkinitcpio hook | false"
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'" @echo " SYSTEMD | bool | include unit files | true"
@echo " PKGNAME | name | name of the ditributed package | 'grub-btrfs'" @echo " OPENRC | bool | include OpenRc daemon | false"
@echo " INITCPIO | bool | include mkinitcpio hook | false"
@echo @echo