# Illegal group name



## mattia08 (Feb 24, 2014)

Hi everybody.

I'm trying to add a new port but when I do `make stage` I've the following error:


```
chown: mcspigot: illegal group name
*** [do-install] Error code 1

Stop in /usr/ports/games/spigot.
*** [install] Error code 1
```

I've added the user/group as explained here http://www.freebsd.org/doc/en/books/porters-handbook/book.html#users-and-groups and in the work/ dir I found the users-groups.sh file that works if I execute it manually.
What am I doing wrong?


----------



## SirDice (Feb 26, 2014)

What are the user and group names you're trying to add?


----------



## mattia08 (Feb 26, 2014)

SirDice said:
			
		

> What are the user and group names you're trying to add?




I'm trying to add @mcspigot, I've added it in /usr/ports/GIDs and in  /usr/ports/UIDs 

This is my Makefile


```
# Created by: Name
# $FreeBSD$

PORTNAME=       spigot
PORTVERSION=    1.7.2R0.4
CATEGORIES=     games java
MASTER_SITES=   http://ci.md-5.net/view/Spigot/job/Spigot/lastStableBuild/artifact/Spigot-Server/target/
DISTNAME=       spigot-1.7.2-R0.4-SNAPSHOT.jar
EXTRACT_SUFX=
EXTRACT_ONLY=

MAINTAINER=     email@provider.tld
COMMENT=        High performance Server for the block building game Minecraft

LICENSE=        GPLv3

RUN_DEPENDS=    tmux:${PORTSDIR}/sysutils/tmux

NO_WRKSUBDIR=   yes
NO_BUILD=       yes
USE_JAVA=       yes
JAVA_VERSION=   1.7
USERS=          mcspigot
GROUPS=         mcspigot
USE_RC_SUBR=    spigot
SUB_FILES=      pkg-deinstall \
                pkg-message

PLIST_FILES=    share/spigot-1.7.2-R0.4-SNAPSHOT.jar

do-install:
        ${INSTALL_DATA} ${DISTDIR}/spigot-1.7.2-R0.4-SNAPSHOT.jar ${STAGEDIR}${PREFIX}/share/spigot-1.7.2-R0.4-SNAPSHOT.jar
        ${CHOWN} -R ${USERS}:${GROUPS} ${DATADIR}

post-install:
        ${CAT} ${PKGMESSAGE}

.include <bsd.port.mk>
```


----------



## SirDice (Feb 26, 2014)

That should be the correct way, I was wondering if the names perhaps had any characters that were not allowed. What UID and GID did you pick? Maybe that's the conflicting part.


----------



## kpa (Feb 26, 2014)

Your do-install target is now changing the ownership on the actual system and not on the stage directory. This should work better:


```
do-install:
        ${INSTALL_DATA} ${DISTDIR}/spigot-1.7.2-R0.4-SNAPSHOT.jar ${STAGEDIR}${PREFIX}/share/spigot-1.7.2-R0.4-SNAPSHOT.jar
        ${CHOWN} -R ${USERS}:${GROUPS} ${STAGEDIR}${DATADIR}
```

However, I'm not sure if the setting of owner/group should be actually postponed to pkg-plist. The documentation (http://www.freebsd.org/doc/en/books/porters-handbook/users-and-groups.html) suggests that the users and groups are not created until `make install` is performed or the package is installed.


----------



## SirDice (Feb 26, 2014)

kpa said:
			
		

> However, I'm not sure if the setting of owner/group should be actually postponed to pkg-plist. The documentation (http://www.freebsd.org/doc/en/books/porters-handbook/users-and-groups.html) suggests that the users and groups are not created until `make install` is performed or the package is installed.


Perhaps it's better to do the chown(1) at the post-install stage?


----------



## kpa (Feb 26, 2014)

I'm pretty sure that is too a non-supported way. What I've gathered is that all user/group/mode changes should be done in pkg-plist so that make install and installing the package do exactly the same steps.


----------



## kpa (Feb 26, 2014)

I don't have time to test this but something like this:


```
@owner mcspigot
@group mcspigot
%%DATADIR%%
%%DATADIR%%/foobar
....
@owner
@group
```

Of course you have the tedious task of generating the entries for all files installed by your port but the new staging system is really strict about missing and extra files. There's a tool that can help you auto-generate a skeleton pkg-plist, `make makeplist`.


----------



## SirDice (Feb 26, 2014)

kpa said:
			
		

> There's a tool that can help you auto-generate a skeleton pkg-plist, `make makeplist`.


For work I've made a couple of custom packages and I noticed that the makeplist target doesn't exist if there's NO_STAGE in the Makefile. You'd have to generate it the old fashioned way in that case.


----------



## kpa (Feb 26, 2014)

Oh and one thing more, get rid of the `${CAT} ${PKGMESSAGE}` stuff in post-install, showing the message won't work with staging that way and it's done automatically on install now anyway.


----------



## kpa (Feb 26, 2014)

SirDice said:
			
		

> kpa said:
> 
> 
> 
> ...



`make -DNO_STAGE makeplist` ?  :e


----------



## mattia08 (Feb 26, 2014)

SirDice said:
			
		

> That should be the correct way, I was wondering if the names perhaps had any characters that were not allowed. What UID and GID did you pick? Maybe that's the conflicting part.



These are last rows of /usr/ports/GIDs and /usr/ports/UIDs


```
[...]
unifi:*:975:
minetest:*:976:
mcspigot:*:978:
nogroup:*:65533:
nobody:*:65534:
```


```
[...]
unifi:*:975:975::0:0:Unifi Wireless Controller:/nonexistent:/usr/sbin/nologin
minetest:*:976:976::0:0:& server:/nonexistent:/usr/sbin/nologin
tests:*:977:65534::0:0:Unprivileged user for tests:/nonexistent:/usr/sbin/nologin
mcspigot:*:978:978::0:0:Spigot Server:/nonexistent:/bin/sh
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
```

With `make install` I've the same error, I'll try with the pkg-plist.


----------



## mattia08 (Feb 26, 2014)

Thank you guys, with the @kpa's solution it works! 

Doing `port test` (or after normal installation with `make deinstall`) I've this error (`port test` example):


```
pkg-static: unlink(/tmp/spigot-1.7.2R0.4/share/spigot/): Operation not permitted
```


----------

