Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 468952

Summary: libtool.eclass depends on GNU chown - not available on all platforms
Product: Gentoo/Alt Reporter: Christian Bricart <christian>
Component: FreeBSDAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED OBSOLETE    
Severity: normal CC: bsd+disabled, douglas.miller, prokennexusa
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: FreeBSD   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: proposed implementation of estat

Description Christian Bricart 2013-05-07 21:57:07 UTC
this patch in libtool.eclass broke portage in e.g. fbsd:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/libtool.eclass?r1=1.102&r2=1.103

it introduced: "chown --reference=..." - which is a GNU extension and not available in i.e chown from sys-freebsd/freebsd-usbin



Reproducible: Always

Steps to Reproduce:
# equery belongs $(which chown)  
 * Searching for /usr/sbin/chown ... 
sys-freebsd/freebsd-usbin-9.1 (/usr/sbin/chown)
# emerge -v dev-libs/libgpg-error

on Portage 2.2.0_alpha174 (default/bsd/fbsd/amd64/9.1, gcc-4.6.3, freebsd-lib-9.1, 9.1-RELEASE amd64)
# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.105 2013/05/07 14:23:33 vapier Exp $

Actual Results:  
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] dev-libs/libgpg-error-1.11  USE="nls -common-lisp -static-libs" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-libs/libgpg-error-1.11
 * libgpg-error-1.11.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                              [ ok ]
>>> Unpacking source...
>>> Unpacking libgpg-error-1.11.tar.bz2 to /var/tmp/portage/dev-libs/libgpg-error-1.11/work
>>> Source unpacked in /var/tmp/portage/dev-libs/libgpg-error-1.11/work
>>> Preparing source in /var/tmp/portage/dev-libs/libgpg-error-1.11/work/libgpg-error-1.11 ...
 * Running elibtoolize in: libgpg-error-1.11/
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
 *   Applying portage/1.2.0 patch ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
 *   Applying sed/1.5.6 patch ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
 *   Applying as-needed/2.4.2 patch ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
 *   Applying target-nm/2.4.2 patch ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
 *   Applying fbsd-conf/00broken-libglade patch ...
chmod: illegal option -- -
usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-libs/libgpg-error-1.11/work/libgpg-error-1.11 ...
 * ERROR: dev-libs/libgpg-error-1.11 failed (configure phase):
 *   configure is not executable
 * 
 * Call stack:
 *          ebuild.sh, line   93:  Called src_configure
 *        environment, line 1109:  Called econf '--enable-nls' '--disable-static' '--disable-languages'
 *   phase-helpers.sh, line  524:  Called die
 * The specific snippet of code:
 *   		die "configure is not executable"
 * 
 * If you need support, post the output of `emerge --info '=dev-libs/libgpg-error-1.11'`,
 * the complete build log and the output of `emerge -pqv '=dev-libs/libgpg-error-1.11'`.
 * The complete build log is located at '/var/tmp/portage/dev-libs/libgpg-error-1.11/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-libs/libgpg-error-1.11/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-libs/libgpg-error-1.11/work/libgpg-error-1.11'
 * S: '/var/tmp/portage/dev-libs/libgpg-error-1.11/work/libgpg-error-1.11'

>>> Failed to emerge dev-libs/libgpg-error-1.11, Log file:

>>>  '/var/tmp/portage/dev-libs/libgpg-error-1.11/temp/build.log'
Comment 1 Alexis Ballier gentoo-dev 2013-05-08 14:23:27 UTC
@base system, I can't think of anything better atm but what about:

local perms="$(find ${file} -maxdepth 0 -printf '%m')"

...

chmod ${perms} ${file}


