diff --git a/packages/termux-api/build.sh b/packages/termux-api/build.sh index e79016c06..4cbb64ee7 100644 --- a/packages/termux-api/build.sh +++ b/packages/termux-api/build.sh @@ -1,11 +1,14 @@ TERMUX_PKG_HOMEPAGE=http://termux.com/add-ons/api/ TERMUX_PKG_DESCRIPTION="Termux API commands" -TERMUX_PKG_VERSION=0.7 +TERMUX_PKG_VERSION=0.8 termux_step_make_install () { mkdir -p $TERMUX_PREFIX/bin - for file in `ls $TERMUX_PKG_BUILDER_DIR/* | grep -v build.sh | grep -v termux-api.c`; do - cp $file $TERMUX_PREFIX/bin + local TERMUX_API_BINARY=$TERMUX_PREFIX/libexec/termux-api + cd $TERMUX_PKG_BUILDER_DIR + for file in `ls termux-* | grep -v termux-api.c`; do + sed "s|@TERMUX_API@|$TERMUX_API_BINARY|" $file > $TERMUX_PREFIX/bin/$file + chmod +x $TERMUX_PREFIX/bin/$file done - $CC $CFLAGS -std=c11 -Wall -Wextra -pedantic -Werror $LDFLAGS $TERMUX_PKG_BUILDER_DIR/termux-api.c -o $TERMUX_PREFIX/bin/termux-api + $CC $CFLAGS -std=c11 -Wall -Wextra -pedantic -Werror $LDFLAGS termux-api.c -o $TERMUX_API_BINARY } diff --git a/packages/termux-api/termux-battery-status b/packages/termux-api/termux-battery-status index 3a457eaa9..4441d48af 100755 --- a/packages/termux-api/termux-battery-status +++ b/packages/termux-api/termux-battery-status @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh if [ "$#" != "0" ]; then echo "usage: termux-battery-status" @@ -6,4 +6,4 @@ if [ "$#" != "0" ]; then exit 1 fi -termux-api BatteryStatus +@TERMUX_API@ BatteryStatus diff --git a/packages/termux-api/termux-camera-info b/packages/termux-api/termux-camera-info index cdd16ca99..ec6bda1f7 100755 --- a/packages/termux-api/termux-camera-info +++ b/packages/termux-api/termux-camera-info @@ -1,3 +1,3 @@ -#!/system/bin/sh +#!/bin/sh -termux-api CameraInfo +@TERMUX_API@ CameraInfo diff --git a/packages/termux-api/termux-camera-photo b/packages/termux-api/termux-camera-photo index 08f44516e..bdb27a5aa 100755 --- a/packages/termux-api/termux-camera-photo +++ b/packages/termux-api/termux-camera-photo @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -e -u @@ -28,4 +28,4 @@ if [ $# != 1 ]; then show_usage; exit 1; fi touch $1 PARAMS="$PARAMS --es file `realpath $1`" -termux-api CameraPhoto $PARAMS +@TERMUX_API@ CameraPhoto $PARAMS diff --git a/packages/termux-api/termux-clipboard-get b/packages/termux-api/termux-clipboard-get index daaf6c426..3a39aace7 100755 --- a/packages/termux-api/termux-clipboard-get +++ b/packages/termux-api/termux-clipboard-get @@ -1,3 +1,3 @@ -#!/system/bin/sh +#!/bin/sh -termux-api Clipboard +@TERMUX_API@ Clipboard diff --git a/packages/termux-api/termux-clipboard-set b/packages/termux-api/termux-clipboard-set index 2ac3f4bd7..076ea0155 100755 --- a/packages/termux-api/termux-clipboard-set +++ b/packages/termux-api/termux-clipboard-set @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh TEXT=`cat -` -termux-api Clipboard --es text "$TEXT" +@TERMUX_API@ Clipboard --es text "$TEXT" diff --git a/packages/termux-api/termux-contact-list b/packages/termux-api/termux-contact-list index 6773a0d81..8f38e0345 100755 --- a/packages/termux-api/termux-contact-list +++ b/packages/termux-api/termux-contact-list @@ -1,10 +1,10 @@ -#!/system/bin/sh +#!/bin/sh set -e -u if [ "$#" != "0" ]; then echo "usage: termux-contact-list" echo "List all contacts." - exit 1 + exit fi -termux-api ContactList +@TERMUX_API@ ContactList diff --git a/packages/termux-api/termux-dialog b/packages/termux-api/termux-dialog index c5555ef89..073c60e41 100755 --- a/packages/termux-api/termux-dialog +++ b/packages/termux-api/termux-dialog @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -e -u @@ -25,4 +25,4 @@ done # Too many arguments: if [ $# != 0 ]; then show_usage; exit 1; fi -eval termux-api Dialog $PARAMS +eval @TERMUX_API@ Dialog $PARAMS diff --git a/packages/termux-api/termux-download b/packages/termux-api/termux-download index 1c7e469ba..c7b8fea98 100755 --- a/packages/termux-api/termux-download +++ b/packages/termux-api/termux-download @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -e -u @@ -27,4 +27,4 @@ done # Too many arguments: if [ $# != 1 ]; then show_usage; exit 1; fi -eval termux-api Download $PARAMS $1 +eval @TERMUX_API@ Download $PARAMS $1 diff --git a/packages/termux-api/termux-location b/packages/termux-api/termux-location index 08d05aff2..1c3e0fa0a 100755 --- a/packages/termux-api/termux-location +++ b/packages/termux-api/termux-location @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -e -u PARAMS="" @@ -25,4 +25,4 @@ done # Too many arguments: if [ $# != 0 ]; then show_usage; exit 1; fi -termux-api Location $PARAMS +@TERMUX_API@ Location $PARAMS diff --git a/packages/termux-api/termux-notification b/packages/termux-api/termux-notification index 9c08440ca..d186d5f04 100755 --- a/packages/termux-api/termux-notification +++ b/packages/termux-api/termux-notification @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -u @@ -35,4 +35,4 @@ if [ $CONTENT_OR_TITLE_SET = "no" ]; then exit 1; fi; -termux-api Notification $PARAMS +@TERMUX_API@ Notification $PARAMS diff --git a/packages/termux-api/termux-share b/packages/termux-api/termux-share index e08327256..68044bdf7 100755 --- a/packages/termux-api/termux-share +++ b/packages/termux-api/termux-share @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh show_usage () { echo "usage: termux-share [options] [file]" @@ -45,4 +45,4 @@ done if [ $# -gt 1 ]; then echo "Only one file can be shared"; exit 1; fi if [ $# != 0 ]; then PARAMS="$PARAMS --es file `realpath $1`"; fi -termux-api Share $PARAMS +@TERMUX_API@ Share $PARAMS diff --git a/packages/termux-api/termux-sms-inbox b/packages/termux-api/termux-sms-inbox index 8203e0397..82b9f8bfd 100755 --- a/packages/termux-api/termux-sms-inbox +++ b/packages/termux-api/termux-sms-inbox @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -u PARAM_LIMIT=10 @@ -37,4 +37,4 @@ if [ $# != 0 ]; then show_usage; exit 1; fi PARAMS="$PARAMS --ei offset $PARAM_OFFSET --ei limit $PARAM_LIMIT" -termux-api SmsInbox $PARAMS +@TERMUX_API@ SmsInbox $PARAMS diff --git a/packages/termux-api/termux-sms-send b/packages/termux-api/termux-sms-send index 7d35a01e7..67b0f3103 100755 --- a/packages/termux-api/termux-sms-send +++ b/packages/termux-api/termux-sms-send @@ -7,4 +7,4 @@ if [ $# != 1 -o $1 = "-h" ]; then exit 1 fi -termux-api SmsSend --es recipient $1 +@TERMUX_API@ SmsSend --es recipient $1 diff --git a/packages/termux-api/termux-toast b/packages/termux-api/termux-toast index e54b04f13..247d09123 100755 --- a/packages/termux-api/termux-toast +++ b/packages/termux-api/termux-toast @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh show_usage () { echo "usage: termux-toast [-s|--short]" @@ -21,4 +21,4 @@ done if [ $# != 0 ]; then show_usage; exit 1; fi -termux-api Toast $PARAMS +@TERMUX_API@ Toast $PARAMS diff --git a/packages/termux-api/termux-tts-engines b/packages/termux-api/termux-tts-engines index fd4f021d7..18b55373d 100755 --- a/packages/termux-api/termux-tts-engines +++ b/packages/termux-api/termux-tts-engines @@ -1,3 +1,3 @@ -#!/system/bin/sh +#!/bin/sh -termux-api TextToSpeech --es engine LIST_AVAILABLE +@TERMUX_API@ TextToSpeech --es engine LIST_AVAILABLE diff --git a/packages/termux-api/termux-tts-speak b/packages/termux-api/termux-tts-speak index ee0987118..9fe2b10ef 100755 --- a/packages/termux-api/termux-tts-speak +++ b/packages/termux-api/termux-tts-speak @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -u @@ -30,4 +30,4 @@ case "$1" in esac done -termux-api TextToSpeech $PARAMS +@TERMUX_API@ TextToSpeech $PARAMS diff --git a/packages/termux-api/termux-vibrate b/packages/termux-api/termux-vibrate index 78187e028..8146d2f33 100755 --- a/packages/termux-api/termux-vibrate +++ b/packages/termux-api/termux-vibrate @@ -1,4 +1,4 @@ -#!/system/bin/sh +#!/bin/sh set -e -u @@ -20,4 +20,4 @@ case "$1" in esac done -termux-api Vibrate $PARAM_DURATION +@TERMUX_API@ Vibrate $PARAM_DURATION