mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-04 13:05:00 +08:00
[Makefile] Modifies install/uninstall target. Adds help target (#135)
Makefile: Install target: - Added "uninstall" and "help" target to ".phony". - Hook initcpio will be installed only on Arch Linux like distributions. Uninstall target: - All commands are in silent mode. - "rmdir" command will not interrupt the uninstallation if the folder does not exist. - Remove "-r" option to "rm" command. - Fix a mistake in deleting the "readme" file. - Uninstalling the "grub-btrfs.cfg" file uses the "GRUB_BTRFS_GRUB_DIRNAME" variable. - Delete initcpio folder if not on Arch. - Delete "grub-btrfs" docs and licenses folders. help target: - Add "help" target.
This commit is contained in:
57
Makefile
57
Makefile
@@ -4,7 +4,7 @@ PREFIX ?= /usr
|
||||
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
|
||||
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
|
||||
|
||||
.PHONY: install
|
||||
.PHONY: install uninstall help
|
||||
|
||||
install:
|
||||
@install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs
|
||||
@@ -12,20 +12,49 @@ install:
|
||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service
|
||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path
|
||||
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
||||
@install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" # Arch Linux only
|
||||
@install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs" # Arch Linux only
|
||||
@# Arch Linux like distros only :
|
||||
@if command -V mkinitcpio >/dev/null 2>&1; then \
|
||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \
|
||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
|
||||
fi
|
||||
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
||||
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs"
|
||||
rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.service"
|
||||
rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path"
|
||||
rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
|
||||
rm -f "$(DESTDIR)/boot/grub/grub-btrfs.cfg"
|
||||
rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" # Arch Linux only
|
||||
rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs" # Arch Linux only
|
||||
rm -rf "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
||||
rm -rf "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs"
|
||||
@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 "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
|
||||
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||
@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"
|
||||
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
|
||||
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
|
||||
@# Arch Linux unlike distros only :
|
||||
@if ! command -V mkinitcpio >/dev/null 2>&1; then \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
|
||||
fi
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/README.md"
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
@rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/doc/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/licenses/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" || :
|
||||
|
||||
help:
|
||||
@echo
|
||||
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
|
||||
@echo
|
||||
@echo " actions: install"
|
||||
@echo " uninstall"
|
||||
@echo " help"
|
||||
@echo
|
||||
@echo " parameters | description | defaults"
|
||||
@echo " -----------+--------------------------------+----------------------------"
|
||||
@echo " DESTDIR | install destination | <unset>"
|
||||
@echo " PREFIX | system tree prefix | '/usr'"
|
||||
@echo " SHARE_DIR | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
||||
@echo " LIB_DIR | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
||||
@echo " PKGNAME | name of the ditributed package | 'grub-btrfs'"
|
||||
@echo
|
||||
|
||||
Reference in New Issue
Block a user