Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 507626 - multibuild.eclass - FreeBSD: cp -a or cp -P -R -p fails when encountering broken symlinks
Summary: multibuild.eclass - FreeBSD: cp -a or cp -P -R -p fails when encountering bro...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Michał Górny
URL: http://www.freebsd.org/cgi/query-pr.c...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-14 11:13 UTC by Yuta SATOH
Modified: 2014-04-15 15:54 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta SATOH 2014-04-14 11:13:46 UTC
dev-python/{pyelftools-0.21-r4,setuptools-2.2} install fails on Gentoo/FreeBSD...


 * Messages for package dev-python/pyelftools-0.21-r4:

 * ERROR: dev-python/pyelftools-0.21-r4::gentoo failed (install phase):
 *   python3_3: merging image failed.
 *
 * Call stack:
 *     ebuild.sh, line   93:  Called src_install
 *   environment, line 3546:  Called distutils-r1_src_install
 *   environment, line 1211:  Called _distutils-r1_run_foreach_impl 'distutils-r1_python_install'
 *   environment, line  233:  Called python_parallel_foreach_impl 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line 3386:  Called multibuild_parallel_foreach_variant '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line 2529:  Called multibuild_foreach_variant '_multibuild_parallel' '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line 2478:  Called _multibuild_run '_multibuild_parallel' '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line 2476:  Called _multibuild_parallel '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line 2520:  Called _python_multibuild_wrapper 'distutils-r1_run_phase' 'distutils-r1_python_install'
 *   environment, line  664:  Called distutils-r1_run_phase 'distutils-r1_python_install'
 *   environment, line 1179:  Called distutils-r1_python_install
 *   environment, line 1129:  Called multibuild_merge_root '/var/tmp/portage/dev-python/pyelftools-0.21-r4/image//_python3.3' '/var/tmp/portage/dev-python/pyelftools-0.21-r4/image/'
 *   environment, line 2509:  Called die
 * The specific snippet of code:
 *           die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
 *
 * If you need support, post the output of `emerge --info '=dev-python/pyelftools-0.21-r4::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-python/pyelftools-0.21-r4::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-python/pyelftools-0.21-r4/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-python/pyelftools-0.21-r4/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-python/pyelftools-0.21-r4/work/pyelftools-0.21'
 * S: '/var/tmp/portage/dev-python/pyelftools-0.21-r4/work/pyelftools-0.21'
 *
 * The following package has failed to build or install:
 *
 *  (dev-python/pyelftools-0.21-r4:0/0::gentoo, ebuild scheduled for merge), Log file:
 *   '/var/tmp/portage/dev-python/pyelftools-0.21-r4/temp/build.log'
 *
Comment 1 Yuta SATOH 2014-04-14 11:14:38 UTC
Results of test the code that has been added to multibuild.eclass recently.
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/multibuild.eclass?r1=1.14&r2=1.15


Tested on Gentoo/FreeBSD 10.0 amd64


        if cp -a --version &>/dev/null; then
                cp_args+=( -a )
        else
                cp_args+=( -P -R -p )
        fi

$ cp -a --version &>/dev/null
$ echo $?
64

FreeBSD's cp does not support the argument --version.
So, the argument of cp is set "-P -R -p" on FreeBSD.

$ mkdir 1 2
$ ln -s python-exec 1/foo
$ cp -P -R -p 1/* 2/
$ cp -P -R -p 1/* 2/
cp: symlink: python-exec: File exists
$ echo $?
1

Error occurs even if set "-a".

$ rm -rf 1 2
$ mkdir 1 2
$ ln -s python-exec 1/foo
$ cp -a 1/* 2/
$ cp -a 1/* 2/
cp: symlink: python-exec: File exists
$ echo $?
1


FYI, 
FreeBSD's cp returns 64, and illegal option -- -.
$ cp -a --version &>/dev/null
$ echo $?
64
$ cp -a --version
cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory


GNU's cp returns 0.
$ gcp -a --version &>/dev/null
$ echo $?
0
Comment 2 Yuta SATOH 2014-04-14 11:15:18 UTC
@bsd team,
I have confirmed that the solved this issue by apply following patch.
http://people.freebsd.org/~markj/patches/cp/002_stat_vs_lstat.diff

I think better it is merged upstream.
However, I don't know how to follow-up for FreeBSD's bug report...
http://www.freebsd.org/cgi/query-pr.cgi?pr=174489


# cd /var/tmp/portage/sys-freebsd/freebsd-bin-10.0/work/bin/cp
# wget http://people.freebsd.org/~markj/patches/cp/002_stat_vs_lstat.diff
# patch -p3 < 002_stat_vs_lstat.diff
# make
# ./cp -a /tmp/1/* /tmp/2/
# ./cp -a /tmp/1/* /tmp/2/
# echo $?
0
Comment 3 Yuta SATOH 2014-04-14 11:16:17 UTC
I think this issue occurs on FreeBSD, OpenBSD, DragonFlyBSD.
Error does not occur on NetBSD.


NetBSD 6.1.2)
# cp -a --version
cp: unknown option -- -
usage: cp [-R [-H | -L | -P]] [-f | -i] [-alNpv] src target
       cp [-R [-H | -L | -P]] [-f | -i] [-alNpv] src1 ... srcN directory

# mkdir 1 2
# ln -s python-exec 1/foo
# cp -P -R -p 1/* 2/
# cp -P -R -p 1/* 2/
# echo $?
0

# rm -rf 1 2
# mkdir 1 2
# ln -s python-exec 1/foo
# cp -a 1/* 2/
# cp -a 1/* 2/
# echo $?
0


OpenBSD 5.4)
# cp -a --version
cp: unknown option -- a
usage: cp [-fip] [-R [-H | -L | -P]] source target
       cp [-fip] [-R [-H | -L | -P]] source ... directory
# cp --version
cp: unknown option -- -
usage: cp [-fip] [-R [-H | -L | -P]] source target
       cp [-fip] [-R [-H | -L | -P]] source ... directory
# cp -a
cp: unknown option -- a
usage: cp [-fip] [-R [-H | -L | -P]] source target
       cp [-fip] [-R [-H | -L | -P]] source ... directory

# mkdir 1 2
# ln -s python-exec 1/foo
# cp -P -R -p 1/* 2/
# cp -P -R -p 1/* 2/
cp: symlink: python-exec: File exists
# echo $?
1


DragonFly BSD 3.6.2)
# cp -a --version
cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory

# mkdir 1 2
# ln -s python-exec 1/foo
# cp -P -R -p 1/* 2/
# cp -P -R -p 1/* 2/
cp: symlink: python-exec: File exists
# echo $?
1

# rm -rf 1 2
# mkdir 1 2
# ln -s python-exec 1/foo
# cp -a 1/* 2/
# cp -a 1/* 2/
cp: symlink: python-exec: File exists
# echo $?
1
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-04-14 15:01:11 UTC
So back to userland_BSD workaround?
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-04-15 15:54:28 UTC
+  15 Apr 2014; Michał Górny <mgorny@gentoo.org> multibuild.eclass:
+  multibuild_merge_root: re-introduce userland_BSD tar fallback, bug #507626.

Let's just reuse the old code that handled BSD.