-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganise file layout and install for multiple platforms. #26
Conversation
This commit has two aims. First, install new files (systemd, bash completion) as appropriate: this forces us to drop BSD make compatibility (oh well). Second, regoranise the repository a bit to allow future expansion for other non-Linux platforms, which may also want to include extra files like these.
It works! Though I am unsure this needs to be gated behind a test for Linux -- the systemd files shouldn't cause trouble on other systems, and might serve as useful documentation there. If you insist, perhaps use a
|
Potentially other OSs will also introduce similar files -- I don't think it's useful to install stuff that's not relevant and that might thus confuse people. That said, if systemd starts to become used on non-Linuxes, this might be worth revisiting.
Good point! Fixed in 61aff49.
Also a good point! I hadn't realised the difference. Fixed in e6f54fe.
Good question. Partly just force of habit I think. But, in general, it's hard to go wrong with fewer permissions, so I'll leave that as-is unless doing so causes concrete problems. If those two new commits still work correctly for you (they seem to for me) then I think we'll be good to cut a new release! |
Looking at e6f54fe, I must've been unclear -- the idea is to prefix all the installation target locations with PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man
SHAREDIR ?= $(PREFIX)/share
PYTHON ?= /usr/bin/env python3
# set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
install: lazy-extractors yt-dlp yt-dlp.1 completions
mkdir -p $(DESTDIR)$(BINDIR)
install -m755 yt-dlp $(DESTDIR)$(BINDIR)/yt-dlp
mkdir -p $(DESTDIR)$(MANDIR)/man1
install -m644 yt-dlp.1 $(DESTDIR)$(MANDIR)/man1/yt-dlp.1
mkdir -p $(DESTDIR)$(SHAREDIR)/bash-completion/completions
install -m644 completions/bash/yt-dlp $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
mkdir -p $(DESTDIR)$(SHAREDIR)/zsh/site-functions
install -m644 completions/zsh/_yt-dlp $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
mkdir -p $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d
install -m644 completions/fish/yt-dlp.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish I'm not sure which of these variables (Needless to say, my build system complains that all of this is installing outside of |
e6f54fe
to
f1ecf8d
Compare
You weren't unclear -- I was stupid. See if f1ecf8d makes more sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package linter's only remaining complaint is that my invocation of make
as make PREFIX="/usr" DESTDIR="$pkgdir/" install
places the manpages at /usr/man
where my distro expects /usr/share/man
. Have a few remaining minor remarks, but otherwise LGTM
Makefile
Outdated
@@ -1,20 +1,35 @@ | |||
PREFIX ?= /usr/local | |||
MAN_PREFIX ?= ${PREFIX}/man | |||
BINDIR ?= $(PREFIX)/bin | |||
MANDIR ?= $(PREFIX)/man |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man hier
on my system indicates man pages should be installed either to /usr/local/man
or /usr/share/man
, with /usr/man
being deprecated in favor of /usr/share/man
.
Looking around for prior art on this, I notice that autotools uses (haven't read the rest of the script, so I'm not sure why they're single-quoting here)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man hier on my system indicates man pages should be installed either to /usr/local/man or /usr/share/man, with /usr/man being deprecated in favor of /usr/share/man.
The only way I can see to handle this is some sort of conditional in the Makefile, unless I'm missing out on something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One hack I've seen here to avoid conditionals comes from batsignal
:
MANPREFIX.$(PREFIX)=$(PREFIX)/share/man
MANPREFIX./usr/local=/usr/local/man
MANPREFIX.=/usr/share/man
MANPREFIX=$(MANPREFIX.$(PREFIX))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is very clever! I guess in our context this would become:
MANDIR.$(PREFIX) = $(PREFIX)/share/man
MANDIR./usr/local = /usr/local/man
MANDIR. = /usr/share/man
MANDIR ?= $(MANDIR.$(PREFIX))
?
Makefile
Outdated
install -d ${PREFIX}/share/examples/pizauth | ||
install -c -m 444 pizauth.conf.example ${PREFIX}/share/examples/pizauth | ||
install -d ${DESTDIR}${BINDIR} | ||
install -c -m 555 target/release/pizauth ${DESTDIR}${PREFIX}/bin/pizauth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor remark: could've reused ${BINDIR}
instead of spelling it out again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in abf06e0.
Makefile
Outdated
install -d ${DESTDIR}${SHAREDIR}/pizauth/bash | ||
install -c -m 444 share/bash/completion.bash ${DESTDIR}${SHAREDIR}/pizauth/bash/completion.bash | ||
ifeq ($(PLATFORM), Linux) | ||
install -d ${DESTDIR}${PREFIX}/lib/systemd/user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cf autotools remark above, could introduce a $LIBDIR
variable for this
Makefile
Outdated
install -d ${DESTDIR}${MANDIR}/man5 | ||
install -c -m 444 pizauth.1 ${DESTDIR}${MANDIR}/man1/pizauth.1 | ||
install -c -m 444 pizauth.conf.5 ${DESTDIR}${MANDIR}/man5/pizauth.conf.5 | ||
install -d ${DESTDIR}${SHAREDIR}/examples/pizauth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a BSDism, but on my system pizauth
is the only package installing examples to /usr/share/examples
-- everyone else uses /usr/share/$pkgname
(optionally with an examples
subdirectory`). Can patch this in my packaging if you're attached to this layout.
f093aec introduces |
Already this much makes packaging to Linux standards easier, thank you! |
On Thu, Jan 04, 2024 at 02:42:01AM -0800, Laurence Tratt wrote:
@ltratt commented on this pull request.
> @@ -1,20 +1,35 @@
PREFIX ?= /usr/local
-MAN_PREFIX ?= ${PREFIX}/man
+BINDIR ?= $(PREFIX)/bin
+MANDIR ?= $(PREFIX)/man
That is very clever! I guess in our context this would become:
```
MANDIR.$(PREFIX) = $(PREFIX)/share/man
MANDIR./usr/local = /usr/local/man
MANDIR. = /usr/share/man
MANDIR ?= $(MANDIR.$(PREFIX))
```
?
I _think_ it should work, but haven't tested it on my machine. I do know that
`batsignal`, on my machine, with `PREFIX=/usr`, indeed installs its manpages to
`/usr/share/man`, but I would recommend testing this just to make sure.
|
install -d ${PREFIX}/share/examples/pizauth | ||
install -c -m 444 pizauth.conf.example ${PREFIX}/share/examples/pizauth | ||
install -d ${DESTDIR}${BINDIR} | ||
install -c -m 555 target/release/pizauth ${DESTDIR}${BINDIR}/pizauth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Til this is a BSDism -- both the separation of -d
away from the installation of files, and the use of -c
make little sense under linux, where -D
(combining install -d $dir
and install $file $dir
) exists and -c
is ignored.
https://man.archlinux.org/man/install.1
https://man.freebsd.org/cgi/man.cgi?query=install&sektion=1
Nothing to change, just a TIL
Also use a cunning trick for `MANDIR` (based on an example pointed out to me in batsignal) to select a location that works as expected for both BSD and Linux file systems.
f093aec
to
c79bed0
Compare
@hseg Thanks for your help on this one! |
This commit has two aims. First, install new files (systemd, bash completion) as appropriate: this forces us to drop BSD make compatibility (oh well). Second, regoranise the repository a bit to allow future expansion for other non-Linux platforms, which may also want to include extra files like these.
@hseg Does this still work as you'd expect on Linux?