Bug 231554

Summary: sysutils/file returns mime type which Mk/Scripts/find-lib.sh doesn't recognise
Product: Ports & Packages Reporter: hostmaster
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: hostmaster, jharris, joel, portmgr
Priority: --- Flags: bugzilla: maintainer-feedback? (jharris)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patches /usr/ports/Mk/Scripts/find-lib.sh to use absolute path for "file" none

Description hostmaster 2018-09-21 16:47:31 UTC

    
Comment 1 hostmaster 2018-09-21 17:25:43 UTC
When sysutils/file is installed, Mk/Scripts/find-lib.sh ends up using it if $PATH puts /usr/local/bin first - the result is that it gives this:

> file -b -L --mime-type /usr/local/lib/liblzo2.so
application/x-pie-executable

rather than what /usr/bin/file gives:

> /usr/bin/file -b -L --mime-type /usr/local/lib/liblzo2.so
application/x-sharedlib

When /usr/local/bin/file is used, this test in Mk/Scripts/find-lib.sh fails:

[ "$(file -b -L --mime-type ${libfile})" = "application/x-sharedlib" ]


So, when any port Makefile uses the "LIB_DEPENDS= " construct, the port incorrectly rebuilds the dependency because it is marked as non-existent


Suggested fixes: 

1. use absolute path in Mk/Scripts/find-lib.sh:

[ "$(/usr/bin/file -b -L --mime-type ${libfile})" = "application/x-sharedlib" ]

2. change test to also recognise "application/x-pie-executable" as a valid shared library object

3. change sysutils/file to return "application/x-sharedlib" when a FreeBSD lib*.so shared library object is encountered

4. all of the above
Comment 2 hostmaster 2018-09-21 17:58:12 UTC
update to comment #1

"the port incorrectly rebuilds the dependency because it is marked as non-existent"

should read:

"the port incorrectly rebuilds an existing dependency because it is always marked as non-existent"


Also the issue showed up via this forum:

https://forum.iredmail.org/topic14696-install-iredmail098-on-fresh-freebsd-112.html
Comment 3 Antoine Brodin freebsd_committer freebsd_triage 2018-09-21 18:53:55 UTC
Don't install file from ports or submit a patch to fix the file port.
Comment 4 hostmaster 2018-09-21 19:52:48 UTC
the  iRedMail distro invokes the sysutils/file option for the security/amavisd-new port since it's more accurate/up-to-date with respect to email body attachments - it's not likely that they would back away from that

in my first comment i made a suggestion which could easily become a patch - it needs to be discussed first to determine which of any or all of the suggestions made would be most apropos
Comment 5 hostmaster 2018-09-21 19:53:34 UTC
reopening this since it needs discussion first
Comment 6 hostmaster 2018-09-21 20:15:51 UTC
Created attachment 197320 [details]
patches /usr/ports/Mk/Scripts/find-lib.sh to use absolute path for "file"


this patches /usr/ports/Mk/Scripts/find-lib.sh to use absolute path for "file"
Comment 7 hostmaster 2018-09-21 20:32:27 UTC
here is an implementation of suggestion 2. above:

https://www.mail-archive.com/svn-src-all@freebsd.org/msg163025.html


suggestion 3. would need the sysutils/file port maintainer to suggest a fix
Comment 8 Joel Lopes Da Silva 2018-10-06 04:00:53 UTC
With the new version of pkg and the large number of new port updates that seems to have been released today for FreeBSD 11.2, I can reproduce this bug on my machine. I would love to see hostmaster@GTS.NET's solution #1 integrated into FreeBSD. It seems like it would avoid a lot of confusion for countless users in the future.
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-10-06 08:19:26 UTC
A commit references this bug:

Author: antoine
Date: Sat Oct  6 08:19:19 UTC 2018
New revision: 481327
URL: https://svnweb.freebsd.org/changeset/ports/481327

Log:
  Use full path to file(1) from base as sysutils/file is buggy

  PR:		231554

Changes:
  head/Mk/Scripts/find-lib.sh