new package: predict

This commit is contained in:
Tee KOBAYASHI 2022-03-15 17:33:30 +09:00 committed by xtkoba
parent eb34f28813
commit de39e20ac5
7 changed files with 193 additions and 0 deletions

67
packages/predict/build.sh Normal file
View File

@ -0,0 +1,67 @@
TERMUX_PKG_HOMEPAGE=https://www.qsl.net/kd2bd/predict.html
TERMUX_PKG_DESCRIPTION="Track and predict passes of satellites in Earth orbit"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2.2.3
TERMUX_PKG_SRCURL=https://ftp-osl.osuosl.org/pub/gentoo/distfiles/predict_${TERMUX_PKG_VERSION}.orig.tar.gz
TERMUX_PKG_SHA256=47b7c185f1cf4d318b6b31a22a533c03c4a3f57394839df036367c7cdf2dd7ff
TERMUX_PKG_DEPENDS="ncurses, ncurses-ui-libs"
TERMUX_PKG_GROUPS="science"
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_post_get_source() {
termux_download \
"https://ftp-osl.osuosl.org/pub/gentoo/distfiles/predict_2.2.3-3.1.diff.gz" \
$TERMUX_PKG_CACHEDIR/predict_2.2.3-3.1.diff.gz \
60c00a542c399e69dba154cc0827ea15f33dae61547f3604b8c232e9d26d06df
zcat $TERMUX_PKG_CACHEDIR/predict_2.2.3-3.1.diff.gz | patch --silent -p1
cat debian/patches/*.diff | patch --silent -p1
ln -sfT fodtrack-0.1 utils/fodtrack
}
termux_step_pre_configure() {
LDFLAGS+=" -lm"
}
termux_step_configure() {
:
}
termux_step_make() {
local p
for p in predict{,-g1yyh}; do
${CC} ${CFLAGS} ${CPPFLAGS} ${p}.c -o ${p} ${LDFLAGS} \
-lncursesw -lmenu
done
local d
for d in clients/kep_reload utils/{fodtrack,geosat,moontracker}; do
p=$(basename ${d})
pushd ${d}
${CC} ${CFLAGS} ${CPPFLAGS} ${p}.c -o ${p} ${LDFLAGS}
popd
done
}
termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin predict{,-g1yyh}
local d
for d in clients/kep_reload utils/{fodtrack,geosat,moontracker}; do
local p=$(basename ${d})
install -Dm700 -t $TERMUX_PREFIX/bin ${d}/${p}
done
install -Dm600 -t $TERMUX_PREFIX/etc utils/fodtrack/fodtrack.conf
install -Dm600 -t $TERMUX_PREFIX/share/man/man1 \
docs/man/predict.1 \
debian/{kep_reload,moontracker}.1
local p
for p in geosat predict-g1yyh; do
install -Dm600 -T debian/${p}.man \
$TERMUX_PREFIX/share/man/man1/${p}.1
done
install -Dm600 -t $TERMUX_PREFIX/share/man/man5 \
utils/fodtrack/fodtrack.conf.5
install -Dm600 -t $TERMUX_PREFIX/share/man/man8 \
utils/fodtrack/fodtrack.8
install -Dm600 -t $TERMUX_PREFIX/share/predict/default default/*
}

View File

@ -0,0 +1,10 @@
--- a/clients/kep_reload/kep_reload.c
+++ b/clients/kep_reload/kep_reload.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>

View File

@ -0,0 +1,53 @@
--- a/predict-g1yyh.c
+++ b/predict-g1yyh.c
@@ -35,7 +35,6 @@
#include <math.h>
#include <time.h>
-#include <sys/timeb.h>
#include <curses.h>
#include <menu.h>
#include <stdlib.h>
@@ -2031,7 +2030,7 @@
exit(-1);
}
- if ((type=SOCK_STREAM && listen(s,qlen))<0) {
+ if (type==SOCK_STREAM && listen(sd,qlen)<0) {
bailout("Listen fail");
exit(-1);
}
@@ -2264,7 +2263,7 @@
/* Send request to predict with output
directed to a temporary file under /tmp */
- strcpy(tempname,"/tmp/XXXXXX\0");
+ strcpy(tempname,"@TERMUX_PREFIX@/tmp/XXXXXX\0");
i=mkstemp(tempname);
sprintf(buff,"%s -f %s -t %s -q %s -o %s\n",predict_name,satname,tlefile,qthfile,tempname);
@@ -2309,7 +2308,7 @@
/* Send request to predict with output
directed to a temporary file under /tmp */
- strcpy(tempname,"/tmp/XXXXXX\0");
+ strcpy(tempname,"@TERMUX_PREFIX@/tmp/XXXXXX\0");
i=mkstemp(tempname);
sprintf(buff,"%s -p %s -t %s -q %s -o %s\n",predict_name, satname,tlefile,qthfile,tempname);
@@ -3301,12 +3300,12 @@
/* Read the system clock and return the number
* of days since 31Dec79 00:00:00 UTC (daynum 0) */
- struct timeb tptr;
+ struct timespec tptr;
int x;
- x=ftime(&tptr);
+ x=clock_gettime(CLOCK_REALTIME, &tptr);
- return ((((double)tptr.time+0.001*(double)tptr.millitm)/86400.0)-3651.0);
+ return ((((double)tptr.tv_sec+0.000000001*(double)tptr.tv_nsec)/86400.0)-3651.0);
}
char *Daynum2String(daynum, stlen, stfmt)

