commit:     4897b29d71ff362abad55a4dd29925bc6a88b06e
Author:     Conrad Kostecki <conikost <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 17 09:42:01 2024 +0000
Commit:     Conrad Kostecki <conikost <AT> gentoo <DOT> org>
CommitDate: Wed Jul 17 09:42:14 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4897b29d

net-dns/hash-slinger: add 3.3

Bug: https://bugs.gentoo.org/933724
Signed-off-by: Conrad Kostecki <conikost <AT> gentoo.org>

 net-dns/hash-slinger/Manifest                      |  1 +
 ...sh-slinger-3.3-fix-tlsa-record-generation.patch | 35 +++++++++++++
 .../files/hash-slinger-3.3-python-3.12.patch       | 57 ++++++++++++++++++++++
 net-dns/hash-slinger/hash-slinger-3.3.ebuild       | 54 ++++++++++++++++++++
 4 files changed, 147 insertions(+)

diff --git a/net-dns/hash-slinger/Manifest b/net-dns/hash-slinger/Manifest
index a9ac022e7d12..d72a964d525e 100644
--- a/net-dns/hash-slinger/Manifest
+++ b/net-dns/hash-slinger/Manifest
@@ -1 +1,2 @@
 DIST hash-slinger-3.2.tar.gz 38376 BLAKE2B 
8c89f9a372818166c862d97354a60dddc2795c70f23b39225ad0fc3a2657cc5e048dca228dc004db0240fcf80e74bc799528d3459a65e6de347a493df5abf7b3
 SHA512 
01a25b3bc00bd9cd86c448f087c48ad04248a5a8755c2f154272b833efdce058a1fc62ea3f5cc6e9ff35180754b3e44db03c4e4888fd9051b749eff5fc8c3110
+DIST hash-slinger-3.3.tar.gz 38597 BLAKE2B 
237affa3f933d3dbd1dca3bc4f927268c15d10eed16c18aae68906f1fe6511eda48283f76da851d70535139bc880074951a1ab4c6be92bd27e32c38e374ce044
 SHA512 
ba59771d32a93f500b61beab1d44e6edf94965c1a7cb30708e4722fe7e6d97a884ccd0e16c9058c29b174a710c13d562b1b6dfc15edc7440692494744392a52e

