From 4ef1aabd4deafdfe7d559fdb2ba73f83477a52cc Mon Sep 17 00:00:00 2001 From: Kevin Daudt Date: Mon, 31 Jan 2022 09:53:06 +0100 Subject: [PATCH 1/2] Makefile: create parent directories cp requires the destination directories to already exist. If they do not exist, it will fail. When packaging applications, it's common they are installed in an empty directory where the expected directory structure does not exist yet. Use `install -D` to copy the files to copy the files so that parent diretories are automatically created. Signed-off-by: Kevin Daudt --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 928d215..84e3fd8 100644 --- a/Makefile +++ b/Makefile @@ -34,10 +34,11 @@ Documentation/html/git-filter-repo.html: git show origin/docs:html/git-filter-repo.html >Documentation/html/git-filter-repo.html install: snag_docs #fixup_locale - cp -a git-filter-repo "$(bindir)/" + install -Dm0755 git-filter-repo "$(bindir)/git-filter-repo" + install -dm0755 "$(pythondir)" ln -sf "$(bindir)/git-filter-repo" "$(pythondir)/git_filter_repo.py" - cp -a Documentation/man1/git-filter-repo.1 "$(mandir)/man1/git-filter-repo.1" - cp -a Documentation/html/git-filter-repo.html "$(htmldir)/git-filter-repo.html" + install -Dm0644 Documentation/man1/git-filter-repo.1 "$(mandir)/man1/git-filter-repo.1" + install -Dm0644 Documentation/html/git-filter-repo.html "$(htmldir)/git-filter-repo.html" if which mandb > /dev/null; then mandb; fi From e1e418018edef443c3ebb27cb4d71cea6a8b7a39 Mon Sep 17 00:00:00 2001 From: Kevin Daudt Date: Mon, 31 Jan 2022 09:56:14 +0100 Subject: [PATCH 2/2] Makefile: support DESTDIR When packaging applications, the application is commonly installed into a different location than it will end up on the users system. While `prefix` can control where the files will be installed, it also affects the location the `git_filter_repo` symlink points to. If the files are then installed in a different location, the symlink is broken. `DESTDIR` is a de facto standard variable to control where files are installed, so that prefix can be used to specify where the files end up on the end-users system. This allows a usecase like `make install prefix=/usr DESTDIR=pkg`. Signed-off-by: Kevin Daudt --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 84e3fd8..a443450 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ # A bunch of installation-related paths people can override on the command line +DESTDIR = / prefix = $(HOME) bindir = $(prefix)/libexec/git-core localedir = $(prefix)/share/locale @@ -34,11 +35,11 @@ Documentation/html/git-filter-repo.html: git show origin/docs:html/git-filter-repo.html >Documentation/html/git-filter-repo.html install: snag_docs #fixup_locale - install -Dm0755 git-filter-repo "$(bindir)/git-filter-repo" - install -dm0755 "$(pythondir)" - ln -sf "$(bindir)/git-filter-repo" "$(pythondir)/git_filter_repo.py" - install -Dm0644 Documentation/man1/git-filter-repo.1 "$(mandir)/man1/git-filter-repo.1" - install -Dm0644 Documentation/html/git-filter-repo.html "$(htmldir)/git-filter-repo.html" + install -Dm0755 git-filter-repo "$(DESTDIR)/$(bindir)/git-filter-repo" + install -dm0755 "$(DESTDIR)/$(pythondir)" + ln -sf "$(bindir)/git-filter-repo" "$(DESTDIR)/$(pythondir)/git_filter_repo.py" + install -Dm0644 Documentation/man1/git-filter-repo.1 "$(DESTDIR)/$(mandir)/man1/git-filter-repo.1" + install -Dm0644 Documentation/html/git-filter-repo.html "$(DESTDIR)/$(htmldir)/git-filter-repo.html" if which mandb > /dev/null; then mandb; fi