# dovecot2 build error on 9.2-RELEASE



## pacija (Oct 2, 2013)

I have upgraded one of my i386 servers to 9.2-RELEASE with `freebsd-update`. I am also rebuilding all ports with `portmaster -afd`, but mail/dovecot2 fails:


```
===>   Registering installation for dovecot-2.2.6
pkg-static: unknown keyword stopdaemon, ignoring @stopdaemon
pkg-static: lstat(/usr/ports/mail/dovecot2/work/stage/usr/local/etc/dovecot/): No such file or directory
*** [fake-pkg] Error code 74

Stop in /usr/ports/mail/dovecot2.
*** [install] Error code 1

Stop in /usr/ports/mail/dovecot2.
```

Any ideas what to do?


----------



## johnblue (Oct 3, 2013)

pacija said:
			
		

> I am also rebuilding all ports with `portmaster -afd`, but mail/dovecot2 fails:
> 
> Any ideas what to do?


Hrmmm. Well. I am shooting from the hip here, but I wonder if the "d" option is causing problems. Perhaps `portmaster -afDR` will get Dovecot successfully rebuilt with "D" being do not delete and "R" does not rebuild ports already rebuilt on previous runs.

Another option that you have is to do a complete reinstall of all of the ports. It is a bit much, but an option none the less.

Hope that helps!


----------



## ShelLuser (Oct 3, 2013)

pacija said:
			
		

