diff --git a/scripts/unpack b/scripts/unpack index 84543366cf..fd7bbf1da0 100755 --- a/scripts/unpack +++ b/scripts/unpack @@ -52,24 +52,40 @@ fi if [ -d "$SOURCES/${PKG_NAME}" -o -d "$PKG_DIR/sources" ]; then build_msg "CLR_UNPACK" "UNPACK" "${PKG_NAME}" "indent" + # unpack into a unique location as unpacking into a single ${BUILD} directory is not thread-safe + PKG_UNPACK_DIR="${BUILD}/.unpack/${PKG_NAME}" + rm -fr "${PKG_UNPACK_DIR}" + mkdir -p "${PKG_UNPACK_DIR}" + pkg_call_exists pre_unpack && pkg_call pre_unpack if pkg_call_exists unpack; then pkg_call unpack else if [ -n "$PKG_URL" ]; then - $SCRIPTS/extract "${PKG_NAME}" $BUILD + ${SCRIPTS}/extract "${PKG_NAME}" "${PKG_UNPACK_DIR}" fi fi - if [ ! -d "$PKG_BUILD" ]; then - if [ -n "$PKG_SOURCE_DIR" ]; then - mv $BUILD/$PKG_SOURCE_DIR "$PKG_BUILD" - elif [ -d "$PKG_BUILD"* ]; then - mv "$PKG_BUILD"* "$PKG_BUILD" + _pkg_build="$(basename "${PKG_BUILD}")" + [ -d "${PKG_UNPACK_DIR}/${_pkg_build}"* ] && mv "${PKG_UNPACK_DIR}/${_pkg_build}"* "${PKG_BUILD}" + + if [ ! -d "${PKG_BUILD}" ]; then + if [ -n "${PKG_SOURCE_DIR}" ]; then + if [ -d "${PKG_UNPACK_DIR}"/${PKG_SOURCE_DIR} ]; then + mv "${PKG_UNPACK_DIR}"/${PKG_SOURCE_DIR} "${PKG_BUILD}" + else + # fallback + mv "${BUILD}"/${PKG_SOURCE_DIR} "${PKG_BUILD}" + fi + elif [ -d "${PKG_BUILD}"* ]; then + mv "${PKG_BUILD}"* "${PKG_BUILD}" fi fi + # cleanup + rm -fr "${PKG_UNPACK_DIR}" + if [ -d "$PKG_DIR/sources" ]; then [ ! -d "$PKG_BUILD" ] && mkdir -p "$PKG_BUILD" cp -PRf "$PKG_DIR/sources/"* "$PKG_BUILD"