From 3e9133659fdd85b1844a9eb328d0c45c52121274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 19 Dec 2015 08:57:56 +0100 Subject: [PATCH 1/3] multibuild.eclass: _copy_sources(), use 'cp -R' for BSD compat, #568692 Use 'cp -R' for multibuild_copy_sources() as the '-r' option triggers triggers undesired '-L' behavior wrt symbolic links. Fixes: https://bugs.gentoo.org/show_bug.cgi?id=568692 --- eclass/multibuild.eclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index d21008cf26662..3d05f46d2a030 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.eclass @@ -195,7 +195,7 @@ multibuild_copy_sources() { _multibuild_create_source_copy() { einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}" - cp -pr "${cp_args[@]}" \ + cp -p -R "${cp_args[@]}" \ "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die } From 983a804804fb6063ffb295bca0a10df064f1bdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 19 Dec 2015 09:03:43 +0100 Subject: [PATCH 2/3] multibuild.eclass: Use 'cp --help' to determine option support Grep output of 'cp --help' to determine which options are supported, rather than relying on parameter checking with '--version'. Neither '--version' nor '--help' is supported on BSD, though, but the usage error triggers help output. Which just incidentally has '-a' in the right place. --- eclass/multibuild.eclass | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index 3d05f46d2a030..6a9ecc43098c5 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.eclass @@ -188,7 +188,7 @@ multibuild_copy_sources() { einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}" local cp_args=() - if cp --reflink=auto --version &>/dev/null; then + if cp --help 2>&1 | grep -q -- --reflink; then # enable reflinking if possible to make this faster cp_args+=( --reflink=auto ) fi @@ -245,13 +245,14 @@ multibuild_merge_root() { else local cp_args=() - if cp -a --version &>/dev/null; then + # note: BSD outputs joint args like -apvX, so only -a is safe + if cp --help 2>&1 | grep -q -- -a &>/dev/null; then cp_args+=( -a ) else cp_args+=( -P -R -p ) fi - if cp --reflink=auto --version &>/dev/null; then + if cp --help 2>&1 | grep -q -- --reflink; then # enable reflinking if possible to make this faster cp_args+=( --reflink=auto ) fi From 43762fce8d7f768d147daa546c1976a9c71255ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 19 Dec 2015 09:09:30 +0100 Subject: [PATCH 3/3] multibuild.eclass: _merge_root(), reuse same code on all platforms After fixing the non-BSD code to be more BSD-compatible, reuse it on all supported platforms. --- eclass/multibuild.eclass | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index 6a9ecc43098c5..d07386e62bc00 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.eclass @@ -233,34 +233,23 @@ multibuild_merge_root() { local dest=${2} local ret + local cp_args=() - if use userland_BSD; then - # Most of BSD variants fail to copy broken symlinks, #447370 - # also, they do not support --version - - tar -C "${src}" -f - -c . \ - | tar -x -f - -C "${dest}" - [[ ${PIPESTATUS[*]} == '0 0' ]] - ret=${?} + # note: BSD outputs joint args like -apvX, so only -a is safe + if cp --help 2>&1 | grep -q -- -a &>/dev/null; then + cp_args+=( -a ) else - local cp_args=() - - # note: BSD outputs joint args like -apvX, so only -a is safe - if cp --help 2>&1 | grep -q -- -a &>/dev/null; then - cp_args+=( -a ) - else - cp_args+=( -P -R -p ) - fi - - if cp --help 2>&1 | grep -q -- --reflink; then - # enable reflinking if possible to make this faster - cp_args+=( --reflink=auto ) - fi - - cp "${cp_args[@]}" "${src}"/. "${dest}"/ - ret=${?} + cp_args+=( -P -R -p ) fi + if cp --help 2>&1 | grep -q -- --reflink; then + # enable reflinking if possible to make this faster + cp_args+=( --reflink=auto ) + fi + + cp "${cp_args[@]}" "${src}"/. "${dest}"/ + ret=${?} + if [[ ${ret} -ne 0 ]]; then die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed." fi