> ```
> ===>   Registering installation for dovecot-2.2.6
> pkg-static: unknown keyword stopdaemon, ignoring @stopdaemon
> pkg-static: lstat(/usr/ports/mail/dovecot2/work/stage/usr/local/etc/dovecot/): No such file or directory
> ...


It almost looks to me as if there's some error in the part where the package is being registered with the system.

In the mean time I tried to reproduce the error, and what do you know...


```
===>   Registering installation for dovecot-2.2.6
pkg-static: unknown keyword stopdaemon, ignoring @stopdaemon
pkg-static: lstat(/usr/ports/mail/dovecot2/work/stage/usr/local/etc/dovecot/): No such file or directory
*** [fake-pkg] Error code 74
```
I guess this answers my (removed) second question if you've been using pkgng. According to pkg-static(8) this is part of the new set of tools.

But after 'ruining' my jail (by removing pkgng and forcing the environment to go back to the pkg_* set of tool, not recommended for a production system! ) I can confirm that this has nothing to do with the package environment but more so the port itself:


```
===>  Building package for dovecot-2.2.6
Creating package /usr/ports/mail/dovecot2/work/dovecot-2.2.6.tbz
Registering depends:.
Registering conflicts: dovecot-1.[0-9]*.
pkg_create: read_plist: unknown command '@stopdaemon dovecot' (package tools out of date?)
pkg_create: read_plist: unknown command '@dirrmtry lib/dovecot/auth' (package tools out of date?)
pkg_create: read_plist: unknown command '@dirrmtry etc/dovecot' (package tools out of date?)
pkg_create: write_plist: unknown command type -1 (dovecot)
```
So the obvious solution is to either stick with mail/dovecot or contact the port maintainer to inform him about this problem.


----------



## xtaz (Oct 3, 2013)

You say that, but I'm using this port without any issues. I've never used `pkgng` on my system and mail/dovecot2 installs perfectly fine:


```
===>  Building package for dovecot-2.2.6
Creating package /usr/obj/usr/ports/mail/dovecot2/work/dovecot-2.2.6.tbz
Registering depends: libiconv-1.14_1.
Registering conflicts: dovecot-1.[0-9]*.
Creating bzip'd tar ball in '/usr/obj/usr/ports/mail/dovecot2/work/dovecot-2.2.6.tbz'
===>  Installing for dovecot-2.2.6
===> Creating users and/or groups.
```


----------



## ShelLuser (Oct 3, 2013)

An interesting point @xtaz! I can't rule out that I sort of trashed my jail up there (the packaging system anyway), so I'll give this another attempt later when I have restored the pkg_* database.

But I agree; right now it looks like a specific pkgng related issue.


----------



## EasyTarget (Oct 3, 2013)

*workaround*

The latest update (on the 1st Oct) addes stage support to this port; but the implementation appears to have issues in some circumstances. A brief glance at the Makefile makes me wonder if it was only partially implemented, but I'm speculating; although it led me to a workaround.

If (like me) this failure has left you without a working mail solution here is an quick/dirty/easy workaround until the port maintainer gets a permanent fix implemented. Disable staging in the port by inserting: 

```
NO_STAGE=       yes
```
 to the Makefile at /usr/ports/dovecot2/Makefile in the local declarations, eg. at line 57. 

The port then built correctly, and (after I had rebuilt the corresponding dependent port(s); mail/dovecot2-pigeonhole in my case), I was able to start and use Dovecot again.


----------



## kpa (Oct 3, 2013)

I think you can also set the NO_STAGE variable on the make(1) command line: `make -DNO_STAGE install clean`. With ports-mgmt/portmaster the -m option can be used to pass options to make(1): `portmaster -m "-DNO_STAGE" mail/dovecot2`


----------



## pacija (Oct 3, 2013)

I also suspected this is due to staging. So I visited the StageDir page and looked at the "TIPS and TRICKS" section, which gave me an idea not to do the usual `make install clean`, but to work in stages.

`make configure` - finished fine
`make stage` - finished fine
`make check-orphans` - finished fine
`make package` - this is where I got the error:

```
pkg-static: lstat(/usr/ports/mail/dovecot2/work/stage/usr/local/etc/dovecot/): No such file or directory
```

So I created the directory manually: `mkdir /usr/ports/mail/dovecot2/work/stage/usr/local/etc/dovecot/` and repeated `make package` which finished fine this time. Finally, `make install` finished fine, and so did `make clean`.

I have my mail server back


----------



## chrcol (Oct 22, 2013)

I am seeing this issue on the mariadb55 port also. Someone playing testing games with the ports system?


----------



## T-Aoki (Oct 24, 2013)

Staging should have some problems. In case of sysutils/kiconvtool, it installed the /usr/local/etc/rc.d/kiconv script which has an erroneous line below.


```
command="/usr/ports/sysutils/kiconvtool/work/stage/usr/local/sbin/kiconvtool"
```

It must be as below to work:


```
command="/usr/local/sbin/kiconvtool"
```

I can't determine how this happens, but it should be a staging problem.


----------



## kpa (Oct 24, 2013)

T-Aoki said:
			
		

> Staging should have some problems. In case of sysutils/kiconvtool, it installed the /usr/local/etc/rc.d/kiconv script which has an erroneous line below.
> 
> 
> ```
> ...



Most likely the Makefile of the port uses some magic to automatically edit the paths in the rc(8) script but instead of using the correct PREFIX variable for the editing it uses DESTDIR.  Under staging the DESTDIR variable is set to the temporary staging directory so that make install will install the files in the stage directory instead of installing them over the running system. This is analogous to "cross building" for another system that is mounted at some directory on the build host (let's say /mnt) and setting DESTDIR to that directory.  This has worked quite well on FreeBSD system sources afaik but it has never worked properly on large part of the ports before. So yes, the ports system has been very badly broken in this regard for a long time.

 Please report this kind of problems to the port maintainers and/or to the freebsd-ports mailing list. The port maintainers or the portmgr@ people rarely read these forums.


----------



## kpa (Oct 31, 2013)

I poked around the Makefile of the port and the error is obvious, the latest change to it makes PREFIX equal to ${STAGEDIR}${PREFIX} that is just wrong. Try the attached patch, apply it at the port directory with `patch  -p0 </path/to/patchfile.txt`.


----------



## kpa (Oct 31, 2013)

I submitted a PR with this patch, committed today:

http://www.freebsd.org/cgi/query-pr.cgi?pr=183518


----------



## johnblue (Nov 7, 2013)

kpa said:
			
		

> I submitted a PR with this patch, committed today:
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=183518


Nice work @kpa.


----------

