termux-api: Cleanup and put termux-api binary in libexec
authorFredrik Fornwall <fredrik@fornwall.net>
Fri, 14 Aug 2015 19:27:47 +0000 (15:27 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Fri, 14 Aug 2015 19:27:47 +0000 (15:27 -0400)
18 files changed:
packages/termux-api/build.sh
packages/termux-api/termux-battery-status
packages/termux-api/termux-camera-info
packages/termux-api/termux-camera-photo
packages/termux-api/termux-clipboard-get
packages/termux-api/termux-clipboard-set
packages/termux-api/termux-contact-list
packages/termux-api/termux-dialog
packages/termux-api/termux-download
packages/termux-api/termux-location
packages/termux-api/termux-notification
packages/termux-api/termux-share
packages/termux-api/termux-sms-inbox
packages/termux-api/termux-sms-send
packages/termux-api/termux-toast
packages/termux-api/termux-tts-engines
packages/termux-api/termux-tts-speak
packages/termux-api/termux-vibrate

index e79016c..4cbb64e 100644 (file)
@@ -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
 }
index 3a457ea..4441d48 100755 (executable)
@@ -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
index cdd16ca..ec6bda1 100755 (executable)
@@ -1,3 +1,3 @@
-#!/system/bin/sh
+#!/bin/sh
 
-termux-api CameraInfo
+@TERMUX_API@ CameraInfo
index 08f4451..bdb27a5 100755 (executable)
@@ -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
index daaf6c4..3a39aac 100755 (executable)
@@ -1,3 +1,3 @@
-#!/system/bin/sh
+#!/bin/sh
 
-termux-api Clipboard
+@TERMUX_API@ Clipboard
index 2ac3f4b..076ea01 100755 (executable)
@@ -1,4 +1,4 @@
-#!/system/bin/sh
+#!/bin/sh
 
 TEXT=`cat -`
-termux-api Clipboard --es text "$TEXT"
+@TERMUX_API@ Clipboard --es text "$TEXT"
index 6773a0d..8f38e03 100755 (executable)
@@ -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
index c5555ef..073c60e 100755 (executable)
@@ -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
index 1c7e469..c7b8fea 100755 (executable)
@@ -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
index 08d05af..1c3e0fa 100755 (executable)
@@ -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
index 9c08440..d186d5f 100755 (executable)
@@ -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
index e083272..68044bd 100755 (executable)
@@ -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
index 8203e03..82b9f8b 100755 (executable)
@@ -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
index 7d35a01..67b0f31 100755 (executable)
@@ -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
index e54b04f..247d091 100755 (executable)
@@ -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
index fd4f021..18b5537 100755 (executable)
@@ -1,3 +1,3 @@
-#!/system/bin/sh
+#!/bin/sh
 
-termux-api TextToSpeech --es engine LIST_AVAILABLE
+@TERMUX_API@ TextToSpeech --es engine LIST_AVAILABLE
index ee09871..9fe2b10 100755 (executable)
@@ -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
index 78187e0..8146d2f 100755 (executable)
@@ -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