Give ownership of a directory to a user created by the port

Hello,

I am trying to write a port that creates a user _xd and a group _xd (added as 839 in UIDs and GIDs) and gives them ownership of the configuration directory ${PREFIX}/etc/xd-torrent added by the port. The software creates sample config files if they don't exist and updates one of the files from time to time, so it needs to have write access to the directory and its content.

I added the following in the Makefile:
Code:
USERS=  _xd
GROUPS= _xd
# [...]
post-install:
    # [...]
    @${MKDIR} ${STAGEDIR}${PREFIX}/etc/xd-torrent
    @${CHOWN} ${USERS}:${GROUPS} ${STAGEDIR}${PREFIX}/etc/xd-torrent

However, when I run make package, it fails with the following:
Code:
chown: _xd: illegal group name
*** Error code 1

Stop.
make: stopped in /usr/ports/net-p2p/xd-torrent

I'm assuming it's because make is trying to chmod the directory in the staging location before the user and group are created (this happens when the package is installed). I tried placing these commands in the pkg-post-install target instead, but it didn't seem to be doing anything.

How should one approach this problem? Thank you for your help
 
As far as I know you don't handle that in the Makefile but let pkg deal with it, courtesy of pkg-list. See also pkg-create(8), in specific the section about the PLIST format.

So during the build process you don't bother with any of this, but specify what needs to be done during installation with keys like @dir and @mode.
 
Back
Top