mirror of
https://github.com/nmap/nmap.git
synced 2025-12-31 03:49:01 +00:00
Bundling update for macOS
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/bash -e
|
||||
set -x
|
||||
|
||||
test "x$UNDER_JHBUILD" = "x" && exit 1
|
||||
@@ -14,49 +14,69 @@ export ZENMAP_BUILD_DIR
|
||||
BASE=$ZENMAP_DIST_DIR/$APP_NAME.app/Contents
|
||||
SCRIPT_DIR=`dirname "$0"`
|
||||
|
||||
CC=${CC:-clang}
|
||||
CFLAGS=${CFLAGS:--Wall -arch i386}
|
||||
|
||||
echo "Running $0."
|
||||
|
||||
echo "Removing old build."
|
||||
rm -rf "$ZENMAP_DIST_DIR" "$ZENMAP_BUILD_DIR"
|
||||
|
||||
echo "Building bundle"
|
||||
gtk-mac-bundler "$SCRIPT_DIR/zenmap.bundle"
|
||||
echo "Building python-launcher"
|
||||
$CC $CPPFLAGS $CFLAGS $LDFLAGS -L$PREFIX/lib `python3-config --cflags --ldflags --embed` \
|
||||
-o $PREFIX/bin/zenmap-launcher \
|
||||
~/gtk-mac-bundler/examples/python-launcher.c
|
||||
|
||||
echo "Generating dependencies"
|
||||
# Have to run this with ~/gtk/inst/python3 or deps have wrong paths
|
||||
python3 "$SCRIPT_DIR/../utils/get_deps.py" "$SCRIPT_DIR/pyreqs.xml"
|
||||
# gtk-mac-bundler (xml.dom.minidom) doesn't expand external entities
|
||||
xmllint --format --noent "$SCRIPT_DIR/zenmap.bundle" > "$SCRIPT_DIR/tmp.bundle"
|
||||
|
||||
echo "Building bundle"
|
||||
gtk-mac-bundler "$SCRIPT_DIR/tmp.bundle"
|
||||
|
||||
echo "Removing unneeded items"
|
||||
# GIR files not needed, only typelib
|
||||
rm -rf $BASE/Resources/share/gir-1.0/
|
||||
|
||||
echo "Creating caches"
|
||||
pushd "$BASE/Resources"
|
||||
export GDK_PIXBUF_MODULEDIR=$(ls - lib/gdk-pixbuf-2.0/2.*/loaders)
|
||||
gdk-pixbuf-query-loaders > "$GDK_PIXBUF_MODULEDIR".cache
|
||||
gtk-update-icon-cache share/icons/hicolor
|
||||
popd
|
||||
|
||||
# echo "Compiling Python to bytecode"
|
||||
PYTHONLIB=$(ls -d $BASE/Resources/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 '{}' \;
|
||||
python -m compileall -b -x 'zenmapGUI|zenmapCore|radialnet' "$PYTHONLIB"
|
||||
|
||||
# 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
|
||||
echo "Stripping unoptimized Python libraries"
|
||||
#Remove some stuff that is unneeded. This cuts 40M off the installed size.
|
||||
rm -rf $BASE/Resources/lib/python2.7/test/
|
||||
rm -rf $BASE/Resources/lib/python2.7/config/
|
||||
rm -rf $BASE/Resources/lib/python2.7/idlelib/
|
||||
rm -rf $BASE/Resources/lib/python2.7/lib-tk/
|
||||
rm -rf $BASE/Resources/lib/python2.7/lib2to3/
|
||||
rm -f $BASE/Resources/lib/python2.7/site-packages/*.a
|
||||
find "$BASE/Resources/lib/python2.7" -type f -name '*.py' | while read py; do
|
||||
# If the .pyc exists, delete the .py
|
||||
test -f "${py}c" && rm -v "$py"
|
||||
done
|
||||
find "$BASE/Resources/lib/python2.7" -type f -name '*.pyo' | while read py; do
|
||||
# If the .pyc exists, delete the .pyo
|
||||
test -f "${py/%o/c}" && rm -v "$py"
|
||||
done
|
||||
|
||||
echo "Building using distutils"
|
||||
python setup.py build --executable "/usr/bin/env python"
|
||||
python setup.py install vanilla --prefix "$BASE/Resources"
|
||||
$PYTHON setup.py build --executable "/usr/bin/env python3"
|
||||
$PYTHON setup.py install vanilla --prefix "$BASE/Resources"
|
||||
|
||||
echo "Renaming main Zenmap executable."
|
||||
mv $BASE/MacOS/$APP_NAME $BASE/MacOS/zenmap.bin
|
||||
# This is a dummy script, so we'll clean it up:
|
||||
rm $BASE/MacOS/$APP_NAME-bin
|
||||
#rm $BASE/MacOS/$APP_NAME-bin
|
||||
|
||||
echo "Compiling and installing authorization wrapper."
|
||||
echo $CC $CPPFLAGS $CFLAGS $LDFLAGS -v "$SCRIPT_DIR/zenmap_auth.m" -lobjc -framework Foundation -o "$BASE/MacOS/$APP_NAME"
|
||||
$CC $CPPFLAGS $CFLAGS $LDFLAGS -v "$SCRIPT_DIR/zenmap_auth.m" -lobjc -framework Foundation -o "$BASE/MacOS/$APP_NAME"
|
||||
echo $CC $CPPFLAGS $OBJCFLAGS $LDFLAGS -v "$SCRIPT_DIR/zenmap_auth.m" -lobjc -framework Foundation -o "$BASE/MacOS/$APP_NAME"
|
||||
$CC $CPPFLAGS $OBJCFLAGS $LDFLAGS -v "$SCRIPT_DIR/zenmap_auth.m" -lobjc -framework Foundation -o "$BASE/MacOS/$APP_NAME"
|
||||
|
||||
echo "Filling out Info.plist"
|
||||
python - "$SCRIPT_DIR/Info.plist" >"$BASE/Info.plist" <<'EOF'
|
||||
$PYTHON - "$SCRIPT_DIR/Info.plist" >"$BASE/Info.plist" <<'EOF'
|
||||
import sys
|
||||
from string import Template
|
||||
from zenmapCore.Version import *
|
||||
|
||||
Reference in New Issue
Block a user