Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 489170 - app-arch/tar-1.27.1[xattr]: Incorrect dependency / Needless usage of attr/xattr.h
Summary: app-arch/tar-1.27.1[xattr]: Incorrect dependency / Needless usage of attr/xat...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://savannah.gnu.org/patch/index....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-23 15:19 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2014-01-10 08:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Use <sys/xattr.h> and link against libc OR use <attr/xattr.h> and link against libattr.so (tar-1.27.1-sys-attr.patch,4.35 KB, patch)
2013-11-28 20:28 UTC, Anthony Basile
Details | Diff
Patch as submitted upstream. (0001-Fix-build-with-xattr-support.patch,4.12 KB, patch)
2013-12-06 19:32 UTC, Anthony Basile
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2013-10-23 15:19:05 UTC
app-arch/tar-1.27-r1 has "xattr? ( sys-apps/attr )" in DEPEND and RDEPEND, but actually this dependency is currently needed only at build time. Installed executables do not use sys-apps/attr.

Build system tries to find only attr/xattr.h (from sys-apps/attr) and not sys/xattr.h (from sys-libs/glibc).

Build system does not try to link against libattr.so (from sys-apps/attr), so functions from libc.so are actually used.

(See bug #382067 for similar problem in the past...)
Comment 1 Arfrever Frehtes Taifersar Arahesis 2013-10-23 18:05:35 UTC
Build system should look for both sys/xattr.h, and if it is not found, then for attr/xattr.h. When only attr/xattr.h is found, then build system should enable linking against -lattr.
Ebuild should have "!elibc_glibc? ( xattr? ( sys-apps/attr ) )" dependency.

Source files should have something similar to:

#if defined(HAVE_SYS_XATTR_H)
#include <sys/xattr.h>
#elif defined(HAVE_ATTR_XATTR_H)
#include <attr/xattr.h>
#endif
Comment 2 Anthony Basile gentoo-dev 2013-10-24 00:13:12 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #1)
> Build system should look for both sys/xattr.h, and if it is not found, then
> for attr/xattr.h. When only attr/xattr.h is found, then build system should
> enable linking against -lattr.
> Ebuild should have "!elibc_glibc? ( xattr? ( sys-apps/attr ) )" dependency.
> 
> Source files should have something similar to:
> 
> #if defined(HAVE_SYS_XATTR_H)
> #include <sys/xattr.h>
> #elif defined(HAVE_ATTR_XATTR_H)
> #include <attr/xattr.h>
> #endif

Correct, because on a uclibc system you need that dependency.
Comment 3 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-10-24 06:47:15 UTC
So please provide a working patch here and/or report this upstream.

Meanwhile I added tar-1.27-r2 to the tree where sys-apps/attr was moved from RDEPEND to DEPEND.
Comment 4 Anthony Basile gentoo-dev 2013-11-28 19:31:20 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #3)
> So please provide a working patch here and/or report this upstream.
> 
> Meanwhile I added tar-1.27-r2 to the tree where sys-apps/attr was moved from
> RDEPEND to DEPEND.

Okay I've got a patch and ebuild on the hardened-dev::uclibc overlay.  For the patch take a look at:

http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=blob;f=app-arch/tar/files/tar-1.27.1-sys-attr.patch;h=d999fd91c34995130e39e4a9e33c5c8f72f21425;hb=bab4d804668603d12366ee3d0d5e295dbebf39b8

and for the ebuild take a look at 

http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=blob;f=app-arch/tar/tar-1.27.1-r99.ebuild;h=c8a8853fa42298bfb22b8a0c5367c2dd11c5b993;hb=bab4d804668603d12366ee3d0d5e295dbebf39b8

We should probably push the patch upstream.  Let me do some testing first.
Comment 5 Anthony Basile gentoo-dev 2013-11-28 20:23:27 UTC
There was a slight error in that patch.  I'll upload a better one in a minute.  But here are the results of my testing of the 4 possible combinations: xattrs provided by uclibc X xattrs provided by sys-apps/attr:


1) Both sources of xattr:

	uclibc with UCLIBC_HAS_XATTR=y
	libattr.so from sys-apps/attr


