net-analyzer/nmap: Sync with Gentoo

It's from Gentoo commit 350458ecda5f78ef834191b50029b1e48548f188.
This commit is contained in:
Flatcar Buildbot 2022-12-12 07:15:06 +00:00
parent 2cdaf14981
commit 07bcf8ae60
3 changed files with 157 additions and 22 deletions

View File

@ -0,0 +1,103 @@
https://github.com/nmap/nmap/pull/2580
From 14f8e230a61748b1cde86d13a2cf2353d7ad1fa7 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Fri, 9 Dec 2022 15:58:35 +0000
Subject: [PATCH] zenmap: further Python 3 compatibility fixes
Without this, we get:
```
Traceback (most recent call last):
File "/var/tmp/portage/net-analyzer/nmap-9999/work/nmap-9999/zenmap/setup.py", line 584, in <module>
setup(**setup_args)
File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 1208, in run_command
super().run_command(command)
File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/var/tmp/portage/net-analyzer/nmap-9999/work/nmap-9999/zenmap/setup.py", line 188, in run
self.write_installed_files()
File "/var/tmp/portage/net-analyzer/nmap-9999/work/nmap-9999/zenmap/setup.py", line 419, in write_installed_files
print >> f, output
TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'. Did you mean "print(<message>, file=<output_stream>)"?
make: *** [Makefile:372: install-zenmap] Error 1
```
This is because Python 3 doesn't support Python 2-style print without
parentheses, or specifying the output file in that manner.
Signed-off-by: Sam James <sam@gentoo.org>
--- a/zenmap/setup.py
+++ b/zenmap/setup.py
@@ -215,13 +215,13 @@ def create_uninstaller(self):
#!/usr/bin/env python3
import errno, os, os.path, sys
-print 'Uninstall %(name)s %(version)s'
+print('Uninstall %(name)s %(version)s')
answer = raw_input('Are you sure that you want to uninstall '
'%(name)s %(version)s? (yes/no) ')
if answer != 'yes' and answer != 'y':
- print 'Not uninstalling.'
+ print('Not uninstalling.')
sys.exit(0)
""" % {'name': APP_DISPLAY_NAME, 'version': VERSION}
@@ -237,8 +237,8 @@ def create_uninstaller(self):
# This should never happen (everything gets installed
# inside the root), but if it does, be safe and don't
# delete anything.
- uninstaller += ("print '%s was not installed inside "
- "the root %s; skipping.'\n" % (output, self.root))
+ uninstaller += ("print('%s was not installed inside "
+ "the root %s; skipping.')\n" % (output, self.root))
continue
output = path_strip_prefix(output, self.root)
assert os.path.isabs(output)
@@ -262,24 +262,24 @@ def create_uninstaller(self):
dirs.append(path)
# Delete the files.
for file in files:
- print "Removing '%s'." % file
+ print("Removing '%s'." % file)
try:
os.remove(file)
except OSError as e:
- print >> sys.stderr, ' Error: %s.' % str(e)
+ print(' Error: %s.' % str(e), file=sys.stderr)
# Delete the directories. First reverse-sort the normalized paths by
# length so that child directories are deleted before their parents.
dirs = [os.path.normpath(dir) for dir in dirs]
dirs.sort(key = len, reverse = True)
for dir in dirs:
try:
- print "Removing the directory '%s'." % dir
+ print("Removing the directory '%s'." % dir)
os.rmdir(dir)
except OSError as e:
if e.errno == errno.ENOTEMPTY:
- print "Directory '%s' not empty; not removing." % dir
+ print("Directory '%s' not empty; not removing." % dir)
else:
- print >> sys.stderr, str(e)
+ print(str(e), file=sys.stderr)
"""
uninstaller_file = open(uninstaller_filename, 'w')
@@ -419,7 +419,7 @@ def write_installed_files(self):
with open(INSTALLED_FILES_NAME, "w") as f:
for output in self.get_installed_files():
assert "\n" not in output
- print >> f, output
+ print(output, file=f)
class my_uninstall(Command):

View File

@ -16,10 +16,12 @@
<use>
<flag name="libssh2">Enable SSH support through <pkg>net-libs/libssh2</pkg></flag>
<flag name="ncat">Install the ncat utility</flag>
<flag name="ndiff">Install the ndiff utility</flag>
<flag name="nping">Install the nping utility</flag>
<flag name="nse">Include support for the Nmap Scripting Engine (NSE)</flag>
<flag name="symlink">Install symlink to nc</flag>
<flag name="system-lua">Use <pkg>dev-lang/lua</pkg> instead of the bundled liblua</flag>
<flag name="zenmap">Install the GTK+ based nmap GUI, zenmap</flag>
</use>
<upstream>
<remote-id type="github">nmap/nmap</remote-id>

View File

