uftp: added package to upstream

added net-misc/uftp to version 4.10.1 on amd64

BUG=b:155147650
TEST=make_netboot.sh --board=octopus

Change-Id: I32b3cdef1570ee93be75ab9f4370e37b676ddb08
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2172842
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Stimim Chen <stimim@chromium.org>
Tested-by: Pin-yen Lin <treapking@chromium.org>
Commit-Queue: Pin-yen Lin <treapking@chromium.org>
diff --git a/metadata/md5-cache/net-misc/uftp-4.10.1 b/metadata/md5-cache/net-misc/uftp-4.10.1
new file mode 100644
index 0000000..947f698
--- /dev/null
+++ b/metadata/md5-cache/net-misc/uftp-4.10.1
@@ -0,0 +1,14 @@
+DEFINED_PHASES=compile install postinst
+DEPEND=ssl? ( dev-libs/openssl:0=[-bindist] )
+DESCRIPTION=Encrypted UDP based FTP with multicast
+EAPI=7
+HOMEPAGE=http://uftp-multicast.sourceforge.net/
+IUSE=+server ssl
+KEYWORDS=*
+LICENSE=GPL-3-with-openssl-exception
+RDEPEND=ssl? ( dev-libs/openssl:0=[-bindist] )
+RESTRICT=test
+SLOT=0
+SRC_URI=https://download.sourceforge.net/uftp-multicast/source-tar/uftp-4.10.1.tar.gz
+_eclasses_=multilib	b2f01ad412baf81650c23fcf0975fa33	toolchain-funcs	209edad4a5c4812e7b2f8021650974f0
+_md5_=81bfdcd7b4ab8d7277a7f8a253f52d55
diff --git a/net-misc/uftp/Manifest b/net-misc/uftp/Manifest
new file mode 100644
index 0000000..9f1cf5a
--- /dev/null
+++ b/net-misc/uftp/Manifest
@@ -0,0 +1 @@
+DIST uftp-4.10.1.tar.gz 245625 BLAKE2B 23b01758fa5a0387471f8d95b24738d8157801822b8a07a59072eeab81277ceb5283463465ed522af6971d65141712ead3e2206caa286bedece9e0c34a149873 SHA512 9ef4594e0cde2f64970523661fcee07f34600bd4f2ab235c34bde9d20ef1b0312d5e430e1f52ab605c188c42aee4a0384ed02ae9f5e93b3edc062f848a8130bf
diff --git a/net-misc/uftp/files/logrotate b/net-misc/uftp/files/logrotate
new file mode 100644
index 0000000..8dd18f7
--- /dev/null
+++ b/net-misc/uftp/files/logrotate
@@ -0,0 +1,16 @@
+#
+#      /etc/logrotate.d/uftpd
+#
+/var/log/uftpd.log {
+	daily
+	rotate 5
+	notifempty
+	missingok
+}
+
+/var/log/uftpproxyd.log {
+	daily
+	rotate 5
+	notifempty
+	missingok
+}
diff --git a/net-misc/uftp/files/uftp-4.10.1_gcc10.patch b/net-misc/uftp/files/uftp-4.10.1_gcc10.patch
new file mode 100644
index 0000000..d25de61
--- /dev/null
+++ b/net-misc/uftp/files/uftp-4.10.1_gcc10.patch
@@ -0,0 +1,14 @@
+diff -Nuar uftp-4.10.1.orig/proxy.h uftp-4.10.1/proxy.h
+--- uftp-4.10.1.orig/proxy.h	2020-02-06 17:30:34.904020513 +0300
++++ uftp-4.10.1/proxy.h	2020-02-06 17:30:49.214021144 +0300
+@@ -167,8 +167,8 @@
+ extern int proxy_type, debug, rcvbuf, dscp, keyfile_count, keyinfo_count;
+ extern int hb_interval, priority;
+ extern unsigned int ttl;
+-char portname[PORTNAME_LEN], out_portname[PORTNAME_LEN];
+-int port, out_port;
++extern char portname[PORTNAME_LEN], out_portname[PORTNAME_LEN];
++extern int port, out_port;
+ extern union sockaddr_u down_addr;
+ extern int have_down_fingerprint;
+ extern uint8_t down_fingerprint[HMAC_LEN];
diff --git a/net-misc/uftp/files/uftp-4.10.1_makefile.patch b/net-misc/uftp/files/uftp-4.10.1_makefile.patch
new file mode 100644
index 0000000..5a131c3
--- /dev/null
+++ b/net-misc/uftp/files/uftp-4.10.1_makefile.patch
@@ -0,0 +1,41 @@
+diff -Nuar uftp-4.9.4-orig/makefile uftp-4.9.4/makefile
+--- uftp-4.9.4-orig/makefile	2017-12-13 13:15:53.873252064 +0500
++++ uftp-4.9.4/makefile	2017-12-13 13:25:44.092223428 +0500
+@@ -42,24 +42,24 @@
+ endif
+ 
+ # defaults
+-OPTIONS=-g -Wall $(ENC_OPTS)
++OPTIONS=-Wall $(ENC_OPTS)
+ LDLIBS=-lc -lm $(CRYPT_LIB)
+ MTFLAGS=
+ 
+ # FreeBSD
+ ifeq ("FreeBSD", "$(UNAME_S)")
+-OPTIONS=-g -Wall -DHAS_GETIFADDRS -DNO_DUAL -DSOCKADDR_LEN $(ENC_OPTS)
++OPTIONS=-DHAS_GETIFADDRS -DNO_DUAL -DSOCKADDR_LEN $(ENC_OPTS)
+ endif
+ 
+ # OSX, aka Darwin
+ ifeq ("Darwin", "$(UNAME_S)")
+-OPTIONS=-g -Wall -DHAS_GETIFADDRS $(ENC_OPTS)
++OPTIONS=-Wall -DHAS_GETIFADDRS $(ENC_OPTS)
+ endif
+ 
+ # Sun
+ ifeq ("SunOS", "$(UNAME_S)")
+ CC = cc
+-OPTIONS=-g -DBSD_COMP -DNO_DUAL -DNO_RECVMSG $(ENC_OPTS)
++OPTIONS=-DBSD_COMP -DNO_DUAL -DNO_RECVMSG $(ENC_OPTS)
+ LDLIBS=-lnsl -lsocket -lm $(CRYPT_LIB)
+ CFLAGS+=`getconf LFS_CFLAGS`
+ OPENSSL=/usr/sfw
+@@ -68,7 +68,7 @@
+ 
+ # Linux
+ ifeq ("Linux", "$(UNAME_S)")
+-OPTIONS=-g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wshadow -Wno-missing-field-initializers -Wstrict-prototypes -Winline -Wbad-function-cast -DHAS_GETIFADDRS $(ENC_OPTS)
++OPTIONS=-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wshadow -Wno-missing-field-initializers -Wstrict-prototypes -Winline -Wbad-function-cast -DHAS_GETIFADDRS $(ENC_OPTS)
+ LDLIBS=-lm $(CRYPT_LIB)
+ CFLAGS+=`getconf LFS_CFLAGS`
+ endif
diff --git a/net-misc/uftp/files/uftpd.conf b/net-misc/uftp/files/uftpd.conf
new file mode 100644
index 0000000..c38336c
--- /dev/null
+++ b/net-misc/uftp/files/uftpd.conf
@@ -0,0 +1,8 @@
+# conf.d file for uftpd
+
+# Destionation dir for downloaded files
+UFTPD_DIR="/tmp"
+
+# Options to pass to the uftpd process
+# For more info see man utfpd(1)
+UFTPD_OPTS=""
diff --git a/net-misc/uftp/files/uftpd.init b/net-misc/uftp/files/uftpd.init
new file mode 100644
index 0000000..38a6ea3
--- /dev/null
+++ b/net-misc/uftp/files/uftpd.init
@@ -0,0 +1,23 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+PROGRAM=/usr/sbin/uftpd
+PIDFILE=/var/run/uftpd.pid
+
+depend() {
+	need net
+}
+
+start() {
+	ebegin "Starting uftpd"
+	start-stop-daemon --start --exec ${PROGRAM} -- \
+		-L /var/log/uftpd.log -P ${PIDFILE} -D ${UFTPD_DIR} ${UFTPD_OPTS}
+	eend $? "Failed to start uftpd"
+}
+
+stop() {
+	ebegin "Stopping uftpd"
+	start-stop-daemon --stop --exec ${PROGRAM} -p ${PIDFILE}
+	eend $? "Failed to stop uftpd"
+}
diff --git a/net-misc/uftp/files/uftpproxyd.conf b/net-misc/uftp/files/uftpproxyd.conf
new file mode 100644
index 0000000..37c094d
--- /dev/null
+++ b/net-misc/uftp/files/uftpproxyd.conf
@@ -0,0 +1,5 @@
+# conf.d file for uftpd
+
+# Options to pass to the uftpd process
+# For more info see man utfpproxyd(1)
+UFTPPROXYD_OPTS=""
diff --git a/net-misc/uftp/files/uftpproxyd.init b/net-misc/uftp/files/uftpproxyd.init
new file mode 100644
index 0000000..a4b1107
--- /dev/null
+++ b/net-misc/uftp/files/uftpproxyd.init
@@ -0,0 +1,23 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+PROGRAM=/usr/sbin/uftpproxyd
+PIDFILE=/var/run/uftpproxyd.pid
+
+depend() {
+	need net
+}
+
+start() {
+	ebegin "Starting uftpd"
+	start-stop-daemon --start --exec ${PROGRAM} -- \
+		-L /var/log/uftpproxyd.log -P ${PIDFILE} ${UFTPPROXYD_OPTS}
+	eend $? "Failed to start uftpd"
+}
+
+stop() {
+	ebegin "Stopping uftpd"
+	start-stop-daemon --stop --exec ${PROGRAM} -p ${PIDFILE}
+	eend $? "Failed to stop uftpd"
+}
diff --git a/net-misc/uftp/metadata.xml b/net-misc/uftp/metadata.xml
new file mode 100644
index 0000000..2a33d8e
--- /dev/null
+++ b/net-misc/uftp/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="person">
+	<email>azamat.hackimov@gmail.com</email>
+	<name>Azamat Hackimov</name>
+</maintainer>
+<maintainer type="project">
+	<email>proxy-maint@gentoo.org</email>
+	<name>Proxy Maintainers</name>
+</maintainer>
+<use>
+	<flag name="server">Install uftp server daemon</flag>
+</use>
+</pkgmetadata>
diff --git a/net-misc/uftp/uftp-4.10.1.ebuild b/net-misc/uftp/uftp-4.10.1.ebuild
new file mode 100644
index 0000000..189b7e7
--- /dev/null
+++ b/net-misc/uftp/uftp-4.10.1.ebuild
@@ -0,0 +1,57 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit toolchain-funcs
+
+DESCRIPTION="Encrypted UDP based FTP with multicast"
+HOMEPAGE="http://uftp-multicast.sourceforge.net/"
+SRC_URI="https://download.sourceforge.net/${PN}-multicast/source-tar/${P}.tar.gz"
+
+LICENSE="GPL-3-with-openssl-exception"
+SLOT="0"
+KEYWORDS="*"
+IUSE="+server ssl"
+
+# openssl with EC required, see #644674
+DEPEND="ssl? ( dev-libs/openssl:0=[-bindist] )"
+RDEPEND="${DEPEND}"
+
+# Workaround, see #644670
+RESTRICT=test
+
+PATCHES=(
+	"${FILESDIR}/${P}_makefile.patch"
+	"${FILESDIR}/${P}_gcc10.patch"
+)
+
+src_compile() {
+	use ssl || local opt="NO_ENCRYPTION=1"
+	emake CC=$(tc-getCC) $opt uftp uftp_keymgt
+	use server && emake CC=$(tc-getCC) $opt uftpd uftpproxyd
+}
+
+src_install() {
+	dobin uftp uftp_keymgt
+	dodoc {Changes,protocol,ReadMe}.txt
+	doman {uftp,uftp_keymgt}.1
+
+	if use server ; then
+		dosbin uftpd uftpproxyd
+		newinitd "${FILESDIR}/uftpd.init" uftpd
+		newconfd "${FILESDIR}/uftpd.conf" uftpd
+		newinitd "${FILESDIR}/uftpproxyd.init" uftpproxyd
+		newconfd "${FILESDIR}/uftpproxyd.conf" uftpproxyd
+		doman {uftpd,uftpproxyd}.1
+		insinto /etc/logrotate.d
+		newins "${FILESDIR}/logrotate" uftpd
+	fi
+}
+
+pkg_postinst() {
+	if use server ; then
+		ewarn "Please note, uftpd 4.x server is not backward compatible with"
+		ewarn "uftp 3.x clients! Please upgrade clients before servers."
+	fi
+}