2013-07-19 00:35:52 +00:00
|
|
|
#!/bin/bash
|
2011-01-09 22:32:01 +00:00
|
|
|
|
2018-07-16 18:45:36 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
2018-11-02 18:02:57 +00:00
|
|
|
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
. config/options "${1}"
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -z "${1}" ]; then
|
|
|
|
die "usage: ${0} package_name [parent_pkg]"
|
2009-03-18 12:02:53 +00:00
|
|
|
fi
|
|
|
|
|
2018-12-18 03:43:28 +00:00
|
|
|
if [ -z "${PKG_NAME}" ]; then
|
|
|
|
die "$(print_color CLR_ERROR "${1}: no package.mk file found")"
|
2014-01-27 02:34:44 +00:00
|
|
|
fi
|
2019-02-08 17:17:43 +00:00
|
|
|
PARENT_PKG="${2:-${PKG_NAME}}"
|
2014-01-27 02:34:44 +00:00
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
pkg_lock "${PKG_NAME}" "unpack" "${PARENT_PKG}"
|
|
|
|
|
2019-07-06 22:18:47 +00:00
|
|
|
${SCRIPTS}/get "${PKG_NAME}"
|
|
|
|
|
2019-06-29 10:06:42 +00:00
|
|
|
if [ -n "${PKG_DEPENDS_UNPACK}" ]; then
|
2020-07-11 17:24:31 +00:00
|
|
|
export _unpack_recursive_cnt=$((_unpack_recursive_cnt+1))
|
|
|
|
if [ ${_unpack_recursive_cnt} -gt 2 ]; then
|
|
|
|
die "unpack recursive limit hit: ${PKG_DEPENDS_UNPACK}, ${PARENT_PKG}"
|
|
|
|
fi
|
|
|
|
|
2019-06-29 10:06:42 +00:00
|
|
|
for p in ${PKG_DEPENDS_UNPACK}; do
|
|
|
|
${SCRIPTS}/unpack "${p}" "${PARENT_PKG}"
|
|
|
|
done
|
2020-07-11 17:24:31 +00:00
|
|
|
|
|
|
|
unset _unpack_recursive_cnt
|
2019-06-29 10:06:42 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
STAMP="${PKG_BUILD}/.libreelec-unpack"
|
2014-01-27 13:05:34 +00:00
|
|
|
|
2019-11-30 11:31:03 +00:00
|
|
|
mkdir -p ${BUILD}/build
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2017-03-23 14:59:46 +00:00
|
|
|
# Perform a wildcard match on the package to ensure old versions are cleaned too
|
2018-04-02 09:09:11 +00:00
|
|
|
PKG_DEEPHASH=
|
2019-11-30 11:31:03 +00:00
|
|
|
for i in ${BUILD}/build/${PKG_NAME}-*; do
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -d ${i} -a -f "${i}/.libreelec-unpack" ] ; then
|
|
|
|
. "${i}/.libreelec-unpack"
|
|
|
|
if [ "${STAMP_PKG_NAME}" = "${PKG_NAME}" ]; then
|
2018-04-02 09:09:11 +00:00
|
|
|
[ -z "${PKG_DEEPHASH}" ] && PKG_DEEPHASH=$(calculate_stamp)
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ ! "${PKG_DEEPHASH}" = "${STAMP_PKG_DEEPHASH}" ] ; then
|
|
|
|
${SCRIPTS}/clean "${PKG_NAME}"
|
2013-12-12 17:59:28 +00:00
|
|
|
fi
|
|
|
|
fi
|
2009-03-18 12:02:53 +00:00
|
|
|
fi
|
2017-03-23 14:33:17 +00:00
|
|
|
done
|
buildsystem: big rework & cleanup - PART-1: split functions from 'config/path' to an seperate file 'config/functions', rework and cleanup some build scripts, remove references to $TARGET_PLATFORM, add support for more then one downloadurl for $PKG_URL (partially done), remove support for: $PKG_DIR/arch, $PKG_DIR/platform, $PKG_DIR/url files, remove support for *.diff patches, create download-stampfiles in sources/$PKG_NAME, create md5 files after download, add support to download all sources at once with './scripts/get'
Signed-off-by: Stephan Raue <stephan@openelec.tv>
2010-11-19 21:01:08 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -d "${PKG_BUILD}" -a ! -f "${STAMP}" ]; then
|
2016-09-11 13:33:59 +00:00
|
|
|
# stale pkg build dir
|
2019-06-16 01:45:52 +00:00
|
|
|
${SCRIPTS}/clean "${PKG_NAME}"
|
2016-09-11 13:33:59 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -f "${STAMP}" ]; then
|
2019-02-08 17:17:43 +00:00
|
|
|
pkg_lock_status "UNLOCK" "${PKG_NAME}" "unpack" "already unpacked"
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-06-29 10:07:51 +00:00
|
|
|
pkg_lock_status "ACTIVE" "${PKG_NAME}" "unpack"
|
|
|
|
|
2020-02-13 11:44:31 +00:00
|
|
|
if [ -d "${SOURCES}/${PKG_NAME}" -o -d "${PKG_DIR}/sources" ] || pkg_call_exists_opt unpack; then
|
|
|
|
pkg_call_finish
|
2019-02-08 17:17:43 +00:00
|
|
|
build_msg "CLR_UNPACK" "UNPACK" "${PKG_NAME}" "indent"
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-02-08 17:17:43 +00:00
|
|
|
# unpack into a unique location as unpacking into a single ${BUILD} directory is not thread-safe
|
|
|
|
PKG_UNPACK_DIR="${BUILD}/.unpack/${PKG_NAME}"
|
2019-02-22 20:08:42 +00:00
|
|
|
rm -rf "${PKG_UNPACK_DIR}"
|
2019-02-08 17:17:43 +00:00
|
|
|
mkdir -p "${PKG_UNPACK_DIR}"
|
|
|
|
|
2019-07-06 08:19:38 +00:00
|
|
|
# Save PKG_BUILD and point at our private unpack directory so that any
|
|
|
|
# modifications to the content of ${PKG_BUILD} will be "safe".
|
|
|
|
PKG_BUILD_ORIG="${PKG_BUILD}"
|
|
|
|
PKG_BUILD="${PKG_UNPACK_DIR}/${PKG_NAME}-${PKG_VERSION}"
|
|
|
|
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_exists_opt pre_unpack && pkg_call
|
2014-01-02 13:12:03 +00:00
|
|
|
|
2019-01-21 13:15:11 +00:00
|
|
|
if pkg_call_exists unpack; then
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call
|
2019-01-21 13:15:11 +00:00
|
|
|
else
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -n "${PKG_URL}" ]; then
|
2019-02-08 17:17:43 +00:00
|
|
|
${SCRIPTS}/extract "${PKG_NAME}" "${PKG_UNPACK_DIR}"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_finish
|
2014-01-02 13:12:03 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-23 21:56:24 +00:00
|
|
|
if [ -z "${PKG_SOURCE_DIR}" -a -d "${PKG_UNPACK_DIR}/${PKG_NAME}-${PKG_VERSION}"* ]; then
|
|
|
|
mv "${PKG_UNPACK_DIR}/${PKG_NAME}-${PKG_VERSION}"* "${PKG_UNPACK_DIR}/.intermediate"
|
|
|
|
fi
|
2019-02-08 17:17:43 +00:00
|
|
|
|
2019-05-23 21:56:24 +00:00
|
|
|
if [ ! -d "${PKG_UNPACK_DIR}/.intermediate" ]; then
|
2019-02-08 17:17:43 +00:00
|
|
|
if [ -n "${PKG_SOURCE_DIR}" ]; then
|
|
|
|
if [ -d "${PKG_UNPACK_DIR}"/${PKG_SOURCE_DIR} ]; then
|
2019-05-23 21:56:24 +00:00
|
|
|
mv "${PKG_UNPACK_DIR}"/${PKG_SOURCE_DIR} "${PKG_UNPACK_DIR}/.intermediate"
|
2019-02-08 17:17:43 +00:00
|
|
|
else
|
|
|
|
# fallback
|
2019-05-23 21:56:24 +00:00
|
|
|
mv "${BUILD}"/${PKG_SOURCE_DIR} "${PKG_UNPACK_DIR}/.intermediate"
|
2019-02-08 17:17:43 +00:00
|
|
|
fi
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2016-03-29 21:51:55 +00:00
|
|
|
fi
|
2014-01-02 13:12:03 +00:00
|
|
|
|
2019-05-23 21:56:24 +00:00
|
|
|
[ ! -d "${PKG_UNPACK_DIR}/.intermediate" ] && mkdir -p "${PKG_UNPACK_DIR}/.intermediate"
|
2019-02-08 17:17:43 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -d "${PKG_DIR}/sources" ]; then
|
|
|
|
cp -PRf "${PKG_DIR}/sources/"* "${PKG_UNPACK_DIR}/.intermediate"
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2015-08-03 12:58:14 +00:00
|
|
|
|
2019-07-06 08:19:38 +00:00
|
|
|
# Add a tag to the unpacked folder before transferring into the shared build folder
|
2019-05-23 21:56:24 +00:00
|
|
|
echo "INFO_PKG_NAME=\"${PKG_NAME}\"" > "${PKG_UNPACK_DIR}/.intermediate/.libreelec-package"
|
|
|
|
|
2019-07-06 08:19:38 +00:00
|
|
|
# Restore original PKG_BUILD, and transfer the unpacked folder
|
|
|
|
PKG_BUILD="${PKG_BUILD_ORIG}"
|
2019-05-23 21:56:24 +00:00
|
|
|
rm -fr "${PKG_BUILD}"
|
|
|
|
mv "${PKG_UNPACK_DIR}/.intermediate" "${PKG_BUILD}"
|
|
|
|
|
|
|
|
# cleanup
|
|
|
|
rm -rf "${PKG_UNPACK_DIR}"
|
2016-02-22 13:12:07 +00:00
|
|
|
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_exists_opt post_unpack && pkg_call
|
2013-12-05 00:02:48 +00:00
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
if [ "${PKG_SKIP_PATCHES}" != "yes" ]; then
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_exists_opt pre_patch && pkg_call
|
2014-01-05 18:14:45 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ "${TARGET_ARCH}" = "x86_64" ]; then
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_ARCH="x86"
|
2021-06-11 16:06:58 +00:00
|
|
|
elif [ "${PKG_IS_KERNEL_PKG}" = "yes" ]; then
|
|
|
|
PATCH_ARCH="${TARGET_KERNEL_PATCH_ARCH:-${TARGET_ARCH}}"
|
2018-02-25 11:39:58 +00:00
|
|
|
else
|
2019-06-16 01:45:52 +00:00
|
|
|
PATCH_ARCH="${TARGET_PATCH_ARCH:-${TARGET_ARCH}}"
|
2018-02-25 11:39:58 +00:00
|
|
|
fi
|
2014-05-24 14:22:33 +00:00
|
|
|
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_DIRS_PKG=""
|
|
|
|
PATCH_DIRS_PRJ=""
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -n "${PKG_PATCH_DIRS}" ]; then
|
|
|
|
for patch_dir in ${PKG_PATCH_DIRS}; do
|
2019-07-05 15:32:38 +00:00
|
|
|
if [[ ${patch_dir} =~ ^/ ]]; then
|
|
|
|
[ -f ${patch_dir} ] && PATCH_DIRS_PKG+=" ${patch_dir}"
|
|
|
|
[ -d ${patch_dir} ] && PATCH_DIRS_PKG+=" ${patch_dir}/*.patch"
|
|
|
|
else
|
|
|
|
[ -d ${PKG_DIR}/patches/${patch_dir} ] && PATCH_DIRS_PKG+=" ${PKG_DIR}/patches/${patch_dir}/*.patch"
|
|
|
|
[ -d ${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${patch_dir} ] && PATCH_DIRS_PRJ+=" ${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${patch_dir}/*.patch"
|
|
|
|
[ -d ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/patches/${PKG_NAME}/${patch_dir} ] && PATCH_DIRS_PRJ+=" ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/patches/${PKG_NAME}/${patch_dir}/*.patch"
|
|
|
|
fi
|
2018-02-25 11:39:58 +00:00
|
|
|
done
|
|
|
|
fi
|
2016-12-06 18:25:25 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
for i in ${PKG_DIR}/patches/*.patch \
|
|
|
|
${PKG_DIR}/patches/${PATCH_ARCH}/*.patch \
|
|
|
|
${PATCH_DIRS_PKG} \
|
|
|
|
${PKG_DIR}/patches/${PKG_VERSION}/*.patch \
|
|
|
|
${PKG_DIR}/patches/${PKG_VERSION}/${PATCH_ARCH}/*.patch \
|
|
|
|
${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/*.patch \
|
|
|
|
${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${PATCH_ARCH}/*.patch \
|
|
|
|
${PATCH_DIRS_PRJ} \
|
|
|
|
${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${PKG_VERSION}/*.patch \
|
|
|
|
${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/patches/${PKG_NAME}/*.patch; do
|
2018-02-25 11:39:58 +00:00
|
|
|
|
2021-03-12 02:39:53 +00:00
|
|
|
thisdir="${i%/*}"
|
2018-02-25 11:39:58 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ "${thisdir}" = "${PKG_DIR}/patches" ]; then
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_DESC="(common)"
|
2019-06-16 01:45:52 +00:00
|
|
|
elif [ "${thisdir}" = "${PKG_DIR}/patches/${PATCH_ARCH}" ]; then
|
|
|
|
PATCH_DESC="(common - ${PATCH_ARCH})"
|
|
|
|
elif [ "${thisdir}" = "${PKG_DIR}/patches/${PKG_VERSION}" ]; then
|
|
|
|
PATCH_DESC="(common - ${PKG_VERSION})"
|
|
|
|
elif [ "${thisdir}" = "${PKG_DIR}/patches/${PKG_VERSION}/${PATCH_ARCH}" ]; then
|
|
|
|
PATCH_DESC="(${PKG_VERSION} - ${PATCH_ARCH})"
|
|
|
|
elif [ "${thisdir}" = "${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}" ]; then
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_DESC="(project)"
|
2019-06-16 01:45:52 +00:00
|
|
|
elif [ "${thisdir}" = "${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${PATCH_ARCH}" ]; then
|
|
|
|
PATCH_DESC="(project - ${PATCH_ARCH})"
|
|
|
|
elif [ "${thisdir}" = "${PROJECT_DIR}/${PROJECT}/patches/${PKG_NAME}/${PKG_VERSION}" ]; then
|
|
|
|
PATCH_DESC="(project - ${PKG_VERSION})"
|
|
|
|
elif [ "${thisdir}" = "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/patches/${PKG_NAME}" ]; then
|
2018-02-25 11:39:58 +00:00
|
|
|
PATCH_DESC="(device)"
|
2017-02-23 11:42:08 +00:00
|
|
|
else
|
2019-06-16 01:45:52 +00:00
|
|
|
if [[ "${thisdir}" =~ ^${PKG_DIR}/.* ]]; then
|
2021-03-12 02:39:53 +00:00
|
|
|
PATCH_DESC="(common - ${thisdir##*/})"
|
2019-06-16 01:45:52 +00:00
|
|
|
elif [[ "${thisdir}" =~ ^${PROJECT_DIR}/.*/devices/.* ]]; then
|
2021-03-12 02:39:53 +00:00
|
|
|
PATCH_DESC="(device - ${thisdir##*/})"
|
2019-06-16 01:45:52 +00:00
|
|
|
elif [[ "${thisdir}" =~ ^${PROJECT_DIR}/.* ]]; then
|
2021-03-12 02:39:53 +00:00
|
|
|
PATCH_DESC="(project - ${thisdir##*/})"
|
2018-02-25 11:39:58 +00:00
|
|
|
else
|
2019-07-05 15:32:38 +00:00
|
|
|
PATCH_DESC="(absolute - ${i})"
|
2018-02-25 11:39:58 +00:00
|
|
|
fi
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2009-03-18 12:02:53 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ -f "${i}" ]; then
|
2018-11-18 22:20:06 +00:00
|
|
|
build_msg "CLR_APPLY_PATCH" "APPLY PATCH $(print_color "CLR_PATCH_DESC" "${PATCH_DESC}")" "${i#${ROOT}/}"
|
2019-06-16 01:45:52 +00:00
|
|
|
if grep -qE '^GIT binary patch$|^rename from|^rename to' ${i}; then
|
2021-03-11 08:50:33 +00:00
|
|
|
git apply --directory="${PKG_BUILD}" -p1 --verbose --whitespace=nowarn --unsafe-paths < ${i} >&${VERBOSE_OUT}
|
2018-02-25 11:39:58 +00:00
|
|
|
else
|
2021-03-11 08:50:33 +00:00
|
|
|
patch -d "${PKG_BUILD}" -p1 < ${i} >&${VERBOSE_OUT}
|
2018-02-25 11:39:58 +00:00
|
|
|
fi
|
2017-02-23 11:42:08 +00:00
|
|
|
fi
|
2018-02-25 11:39:58 +00:00
|
|
|
done
|
2017-02-23 11:42:08 +00:00
|
|
|
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_exists_opt post_patch && pkg_call
|
2012-12-27 09:40:15 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-11 08:50:33 +00:00
|
|
|
if [ "${PKG_NAME}" != "configtools" ] ; then
|
2019-06-16 01:45:52 +00:00
|
|
|
for config in $(find "${PKG_BUILD}" -name config.guess | sed 's/config.guess//'); do
|
2018-11-18 22:20:06 +00:00
|
|
|
build_msg "CLR_FIXCONFIG" "FIXCONFIG" "${config}"
|
2017-02-23 11:42:08 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
[ -f "${config}/config.guess" -a -f ${TOOLCHAIN}/configtools/config.guess ] && \
|
|
|
|
cp -f ${TOOLCHAIN}/configtools/config.guess ${config}
|
|
|
|
[ -f "${config}/config.sub" -a -f ${TOOLCHAIN}/configtools/config.sub ] && \
|
|
|
|
cp -f ${TOOLCHAIN}/configtools/config.sub ${config}
|
2017-02-23 11:42:08 +00:00
|
|
|
done
|
|
|
|
fi
|
2013-12-21 06:53:41 +00:00
|
|
|
fi
|
2020-02-13 11:44:31 +00:00
|
|
|
pkg_call_finish
|
2013-12-21 06:53:41 +00:00
|
|
|
|
2019-06-16 01:45:52 +00:00
|
|
|
if [ "${PKG_SECTION}" != "virtual" ]; then
|
|
|
|
mkdir -p "${PKG_BUILD}"
|
2019-05-23 21:56:24 +00:00
|
|
|
echo "INFO_PKG_NAME=\"${PKG_NAME}\"" > "${PKG_BUILD}/.libreelec-package"
|
2011-02-09 10:09:22 +00:00
|
|
|
|
2018-04-02 09:09:11 +00:00
|
|
|
PKG_DEEPHASH=$(calculate_stamp)
|
|
|
|
for i in PKG_NAME PKG_DEEPHASH; do
|
2019-06-16 01:45:52 +00:00
|
|
|
echo "STAMP_${i}=\"${!i}\"" >> ${STAMP}
|
2017-02-23 11:42:08 +00:00
|
|
|
done
|
|
|
|
fi
|
2019-02-08 17:17:43 +00:00
|
|
|
|
|
|
|
pkg_lock_status "UNLOCK" "${PKG_NAME}" "unpack" "unpacked"
|