From ae570b2edddd5747daaa6e64d36695297dcaa712 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Sun, 28 Apr 2019 22:07:07 +0200 Subject: [PATCH] build-package: install licenses to $PREFIX/share/$PKG/LICENSE --- build-package.sh | 4 ++++ docs/BUILD.md | 19 +++++++++--------- packages/apt/build.sh | 2 +- scripts/build/termux_step_install_license.sh | 21 ++++++++++++++++++++ scripts/build/termux_step_start_build.sh | 2 +- 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 scripts/build/termux_step_install_license.sh diff --git a/build-package.sh b/build-package.sh index 07c2af553..4f839ed5b 100755 --- a/build-package.sh +++ b/build-package.sh @@ -120,6 +120,9 @@ termux_step_post_make_install() { return } +# Link/copy the LICENSE for the package to $TERMUX_PREFIX/share/$TERMUX_PKG_NAME/ +source scripts/build/termux_step_install_license.sh + # Function to cp (through tar) installed files to massage dir source scripts/build/termux_step_extract_into_massagedir.sh @@ -175,6 +178,7 @@ source scripts/build/termux_step_finish_build.sh termux_step_make_install cd "$TERMUX_PKG_BUILDDIR" termux_step_post_make_install + termux_step_license cd "$TERMUX_PKG_MASSAGEDIR" termux_step_extract_into_massagedir cd "$TERMUX_PKG_MASSAGEDIR" diff --git a/docs/BUILD.md b/docs/BUILD.md index bee5fb35f..5ee179799 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -61,15 +61,16 @@ Package build flow is controlled by script [build-package.sh](../build-package.s | 15 | `termux_step_make` | yes | Make the package. | | 16 | `termux_step_make_install` | yes | Install the package. | | 17 | `termux_step_post_make_install` | yes | Hook before extraction. | -| 18 | `termux_step_extract_into_massagedir` | no with `make_install` | Extracts installed files. | -| 19 | `termux_step_massage` | no | Remove unusable files. | -| 19.1 | `termux_create_subpackages` | no | Creates all subpackages. | -| 20 | `termux_step_post_massage` | yes | Final hook before packaging. | -| 21 | `termux_step_create_datatar` | no | Archive package files. | -| 22 | `termux_step_create_debfile` | no | Create package. | -| 22.1 | `termux_step_create_debscripts` | yes | Create additional Debian package files. | -| 23 | `termux_step_compare_debfiles` | no | Compare packages if `-i` option is specified. | -| 24 | `termux_step_finish_build` | no | Notification of finish. | +| 18 | `termux_step_install_license` | yes | ln or cp package LICENSE to usr/share/PKG/. | +| 19 | `termux_step_extract_into_massagedir` | no with `make_install` | Extracts installed files. | +| 20 | `termux_step_massage` | no | Remove unusable files. | +| 20.1 | `termux_create_subpackages` | no | Creates all subpackages. | +| 21 | `termux_step_post_massage` | yes | Final hook before packaging. | +| 22 | `termux_step_create_datatar` | no | Archive package files. | +| 23 | `termux_step_create_debfile` | no | Create package. | +| 23.1 | `termux_step_create_debscripts` | yes | Create additional Debian package files. | +| 24 | `termux_step_compare_debfiles` | no | Compare packages if `-i` option is specified. | +| 25 | `termux_step_finish_build` | no | Notification of finish. | Order specifies function sequence. 0 order specifies utility functions. diff --git a/packages/apt/build.sh b/packages/apt/build.sh index fa4fc39ee..7fd8dae78 100644 --- a/packages/apt/build.sh +++ b/packages/apt/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://packages.debian.org/apt TERMUX_PKG_DESCRIPTION="Front-end for the dpkg package manager" TERMUX_PKG_LICENSE="GPL-2.0" -TERMUX_PKG_DEPENDS="libcurl, liblzma, dpkg, gpgv, libc++, termux-exec, zlib" +TERMUX_PKG_DEPENDS="libcurl, liblzma, dpkg, gpgv, libc++, termux-exec, zlib, termux-licenses" TERMUX_PKG_RECOMMENDS="game-repo, science-repo" TERMUX_PKG_SUGGESTS="unstable-repo" TERMUX_PKG_VERSION=1.4.9 diff --git a/scripts/build/termux_step_install_license.sh b/scripts/build/termux_step_install_license.sh new file mode 100644 index 000000000..bc7d3bc81 --- /dev/null +++ b/scripts/build/termux_step_install_license.sh @@ -0,0 +1,21 @@ +termux_step_install_license() { + mkdir -p "$TERMUX_PREFIX/share/$TERMUX_PKG_NAME" + local COUNTER=0 + for LICENSE in $(echo $TERMUX_PKG_LICENSE | sed 's/,/ /g'); do + if [ -f "$TERMUX_SCRIPTDIR/packages/termux-licenses/LICENSES/${LICENSE}.txt" ]; then + if [[ $COUNTER > 0 ]]; then + ln -s "../licenses/${LICENSE}.txt" "$TERMUX_PREFIX/share/$TERMUX_PKG_NAME/LICENSE.${COUNTER}" + else + ln -s "../licenses/${LICENSE}.txt" "$TERMUX_PREFIX/share/$TERMUX_PKG_NAME/LICENSE" + fi + else + for POSSIBLE_LICENSE in "LICENSE*" "license*" "COPYRIGHT" "copyright"; do + if [ -f "$TERMUX_PKG_SRCDIR/$POSSIBLE_LICENSE" ]; then + cp "$TERMUX_PKG_SRCDIR/$POSSIBLE_LICENSE" "$TERMUX_PREFIX/share/$TERMUX_PKG_NAME/" + break + fi + done + fi + COUNTER=$((COUNTER + 1)) + done +} diff --git a/scripts/build/termux_step_start_build.sh b/scripts/build/termux_step_start_build.sh index 8fe979033..7e3a8d412 100644 --- a/scripts/build/termux_step_start_build.sh +++ b/scripts/build/termux_step_start_build.sh @@ -107,7 +107,7 @@ termux_step_start_build() { "$TERMUX_PKG_TMPDIR" \ "$TERMUX_PKG_CACHEDIR" \ "$TERMUX_PKG_MASSAGEDIR" \ - $TERMUX_PREFIX/{bin,etc,lib,libexec,share,tmp,include} + $TERMUX_PREFIX/{bin,etc,lib,libexec,share,share/licenses,tmp,include} # Make $TERMUX_PREFIX/bin/sh executable on the builder, so that build # scripts can assume that it works on both builder and host later on: