Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multibuild BSD fixes #489

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 14 additions & 24 deletions eclass/multibuild.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ 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

_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
}

Expand Down Expand Up @@ -233,33 +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=()

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

if cp --reflink=auto --version &>/dev/null; then
# enable reflinking if possible to make this faster
cp_args+=( --reflink=auto )
fi
cp_args+=( -P -R -p )
fi

cp "${cp_args[@]}" "${src}"/. "${dest}"/
ret=${?}
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
Expand Down