git: 670f7113501b - main - polish/napi: Add new port

From: Yasuhiro Kimura <yasu_at_FreeBSD.org>
Date: Sun, 31 Oct 2021 16:09:15 UTC
The branch main has been updated by yasu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=670f7113501b81f3ea7ae1aca7c44fa335048b20

commit 670f7113501b81f3ea7ae1aca7c44fa335048b20
Author:     Dominik Lisiak <dominik.lisiak@bemsoft.pl>
AuthorDate: 2021-10-31 15:44:19 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2021-10-31 16:08:14 +0000

    polish/napi: Add new port
    
    "napi.sh" is a napiprojekt.pl client written in Bash. The purpose of
    the project was to create simple tool for systems with very limited
    resources (NAS QNAP drives, Synology, OpenWRT routers, Popcorn
    streamers, etc). It was inspired by "pynapi.py" script.
    
    "napi.sh" is distributed together with automatic subtitle format
    converter "subotage.sh" created specially for "napi.sh". "subotage.sh"
    is written in Bash and uses awk for text processing.
    
    PR:             245996
---
 polish/Makefile                                   |  1 +
 polish/napi/Makefile                              | 56 +++++++++++++++++++++++
 polish/napi/distinfo                              |  3 ++
 polish/napi/files/patch-libs_libnapi__fs.sh       | 29 ++++++++++++
 polish/napi/files/patch-libs_libnapi__subs.sh     | 16 +++++++
 polish/napi/files/patch-libs_libnapi__wrappers.sh | 24 ++++++++++
 polish/napi/pkg-descr                             | 10 ++++
 polish/napi/pkg-plist                             | 23 ++++++++++
 8 files changed, 162 insertions(+)

diff --git a/polish/Makefile b/polish/Makefile
index 208f69285a27..76f6cae99dd4 100644
--- a/polish/Makefile
+++ b/polish/Makefile
@@ -10,6 +10,7 @@
     SUBDIR += libreoffice
     SUBDIR += libtlen
     SUBDIR += mythes
+    SUBDIR += napi
     SUBDIR += qnapi
     SUBDIR += tleenx2
     SUBDIR += trf