a) both header available, but only <sys/attr.h> used, as expected.

uclibc # cat config.h | grep XATTR_H
/* #undef HAVE_ATTR_XATTR_H */
#define HAVE_SYS_XATTR_H 1


b) symbols link against uclibc, as expected:

uclibc# ldd /bin/tar 
checking sub-depends for '/lib/libiconv.so.2'
checking sub-depends for '/usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1'
checking sub-depends for '/lib/libc.so.0'
	libiconv.so.2 => /lib/libiconv.so.2 (0x00000000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1 (0x00000000)
	libc.so.0 => /lib/libc.so.0 (0x00000000)
	/lib/ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x00000000)

uclibc# readelf -sW /bin/tar  | grep attr
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND llistxattr
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lsetxattr
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgetxattr
    90: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND listxattr
   131: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lgetxattr
   150: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setxattr
   168: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND flistxattr
   193: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getxattr
   305: 0000000000279190     4 OBJECT  GLOBAL DEFAULT   24 xattrs_option


c) Works:

uclibc yellow ~ # tar --xattrs -xf zzz.tar 
uclibc yellow ~ # getfattr -d zzz/zzz 
# file: zzz/zzz
user.hi="hi"

================================================================================

2) Only uclibc as a source:

	uclibc with UCLIBC_HAS_XATTR=y
	un-emerged sys-apps/attr


a) only <sys/attr.h> available and used, as expected:

uclibc# cat config.h | grep XATTR_H
/* #undef HAVE_ATTR_XATTR_H */
#define HAVE_SYS_XATTR_H 1


b) symbols link against uclibc, as expected:

uclibc# ldd /bin/tar 
checking sub-depends for '/lib/libiconv.so.2'
checking sub-depends for '/usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1'
checking sub-depends for '/lib/libc.so.0'
	libiconv.so.2 => /lib/libiconv.so.2 (0x00000000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1 (0x00000000)
	libc.so.0 => /lib/libc.so.0 (0x00000000)
	/lib/ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x00000000)

uclibc# readelf -sW /bin/tar  | grep attr
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND llistxattr
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lsetxattr
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgetxattr
    90: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND listxattr
   131: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lgetxattr
   150: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setxattr
   168: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND flistxattr
   193: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getxattr
   305: 0000000000279190     4 OBJECT  GLOBAL DEFAULT   24 xattrs_option


c) Works --- I ran getfattr from outside a chroot since sys-apps/attr was un-emerged

uclibc# tar --xattrs -xf zzz.tar 
uclibc# getfattr -d zzz/zzz
# file: zzz/zzz
user.hi="hi"

================================================================================

3) No xattr source:

	uclibc with # UCLIBC_HAS_XATTR is not set
	un-emerged sys-apps/attr


a) no header available:

uclibc yellow tar-1.27 # cat config.h | grep ATTR_H
/* #undef HAVE_ATTR_XATTR_H */
/* #undef HAVE_SYS_XATTR_H */

b) no symbols:

uclibc# ldd /bin/tar 
checking sub-depends for '/lib/libiconv.so.2'
checking sub-depends for '/usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1'
checking sub-depends for '/lib/libc.so.0'
	libiconv.so.2 => /lib/libiconv.so.2 (0x00000000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1 (0x00000000)
	libc.so.0 => /lib/libc.so.0 (0x00000000)
	/lib/ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x00000000)

uclibc# readelf -sW /bin/tar  | grep attr
   297: 0000000000278170     4 OBJECT  GLOBAL DEFAULT   24 xattrs_option

c) doesn't work, as expected:

uclibc yellow ~ # tar --xattrs -xf zzz.tar 
tar: XATTR support is not available


================================================================================

4) Only sys-apps/attr as a source:

a) only <attr/attr.h> availabe and used, as expected:

