From bfedc132eec42c6e6f79583ee7c2dcd440e719b6 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Sun, 3 Feb 2019 15:02:06 +0100 Subject: [PATCH] Move termux_dep_extract_info to another function Can be used in bintray upload script to extract pkg version --- build-package.sh | 37 +-------------------------- scripts/termux_extract_dep_info.sh | 41 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 scripts/termux_extract_dep_info.sh diff --git a/build-package.sh b/build-package.sh index 545baa6c6..006c76ec8 100755 --- a/build-package.sh +++ b/build-package.sh @@ -433,42 +433,7 @@ termux_step_handle_buildarch() { } # Function to get TERMUX_PKG_VERSION from build.sh -termux_extract_dep_info() { - package=$1 - if [ ! -d packages/$package ] && [ -f packages/*/${package}.subpackage.sh ]; then - # We are dealing with a subpackage - TERMUX_ARCH=$( - # set TERMUX_SUBPKG_PLATFORM_INDEPENDENT to mother package's value and override if needed - TERMUX_PKG_PLATFORM_INDEPENDENT="" - source $(dirname $(find packages/ -name "$package.subpackage.sh"))/build.sh - TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT - source $(find packages/ -name "$package.subpackage.sh") - if [ "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" = yes ]; then - echo all - else - echo $TERMUX_ARCH - fi - ) - - package=$(basename $(dirname $(find packages/ -name "$package.subpackage.sh"))) - elif [ "${package/-dev/}-dev" == "${package}" ]; then - # dev package - package=${package/-dev/} - fi - ( - # Reset TERMUX_PKG_PLATFORM_INDEPENDENT and TERMUX_PKG_REVISION since these aren't - # mandatory in a build.sh. Otherwise these will equal the main package's values for - # deps that should have the default values - TERMUX_PKG_PLATFORM_INDEPENDENT="" - TERMUX_PKG_REVISION="0" - source packages/$package/build.sh - if [ "$TERMUX_PKG_PLATFORM_INDEPENDENT" = yes ]; then TERMUX_ARCH=all; fi - if [ "$TERMUX_PKG_REVISION" != "0" ] || [ "$TERMUX_PKG_VERSION" != "${TERMUX_PKG_VERSION/-/}" ]; then - TERMUX_PKG_VERSION+="-$TERMUX_PKG_REVISION" - fi - echo ${TERMUX_ARCH} ${TERMUX_PKG_VERSION} - ) -} +source scripts/termux_extract_dep_info.sh termux_download_deb() { local package=$1 diff --git a/scripts/termux_extract_dep_info.sh b/scripts/termux_extract_dep_info.sh new file mode 100644 index 000000000..91b99c301 --- /dev/null +++ b/scripts/termux_extract_dep_info.sh @@ -0,0 +1,41 @@ +termux_extract_dep_info() { + package=$1 + if [ ! -d packages/$package ] && [ -f packages/*/${package}.subpackage.sh ]; then + # We are dealing with a subpackage + TERMUX_ARCH=$( + # set TERMUX_SUBPKG_PLATFORM_INDEPENDENT to mother package's value and override if needed + TERMUX_PKG_PLATFORM_INDEPENDENT="" + source $(dirname $(find packages/ -name "$package.subpackage.sh"))/build.sh + TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT + source $(find packages/ -name "$package.subpackage.sh") + if [ "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" = yes ]; then + echo all + else + echo $TERMUX_ARCH + fi + ) + + package=$(basename $(dirname $(find packages/ -name "$package.subpackage.sh"))) + elif [ "${package/-dev/}-dev" == "${package}" ]; then + # dev package + package=${package/-dev/} + fi + ( + # Reset TERMUX_PKG_PLATFORM_INDEPENDENT and TERMUX_PKG_REVISION since these aren't + # mandatory in a build.sh. Otherwise these will equal the main package's values for + # deps that should have the default values + TERMUX_PKG_PLATFORM_INDEPENDENT="" + TERMUX_PKG_REVISION="0" + source packages/$package/build.sh + if [ "$TERMUX_PKG_PLATFORM_INDEPENDENT" = yes ]; then TERMUX_ARCH=all; fi + if [ "$TERMUX_PKG_REVISION" != "0" ] || [ "$TERMUX_PKG_VERSION" != "${TERMUX_PKG_VERSION/-/}" ]; then + TERMUX_PKG_VERSION+="-$TERMUX_PKG_REVISION" + fi + echo ${TERMUX_ARCH} ${TERMUX_PKG_VERSION} + ) +} + +# Make script standalone executable as well as sourceable +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + termux_extract_dep_info "$@" +fi