Skip to content

Commit 8802241

Browse files
committed
fix: support for staged installs (DESTDIR)
Signed-off-by: Leonardo Di Donato <[email protected]>
1 parent 682b377 commit 8802241

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Files are installed under $(DESTDIR)/$(PREFIX)
22
PREFIX ?= /usr/local
3+
DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
34

45
GO ?= go
56

@@ -52,17 +53,19 @@ _output/share/lima/lima-guestagent.Linux-aarch64:
5253

5354
.PHONY: install
5455
install:
55-
cp -av _output/* "$(DESTDIR)/$(PREFIX)/"
56-
if [[ $(shell uname -s ) != Linux && ! -e "$(DESTDIR)/$(PREFIX)/bin/nerdctl" ]]; then ln -sf nerdctl.lima "$(DESTDIR)/$(PREFIX)/bin/nerdctl"; fi
56+
mkdir -p "$(DEST)"
57+
cp -av _output/* "$(DEST)"
58+
if [[ $(shell uname -s ) != Linux && ! -e "$(DEST)/bin/nerdctl" ]]; then ln -sf nerdctl.lima "$(DEST)/bin/nerdctl"; fi
5759

5860
.PHONY: uninstall
5961
uninstall:
62+
@test -f "$(DEST)/bin/lima" || (echo "lima not found in $(DEST) prefix"; exit 1)
6063
rm -rf \
61-
"$(DESTDIR)/$(PREFIX)/bin/lima" \
62-
"$(DESTDIR)/$(PREFIX)/bin/limactl" \
63-
"$(DESTDIR)/$(PREFIX)/bin/nerdctl.lima" \
64-
"$(DESTDIR)/$(PREFIX)/share/lima" "$(DESTDIR)/$(PREFIX)/share/doc/lima"
65-
# TODO: remove $(DESTDIR)/$(PREFIX)/bin/nerdctl only when it is a symlink to nerdctl.lima
64+
"$(DEST)/bin/lima" \
65+
"$(DEST)/bin/limactl" \
66+
"$(DEST)/bin/nerdctl.lima" \
67+
"$(DEST)/share/lima" "$(DEST)/share/doc/lima"
68+
# TODO: remove $(DEST)/bin/nerdctl only when it is a symlink to nerdctl.lima
6669

6770
.PHONY: clean
6871
clean:

0 commit comments

Comments
 (0)