Skip to content

Commit

Permalink
Install files as current user respecting DESTDIR (#2)
Browse files Browse the repository at this point in the history
* Install files as current user respecting DESTDIR

Poudriere expects to be able to build and install any package into a
staging area as non-root.  pkg(8) will sort out the permissions based
on settings in the plist.

This should also work correctly if installing directly from the github
sources: you would need to become root before running 'make install'
in any case, and consequently all the files would end up with
root:wheel ownership as expected.

* Don't require `make all` before `make install`

Ports always runs separate commands for each stage of building and
packaging the port, but other users (like github CI) may assume `make
install` does everything.
  • Loading branch information
infracaninophile authored Apr 17, 2023
1 parent d6b9eb4 commit c0734f9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,41 @@ CONFDIR= ${PREFIX}/etc
LIBEXECDIR= ${PREFIX}/libexec
SHAREDIR= ${PREFIX}/share

DIRS= SCRIPTSDIR

SCRIPTS= dynamic_motd
SCRIPTSDIR= ${LIBEXECDIR}

FILESGROUPS= DOCS EXAMPLES

DOCS= CONTRIBUTING.md README.md
DOCSDIR= ${SHAREDIR}/doc/dynamic_motd

EXAMPLES= examples/motd.subr examples/rc.motd
EXAMPLESDIR= ${SHAREDIR}/examples/dynamic_motd

CONFGROUPS= CONFETC CONFRCD

CONFETC= rc.motd.sample

CONFRCD= rc.d/dynamic_motd
CONFRCDDIR= ${CONFDIR}/rc.d
CONFRCDMODE= ${BINMODE}

CLEANFILES= rc.d/dynamic_motd
PREFIX_SUB= -e 's,@@PREFIX@@,${PREFIX},g'

INSTALL_DATA= install -m 0644
INSTALL_SCRIPT= install -m 0555
MKDIR= mkdir -p

all: rc.d/dynamic_motd

rc.d/dynamic_motd: rc.d/dynamic_motd.in
sed ${PREFIX_SUB} ${.ALLSRC} >${.TARGET}

beforeinstall: installdirs
afterinstall: installconfig
install: all installdirs
${INSTALL_SCRIPT} ${CONFRCD} ${DESTDIR}${CONFRCDDIR}
${INSTALL_DATA} ${CONFETC} ${DESTDIR}${CONFDIR}
${INSTALL_SCRIPT} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}
${INSTALL_DATA} ${DOCS} ${DESTDIR}${DOCSDIR}
${INSTALL_DATA} ${EXAMPLES} ${DESTDIR}${EXAMPLESDIR}

installdirs:
.for dir in ${CONFRCDDIR} ${CONFDIR} ${SCRIPTSDIR} ${DOCSDIR} ${EXAMPLESDIR}
${MKDIR} ${DESTDIR}${dir}
.endfor

.include <bsd.prog.mk>

0 comments on commit c0734f9

Please sign in to comment.