uclibc yellow tar-1.27 # cat config.h | grep ATTR_H
#define HAVE_ATTR_XATTR_H 1
/* #undef HAVE_SYS_XATTR_H */


b) symbols link against /lib/libattr.so.1, as expected:

uclibc yellow ~ # ldd /bin/tar 
checking sub-depends for '/lib/libattr.so.1'
checking sub-depends for '/lib/libiconv.so.2'
checking sub-depends for '/usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1'
checking sub-depends for '/lib/libc.so.0'
	libattr.so.1 => /lib/libattr.so.1 (0x00000000)
	libiconv.so.2 => /lib/libiconv.so.2 (0x00000000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-gentoo-linux-uclibc/4.7.3/libgcc_s.so.1 (0x00000000)
	libc.so.0 => /lib/libc.so.0 (0x00000000)
	/lib/ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x00000000)

uclibc yellow ~ # readelf -sW /bin/tar  | grep attr
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND llistxattr@ATTR_1.0 (2)
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND listxattr@ATTR_1.0 (2)
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lgetxattr@ATTR_1.0 (2)
   133: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lsetxattr@ATTR_1.0 (2)
   149: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getxattr@ATTR_1.0 (2)
   152: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgetxattr@ATTR_1.0 (2)
   163: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setxattr@ATTR_1.0 (2)
   199: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND flistxattr@ATTR_1.0 (2)
   305: 0000000000279190     4 OBJECT  GLOBAL DEFAULT   24 xattrs_option


c) Works:

uclibc yellow ~ # tar --xattrs -xf zzz.tar 
uclibc yellow ~ # getfattr -d zzz/zzz 
# file: zzz/zzz
user.hi="hi"
Comment 6 Anthony Basile gentoo-dev 2013-11-28 20:28:34 UTC
Created attachment 364152 [details, diff]
Use <sys/xattr.h> and link against libc OR use <attr/xattr.h> and link against libattr.so

This patch and the ebuild are on the hardened-dev::uclibc overlay at

http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=tree;f=app-arch/tar;hb=205e02b3575f70b143d4dbee0961fc472ab5aecb

Note, I've dropped DEPEND="xattr? ( sys-apps/attr )".  Here's a diff with the in tree ebuild:

 diff -Naur tar-1.27.1-r99.ebuild /usr/portage/app-arch/tar/tar-1.27.1.ebuild 
--- tar-1.27.1-r99.ebuild	2013-11-28 20:20:16.061585124 +0000
+++ /usr/portage/app-arch/tar/tar-1.27.1.ebuild	2013-11-25 12:20:59.000000000 +0000
@@ -2,9 +2,9 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/app-arch/tar/tar-1.27.1.ebuild,v 1.1 2013/11/25 12:20:59 polynomial-c Exp $
 
-EAPI="5"
+EAPI="3"
 
-inherit autotools flag-o-matic eutils
+inherit flag-o-matic eutils
 
 DESCRIPTION="Use this to make tarballs :)"
 HOMEPAGE="http://www.gnu.org/software/tar/"
@@ -19,12 +19,10 @@
 RDEPEND="acl? ( virtual/acl )
 	selinux? ( sys-libs/libselinux )"
 DEPEND="${RDEPEND}
