summaryrefslogtreecommitdiffstats
path: root/zenmap/install_scripts/windows
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:42:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:42:04 +0000
commit0d47952611198ef6b1163f366dc03922d20b1475 (patch)
tree3d840a3b8c0daef0754707bfb9f5e873b6b1ac13 /zenmap/install_scripts/windows
parentInitial commit. (diff)
downloadnmap-0d47952611198ef6b1163f366dc03922d20b1475.tar.xz
nmap-0d47952611198ef6b1163f366dc03922d20b1475.zip
Adding upstream version 7.94+git20230807.3be01efb1+dfsg.upstream/7.94+git20230807.3be01efb1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'zenmap/install_scripts/windows')
-rwxr-xr-xzenmap/install_scripts/windows/Makefile15
-rw-r--r--zenmap/install_scripts/windows/PKGBUILD32
-rw-r--r--zenmap/install_scripts/windows/boot_script.py27
-rw-r--r--zenmap/install_scripts/windows/build.sh69
-rwxr-xr-xzenmap/install_scripts/windows/copy_and_compile.bat57
-rw-r--r--zenmap/install_scripts/windows/nmap-eye.icobin0 -> 419614 bytes
-rwxr-xr-xzenmap/install_scripts/windows/styrene.cfg171
7 files changed, 371 insertions, 0 deletions
diff --git a/zenmap/install_scripts/windows/Makefile b/zenmap/install_scripts/windows/Makefile
new file mode 100755
index 0000000..a1479fb
--- /dev/null
+++ b/zenmap/install_scripts/windows/Makefile
@@ -0,0 +1,15 @@
+export MSYS2_ARG_CONV_EXCL=""
+all: dist/zenmap-w64-deletelog.txt mingw-w64-x86_64-python-zenmap-*.pkg.tar.zst
+ ./build.sh
+
+mingw-w64-x86_64-python-zenmap-%.pkg.tar.zst: PKGBUILD
+ makepkg-mingw -RdfL
+
+dist/zenmap-w64-deletelog.txt: tmp.cfg mingw-w64-x86_64-python-zenmap-*.pkg.tar.zst
+ styrene -p . -o $(dir $@) tmp.cfg --no-exe --no-zip
+
+tmp.cfg: styrene.cfg ../utils/get_deps.py
+ python3 ../utils/get_deps.py $@ $<
+
+clean:
+ rm -rf tmp.cfg pkg/ src/ dist/ mingw-w64-*-package.log* mingw-w64-*.zst
diff --git a/zenmap/install_scripts/windows/PKGBUILD b/zenmap/install_scripts/windows/PKGBUILD
new file mode 100644
index 0000000..69a6eaf
--- /dev/null
+++ b/zenmap/install_scripts/windows/PKGBUILD
@@ -0,0 +1,32 @@
+# PKGBUILD for Zenmap targeting MinGW and MSYS2, for use in packaging Zenmap for Windows.
+# Expected invocation: makepkg-mingw -RdfL
+# -R: repackage, do not download source
+# -d: do not verify dependencies (Python 3 is the only build dependency)
+# -f: force, overwrite existing package.
+# -L: log progress to file
+_realname=zenmap
+pkgbase=mingw-w64-python-${_realname}
+pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
+provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
+conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
+replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
+NMAP_DIR=$(realpath "../../..")
+pkgver=$(echo NMAP_VERSION | ${CC} -E -imacros "${NMAP_DIR}/nmap.h" - | sed -n '$s/[" ]//g;$p')
+pkgrel=1
+pkgdesc="Graphical Nmap frontend and results viewer"
+url="https://nmap.org/zenmap/"
+arch=("any")
+license=("NPSL")
+source=("https://nmap.org/dist/nmap-${pkgver}.tar.bz2")
+sha256sums=("SKIP")
+mingw_arch=('mingw64')
+depends=("${MINGW_PACKAGE_PREFIX}-python" "${MINGW_PACKAGE_PREFIX}-python-gobject")
+makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
+
+package() {
+ cd "${NMAP_DIR}/zenmap"
+ ${MINGW_PREFIX}/bin/python setup.py build
+ MSYS2_ARG_CONV_EXCL="--prefix=" \
+ ${MINGW_PREFIX}/bin/python setup.py install vanilla --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
+ install -Dm644 install_scripts/unix/zenmap.desktop "${pkgdir}${MINGW_PREFIX}/share/applications/zenmap.desktop"
+}
diff --git a/zenmap/install_scripts/windows/boot_script.py b/zenmap/install_scripts/windows/boot_script.py
new file mode 100644
index 0000000..db0be73
--- /dev/null
+++ b/zenmap/install_scripts/windows/boot_script.py
@@ -0,0 +1,27 @@
+# Custom py2exe boot script
+
+# This runs after py2exe's boot_common.py. That file overrides sys.stderr and
+# sys.stdout to write to a logfile and a black hole, respectively. The location
+# for the stderr logfile is sys.executable + '.log', though, which is not
+# usually writable. We'll change it here to write to some other writable path.
+
+
+import sys
+import os
+import os.path
+
+
+#sys.stderr.write("Enter boot_script\n")
+# Only do this if py2exe installed its Stderr object
+if sys.stderr.__class__.__name__ == "Stderr":
+ logdir = os.environ.get("LOCALAPPDATA",
+ os.environ.get("APPDATA",
+ os.environ.get("TEMP", "")))
+
+ if sys.stderr._file is not None:
+ sys.stderr._file.close()
+ sys.stderr._file = open(os.path.join(logdir, "zenmap.exe.log"), 'a')
+
+
+del os
+del sys
diff --git a/zenmap/install_scripts/windows/build.sh b/zenmap/install_scripts/windows/build.sh
new file mode 100644
index 0000000..89ce43e
--- /dev/null
+++ b/zenmap/install_scripts/windows/build.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+# bash shebang because MSYS2/Styrene require Bash, not just /bin/sh
+set -x
+set -e
+
+export MSYS2_ARG_CONV_EXCL=""
+BUILDDIR=dist
+
+: << '#MULTILINE_COMMENT'
+# Setup environment
+pacman -S --needed zip mingw-w64-x86_64-{python3,gcc,nsis,binutils,git}
+pacman -S --needed mingw-w64-x86_64-python3-pip
+git clone https://github.com/achadwick/styrene.git
+git apply <<EOF
+diff --git a/styrene/bundle.py b/styrene/bundle.py
+index 7f5155e..e5c31d3 100644
+--- a/styrene/bundle.py
++++ b/styrene/bundle.py
+@@ -446,7 +446,7 @@ class NativeBundle:
+ - (?P<version> [^-]+ - \d+ )
+ - any
+ [.]pkg[.]tar
+- (?: [.](?:gz|xz) )?
++ (?: [.](?:gz|xz|zst) )?
+ $
+ '''
+ keyobj = functools.cmp_to_key(self._vercmp)
+EOF
+cd styrene
+pip3 install .
+#MULTILINE_COMMENT
+
+# make the zenmap package
+#makepkg-mingw -RdfL
+
+# make the minimal msys2 environment
+#styrene -p . -o "$BUILDDIR" styrene.cfg --no-exe --no-zip
+
+PACKAGEDIR=$BUILDDIR/zenmap-w64/mingw64
+PYTHONLIB=$(ls -d $PACKAGEDIR/lib/python3.*)
+
+# Remove compiled bytecode, recompile in legacy locations, allowing for removal of source.
+# See PEP-3147
+find "$PYTHONLIB" -depth \( -name 'zenmap*' -o -name 'radialnet' \) -prune -o -name __pycache__ -exec rm -rf '{}' \;
+# Exit code not reliable
+python -m compileall -b -x 'zenmapGUI|zenmapCore|radialnet' "$PYTHONLIB" #|| true
+
+# Remove source if compiled is available, except for Zenmap itself:
+find "$PYTHONLIB" \( -name 'zenmap*' -o -name 'radialnet' \) -prune -o \( -name '*.pyc' -print \) | while read pyc; do
+rm -f "${pyc%.pyc}.py"
+done
+
+# Now compile Zenmap using default (not legacy) location.
+# If we had used legacy location, python.exe tries to write out the PEP-3147
+# location anyway when source is available.
+python -m compileall "$PYTHONLIB"/site-packages #|| true
+
+# Remove some of the larger unused items
+rm -f "$PACKAGEDIR"/bin/win7appid.exe
+
+# strip binaries
+find "$PACKAGEDIR" \( -name '*.exe' -o -name '*.dll' -o -name '*.pyd' \) -exec strip -g '{}' \;
+
+# Create cache files as needed
+cd "$PACKAGEDIR"
+export GDK_PIXBUF_MODULEDIR=$(ls -d lib/gdk-pixbuf-2.0/2.*/loaders)
+gdk-pixbuf-query-loaders > "$GDK_PIXBUF_MODULEDIR".cache
+gtk-update-icon-cache share/icons/hicolor
+
diff --git a/zenmap/install_scripts/windows/copy_and_compile.bat b/zenmap/install_scripts/windows/copy_and_compile.bat
new file mode 100755
index 0000000..b6cb68a
--- /dev/null
+++ b/zenmap/install_scripts/windows/copy_and_compile.bat
@@ -0,0 +1,57 @@
+@echo off
+
+echo Setting installation variables...
+set PythonDir=..\..\nmap-mswin32-aux\Python
+set PythonEXE=%PythonDir%\python.exe
+set DistDir=dist
+set LibraryDir=%DistDir%\py2exe
+set GTKDir=%PythonDir%\Lib\site-packages\gtk-2.0\runtime
+set Output=win_install.log
+
+IF EXIST %PythonEXE% GOTO GGTK
+ECHO No Python found!
+EXIT 1
+
+:GGTK
+IF EXIST %GTKDir% GOTO GWork
+ECHO No GTK found!
+EXIT 1
+
+:GWork
+
+echo Writing output to %Output%
+
+echo Removing old compilation...
+IF EXIST %DistDir% rd %DistDir% /s /q > %Output%
+
+echo Creating dist directory tree...
+mkdir %LibraryDir%\etc
+mkdir %LibraryDir%\share
+mkdir %LibraryDir%\share\themes
+mkdir %LibraryDir%\share\icons
+mkdir %LibraryDir%\lib
+
+echo Copying GTK files to dist directory...
+xcopy %GTKDir%\bin\*.dll %LibraryDir% /S >> %Output%
+rem intl.dll is a special case; has to be in the executable directory instead of
+rem the py2exe subdirectory.
+xcopy %GTKDir%\etc %LibraryDir%\etc /S /I >> %Output%
+xcopy %GTKDir%\lib\gtk-2.0 %LibraryDir%\lib\gtk-2.0 /S /I >> %Output%
+xcopy %GTKDir%\share\themes\Default %LibraryDir%\share\themes\Default /S /I >> %Output%
+xcopy %GTKDir%\share\themes\MS-Windows %LibraryDir%\share\themes\MS-Windows /S /I >> %Output%
+xcopy %GTKDir%\share\icons\hicolor %LibraryDir%\share\icons\hicolor /S /I >> %Output%
+
+echo Compiling using py2exe...
+%PythonEXE% setup.py py2exe >> %Output%
+
+echo Removing the build directory...
+rd build /s /q >> %Output%
+
+rem Check that the gtkrc file was manually created so Zenmap will look pretty
+IF EXIST %DistDir%\etc\gtk-2.0\gtkrc GOTO gtkrc
+echo gtk-theme-name = "MS-Windows" > %DistDir%\py2exe\etc\gtk-2.0\gtkrc
+echo Created the missing file %DistDir%\py2exe\etc\gtk-2.0\gtkrc >> %Output%
+:gtkrc
+
+echo Done!
+
diff --git a/zenmap/install_scripts/windows/nmap-eye.ico b/zenmap/install_scripts/windows/nmap-eye.ico
new file mode 100644
index 0000000..7cb8b12
--- /dev/null
+++ b/zenmap/install_scripts/windows/nmap-eye.ico
Binary files differ
diff --git a/zenmap/install_scripts/windows/styrene.cfg b/zenmap/install_scripts/windows/styrene.cfg
new file mode 100755
index 0000000..b5cfd2c
--- /dev/null
+++ b/zenmap/install_scripts/windows/styrene.cfg
@@ -0,0 +1,171 @@
+# Styrene config file for Zenmap and Ndiff
+
+[bundle]
+
+# Packages to install into the bundle, separated by spaces.
+# Pacman will resolve dependencies automatically.
+# Substs: {pkg_prefix} for "mingw-w64-x86_64-" or "mingw-w64-i686-".
+# The first package is the main one: it provides the default metadata.
+packages = {pkg_prefix}python-zenmap {pkg_prefix}python-gobject {pkg_prefix}python {pkg_prefix}gtk3 msys2-runtime
+
+# Reduce some bundling time and size by skipping these prereqs we don't use
+assume_installed = {pkg_prefix}ncurses {pkg_prefix}expat {pkg_prefix}openssl {pkg_prefix}tcl {pkg_prefix}tk
+
+# The first part of generated installer or archive filenames.
+# Will be suffixed with the version, an architecture spec
+# like "-w64" or "-w32", and the appropriate filename extension.
+# Default: the main package's name (with {pkg_prefix} as "").
+filename_stub = zenmap
+
+# Display name for the bundle. Spaces are OK.
+# The suffix " (w32)" is appended for MINGW32 bundles.
+# Default: the filename stub
+display_name = Zenmap
+
+# Short human-readable description.
+description = Nmap GUI
+
+# Version number for the bundle.
+# Default: parsed from the main package's version.
+# version =
+
+# URLs that default to the main package's URL metadata.
+# url =
+
+# Launchers to install.
+# Entries here should name a desktop file,
+# or an equivalent section below.
+launchers =
+ zenmap.desktop
+
+# Additional icons to explicitly convert.
+# These will be converted from the bundle's FreeDesktop.org PNG icons.
+# They are used in addition to the ones listed in the launchers.
+# The conversion only knows about Adwaita & the default hicolor theme.
+# The first converted icon will be used for the installer too [VOLATILE]
+; icons =
+
+# Surplus files and folders to be deleted.
+# Space-separated list of glob patterns rooted in $INSTDIR.
+
+delete = *
+
+
+# List files and directories you *don't* want to be deleted here.
+# If you're cleaning out $PREFIX/bin, you need to keep all the EXEs
+# which are called from the postinst.cmd.
+
+nodelete =
+ # The postinst scripts that GTK needs, followed by their binaries.
+ mingw*/share/glib*/schemas
+
+ #mingw*/bin/gtk-update-icon-cache*.exe
+ #usr/bin/mkdir.exe
+ #usr/bin/msys-2*.dll
+ #usr/share/libalpm
+
+ #var/lib/pacman/local/mingw-w64-*-hicolor-icon-theme-*-*/install
+
+ # Runtime requirements for the demos etc.
+ mingw*/etc/gtk-3.0
+ # Required DLLs. Checked with:
+ # * recursive `dumpbin /imports` on known python/gtk dlls
+ # * recursive `dumpbin /imports` on pyd files in lib/python3.10
+ # * `g-ir-inspect --print-shlibs` for typelibs listed below
+ mingw*/bin/libatk-1.0-0.dll
+ mingw*/bin/libbrotlicommon.dll
+ mingw*/bin/libbrotlidec.dll
+ mingw*/bin/libbz2-1.dll
+ mingw*/bin/libcairo-2.dll
+ mingw*/bin/libcairo-gobject-2.dll
+ mingw*/bin/libdatrie-1.dll
+ mingw*/bin/libepoxy-0.dll
+ mingw*/bin/libexpat-1.dll
+ mingw*/bin/libffi-8.dll
+ mingw*/bin/libfontconfig-1.dll
+ mingw*/bin/libfreetype-6.dll
+ mingw*/bin/libfribidi-0.dll
+ mingw*/bin/libgcc_s_seh-1.dll
+ mingw*/bin/libgdk-3-0.dll
+ mingw*/bin/libgdk_pixbuf-2.0-0.dll
+ mingw*/bin/libgio-2.0-0.dll
+ mingw*/bin/libgirepository-1.0-1.dll
+ mingw*/bin/libglib-2.0-0.dll
+ mingw*/bin/libgmodule-2.0-0.dll
+ mingw*/bin/libgobject-2.0-0.dll
+ mingw*/bin/libgraphite2.dll
+ mingw*/bin/libgtk-3-0.dll
+ mingw*/bin/libharfbuzz-0.dll
+ mingw*/bin/libharfbuzz-gobject-0.dll
+ mingw*/bin/libiconv-2.dll
+ mingw*/bin/libintl-8.dll
+ mingw*/bin/libpango-1.0-0.dll
+ mingw*/bin/libpangocairo-1.0-0.dll
+ mingw*/bin/libpangoft2-1.0-0.dll
+ mingw*/bin/libpangowin32-1.0-0.dll
+ mingw*/bin/libpcre2-8-0.dll
+ mingw*/bin/libpixman-1-0.dll
+ mingw*/bin/libpng16-16.dll
+ mingw*/bin/libpython3.10.dll
+ mingw*/bin/libsqlite3-0.dll
+ mingw*/bin/libstdc++-6.dll
+ mingw*/bin/libthai-0.dll
+ mingw*/bin/libwinpthread-1.dll
+ mingw*/bin/zlib1.dll
+
+ mingw*/lib/gtk-3.0
+ mingw*/lib/gdk-pixbuf-2.0/*/loaders/libpixbufloader-png.dll
+ mingw*/lib/gdk-pixbuf-2.0/*/loaders/libpixbufloader-png.dll.a
+ mingw*/lib/gdk-pixbuf-2.0/*/loaders/libpixbufloader-gif.dll
+ mingw*/lib/gdk-pixbuf-2.0/*/loaders/libpixbufloader-gif.dll.a
+
+
+ mingw*/share/icons/hicolor/index.theme
+
+ # python-gobject stuff
+ mingw*/lib/girepository-*/Atk-1.0.typelib
+ mingw*/lib/girepository-*/GLib-2.0.typelib
+ mingw*/lib/girepository-*/GModule-2.0.typelib
+ mingw*/lib/girepository-*/GObject-2.0.typelib
+ mingw*/lib/girepository-*/Gdk-3.0.typelib
+ mingw*/lib/girepository-*/GdkPixbuf-2.0.typelib
+ mingw*/lib/girepository-*/Gio-2.0.typelib
+ mingw*/lib/girepository-*/Gtk-3.0.typelib
+ mingw*/lib/girepository-*/HarfBuzz-0.0.typelib
+ mingw*/lib/girepository-*/Pango-1.0.typelib
+ mingw*/lib/girepository-*/PangoCairo-1.0.typelib
+ mingw*/lib/girepository-*/PangoOT-1.0.typelib
+ mingw*/lib/girepository-*/cairo-1.0.typelib
+ mingw*/lib/girepository-*/freetype2-2.0.typelib
+
+ # To avoid terminal window, use pythonw.exe
+ mingw*/bin/pythonw.exe
+ # For debugging use python.exe
+ mingw*/bin/python.exe
+ # Zenmap's files (mostly in site-packages above)
+ mingw*/share/zenmap
+ # mingw*/bin/zenmap
+ mingw*/lib/python3.*/site-packages/zenmapCore
+ mingw*/lib/python3.*/site-packages/zenmapGUI
+ mingw*/lib/python3.*/site-packages/radialnet
+
+ # The python modules here will be added by script:
+ # mingw*/lib/python3.*
+ # mingw*/lib/python3.*/encodings
+ # mingw*/lib/python3.*/site.py
+ # mingw*/lib/python3.*/_sitebuiltins.py
+ # mingw*/lib/python3.*/site-packages/gi
+ # mingw*/lib/python3.*/site-packages/cairo
+
+# Local launcher definitions
+
+; You can define new app launchers here, or extend the launchers in
+; installed .desktop files by overriding their keys.
+;
+; All launchers need to be listed in the [bundle]'s "launchers" key.
+[zenmap.desktop]
+exec = pythonw.exe -c 'from zenmapGUI.App import run; run()'
+icon = {msystem_subdir}/share/zenmap/pixmaps/zenmap.png
+; For debugging:
+;Terminal = true
+;exec = python.exe -c 'from zenmapGUI.App import run; run()' -vvvvv