Bug 190739 - Building libunbound writes to /usr/src
Summary: Building libunbound writes to /usr/src
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Dag-Erling Smørgrav
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-07 01:03 UTC by Peter Jeremy
Modified: 2014-08-23 11:47 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Jeremy freebsd_committer 2014-06-07 01:03:54 UTC
Running "make depend" in /usr/src/lib/libunbound attempts to rewrite /usr/src/contrib/unbound/util/configparser.c  This fails if /usr/src is read-only.

This looks similar to http://lists.freebsd.org/pipermail/freebsd-hackers/2013-October/043627.html but there was no followup to that mail and the problem is still present in -current.

To reproduce:
1) Make /usr/src read-only
2) Run:
 $ cd /usr/src/lib/libunbound
 $ make obj
 $ make depend

I get:
yacc -d /usr/src/lib/libunbound/../../contrib/unbound/util/configparser.y
mv y.tab.c /usr/src/lib/libunbound/../../contrib/unbound/util/configparser.c
override rw-r--r--  root/wheel for /usr/src/lib/libunbound/../../contrib/unbound/util/configparser.c? (y/n [n]) y
mv: rename y.tab.c to /usr/src/lib/libunbound/../../contrib/unbound/util/configparser.c: Read-only file system
*** Error code 1

Stop.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2014-06-15 04:40:58 UTC
Notify most recent committer to libunbound/Makefile.
Comment 2 Herbert J. Skuhra 2014-07-17 15:09:40 UTC
I have a similar issue on stable/10 (r267569) trying to build r268791, but only on one machine.

Permissions of /usr/src on both machines are:
 
drwxr-xr-x  24 root  wheel   32 Jul 16 16:21 src

And /usr/src is not mounted read-only.

Also the permissions of configparser.c and util directory is the same:

% find . -name "configparser.c" -ls
7999087      164 -rw-r--r--    1 root                             wheel                               83337 Jul  2 10:48 ./contrib/unbound/util/configparser.c

drwxr-xr-x   4 root  wheel    1024 Jul  2 10:48 util

I am asked to override the file during buildworld:

override rw-r--r-- root/wheel for /usr/src/lib/libunbound/../../contrib/unbound/util/configparser.c? (y/n [n])

On the working machine:

- I don't find the yacc command in the build.log
- configparser.c is unchanged and also not writeable for the user

I haven't yet figured out why it tries to update configparser.c only on this machine.

Is the command executed from contrib/unboud/freebsd-configure.sh? Can it be removed?

Index: contrib/unbound/freebsd-configure.sh
===================================================================
--- contrib/unbound/freebsd-configure.sh        (revision 268797)
+++ contrib/unbound/freebsd-configure.sh        (working copy)
@@ -41,4 +41,3 @@
 /usr/bin/flex -L -t util/configlexer.lex
 } >util/configlexer.c
 
-/usr/bin/yacc -d -o util/configparser.c util/configparser.y
Comment 3 Dag-Erling Smørgrav freebsd_committer 2014-07-18 09:49:50 UTC
freebsd-configure.sh is only used when importing a new version of unbound.

The problem is that make has builtin rules for lex and yacc that can't be turned off.  Most people don't run into this because their configparser.c is newer (or at least not older) than configparser.y, but sometimes svn plays a trick on you and suddenly make wants to regenerate configparser.c.  Fixing this is not simply a matter of removing configlexer.c and configparser.c from the repo, because make's builtin rules won't produce working code in this case.  As a workaround, make sure that configlexer.c and configparser.c are newer than configlexer.lex and configparser.y.
Comment 4 commit-hook freebsd_committer 2014-07-19 18:39:47 UTC
A commit references this bug:

Author: des
Date: Sat Jul 19 18:38:50 UTC 2014
New revision: 268883
URL: http://svnweb.freebsd.org/changeset/base/268883

Log:
  Clean up the libunbound build to avoid accidentally regenerating the
  configuration lexer and parser during buildworld.  Instead of being
  included in the source as it is in the upstream distribution, the code is
  now always generated (in ${.OBJDIR}) at build time.

  PR:		190739
  MFC after:	1 week

Changes:
  head/contrib/unbound/freebsd-configure.sh
  head/contrib/unbound/util/config_file.c
  head/contrib/unbound/util/configlexer.c
  head/contrib/unbound/util/configlexer.lex
  head/contrib/unbound/util/configparser.c
  head/contrib/unbound/util/configparser.h
  head/contrib/unbound/util/configparser.y
  head/lib/libunbound/Makefile
Comment 5 Dag-Erling Smørgrav freebsd_committer 2014-08-23 11:47:06 UTC
Merged to 10 in r269257 on 2014-07-29.