diff --git a/polish/napi/Makefile b/polish/napi/Makefile
new file mode 100644
index 000000000000..e6db02445bed
--- /dev/null
+++ b/polish/napi/Makefile
@@ -0,0 +1,56 @@
+PORTNAME=	napi
+PORTVERSION=	2.0.1
+CATEGORIES=	polish multimedia
+
+MAINTAINER=	dominik.lisiak@bemsoft.pl
+COMMENT=	Command line subtitles downloader for napiprojekt.pl
+
+LICENSE=	GPLv3
+
+RUN_DEPENDS=	7z:archivers/p7zip \
+		base64:converters/base64 \
+		bash:shells/bash \
+		mediainfo:multimedia/mediainfo \
+		wget:ftp/wget
+
+USES=		cmake shebangfix
+
+USE_GITLAB=	yes
+GL_ACCOUNT=	hesperos
+GL_PROJECT=	${PORTNAME}
+GL_COMMIT=	ac404649571e470bf9494f788bd8a74843956851
+
+SHEBANG_GLOB=	*.sh *.sh.in
+
+STRIP=
+NO_ARCH=	yes
+
+OPTIONS_DEFINE=	COVER NFO RMORIG SUBRIP UTF8
+
+COVER_DESC=	Always try to download cover (-c)
+NFO_DESC=	Always try to download .nfo file (-n)
+RMORIG_DESC=	Always remove intermediate files (-d)
+SUBRIP_DESC=	Convert subtitles to SubRip (.srt) by default (-f subrip)
+UTF8_DESC=	Convert subtitles to UTF-8 by default (-C UTF-8)
+
+NAPI_CONF=	libs/libnapi_sysconf.sh
+
+post-patch-COVER-on:
+	@${REINPLACE_CMD} -e 's|\(napiprojekt\.cover\.download\)=0|\1=1|' ${WRKSRC}/${NAPI_CONF}
+
+post-patch-NFO-on:
+	@${REINPLACE_CMD} -e 's|\(napiprojekt\.nfo\.download\)=0|\1=1|' ${WRKSRC}/${NAPI_CONF}
+
+post-patch-RMORIG-on:
+	@${REINPLACE_CMD} -e 's|\(napiprojekt\.subtitles\.orig\.delete\)=0|\1=1|' ${WRKSRC}/${NAPI_CONF}
+
+post-patch-SUBRIP-on:
+	@${REINPLACE_CMD} -e 's|\(napiprojekt\.subtitles\.format\)=default|\1=subrip|' ${WRKSRC}/${NAPI_CONF}
+
+post-patch-UTF8-on:
+	@${REINPLACE_CMD} -e 's|\(napiprojekt\.subtitles\.encoding\)=default|\1=UTF-8|' ${WRKSRC}/${NAPI_CONF}
+
+post-install:
+	@${RM} -r ${STAGEDIR}${LOCALBASE}/lib/napi/*.in
+
+.include <bsd.port.mk>
diff --git a/polish/napi/distinfo b/polish/napi/distinfo
new file mode 100644
index 000000000000..f9e74e94c15e
--- /dev/null
+++ b/polish/napi/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1624840400
+SHA256 (hesperos-napi-ac404649571e470bf9494f788bd8a74843956851_GL0.tar.gz) = 41919054d04b93f90d5a4a13f2964322111194afe60212bb434f105f6c7675e0
+SIZE (hesperos-napi-ac404649571e470bf9494f788bd8a74843956851_GL0.tar.gz) = 106739
diff --git a/polish/napi/files/patch-libs_libnapi__fs.sh b/polish/napi/files/patch-libs_libnapi__fs.sh
new file mode 100644
index 000000000000..755e942821a3
--- /dev/null
+++ b/polish/napi/files/patch-libs_libnapi__fs.sh
@@ -0,0 +1,29 @@
+--- libs/libnapi_fs.sh.orig	2020-04-24 07:22:41 UTC
++++ libs/libnapi_fs.sh
+@@ -54,7 +54,7 @@ _fs_configureStat_GV() {
+     # verify stat tool
+     ___g_fsWrappers[$___g_fsStat]="stat -c%s "
+ 
+-    if wrappers_isSystemDarwin; then
++    if wrappers_isSystemDarwin || wrappers_isSystemFreeBSD; then
+         # stat may be installed through macports, check if
+         # there's a need to reconfigure it to BSD flavour
+         ${___g_fsWrappers[$___g_fsStat]} "$0" >/dev/null 2>&1 ||
+@@ -72,6 +72,8 @@ _fs_configureBase64_GV() {
+     # verify base64
+     wrappers_isSystemDarwin &&
+         ___g_fsWrappers[$___g_fsBase64]="base64 -D"
++    wrappers_isSystemFreeBSD &&
++        ___g_fsWrappers[$___g_fsBase64]="base64 -d"
+ }
+ 
+ #
+@@ -83,6 +85,8 @@ _fs_configureMd5_GV() {
+     # verify md5 tool
+     ___g_fsWrappers[$___g_fsMd5]="md5sum"
+     wrappers_isSystemDarwin &&
++        ___g_fsWrappers[$___g_fsMd5]="md5"
++    wrappers_isSystemFreeBSD &&
+         ___g_fsWrappers[$___g_fsMd5]="md5"
+ }
+ 
diff --git a/polish/napi/files/patch-libs_libnapi__subs.sh b/polish/napi/files/patch-libs_libnapi__subs.sh
new file mode 100644
index 000000000000..2b55c8f3f902
--- /dev/null
+++ b/polish/napi/files/patch-libs_libnapi__subs.sh
@@ -0,0 +1,16 @@
+--- libs/libnapi_subs.sh.orig	2020-04-26 01:52:36 UTC
++++ libs/libnapi_subs.sh
+@@ -189,11 +189,11 @@ subs_convertFormat() {
+     subotage_processFile \
+         "${videoFileDir}/${sourceSubsFileName}" \
+         "none" \
+-        "0" \
++        "${fps}" \
+         "" \
+         "${videoFileDir}/${destSubsFileName}" \
+         "${format}" \
+-        "${fps}" \
++        "0" \
+         ""
+     convStatus=$?
+ 
diff --git a/polish/napi/files/patch-libs_libnapi__wrappers.sh b/polish/napi/files/patch-libs_libnapi__wrappers.sh
new file mode 100644
index 000000000000..fd696a768cbe
--- /dev/null
+++ b/polish/napi/files/patch-libs_libnapi__wrappers.sh
@@ -0,0 +1,24 @@
+--- libs/libnapi_wrappers.sh.orig	2020-04-24 07:38:48 UTC
++++ libs/libnapi_wrappers.sh
+@@ -129,13 +129,20 @@ wrappers_isSystemDarwin() {
+ }
+ 
+ #
++# @brief returns true if system is FreeBSD
++#
++wrappers_isSystemFreeBSD() {
++    [ "$(wrappers_getSystem_SO)" = "freebsd" ]
++}
++
++#
+ # @brief determines number of available cpu's in the system
+ #
+ # @param system type (linux|darwin)
+ #
+ wrappers_getCores_SO() {
+     local os="${1:-linux}"
+-    if wrappers_isSystemDarwin; then
++    if wrappers_isSystemDarwin || wrappers_isSystemFreeBSD; then
+         sysctl hw.ncpu | cut -d ' ' -f 2
+ 	else
+         grep -i processor /proc/cpuinfo | wc -l
diff --git a/polish/napi/pkg-descr b/polish/napi/pkg-descr
new file mode 100644
index 000000000000..ff00f50bb29a
--- /dev/null
+++ b/polish/napi/pkg-descr
@@ -0,0 +1,10 @@
+"napi.sh" is a napiprojekt.pl client written in Bash. The purpose of the project
+was to create simple tool for systems with very limited resources (NAS QNAP
+drives, Synology, OpenWRT routers, Popcorn streamers, etc). It was inspired by
+"pynapi.py" script.
+
+"napi.sh" is distributed together with automatic subtitle format converter
+"subotage.sh" created specially for "napi.sh". "subotage.sh" is written in Bash
+and uses awk for text processing.
+
+WWW: https://gitlab.com/hesperos/napi
diff --git a/polish/napi/pkg-plist b/polish/napi/pkg-plist
new file mode 100644
index 000000000000..7a30d3b29174
--- /dev/null
+++ b/polish/napi/pkg-plist
@@ -0,0 +1,23 @@
+bin/napi.sh
+bin/subotage.sh
+lib/napi/actions/libnapi_download.sh
+lib/napi/actions/libnapi_scan.sh
+lib/napi/actions/libnapi_search.sh
+lib/napi/actions/libnapi_subtitles.sh
+lib/napi/libnapi_argv.sh
+lib/napi/libnapi_assoc.sh
+lib/napi/libnapi_constants.sh
+lib/napi/libnapi_fs.sh
+lib/napi/libnapi_hooks.sh
+lib/napi/libnapi_http.sh
+lib/napi/libnapi_language.sh
+lib/napi/libnapi_logging.sh
+lib/napi/libnapi_napiprojekt.sh
+lib/napi/libnapi_retvals.sh
+lib/napi/libnapi_subotage.sh
+lib/napi/libnapi_subs.sh
+lib/napi/libnapi_sysconf.sh
+lib/napi/libnapi_tools.sh
+lib/napi/libnapi_version.sh
+lib/napi/libnapi_wrappers.sh
+lib/napi/libnapi_xml.sh