mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-08 21:00:05 +02:00
net-dns/yaddns: new recipe (#2086)
This commit is contained in:
232
net-dns/yaddns/patches/yaddns-1.1.patchset
Normal file
232
net-dns/yaddns/patches/yaddns-1.1.patchset
Normal file
@@ -0,0 +1,232 @@
|
||||
From d10b7fed809920348adeee24fa8c83656df1bc1d Mon Sep 17 00:00:00 2001
|
||||
From: sfanxiang <sfanxiang@gmail.com>
|
||||
Date: Mon, 8 Jan 2018 10:10:48 +0000
|
||||
Subject: port to Haiku
|
||||
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index d8c6668..fd6b42d 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -9,6 +9,7 @@ test ".$CFLAGS" = "." && CFLAGS=" "
|
||||
|
||||
# programs needed to build/install
|
||||
AC_PROG_CC
|
||||
+AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_RANLIB
|
||||
|
||||
@@ -66,6 +67,8 @@ if test "x$enable_log_color" = "xyes"; then
|
||||
CFLAGS="$CFLAGS -DENABLE_LOG_COLOR"
|
||||
fi
|
||||
|
||||
+CXXFLAGS=$CFLAGS
|
||||
+
|
||||
# the generated files
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 750ae3a..122a989 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -5,6 +5,7 @@ bin_PROGRAMS = yaddns
|
||||
yaddns_SOURCES = yaddns.c yaddns.h \
|
||||
config.c config.h \
|
||||
account.c account.h \
|
||||
+ ifaddr.cc ifaddr.h \
|
||||
request.c request.h \
|
||||
log.c log.h \
|
||||
util.c util.h \
|
||||
diff --git a/src/config.c b/src/config.c
|
||||
index 8f7b324..2897610 100644
|
||||
--- a/src/config.c
|
||||
+++ b/src/config.c
|
||||
@@ -7,13 +7,15 @@
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
|
||||
+#include <FindDirectory.h>
|
||||
+#include <fs_info.h>
|
||||
+
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "service.h"
|
||||
#include "services.h"
|
||||
#include "util.h"
|
||||
|
||||
-#define CFG_DEFAULT_FILENAME "/etc/yaddns.conf"
|
||||
#define CFG_DEFAULT_WANIFNAME "ppp0"
|
||||
|
||||
/*
|
||||
@@ -228,7 +230,18 @@ int config_parse(struct cfg *cfg, int argc, char **argv)
|
||||
|
||||
if(!cfgstr_is_set(&(cfg->cfgfile)))
|
||||
{
|
||||
- cfgstr_set(&(cfg->cfgfile), CFG_DEFAULT_FILENAME);
|
||||
+ const char filename[] = "/yaddns.conf";
|
||||
+
|
||||
+ dev_t vol = dev_for_path("/boot");
|
||||
+ static char buf[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
|
||||
+
|
||||
+ status_t res = find_directory(
|
||||
+ B_SYSTEM_SETTINGS_DIRECTORY,
|
||||
+ vol, 0, buf, sizeof(buf));
|
||||
+ if (res != B_NO_ERROR) return -1;
|
||||
+
|
||||
+ strcpy(&buf[strlen(buf)], filename);
|
||||
+ cfgstr_set(&(cfg->cfgfile), buf);
|
||||
}
|
||||
|
||||
if(config_parse_file(cfg) != 0)
|
||||
diff --git a/src/ifaddr.cc b/src/ifaddr.cc
|
||||
new file mode 100644
|
||||
index 0000000..650d9a9
|
||||
--- /dev/null
|
||||
+++ b/src/ifaddr.cc
|
||||
@@ -0,0 +1,28 @@
|
||||
+#include "ifaddr.h"
|
||||
+
|
||||
+#include <NetworkInterface.h>
|
||||
+#include <NetworkRoster.h>
|
||||
+
|
||||
+extern "C" {
|
||||
+
|
||||
+int getifaddr(const char *ifname, struct in_addr *addr)
|
||||
+{
|
||||
+ if(!ifname || ifname[0]=='\0')
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ BNetworkInterface interface(ifname);
|
||||
+ if (!interface.Exists()) return -1;
|
||||
+
|
||||
+ BNetworkInterfaceAddress address;
|
||||
+ if (interface.GetAddressAt(0, address) != B_OK) return -1;
|
||||
+
|
||||
+ struct sockaddr sa = address.Address().SockAddr();
|
||||
+ if (sa.sa_family != AF_INET) return -1;
|
||||
+
|
||||
+ *addr = ((struct sockaddr_in *)&sa)->sin_addr;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+}
|
||||
diff --git a/src/ifaddr.h b/src/ifaddr.h
|
||||
new file mode 100644
|
||||
index 0000000..ae723c3
|
||||
--- /dev/null
|
||||
+++ b/src/ifaddr.h
|
||||
@@ -0,0 +1,17 @@
|
||||
+#ifndef _IFADDR_H
|
||||
+#define _IFADDR_H
|
||||
+
|
||||
+#include <netinet/in.h>
|
||||
+#include <sys/socket.h>
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+int getifaddr(const char *ifname, struct in_addr *addr);
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#endif
|
||||
diff --git a/src/util.c b/src/util.c
|
||||
index 624ab3e..80fdb4b 100644
|
||||
--- a/src/util.c
|
||||
+++ b/src/util.c
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
+#include "ifaddr.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -90,42 +91,12 @@ time_t util_getuptime(void)
|
||||
|
||||
int util_getifaddr(const char *ifname, struct in_addr *addr)
|
||||
{
|
||||
- /* SIOCGIFADDR struct ifreq * */
|
||||
- int s;
|
||||
- struct ifreq ifr;
|
||||
- int ifrlen;
|
||||
-
|
||||
- if(!ifname || ifname[0]=='\0')
|
||||
- {
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- s = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
- if(s < 0)
|
||||
- {
|
||||
- log_error("socket(PF_INET, SOCK_DGRAM): %s",
|
||||
- strerror(errno));
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- memset(&ifr, 0, sizeof(ifr));
|
||||
- ifr.ifr_addr.sa_family = AF_INET; /* IPv4 IP address */
|
||||
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
|
||||
- ifrlen = sizeof(ifr);
|
||||
-
|
||||
- if(ioctl(s, SIOCGIFADDR, &ifr, &ifrlen) < 0)
|
||||
- {
|
||||
- log_error("ioctl(s, SIOCGIFADDR, ...): %s",
|
||||
- strerror(errno));
|
||||
- close(s);
|
||||
+ if (getifaddr(ifname, addr) == 0) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ log_error("getifaddr(ifname, addr) failed");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- *addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
|
||||
-
|
||||
- close(s);
|
||||
-
|
||||
- return 0;
|
||||
}
|
||||
|
||||
char *strdup_trim(const char *s)
|
||||
diff --git a/src/yaddns.c b/src/yaddns.c
|
||||
index 722d324..0b53c17 100644
|
||||
--- a/src/yaddns.c
|
||||
+++ b/src/yaddns.c
|
||||
@@ -229,8 +229,6 @@ int main(int argc, char **argv)
|
||||
goto exit_clean;
|
||||
}
|
||||
|
||||
- sig_blockall();
|
||||
-
|
||||
sigemptyset(&unblocked);
|
||||
|
||||
/* config */
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index 3d03671..baa8cef 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -14,6 +14,7 @@ YADDNS_OBJS = $(top_builddir)/src/request.o \
|
||||
$(top_builddir)/src/services/libservices.a \
|
||||
$(top_builddir)/src/account.o \
|
||||
$(top_builddir)/src/config.o \
|
||||
+ $(top_builddir)/src/ifaddr.o \
|
||||
$(top_builddir)/src/util.o \
|
||||
$(top_builddir)/src/log.o
|
||||
|
||||
@@ -31,5 +32,6 @@ check_account_SOURCES = check_account.c $(top_builddir)/src/account.h \
|
||||
$(top_builddir)/src/service.h
|
||||
check_account_LDADD = $(YADDNS_OBJS)
|
||||
|
||||
-check_util_SOURCES = check_util.c $(top_builddir)/src/util.h
|
||||
+check_util_SOURCES = check_util.c $(top_builddir)/src/util.h \
|
||||
+ $(top_builddir)/src/ifaddr.h
|
||||
check_util_LDADD = $(YADDNS_OBJS)
|
||||
--
|
||||
2.15.0
|
||||
|
||||
83
net-dns/yaddns/yaddns-1.1.recipe
Normal file
83
net-dns/yaddns/yaddns-1.1.recipe
Normal file
@@ -0,0 +1,83 @@
|
||||
SUMMARY="A small dynamic DNS client"
|
||||
DESCRIPTION="Yaddns is a small dynamic dns client with multiple servers \
|
||||
support and a high flexibility."
|
||||
HOMEPAGE="https://yaddns.github.io/"
|
||||
COPYRIGHT="2015 Anthony Viallard and Raphael Huck"
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="1"
|
||||
SOURCE_URI="https://github.com/yaddns/yaddns/archive/yaddns-$portVersion.tar.gz"
|
||||
CHECKSUM_SHA256="23b527b7f71e1449746f1e39cbc3a074d58bd261a33399fb4e2d90eb63149059"
|
||||
SOURCE_DIR="yaddns-yaddns-$portVersion"
|
||||
PATCHES="yaddns-$portVersion.patchset"
|
||||
|
||||
ARCHITECTURES="!x86_gcc2 ?x86 x86_64"
|
||||
SECONDARY_ARCHITECTURES="x86"
|
||||
|
||||
commandBinDir=$binDir
|
||||
commandSuffix=$secondaryArchSuffix
|
||||
if [ "$targetArchitecture" = x86_gcc2 ]
|
||||
then
|
||||
commandBinDir=$prefix/bin
|
||||
commandSuffix=
|
||||
fi
|
||||
|
||||
PROVIDES="
|
||||
yaddns$secondaryArchSuffix = $portVersion
|
||||
cmd:yaddns$commandSuffix = $portVersion
|
||||
"
|
||||
REQUIRES="
|
||||
haiku$secondaryArchSuffix
|
||||
"
|
||||
|
||||
BUILD_REQUIRES="
|
||||
haiku${secondaryArchSuffix}_devel
|
||||
devel:libcrypto$secondaryArchSuffix
|
||||
"
|
||||
BUILD_PREREQUIRES="
|
||||
cmd:aclocal
|
||||
cmd:autoconf
|
||||
cmd:autom4te
|
||||
cmd:automake
|
||||
cmd:autoreconf
|
||||
cmd:g++$secondaryArchSuffix
|
||||
cmd:gcc$secondaryArchSuffix
|
||||
cmd:ld$secondaryArchSuffix
|
||||
cmd:make
|
||||
cmd:makeinfo
|
||||
"
|
||||
|
||||
USER_SETTINGS_FILES="
|
||||
settings/yaddns.conf
|
||||
"
|
||||
|
||||
defineDebugInfoPackage yaddns$secondaryArchSuffix \
|
||||
$commandBinDir/yaddns
|
||||
|
||||
PATCH()
|
||||
{
|
||||
sed -i -e "s|/etc\(/yaddns\.conf\)|`finddir B_SYSTEM_SETTINGS_DIRECTORY`\1|;" \
|
||||
doc/yaddns.1
|
||||
}
|
||||
|
||||
BUILD()
|
||||
{
|
||||
./autogen.sh
|
||||
CPPFLAGS="-D_BSD_SOURCE" \
|
||||
LIBS="-Wl,--as-needed -lbnetapi -lbsd -lnetwork" runConfigure \
|
||||
--omit-dirs binDir ./configure --bindir $commandBinDir
|
||||
|
||||
make $jobArgs
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
make install
|
||||
install -d $docDir
|
||||
install AUTHORS $docDir
|
||||
install etc/yaddns.conf $docDir/yaddns.conf.example
|
||||
}
|
||||
|
||||
TEST()
|
||||
{
|
||||
LIBS="-Wl,--as-needed -lbnetapi -lnetwork" make check
|
||||
}
|
||||
Reference in New Issue
Block a user