its not very satisfactory but since we require gnu find, stat is rarely portable and not required to be gnu, it should work on every system; it also saves using a temp file.
Comment 2 SpanKY gentoo-dev 2013-05-08 15:35:30 UTC
(In reply to comment #1)

i'd add a function to portability.eclass called "chmod_reference" and once that's in place, we can cut libtool.eclass over to it
Comment 3 Alexis Ballier gentoo-dev 2013-05-08 16:35:15 UTC
(In reply to comment #2)
> (In reply to comment #1)
> 
> i'd add a function to portability.eclass called "chmod_reference" and once
> that's in place, we can cut libtool.eclass over to it

do you really want this or rather some push perms / pop perms mechanism ?
cp -p for saving the perms isn't terribly beautiful either
Comment 4 SpanKY gentoo-dev 2013-05-08 20:29:27 UTC
(In reply to comment #3)

a generic stack doesn't make sense.  i would have used `stat -c %a`, but i know BSD's stat program is utterly worthless and doesn't support that either.

probably a stat helper where you can give it the format as expected by GNU stat would be sufficient:
  estat %a <files>
Comment 5 Alexis Ballier gentoo-dev 2013-05-08 22:22:43 UTC
(In reply to comment #4)

and then the above find command does precisely this, with the advantage of not needing a wrapper, esp. a wrapper that needs to convert printf format strings...
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2013-05-09 01:26:15 UTC
*** Bug 469128 has been marked as a duplicate of this bug. ***
Comment 7 SpanKY gentoo-dev 2013-05-09 04:16:19 UTC
(In reply to comment #5)

i don't want to inline BSD workarounds everywhere.  hence my suggestion to write something for portability.eclass.
Comment 8 Alexis Ballier gentoo-dev 2013-05-09 07:16:52 UTC
(In reply to comment #7)

fair enough, but please explain me how you would write this estat function because I have no clue how to write a parser for the format specifiers.

OTOH, its not really a "workaround" but rather a fix to use what we are guaranteed to have and not something system dependent (we require gnu find, I couldn't find a posix manpage for stat and while most stat(1) will have equivalent basic features the syntax differs a lot between systems)
Comment 9 SpanKY gentoo-dev 2013-05-09 22:10:49 UTC
(In reply to comment #8)

`stat` isn't covered by POSIX.  BSD's stat has a format specification similar to 
GNU's stat, just the format specifiers are completely different.

i would start simple and accept just 1 field rather than a whole format string (`estat %a`).  then do a case statement to map the GNU form.

local fmt=$1; shift
if <gnu stat>; then
  stat -c "${fmt}" "$@"
else
  case ${fmt} in
  %a) ...find...
  *) die "unhandled form";;
  esac
fi
Comment 10 Christian Bricart 2013-05-10 06:57:27 UTC
are all $USE variables available in eclasses?
so may be something practical to switch for GNU tools available?:

  use userland_GNU && do_something_in_GNU_tools_syntax || do_something_in_BSD_syntax

second, would be parsing output from `ls -l` be more portable..?
Comment 11 Naohiro Aota gentoo-dev 2013-05-10 08:51:16 UTC
*** Bug 469250 has been marked as a duplicate of this bug. ***
Comment 12 Alexis Ballier gentoo-dev 2013-05-10 10:53:17 UTC
(In reply to comment #10)

nah, its better to do sth like 'stat --help | grep -q GNU' to determine it so that we don't need to declare userland in IUSE.
also, if you want something reliable you don't want to parse ls output


(In reply to comment #9)

sounds sane enough for one format specifier; I'd like to have some kind of spec for this function though, so that'd be: format specifiers are the one from gnu stat; format specifiers are more limited but estat can be extended at will. Then I don't really see how to handle more complex format specifiers (which was what my question was about actually): how to parse formats like '%a%A%b' or '%a foo %b'? I tend to think we'll need to restrict it to only one format specifier.
Comment 13 prokennexusa 2013-05-10 23:59:56 UTC
Do you have any workaround or patch until you are able to deply a fix? I am unable to emerge any software at the moment, so in essance I am 'system down'.
Comment 14 Alexis Ballier gentoo-dev 2013-05-11 11:19:01 UTC
(In reply to comment #13)

I committed the find workaround; it's technically better than cp -p and the estat idea is nice but I still don't have a precise idea of how to do it. We can add the estat function and use it later without breaking users systems anyway.
Comment 15 prokennexusa 2013-05-11 13:49:39 UTC
(In reply to comment #14)
> (In reply to comment #13)
> 
> I committed the find workaround; it's technically better than cp -p and the
> estat idea is nice but I still don't have a precise idea of how to do it. We
> can add the estat function and use it later without breaking users systems
> anyway.

Alexis Ballier,

Thank you for the quick fix, I will sync my Portage tree now.
Comment 16 SpanKY gentoo-dev 2013-05-13 04:45:30 UTC
(In reply to comment #14)

your code has wrong quoting, the maxdepth makes no sense, and i'm still not interested in inlining BSD workarounds in code.  implement the estat idea before i punt this crap.
Comment 17 Alexis Ballier gentoo-dev 2013-05-13 10:09:09 UTC
(In reply to comment #16)

I understood that, but there is no point in completely breaking users' system meanwhile.

If an estat function with only one format specifier allowed is fine by you, then this can be done quickly. Otherwise, my questions from comment #12 still stand: such a function can be easily extended to more format specifiers, but it seems much harder to extend it to a whole printf format ('%a foo %a').
Comment 18 Alexis Ballier gentoo-dev 2013-05-13 11:02:11 UTC
Created attachment 348154 [details, diff]
proposed implementation of estat

.
Comment 19 Alexis Ballier gentoo-dev 2013-05-13 11:23:08 UTC
(In reply to comment #18)
> Created attachment 348154 [details, diff] [details, diff]
> proposed implementation of estat

note: this implementation is done as such on purpose to guarantee the same output and behavior regardless of the underlying system; yours wasnt portable in that sense.
Comment 20 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-10-11 17:37:17 UTC
*-fbsd is gone.