View File

@ -0,0 +1,29 @@
--- a/predict.c
+++ b/predict.c
@@ -2027,7 +2027,7 @@
exit(-1);
}
- if ((type=SOCK_STREAM && listen(s,qlen))<0)
+ if (type==SOCK_STREAM && listen(sd,qlen)<0)
{
bailout("Listen fail");
exit(-1);
@@ -2283,7 +2283,7 @@
/* Send request to predict with output
directed to a temporary file under /tmp */
- strcpy(tempname,"/tmp/XXXXXX\0");
+ strcpy(tempname,"@TERMUX_PREFIX@/tmp/XXXXXX\0");
i=mkstemp(tempname);
sprintf(buff,"%s -f %s -t %s -q %s -o %s\n",predict_name,satname,tlefile,qthfile,tempname);
@@ -2330,7 +2330,7 @@
/* Send request to predict with output
directed to a temporary file under /tmp */
- strcpy(tempname,"/tmp/XXXXXX\0");
+ strcpy(tempname,"@TERMUX_PREFIX@/tmp/XXXXXX\0");
i=mkstemp(tempname);
sprintf(buff,"%s -p %s -t %s -q %s -o %s\n",predict_name, satname,tlefile,qthfile,tempname);

View File

@ -0,0 +1,5 @@
--- a/predict.h
+++ b/predict.h
@@ -1 +1 @@
-char *predictpath={"/usr/lib/predict/"}, soundcard=1, *version={"2.2.3"};
+char *predictpath={"@TERMUX_PREFIX@/share/predict/"}, soundcard=0, *version={"2.2.3"};

View File

@ -0,0 +1,13 @@
--- a/utils/fodtrack-0.1/fodtrack.c
+++ b/utils/fodtrack-0.1/fodtrack.c
@@ -20,8 +20,8 @@
#define false 0
#define true 1
-#define PSEUDODEVICEFILE "/tmp/fodtrackdevice"
-#define CONFIGFILE "/etc/fodtrack.conf"
+#define PSEUDODEVICEFILE "@TERMUX_PREFIX@/tmp/fodtrackdevice"
+#define CONFIGFILE "@TERMUX_PREFIX@/etc/fodtrack.conf"
static int fodtrackfd;
static int azimuthcorrection;

View File

@ -0,0 +1,16 @@
--- a/utils/moontracker/moontracker.c
+++ b/utils/moontracker/moontracker.c
@@ -23,11 +23,12 @@
#include <stdio.h>
#include <math.h>
#include <string.h>
+#include <strings.h>
#include <fcntl.h>
#include <termios.h>
#include <signal.h>
-char callsign[20], output[20];
+char callsign[20], output[21];
int qthalt, pid;
double qthlat, qthlong, moon_az, moon_el, moonrise,
PI=3.141592653589793, TWOPI=6.28318530717958623,