~sircmpwn/email-test-drive

Fix BSD install error when mixing `-d` and `-C` (via `-p`) v1 PROPOSED

حبيب الأمين: 2
 Fix BSD install error when mixing `-d` and `-C` (via `-p`)
 Fix BSD install error when using `-t` option

 2 files changed, 3 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/email-test-drive/patches/31400/mbox | git am -3
Learn more about email & git

[PATCH 1/2] Fix BSD install error when mixing `-d` and `-C` (via `-p`) Export this patch

>```
>install: the -d and -C options may not be specified together
>```

This is because of the `-p` flag on the first `install` command line;

>```
>     -p      Preserve the modification time.  Copy the file, as if the -C
>             (compare and copy) option is specified, except if the target file
>             doesn't already exist or is different, then preserve the
>             modification time of the file.
>```

This reads to me like the target file will have the same modification
time as the source file, so at first, I thought we're copying
directories across and we want to preserve the modification times of the
directories, but even after a `make`, the directories being installed
don't exist in the repo directory, they're just being created directly
on the target path. Using the `-p` flag is just pointless in this case.
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 07947a0..5565e63 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ clean:
	$(RM) -f hut doc/hut.1 hut.bash hut.zsh hut.fish

install:
	$(INSTALL) -dp \
	$(INSTALL) -d \
		$(DESTDIR)$(PREFIX)/$(BINDIR)/ \
		$(DESTDIR)$(PREFIX)/$(MANDIR)/man1/ \
		$(DESTDIR)$(BASHCOMPDIR) \
-- 
2.35.1

[PATCH 2/2] Fix BSD install error when using `-t` option Export this patch

>```
>install: -t: No such file or directory
>```

BSD install doesn't have the `-t` option, but according to the GNU info
page for `install`:

>```
>   • If the ‘--target-directory’ (‘-t’) option is given, or failing that
>     if the last file is a directory and the ‘--no-target-directory’
>     (‘-T’) option is not given, ‘install’ copies each SOURCE file to
>     the specified directory, using the SOURCEs’ names.
>```

The directories are strictly specified with a trailing slash, and I
suspect if the directory didn't exist, GNU install would still treat
it as a directory and complain about it being missing. That said, we
don't need to rely on that because the previous line which gives us the
error about combining `-C` and `-d` is exactly the line that creates the
required directories.
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 5565e63..90ddaef 100644
--- a/Makefile
+++ b/Makefile
@@ -42,8 +42,8 @@ install:
		$(DESTDIR)$(BASHCOMPDIR) \
		$(DESTDIR)$(ZSHCOMPDIR) \
		$(DESTDIR)$(FISHCOMPDIR)
	$(INSTALL) -pm 0755 hut -t $(DESTDIR)$(PREFIX)/$(BINDIR)/
	$(INSTALL) -pm 0644 doc/hut.1 -t $(DESTDIR)$(PREFIX)/$(MANDIR)/man1/
	$(INSTALL) -pm 0755 hut $(DESTDIR)$(PREFIX)/$(BINDIR)/
	$(INSTALL) -pm 0644 doc/hut.1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1/
	$(INSTALL) -pm 0644 hut.bash $(DESTDIR)$(BASHCOMPDIR)/hut
	$(INSTALL) -pm 0644 hut.zsh $(DESTDIR)$(ZSHCOMPDIR)/_hut
	$(INSTALL) -pm 0644 hut.fish $(DESTDIR)$(FISHCOMPDIR)/hut.fish
-- 
2.35.1