From 3433754c69220b0379e205c722b849952d5467de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Daase?= Date: Mon, 1 Mar 2021 13:35:44 +0100 Subject: [PATCH] Makefile: Make sure make is invoked with appropriate permissions (#146) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 74bae3e..6ffe8c1 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,10 @@ LIB_DIR = $(DESTDIR)$(PREFIX)/lib .PHONY: install uninstall help install: + @if test "$(shell id -u)" != 0; then \ + echo "You are not root, run this target as root please."; \ + exit 1; \ + fi @install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs @install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config @install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service @@ -23,6 +27,10 @@ install: @install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md" uninstall: + @if test "$(shell id -u)" != 0; then \ + echo "You are not root, run this target as root please."; \ + exit 1; \ + fi @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"