2019-03-07 20:35:32 +01:00
|
|
|
termux_create_subpackages() {
|
|
|
|
# Sub packages:
|
2019-08-14 23:03:58 +02:00
|
|
|
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo lib/**/*.a) ]]; then
|
2019-07-20 10:42:33 +02:00
|
|
|
# Add virtual -static sub package if there are include files:
|
|
|
|
local _STATIC_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-static.subpackage.sh
|
2019-07-30 00:19:13 +02:00
|
|
|
echo TERMUX_SUBPKG_INCLUDE=\"lib/**/*.a lib/**/*.la\" > "$_STATIC_SUBPACKAGE_FILE"
|
2019-07-20 10:42:33 +02:00
|
|
|
echo "TERMUX_SUBPKG_DESCRIPTION=\"Static libraries for ${TERMUX_PKG_NAME}\"" >> "$_STATIC_SUBPACKAGE_FILE"
|
2019-03-07 20:35:32 +01:00
|
|
|
fi
|
2019-07-20 10:42:33 +02:00
|
|
|
|
2019-03-07 20:35:32 +01:00
|
|
|
# Now build all sub packages
|
|
|
|
rm -Rf "$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages"
|
|
|
|
for subpackage in $TERMUX_PKG_BUILDER_DIR/*.subpackage.sh $TERMUX_PKG_TMPDIR/*subpackage.sh; do
|
|
|
|
test ! -f "$subpackage" && continue
|
|
|
|
local SUB_PKG_NAME
|
|
|
|
SUB_PKG_NAME=$(basename "$subpackage" .subpackage.sh)
|
|
|
|
# Default value is same as main package, but sub package may override:
|
|
|
|
local TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT
|
|
|
|
local SUB_PKG_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages/$SUB_PKG_NAME
|
2019-08-12 17:28:41 +02:00
|
|
|
local TERMUX_SUBPKG_ESSENTIAL=false
|
2019-03-07 20:37:47 +01:00
|
|
|
local TERMUX_SUBPKG_BREAKS=""
|
2019-03-07 20:35:32 +01:00
|
|
|
local TERMUX_SUBPKG_DEPENDS=""
|
|
|
|
local TERMUX_SUBPKG_CONFLICTS=""
|
|
|
|
local TERMUX_SUBPKG_REPLACES=""
|
|
|
|
local TERMUX_SUBPKG_CONFFILES=""
|
2019-05-10 07:27:00 +02:00
|
|
|
local TERMUX_SUBPKG_DEPEND_ON_PARENT=""
|
2019-03-07 20:35:32 +01:00
|
|
|
local SUB_PKG_MASSAGE_DIR=$SUB_PKG_DIR/massage/$TERMUX_PREFIX
|
|
|
|
local SUB_PKG_PACKAGE_DIR=$SUB_PKG_DIR/package
|
|
|
|
mkdir -p "$SUB_PKG_MASSAGE_DIR" "$SUB_PKG_PACKAGE_DIR"
|
|
|
|
|
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "$subpackage"
|
|
|
|
|
2019-07-30 00:19:13 +02:00
|
|
|
# Allow globstar (i.e. './**/') patterns.
|
|
|
|
shopt -s globstar
|
2019-03-07 20:35:32 +01:00
|
|
|
for includeset in $TERMUX_SUBPKG_INCLUDE; do
|
|
|
|
local _INCLUDE_DIRSET
|
|
|
|
_INCLUDE_DIRSET=$(dirname "$includeset")
|
|
|
|
test "$_INCLUDE_DIRSET" = "." && _INCLUDE_DIRSET=""
|
2019-07-30 00:19:13 +02:00
|
|
|
|
2019-03-07 20:35:32 +01:00
|
|
|
if [ -e "$includeset" ] || [ -L "$includeset" ]; then
|
|
|
|
# Add the -L clause to handle relative symbolic links:
|
|
|
|
mkdir -p "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
|
|
|
|
mv "$includeset" "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
|
|
|
|
fi
|
|
|
|
done
|
2019-07-30 00:19:13 +02:00
|
|
|
shopt -u globstar
|
2019-03-07 20:35:32 +01:00
|
|
|
|
|
|
|
local SUB_PKG_ARCH=$TERMUX_ARCH
|
2019-08-20 13:53:54 +02:00
|
|
|
[ "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" = "true" ] && SUB_PKG_ARCH=all
|
2019-03-07 20:35:32 +01:00
|
|
|
|
|
|
|
cd "$SUB_PKG_DIR/massage"
|
|
|
|
local SUB_PKG_INSTALLSIZE
|
|
|
|
SUB_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
|
2021-08-24 13:30:02 +02:00
|
|
|
tar -cJf "$SUB_PKG_PACKAGE_DIR/data.tar.xz" .
|
2019-03-07 20:35:32 +01:00
|
|
|
|
|
|
|
mkdir -p DEBIAN
|
|
|
|
cd DEBIAN
|
2019-04-13 17:41:44 +02:00
|
|
|
|
2019-03-07 20:35:32 +01:00
|
|
|
cat > control <<-HERE
|
|
|
|
Package: $SUB_PKG_NAME
|
|
|
|
Architecture: ${SUB_PKG_ARCH}
|
|
|
|
Installed-Size: ${SUB_PKG_INSTALLSIZE}
|
|
|
|
Maintainer: $TERMUX_PKG_MAINTAINER
|
|
|
|
Version: $TERMUX_PKG_FULLVERSION
|
|
|
|
Homepage: $TERMUX_PKG_HOMEPAGE
|
|
|
|
HERE
|
2019-05-05 23:11:30 +02:00
|
|
|
|
2019-05-10 07:27:00 +02:00
|
|
|
local PKG_DEPS_SPC=" ${TERMUX_PKG_DEPENDS//,/} "
|
|
|
|
|
|
|
|
if [ -z "$TERMUX_SUBPKG_DEPEND_ON_PARENT" ] && [ "${PKG_DEPS_SPC/ $SUB_PKG_NAME /}" = "$PKG_DEPS_SPC" ]; then
|
2019-05-10 17:46:13 +02:00
|
|
|
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_NAME (= $TERMUX_PKG_FULLVERSION)"
|
2019-05-10 07:27:00 +02:00
|
|
|
elif [ "$TERMUX_SUBPKG_DEPEND_ON_PARENT" = unversioned ]; then
|
2019-05-10 17:46:13 +02:00
|
|
|
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_NAME"
|
2019-05-10 07:27:00 +02:00
|
|
|
elif [ "$TERMUX_SUBPKG_DEPEND_ON_PARENT" = deps ]; then
|
2019-05-10 17:46:13 +02:00
|
|
|
TERMUX_SUBPKG_DEPENDS+=", $TERMUX_PKG_DEPENDS"
|
2019-05-05 23:11:30 +02:00
|
|
|
fi
|
|
|
|
|
2019-08-20 13:53:54 +02:00
|
|
|
[ "$TERMUX_SUBPKG_ESSENTIAL" = "true" ] && echo "Essential: yes" >> control
|
2019-05-10 07:27:00 +02:00
|
|
|
test ! -z "$TERMUX_SUBPKG_DEPENDS" && echo "Depends: ${TERMUX_SUBPKG_DEPENDS/#, /}" >> control
|
2019-03-07 20:37:47 +01:00
|
|
|
test ! -z "$TERMUX_SUBPKG_BREAKS" && echo "Breaks: $TERMUX_SUBPKG_BREAKS" >> control
|
2019-03-07 20:35:32 +01:00
|
|
|
test ! -z "$TERMUX_SUBPKG_CONFLICTS" && echo "Conflicts: $TERMUX_SUBPKG_CONFLICTS" >> control
|
|
|
|
test ! -z "$TERMUX_SUBPKG_REPLACES" && echo "Replaces: $TERMUX_SUBPKG_REPLACES" >> control
|
|
|
|
echo "Description: $TERMUX_SUBPKG_DESCRIPTION" >> control
|
|
|
|
|
|
|
|
for f in $TERMUX_SUBPKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> conffiles; done
|
|
|
|
|
2020-02-23 21:30:44 +01:00
|
|
|
# Allow packages to create arbitrary control files.
|
|
|
|
termux_step_create_subpkg_debscripts
|
|
|
|
|
|
|
|
# Create control.tar.gz
|
|
|
|
tar -czf "$SUB_PKG_PACKAGE_DIR/control.tar.gz" -H gnu .
|
2019-04-13 17:41:44 +02:00
|
|
|
|
2019-03-07 20:35:32 +01:00
|
|
|
# Create the actual .deb file:
|
|
|
|
TERMUX_SUBPKG_DEBFILE=$TERMUX_DEBDIR/${SUB_PKG_NAME}${DEBUG}_${TERMUX_PKG_FULLVERSION}_${SUB_PKG_ARCH}.deb
|
|
|
|
test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary"
|
|
|
|
ar cr "$TERMUX_SUBPKG_DEBFILE" \
|
|
|
|
"$TERMUX_COMMON_CACHEDIR/debian-binary" \
|
|
|
|
"$SUB_PKG_PACKAGE_DIR/control.tar.gz" \
|
|
|
|
"$SUB_PKG_PACKAGE_DIR/data.tar.xz"
|
|
|
|
|
|
|
|
# Go back to main package:
|
|
|
|
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
|
|
|
|
done
|
|
|
|
}
|