Bug 203157

Summary: [patch] make Mk/Scripts/find-lib.sh error message more readable iff old deprecated expat scripts is found
Product: Ports & Packages Reporter: freebsdpr-20121114
Component: Ports FrameworkAssignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Some People CC: ohauer, ports-bugs
Priority: --- Flags: bugzilla: maintainer-feedback? (apache)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
[patch] Mk/Scripts/find-lib.sh none

Description freebsdpr-20121114 2015-09-16 17:45:51 UTC
I tried building ("make build" in www/apache24) apache24 from the port (to get LDAP support not in the binary package) and it chased the textproc/expat2 dependency and tried to install it from the port even though there was a perfectly usable binary package of expat already installed. The output around the detour was:

===>   apache24-2.4.16_1 depends on executable: libtoolize - found
===>   apache24-2.4.16_1 depends on shared library: libexpat.soEither /usr/share/misc/magic.mime or /usr/share/misc/mime.magic.mgc exist and must be removed.
These are legacy files from an older release and may safely be deleted.
Please see UPDATING 20150213 for more details.
 - not found
===>   expat-2.1.0_3 depends on file: /usr/local/sbin/pkg - found


Note the lack of space after libexpat.so and the 2 file names. I removed /usr/share/misc/magic.mime but /usr/share/misc/mime.magic.mgc did not exist. However /usr/share/misc/magic.mime.mgc DID exist, with the same mtime as /usr/share/misc/magic.mime (suspicious...) 

"make clean ; make build" resulted in the same detour into building expat with the same error message, even though no such files existed. I removed the suspect file, tried again, and the build went perfectly. 

This seems like it is maybe 2 bugs, but I'm not sure:

1. /usr/ports/Mk/Scripts/find-lib.sh looks for files of the correct names, emits an error message with one of them mangled. 

2. The way /usr/ports/Mk/Scripts/find-lib.sh fails, the message it emits, and the resulting upstream reaction of chasing a dependency unnecessarily is not a recipe for least harm. If those obsolete files are so dangerous that they must break port builds, perhaps the check for them should live somewhere higher up where it can be made to break every port build from the start unconditionally.
Comment 1 Olli Hauer freebsd_committer freebsd_triage 2015-09-16 19:21:01 UTC
Created attachment 161123 [details]
[patch] Mk/Scripts/find-lib.sh

Fix find-lib error message by adding an additional new line
Comment 2 Olli Hauer freebsd_committer freebsd_triage 2015-09-16 19:29:43 UTC
In case one of the deprecated files 
- /usr/share/misc/magic.mime 
- /usr/share/misc/mime.magic.mgc 

are still on the system there is no bug (only a cosmetic issue).

IFF there is no deprecated old file on the system then I agree there is a bug.

Please try to follow ports/UPDATING 20150213 (cleanup deprecated files) and report back.
 
Will transfer the PR to portmgr Mk/Scripts is there territory
Provided patch makes the error message more readable.
Comment 3 freebsdpr-20121114 2015-09-16 23:17:57 UTC
(In reply to Olli Hauer from comment #2)

Rephrasing for clarity:

1. /usr/share/misc/mime.magic.mgc NEVER existed. That name is a transposition error (i.e. A BUG) in the error message emitted by /usr/ports/Mk/Scripts/find-lib.sh. That script actually checks for two other files: /usr/share/misc/magic.mime and /usr/share/misc/magic.mime.mgc. When I removed magic.mime, the script still hits that failure mode, but is complaining about 2 files that objectively do not in fact exist, because the error message was (and continues to be in your patch) incorrect. 

2. Removing the two files that find-lib.sh ACTUALLY checks for (one option given in ports/UPDATING-20150213) fixed the build problem and running 'make delete-old' in ${SRCDIR} (the other option given) removed a great number of other files. On a nearly-identical jail which, like this one, had been migrated from a 7.x host, that step done before rebuilding apache24 prevented the problem altogether. 

3. It seems to me (a mere sysadmin trying to keep a jungle of hosts & jails secure and maintainable) that however risky it may be to let old magic data  files lurk (is it really?) it is not rational for their menacing presence to cause the build procedure of a port (ANY port) to determine that a dependency is missing when in objective reality that dependency is quite present. Whether this means the check does not belong in find-lib.sh or whether it means that port builds using that script should check for a non-zero return code rather than just checking for output, I don't know exactly. I think it is perfectly clear that "build a random dependency from its port because there are stale magic files in /usr/share/misc/" is an expression of a BUG, and not a cosmetic issue.
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-12-23 11:50:05 UTC
A commit references this bug:

Author: ohauer
Date: Wed Dec 23 11:49:09 UTC 2015
New revision: 404291
URL: https://svnweb.freebsd.org/changeset/ports/404291

Log:
  - add additional blank line, else the first line of the error message
    is directly appended to the last line from the build output

  deamon@ already fixed the typos in the error message (r404229)

  PR:		203157

Changes:
  head/Mk/Scripts/find-lib.sh
Comment 5 Olli Hauer freebsd_committer freebsd_triage 2015-12-23 11:55:25 UTC
Error message was fixed by deamon@ in r404229