@ -6,7 +6,9 @@ EAPI=8
LUA_COMPAT=( lua5-3 )
LUA_REQ_USE="deprecated"
PYTHON_COMPAT=( python3_{8..11} )
inherit autotools lua-single python-any-r1 toolchain-funcs
PLOCALES="de es fr hi hr hu id it ja pl pt_BR pt_PR ro ru sk zh"
PLOCALE_BACKUP="en"
inherit autotools lua-single plocale python-single-r1 toolchain-funcs
DESCRIPTION="Network exploration tool and security / port scanner"
HOMEPAGE="https://nmap.org/"
@ -27,8 +29,9 @@ fi
LICENSE="|| ( NPSL GPL-2 )"
SLOT="0"
IUSE="ipv6 libssh2 ncat nping +nse ssl symlink +system-lua"
IUSE="ipv6 libssh2 ncat ndiff nping nls +nse ssl symlink +system-lua zenmap"
REQUIRED_USE="
${PYTHON_REQUIRED_USE}
system-lua? ( nse ${LUA_REQUIRED_USE} )
symlink? ( ncat )
"
@ -37,12 +40,14 @@ RDEPEND="
dev-libs/liblinear:=
dev-libs/libpcre
net-libs/libpcap
ndiff? ( ${PYTHON_DEPS} )
libssh2? (
net-libs/libssh2[zlib]
sys-libs/zlib
)
nls? ( virtual/libintl )
nse? ( sys-libs/zlib )
ssl? ( dev-libs/openssl:0= )
ssl? ( dev-libs/openssl:= )
symlink? (
ncat? (
!net-analyzer/netcat
@ -50,11 +55,18 @@ RDEPEND="
)
)
system-lua? ( ${LUA_DEPS} )
zenmap? (
${PYTHON_DEPS}
$(python_gen_cond_dep '
dev-python/pygobject:3[${PYTHON_USEDEP}]
')
)
"
DEPEND="${RDEPEND}"
BDEPEND="
${PYTHON_DEPS}
virtual/pkgconfig
nls? ( sys-devel/gettext )
"
if [[ ${PV} != *9999* ]] ; then
@ -72,20 +84,30 @@ PATCHES=(
"${FILESDIR}"/${PN}-7.80-ac-config-subdirs.patch
"${FILESDIR}"/${PN}-7.91-no-FORTIFY_SOURCE.patch
"${FILESDIR}"/${PN}-9999-netutil-else.patch
"${FILESDIR}"/${PN}-9999-python3.patch
)
pkg_setup() {
python-any-r1_pkg_setup
python-single-r1_pkg_setup
use system-lua && lua-single_pkg_setup
}
src_prepare() {
default
# Drop bundled libraries
rm -r liblinear/ libpcap/ libpcre/ libssh2/ libz/ || die
cat "${FILESDIR}"/nls.m4 >> "${S}"/acinclude.m4 || die
default
delete_disabled_locale() {
# Force here as PLOCALES contains supported locales for man
# pages and zenmap doesn't have all of those
rm -rf zenmap/share/zenmap/locale/${1} || die
rm -f zenmap/share/zenmap/locale/${1}.po || die
}
plocale_for_each_disabled_locale delete_disabled_locale
sed -i \
-e '/^ALL_LINGUAS =/{s|$| id|g;s|jp|ja|g}' \
@ -105,23 +127,27 @@ src_configure() {
export ac_cv_path_PYTHON="${PYTHON}"
export am_cv_pathless_PYTHON="${EPYTHON}"
local myeconfargs=(
$(use_enable ipv6)
$(use_enable nls)
$(use_with libssh2)
$(use_with ncat)
$(use_with ndiff)
$(use_with nping)
$(use_with ssl openssl)
$(use_with zenmap)
$(usex libssh2 --with-zlib)
$(usex nse --with-liblua=$(usex system-lua yes included '' '') --without-liblua)
$(usex nse --with-zlib)
--cache-file="${S}"/config.cache
# The bundled libdnet is incompatible with the version available in the
# tree, so we cannot use the system library here.
econf \
$(use_enable ipv6) \
$(use_with libssh2) \
$(use_with ncat) \
$(use_with nping) \
$(use_with ssl openssl) \
$(usex libssh2 --with-zlib) \
$(usex nse --with-liblua=$(usex system-lua yes included '' '') --without-liblua) \
$(usex nse --with-zlib) \
--cache-file="${S}"/config.cache \
--with-libdnet=included \
--with-pcre="${ESYSROOT}"/usr \
--without-dpdk \
--without-ndiff \
--without-zenmap
--with-libdnet=included
--with-pcre="${ESYSROOT}"/usr
--without-dpdk
)
econf "${myeconfargs[@]}"
}
src_compile() {
@ -146,5 +172,9 @@ src_install() {
dodoc CHANGELOG HACKING docs/README docs/*.txt
if use ndiff || use zenmap ; then
python_optimize
fi
use symlink && dosym /usr/bin/ncat /usr/bin/nc
}