committed by
Leonid Plyushch
2 changed files with 159 additions and 157 deletions
@ -0,0 +1,157 @@ |
|||
termux_step_massage() { |
|||
cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX" |
|||
|
|||
# Remove lib/charset.alias which is installed by gettext-using packages: |
|||
rm -f lib/charset.alias |
|||
|
|||
# Remove non-english man pages: |
|||
test -d share/man && (cd share/man; for f in $(ls | grep -v man); do rm -Rf $f; done ) |
|||
|
|||
if [ -z "${TERMUX_PKG_KEEP_INFOPAGES+x}" ]; then |
|||
# Remove info pages: |
|||
rm -Rf share/info |
|||
fi |
|||
|
|||
# Remove locale files we're not interested in:: |
|||
rm -Rf share/locale |
|||
if [ -z "${TERMUX_PKG_KEEP_SHARE_DOC+x}" ]; then |
|||
# Remove info pages: |
|||
rm -Rf share/doc |
|||
fi |
|||
|
|||
# Remove old kept libraries (readline): |
|||
find . -name '*.old' -delete |
|||
|
|||
# Remove static libraries: |
|||
if [ $TERMUX_PKG_KEEP_STATIC_LIBRARIES = "false" ]; then |
|||
find . -name '*.a' -delete |
|||
find . -name '*.la' -delete |
|||
fi |
|||
|
|||
# Move over sbin to bin: |
|||
for file in sbin/*; do if test -f "$file"; then mv "$file" bin/; fi; done |
|||
|
|||
# Remove world permissions and add write permissions. |
|||
# The -f flag is used to suppress warnings about dangling symlinks (such |
|||
# as ones to /system/... which may not exist on the build machine): |
|||
find . -exec chmod -f u+w,g-rwx,o-rwx \{\} \; |
|||
|
|||
if [ "$TERMUX_DEBUG" = "" ]; then |
|||
# Strip binaries. file(1) may fail for certain unusual files, so disable pipefail. |
|||
set +e +o pipefail |
|||
find . -type f | xargs -r file | grep -E "(executable|shared object)" | grep ELF | cut -f 1 -d : | \ |
|||
xargs -r "$STRIP" --strip-unneeded --preserve-dates |
|||
set -e -o pipefail |
|||
fi |
|||
# Remove DT_ entries which the android 5.1 linker warns about: |
|||
find . -type f -print0 | xargs -r -0 "$TERMUX_ELF_CLEANER" |
|||
|
|||
# Fix shebang paths: |
|||
while IFS= read -r -d '' file |
|||
do |
|||
head -c 100 "$file" | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && sed --follow-symlinks -i -E "1 s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" "$file" |
|||
done < <(find -L . -type f -print0) |
|||
|
|||
test ! -z "$TERMUX_PKG_RM_AFTER_INSTALL" && rm -Rf $TERMUX_PKG_RM_AFTER_INSTALL |
|||
|
|||
find . -type d -empty -delete # Remove empty directories |
|||
|
|||
if [ -d share/man ]; then |
|||
# Compress man pages with gzip: |
|||
find share/man -type f -print0 | xargs -r -0 gzip |
|||
# Update man page symlinks, e.g. unzstd.1 -> zstd.1: |
|||
while IFS= read -r -d '' file |
|||
do |
|||
local _link_value |
|||
_link_value=$(readlink $file) |
|||
rm $file |
|||
ln -s $_link_value.gz $file.gz |
|||
done < <(find share/man -type l -print0) |
|||
fi |
|||
|
|||
# Sub packages: |
|||
if [ -d include ] && [ -z "${TERMUX_PKG_NO_DEVELSPLIT}" ]; then |
|||
# Add virtual -dev sub package if there are include files: |
|||
local _DEVEL_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-dev.subpackage.sh |
|||
echo TERMUX_SUBPKG_INCLUDE=\"include share/vala share/man/man3 lib/pkgconfig share/aclocal lib/cmake $TERMUX_PKG_INCLUDE_IN_DEVPACKAGE\" > "$_DEVEL_SUBPACKAGE_FILE" |
|||
echo "TERMUX_SUBPKG_DESCRIPTION=\"Development files for ${TERMUX_PKG_NAME}\"" >> "$_DEVEL_SUBPACKAGE_FILE" |
|||
if [ -n "$TERMUX_PKG_DEVPACKAGE_DEPENDS" ]; then |
|||
echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME,$TERMUX_PKG_DEVPACKAGE_DEPENDS\"" >> "$_DEVEL_SUBPACKAGE_FILE" |
|||
else |
|||
echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME\"" >> "$_DEVEL_SUBPACKAGE_FILE" |
|||
fi |
|||
fi |
|||
# 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 |
|||
local TERMUX_SUBPKG_DEPENDS="" |
|||
local TERMUX_SUBPKG_CONFLICTS="" |
|||
local TERMUX_SUBPKG_REPLACES="" |
|||
local TERMUX_SUBPKG_CONFFILES="" |
|||
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" |
|||
|
|||
for includeset in $TERMUX_SUBPKG_INCLUDE; do |
|||
local _INCLUDE_DIRSET |
|||
_INCLUDE_DIRSET=$(dirname "$includeset") |
|||
test "$_INCLUDE_DIRSET" = "." && _INCLUDE_DIRSET="" |
|||
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 |
|||
|
|||
local SUB_PKG_ARCH=$TERMUX_ARCH |
|||
test -n "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" && SUB_PKG_ARCH=all |
|||
|
|||
cd "$SUB_PKG_DIR/massage" |
|||
local SUB_PKG_INSTALLSIZE |
|||
SUB_PKG_INSTALLSIZE=$(du -sk . | cut -f 1) |
|||
tar -cJf "$SUB_PKG_PACKAGE_DIR/data.tar.xz" . |
|||
|
|||
mkdir -p DEBIAN |
|||
cd DEBIAN |
|||
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 |
|||
test ! -z "$TERMUX_SUBPKG_DEPENDS" && echo "Depends: $TERMUX_SUBPKG_DEPENDS" >> control |
|||
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 |
|||
tar -czf "$SUB_PKG_PACKAGE_DIR/control.tar.gz" . |
|||
|
|||
for f in $TERMUX_SUBPKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> conffiles; done |
|||
|
|||
# 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 |
|||
|
|||
# .. remove empty directories (NOTE: keep this last): |
|||
find . -type d -empty -delete |
|||
# Make sure user can read and write all files (problem with dpkg otherwise): |
|||
chmod -R u+rw . |
|||
} |
Loading…
Reference in new issue