diff --git 
a/net-dns/hash-slinger/files/hash-slinger-3.3-fix-tlsa-record-generation.patch 
b/net-dns/hash-slinger/files/hash-slinger-3.3-fix-tlsa-record-generation.patch
new file mode 100644
index 000000000000..36b8d60d3057
--- /dev/null
+++ 
b/net-dns/hash-slinger/files/hash-slinger-3.3-fix-tlsa-record-generation.patch
@@ -0,0 +1,35 @@
+From 0bb0dba91c51d367d9a37297f13e07f33c01bfdc Mon Sep 17 00:00:00 2001
+From: anarcat <[email protected]>
+Date: Thu, 5 Oct 2023 02:10:32 -0400
+Subject: [PATCH] fix generic TLSA record generation (#46)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It seems like the calculation for the TLSA record never really worked,
+as we're doing float division here on the `len()` field. In our case,
+that field returned `35.0` which is not valid in our environment.
+
+Doing an integer division gives the correct result in most cases, I
+believe.
+
+Closes: #45
+
+Co-authored-by: Jérôme Charaoui <[email protected]>
+---
+ tlsa | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tlsa b/tlsa
+index cea7230..ec97150 100755
+--- a/tlsa
++++ b/tlsa
+@@ -513,7 +513,7 @@ class TLSARecord:
+       def getRecord(self, generic=False):
+               """Returns the RR string of this TLSARecord, either in rfc 
(default) or generic format"""
+               if generic:
+-                      return '%s IN TYPE52 \# %s %s%s%s%s' % (self.name, 
(len(self.cert)/2)+3 , self._toHex(self.usage), self._toHex(self.selector), 
self._toHex(self.mtype), self.cert)
++                      return '%s IN TYPE52 \# %s %s%s%s%s' % (self.name, 
(len(self.cert)//2)+3 , self._toHex(self.usage), self._toHex(self.selector), 
self._toHex(self.mtype), self.cert)
+               return '%s IN TLSA %s %s %s %s' % (self.name, self.usage, 
self.selector, self.mtype, self.cert)
+ 
+       def _toHex(self, val):

diff --git a/net-dns/hash-slinger/files/hash-slinger-3.3-python-3.12.patch 
b/net-dns/hash-slinger/files/hash-slinger-3.3-python-3.12.patch
new file mode 100644
index 000000000000..d4b1eacc94e6
--- /dev/null
+++ b/net-dns/hash-slinger/files/hash-slinger-3.3-python-3.12.patch
@@ -0,0 +1,57 @@
+From e04d8262f1409725afc8f71720b77083fb43c525 Mon Sep 17 00:00:00 2001
+From: Hoggins! <[email protected]>
+Date: Tue, 16 Jul 2024 23:52:39 +0200
+Subject: [PATCH] Python3.12 compains with a "SyntaxWarning: invalid escape
+ sequence" when regexes are not used with raw strings
+
+---
+ tlsa | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/tlsa b/tlsa
+index ec97150..d06bd49 100755
+--- a/tlsa
++++ b/tlsa
+@@ -495,7 +495,7 @@ class TLSARecord:
+       """When instanciated, this class contains all the fields of a TLSA 
record.
+       """
+       def __init__(self, name, usage, selector, mtype, cert):
+-              """name is the name of the RR in the format: 
/^(_\d{1,5}|\*)\._(tcp|udp|sctp)\.([a-z0-9]*\.){2,}$/
++              r"""name is the name of the RR in the format: 
/^(_\d{1,5}|\*)\._(tcp|udp|sctp)\.([a-z0-9]*\.){2,}$/
+               usage, selector and mtype should be an integer
+               cert should be a hexidecimal string representing the 
certificate to be matched field
+               """
+@@ -513,7 +513,7 @@ class TLSARecord:
+       def getRecord(self, generic=False):
+               """Returns the RR string of this TLSARecord, either in rfc 
(default) or generic format"""
+               if generic:
+-                      return '%s IN TYPE52 \# %s %s%s%s%s' % (self.name, 
(len(self.cert)//2)+3 , self._toHex(self.usage), self._toHex(self.selector), 
self._toHex(self.mtype), self.cert)
++                      return r'%s IN TYPE52 \# %s %s%s%s%s' % (self.name, 
(len(self.cert)//2)+3 , self._toHex(self.usage), self._toHex(self.selector), 
self._toHex(self.mtype), self.cert)
+               return '%s IN TLSA %s %s %s %s' % (self.name, self.usage, 
self.selector, self.mtype, self.cert)
+ 
+       def _toHex(self, val):
+@@ -554,20 +554,20 @@ class TLSARecord:
+ 
+       def isNameValid(self):
+               """Check if the name if in the correct format"""
+-              if not 
re.match('^(_\d{1,5}|\*)\._(tcp|udp|sctp)\.([-a-z0-9]*\.){2,}$', self.name):
++              if not 
re.match(r'^(_\d{1,5}|\*)\._(tcp|udp|sctp)\.([-a-z0-9]*\.){2,}$', self.name):
+                       return False
+               return True
+ 
+       def getProtocol(self):
+               """Returns the protocol based on the name"""
+-              return re.split('\.', self.name)[1][1:]
++              return re.split(r'\.', self.name)[1][1:]
+ 
+       def getPort(self):
+               """Returns the port based on the name"""
+-              if re.split('\.', self.name)[0][0] == '*':
++              if re.split(r'\.', self.name)[0][0] == '*':
+                       return '*'
+               else:
+-                      return re.split('\.', self.name)[0][1:]
++                      return re.split(r'\.', self.name)[0][1:]
+ 
+ class ARecord:
+       """An object representing an A Record (IPv4 address)"""

diff --git a/net-dns/hash-slinger/hash-slinger-3.3.ebuild 
b/net-dns/hash-slinger/hash-slinger-3.3.ebuild
new file mode 100644
index 000000000000..da7e8e7310b8
--- /dev/null
+++ b/net-dns/hash-slinger/hash-slinger-3.3.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit python-single-r1
+
+DESCRIPTION="Various tools to generate DNS records like SSHFP, TLSA, 
OPENPGPKEY, IPSECKEY"
+HOMEPAGE="https://github.com/letoams/hash-slinger";
+SRC_URI="https://github.com/letoams/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~x86"
+IUSE="ipsec +openpgp +ssh"
+
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="
+       ${PYTHON_DEPS}
+       $(python_gen_cond_dep '
+               dev-python/dnspython[${PYTHON_USEDEP}]
+               dev-python/ipaddr[${PYTHON_USEDEP}]
+               dev-python/m2crypto[${PYTHON_USEDEP}]
+       ')
+       net-dns/unbound[python,${PYTHON_SINGLE_USEDEP}]
+       ipsec? ( net-vpn/libreswan[dnssec] )
+       openpgp? ( $(python_gen_cond_dep 
'dev-python/python-gnupg[${PYTHON_USEDEP}]') )
+       ssh? ( virtual/openssh )
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-3.3-fix-tlsa-record-generation.patch"
+       "${FILESDIR}/${PN}-3.3-python-3.12.patch"
+)
+
+src_install() {
+       local tools tool
+
+       tools="tlsa"
+
+       use ssh && tools+=" sshfp"
+       use openpgp && tools+=" openpgpkey"
+       use ipsec && tools+=" ipseckey"
+
+       for tool in $tools ; do
+               doman ${tool}.1
+               python_doscript ${tool}
+       done
+
+       dodoc BUGS CHANGES README
+}

Reply via email to