-	nls? ( >=sys-devel/gettext-0.10.35 )"
+	nls? ( >=sys-devel/gettext-0.10.35 )
+	xattr? ( sys-apps/attr )"
 
 src_prepare() {
-	epatch "${FILESDIR}"/${P}-sys-attr.patch
-	eautoreconf
-
 	if ! use userland_GNU ; then
 		sed -i \
 			-e 's:/backup\.sh:/gbackup.sh:' \
Comment 7 Anthony Basile gentoo-dev 2013-11-28 20:30:10 UTC
(In reply to Anthony Basile from comment #6)
>  diff -Naur tar-1.27.1-r99.ebuild
> /usr/portage/app-arch/tar/tar-1.27.1.ebuild 
> --- tar-1.27.1-r99.ebuild	2013-11-28 20:20:16.061585124 +0000
> +++ /usr/portage/app-arch/tar/tar-1.27.1.ebuild	2013-11-25
> 12:20:59.000000000 +0000
> @@ -2,9 +2,9 @@
>  # Distributed under the terms of the GNU General Public License v2
>  # $Header: /var/cvsroot/gentoo-x86/app-arch/tar/tar-1.27.1.ebuild,v 1.1
> 2013/11/25 12:20:59 polynomial-c Exp $
>  
> -EAPI="5"
> +EAPI="3"
>  
> -inherit autotools flag-o-matic eutils
> +inherit flag-o-matic eutils
>  
>  DESCRIPTION="Use this to make tarballs :)"
>  HOMEPAGE="http://www.gnu.org/software/tar/"
> @@ -19,12 +19,10 @@
>  RDEPEND="acl? ( virtual/acl )
>  	selinux? ( sys-libs/libselinux )"
>  DEPEND="${RDEPEND}
> -	nls? ( >=sys-devel/gettext-0.10.35 )"
> +	nls? ( >=sys-devel/gettext-0.10.35 )
> +	xattr? ( sys-apps/attr )"
>  
>  src_prepare() {
> -	epatch "${FILESDIR}"/${P}-sys-attr.patch
> -	eautoreconf
> -
>  	if ! use userland_GNU ; then
>  		sed -i \
>  			-e 's:/backup\.sh:/gbackup.sh:' \


Oops!  Thats the reverse diff.  That's okay, its just there to make it easy for you to read what I did with the ebuild.
Comment 8 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-12-04 07:40:57 UTC
blueness, thanks for looking into this.

I won't pretend to understand much of the patch. How about you submit it upstream for approval?
Comment 9 Arfrever Frehtes Taifersar Arahesis 2013-12-04 18:21:32 UTC
The patch looks correct.

Minor suggestion about acinclude.m4:
When user explicitly passes --with-xattrs but no xattr implementation is found, then AC_MSG_ERROR should be called.
Comment 10 Anthony Basile gentoo-dev 2013-12-06 19:30:16 UTC
Upstream at https://savannah.gnu.org/patch/index.php?8252.
Comment 11 Anthony Basile gentoo-dev 2013-12-06 19:32:59 UTC
Created attachment 364738 [details, diff]
Patch as submitted upstream.

Note: upstream uses the usual GNU bootstrap script, so you don't need to patch config.h.in as in my original patch.
Comment 12 Anthony Basile gentoo-dev 2013-12-06 19:34:10 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #9)
> The patch looks correct.
> 
> Minor suggestion about acinclude.m4:
> When user explicitly passes --with-xattrs but no xattr implementation is
> found, then AC_MSG_ERROR should be called.

I debated this because I reproduced the original behavior.  If no xattr support is found, tar still builds but just fails when invoked with --xattr.  Let's see what upstream says, its a trivial addition.
Comment 13 Anthony Basile gentoo-dev 2013-12-19 16:25:37 UTC
A new patch has been sent upstream:

http://lists.gnu.org/archive/html/bug-tar/2013-12/msg00023.html

Its a deep rewrite of the previous patch, but I did test it.  Arfrever, any comments?  Upstream has repsonded yet and I'm going to ping them soon.
Comment 14 Arfrever Frehtes Taifersar Arahesis 2013-12-27 18:22:54 UTC
I suggest to apply this new patch in Gentoo.
Comment 15 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-01-10 08:06:07 UTC
+*tar-1.27.1-r1 (10 Jan 2014)
+
+  10 Jan 2014; Lars Wendler <polynomial-c@gentoo.org> +tar-1.27.1-r1.ebuild,
+  +files/tar-1.27.1-recursion_norecursion.patch,
+  +files/tar-1.27.1-xattr_build_fix.patch:
+  Fixed build with xattr (bug #489170). Added an upstream fix regarding
+  recursion/norecursion.
+