mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Use cli defines, not sed, to customize NSIS script. Also addresses #2316
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
MAKENSIS=/cygdrive/c/Program Files (x86)/NSIS-strlen/makensis.exe
|
||||
MAKENSIS_WIN=$(shell echo '$(MAKENSIS)' | sed 's|/cygdrive/\(.\)|\1:|;s|/|\\|g')
|
||||
MAKENSIS=C:/Program Files (x86)/NSIS-strlen/makensis.exe
|
||||
SIGNTOOL := $(shell reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" /v "InstallationFolder" | egrep InstallationFolder | cut -d ' ' -f13- | sed 's%\\%/%g' | tr -d '\r\n' | sed 's%$$%bin/x86/signtool.exe%')
|
||||
NMAPDIR=..
|
||||
NMAPDIR_WIN=$(shell echo '$(NMAPDIR)' | sed 's|/cygdrive/\(.\)|\1:|;s|/|\\|g')
|
||||
@@ -10,17 +9,18 @@ export NPCAP_VERSION := $(shell ls npcap-*.exe | sed -e 's/npcap-\([0-9.]*\)[-oe
|
||||
NSE_FILES = $(NMAPDIR)/scripts/script.db $(NMAPDIR)/scripts/*.nse
|
||||
NMAP_MSWIN32_AUX = $(NMAPDIR)/../nmap-mswin32-aux
|
||||
SIGNTOOL_ARGS = sign /a /n "Insecure.Com LLC" /tr http://timestamp.digicert.com /td sha256 /fd sha256
|
||||
# escape quotes for NSIS
|
||||
# escape for right side of sed regex replace
|
||||
SIGNTOOL_SUBST = $(shell echo '"$(SIGNTOOL)" $(SIGNTOOL_ARGS)' | sed -e 's/"/$$\\"/g' -e 's/[\/&]/\\&/g' )
|
||||
|
||||
PRODUCT_NAME=Nmap
|
||||
PLATFORM=Win32
|
||||
VCCONFIG=Release
|
||||
NSIS_DEFINES=
|
||||
|
||||
all: build-nmap
|
||||
|
||||
check:
|
||||
test -n "$(NMAP_NAME)"
|
||||
test -n "$(NMAP_OEM_NAME)"
|
||||
test -n "$(NMAP_VERSION)"
|
||||
test -n "$(NMAP_NUM_VERSION)"
|
||||
|
||||
make-vars.make: make-vars.h
|
||||
cmd /c Build.bat Vars
|
||||
|
||||
@@ -61,7 +61,6 @@ stage-common: $(NMAPDIR)/CHANGELOG $(NMAPDIR)/LICENSE $(NMAPDIR)/nmap-mac-prefix
|
||||
cp $(NMAPDIR)/zenmap/README nmap-$(NMAP_VERSION)/ZENMAP_README
|
||||
cp $(NMAPDIR)/zenmap/COPYING_HIGWIDGETS nmap-$(NMAP_VERSION)
|
||||
cp $(NMAPDIR)/ndiff/README nmap-$(NMAP_VERSION)/NDIFF_README
|
||||
cp nsis/AddToPath.nsh nsis/shortcuts.ini nsis/final.ini nmap-$(NMAP_VERSION)
|
||||
|
||||
stage: stage-nmap stage-nmap-oem stage-common
|
||||
|
||||
@@ -71,7 +70,7 @@ stage-nmap:
|
||||
stage-nmap-oem:
|
||||
$(MAKE) OEM_SUFFIX=-oem stage-nmap-main
|
||||
|
||||
stage-nmap-main: nmap-$(NMAP_VERSION)/Nmap.nsi build-nmap${OEM_SUFFIX}
|
||||
stage-nmap-main: build-nmap${OEM_SUFFIX}
|
||||
mkdir -p nmap-$(NMAP_VERSION)${OEM_SUFFIX}
|
||||
cp $(VCCONFIG)${OEM_SUFFIX}/nmap.exe nmap-$(NMAP_VERSION)${OEM_SUFFIX}/
|
||||
|
||||
@@ -80,11 +79,10 @@ sign-files: nmap-$(NMAP_VERSION)-oem/nmap.exe nmap-$(NMAP_VERSION)/nmap.exe nmap
|
||||
"$(SIGNTOOL)" $(SIGNTOOL_ARGS) $^
|
||||
touch sign-files
|
||||
|
||||
NSIS_COMMON_ARGS = "/DVERSION=$(NMAP_VERSION)" "/DNUM_VERSION=$(NMAP_NUM_VERSION)" "/DNPCAP_VERSION=$(NPCAP_VERSION)" '/DSIGNTOOL_CMD="$(SIGNTOOL)" $(SIGNTOOL_ARGS)'
|
||||
bundle-nsis: sign-files
|
||||
"$(MAKENSIS)" "/XOutFile nmap-$(NMAP_VERSION)-setup.exe" "/DNSISEXE=$(MAKENSIS_WIN)" nmap-$(NMAP_VERSION)/Nmap.nsi
|
||||
mv nmap-$(NMAP_VERSION)/nmap-$(NMAP_VERSION)-setup.exe .
|
||||
"$(MAKENSIS)" "/XOutFile nmap-$(NMAP_VERSION)-oem-setup.exe" "/DNSISEXE=$(MAKENSIS_WIN)" "/DNMAP_OEM=1" nmap-$(NMAP_VERSION)/Nmap.nsi
|
||||
mv nmap-$(NMAP_VERSION)/nmap-$(NMAP_VERSION)-oem-setup.exe .
|
||||
"$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_NAME)" nmap-$(NMAP_VERSION)/Nmap.nsi
|
||||
"$(MAKENSIS)" $(NSIS_COMMON_ARGS) "/DNMAP_NAME=$(NMAP_OEM_NAME)" "/DNMAP_OEM=1" nmap-$(NMAP_VERSION)/Nmap.nsi
|
||||
"$(SIGNTOOL)" $(SIGNTOOL_ARGS) nmap-$(NMAP_VERSION)-setup.exe nmap-$(NMAP_VERSION)-oem-setup.exe
|
||||
|
||||
bundle-zip: bundle-zip-public bundle-zip-oem
|
||||
@@ -111,26 +109,11 @@ bundle-zip-main: sign-files
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/w9xpopen.exe \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/vcredist2008_x86.exe \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/ndiff.exe \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/\*.ini \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/Uninstall.exe \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/\*.nsi \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/\*.nsh \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/LICENSE.formatted \
|
||||
nmap-$(NMAP_VERSION)${OEM_SUFFIX}/icon1.ico \
|
||||
-r nmap-$(NMAP_VERSION)${OEM_SUFFIX}-win32.zip nmap-$(NMAP_VERSION)${OEM_SUFFIX}
|
||||
rm nmap-$(NMAP_VERSION)${OEM_SUFFIX}/npcap-$(NPCAP_VERSION)${OEM_SUFFIX}.exe
|
||||
|
||||
nmap-$(NMAP_VERSION)/Nmap.nsi: nsis/Nmap.nsi.in $(NMAPDIR)/nmap.h
|
||||
test -n "$(NPCAP_VERSION)" # Make sure NPcap is present
|
||||
mkdir -p nmap-$(NMAP_VERSION)
|
||||
sed -e '1i; Automatically generated from $<.' \
|
||||
-e 's/@@VIPRODUCTVERSION@@/"$(NMAP_NUM_VERSION)"/' \
|
||||
-e 's/@@VERSION@@/"$(NMAP_VERSION)"/' \
|
||||
-e 's/@@NPCAP_VERSION@@/$(NPCAP_VERSION)/' \
|
||||
-e 's/@@SIGNTOOL@@/$(SIGNTOOL_SUBST)/' \
|
||||
-e 's/@@PRODUCT_NAME@@/$(PRODUCT_NAME)/' \
|
||||
"$<" > "$@"
|
||||
|
||||
LICENSE.formatted: $(NMAPDIR)/LICENSE
|
||||
./license-format/licformat.sh "$<" > "$@"
|
||||
|
||||
|
||||
@@ -2,8 +2,13 @@ define IGNORE
|
||||
#include "../nmap.h"
|
||||
endef
|
||||
|
||||
#define EXPORT(_var) export $(name)##_var:= $(patsubst "%",%,$(subst " ",,NMAP##_var))
|
||||
#define EXPORT(_var) export $(name)##_var:= $(patsubst "%,%,$(patsubst %",%,$(subst " ",,NMAP##_var)))
|
||||
|
||||
name = NMAP
|
||||
EXPORT(_NAME)
|
||||
EXPORT(_VERSION)
|
||||
EXPORT(_NUM_VERSION)
|
||||
#undef NMAP_NAME
|
||||
#include "../../nmap-build/nmap-oem.h"
|
||||
#define NMAP_OEM_NAME NMAP_NAME
|
||||
EXPORT(_OEM_NAME)
|
||||
|
||||
@@ -24,8 +24,13 @@
|
||||
!error "Need to use large strings build of NSIS."
|
||||
!endif
|
||||
|
||||
!define STAGE_DIR ..\nmap-${VERSION}
|
||||
|
||||
!ifdef NMAP_OEM
|
||||
!include "..\..\nmap-build\nmap-oem.nsh"
|
||||
!define STAGE_DIR_OEM ${STAGE_DIR}-oem
|
||||
!else
|
||||
!define STAGE_DIR_OEM ${STAGE_DIR}
|
||||
!endif
|
||||
|
||||
;--------------------------------
|
||||
@@ -38,11 +43,6 @@
|
||||
|
||||
;--------------------------------
|
||||
;General
|
||||
!ifdef NMAP_OEM
|
||||
!define NMAP_NAME "@@PRODUCT_NAME@@ OEM"
|
||||
!else
|
||||
!define NMAP_NAME "@@PRODUCT_NAME@@"
|
||||
!endif
|
||||
;Name and file
|
||||
Name "${NMAP_NAME}"
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
; it is invoked, will just write the uninstaller to some location, and then exit.
|
||||
; Be sure to substitute the name of this script here.
|
||||
|
||||
!system "$\"${NSISEXE}$\" /DINNER Nmap.nsi" = 0
|
||||
!system `"${NSISDIR}\makensis.exe" /DINNER Nmap.nsi` = 0
|
||||
|
||||
; So now run that installer we just created as %TEMP%\tempinstaller.exe. Since it
|
||||
; calls quit the return value isn't zero.
|
||||
@@ -75,11 +75,12 @@
|
||||
; favourite code signing tool.
|
||||
|
||||
;!system "icacls.exe $\"$%TEMP%\Uninstall.exe$\" /grant $\"$%USER%$\":M"
|
||||
!system "copy /b $\"$%TEMP%\Uninstall.exe$\" Uninstall.exe"
|
||||
!system "$\"C:/Program Files (x86)/Windows Kits/8.1/bin/x86/signtool.exe$\" sign /a /n $\"Insecure.Com LLC$\" /tr http://timestamp.digicert.com /td sha256 /fd sha256 Uninstall.exe" = 0
|
||||
!system `copy /b "$%TEMP%\Uninstall.exe" "${STAGE_DIR_OEM}\Uninstall.exe"`
|
||||
!system `${SIGNTOOL_CMD} "${STAGE_DIR_OEM}\Uninstall.exe"` = 0
|
||||
|
||||
; Good. Now we can carry on writing the real installer.
|
||||
|
||||
OutFile ${STAGE_DIR_OEM}-setup.exe
|
||||
SetCompressor /SOLID /FINAL lzma
|
||||
|
||||
;Required for removing shortcuts
|
||||
@@ -92,9 +93,7 @@
|
||||
;Get installation folder from registry if available
|
||||
InstallDirRegKey HKCU "Software\${NMAP_NAME}" ""
|
||||
|
||||
!define VERSION @@VERSION@@
|
||||
!define STAGE_DIR ..\nmap-${VERSION}
|
||||
VIProductVersion @@VIPRODUCTVERSION@@
|
||||
VIProductVersion ${NUM_VERSION}
|
||||
VIAddVersionKey /LANG=1033 "FileVersion" "${VERSION}"
|
||||
VIAddVersionKey /LANG=1033 "ProductName" "${NMAP_NAME}"
|
||||
VIAddVersionKey /LANG=1033 "CompanyName" "Insecure.org"
|
||||
@@ -111,7 +110,7 @@
|
||||
;--------------------------------
|
||||
;Pages
|
||||
|
||||
!insertmacro MUI_PAGE_LICENSE "LICENSE.formatted"
|
||||
!insertmacro MUI_PAGE_LICENSE "..\LICENSE.formatted"
|
||||
!insertmacro MUI_PAGE_COMPONENTS
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
@@ -243,24 +242,20 @@ Section "Nmap Core Files" SecCore
|
||||
File ${STAGE_DIR}\nmap-rpc
|
||||
File ${STAGE_DIR}\nmap-service-probes
|
||||
File ${STAGE_DIR}\nmap-services
|
||||
!ifdef NMAP_OEM
|
||||
File ${STAGE_DIR}-oem\nmap.exe
|
||||
!else
|
||||
File ${STAGE_DIR}\nmap.exe
|
||||
!endif
|
||||
File ${STAGE_DIR_OEM}\nmap.exe
|
||||
File ${STAGE_DIR}\nse_main.lua
|
||||
File ${STAGE_DIR}\nmap.xsl
|
||||
File ${STAGE_DIR}\nmap_performance.reg
|
||||
File ${STAGE_DIR}\README-WIN32
|
||||
File ${STAGE_DIR}\3rd-party-licenses.txt
|
||||
File /r /x .svn ${STAGE_DIR}\licenses
|
||||
File libssh2.dll
|
||||
File zlibwapi.dll
|
||||
File libcrypto-1_1.dll
|
||||
File libssl-1_1.dll
|
||||
File ${STAGE_DIR}\libssh2.dll
|
||||
File ${STAGE_DIR}\zlibwapi.dll
|
||||
File ${STAGE_DIR}\libcrypto-1_1.dll
|
||||
File ${STAGE_DIR}\libssl-1_1.dll
|
||||
File /r /x mswin32 /x .svn /x ncat ${STAGE_DIR}\scripts
|
||||
File /r /x mswin32 /x .svn ${STAGE_DIR}\nselib
|
||||
File icon1.ico
|
||||
File ${STAGE_DIR}\icon1.ico
|
||||
|
||||
;Store installation folder
|
||||
WriteRegStr HKCU "Software\${NMAP_NAME}" "" $INSTDIR
|
||||
@@ -276,15 +271,15 @@ Section "Register Nmap Path" SecRegisterPath
|
||||
SectionEnd
|
||||
|
||||
!ifdef NMAP_OEM
|
||||
Section "Npcap @@NPCAP_VERSION@@ OEM" SecNpcap
|
||||
!insertmacro NPCAP_OEM_INSTALL "npcap-@@NPCAP_VERSION@@-oem.exe"
|
||||
Section "Npcap ${NPCAP_VERSION} OEM" SecNpcap
|
||||
!insertmacro NPCAP_OEM_INSTALL "npcap-${NPCAP_VERSION}-oem.exe"
|
||||
SectionEnd
|
||||
!else
|
||||
Section "Npcap @@NPCAP_VERSION@@" SecNpcap
|
||||
Section "Npcap ${NPCAP_VERSION}" SecNpcap
|
||||
SetOutPath "$PLUGINSDIR"
|
||||
SetOverwrite on
|
||||
File "..\npcap-@@NPCAP_VERSION@@.exe"
|
||||
ExecWait '"$PLUGINSDIR\npcap-@@NPCAP_VERSION@@.exe" /loopback_support=no'
|
||||
File "..\npcap-${NPCAP_VERSION}.exe"
|
||||
ExecWait '"$PLUGINSDIR\npcap-${NPCAP_VERSION}.exe" /loopback_support=no'
|
||||
SectionEnd
|
||||
!endif
|
||||
|
||||
@@ -433,7 +428,7 @@ Function create_uninstaller
|
||||
|
||||
; this packages the signed uninstaller
|
||||
|
||||
File "Uninstall.exe"
|
||||
File "${STAGE_DIR_OEM}\Uninstall.exe"
|
||||
!endif
|
||||
StrCpy $addremoveset "true"
|
||||
skipaddremove:
|
||||
@@ -496,7 +491,7 @@ FunctionEnd
|
||||
;Component strings
|
||||
LangString DESC_SecCore ${LANG_ENGLISH} "Installs Nmap executable, NSE scripts and Visual C++ 2013 runtime components"
|
||||
LangString DESC_SecRegisterPath ${LANG_ENGLISH} "Registers Nmap path to System path so you can execute it from any directory"
|
||||
LangString DESC_SecNpcap ${LANG_ENGLISH} "Installs Npcap @@NPCAP_VERSION@@ (required for most Nmap scans unless it is already installed)"
|
||||
LangString DESC_SecNpcap ${LANG_ENGLISH} "Installs Npcap ${NPCAP_VERSION} (required for most Nmap scans unless it is already installed)"
|
||||
LangString DESC_SecPerfRegistryMods ${LANG_ENGLISH} "Modifies Windows registry values to improve TCP connect scan performance. Recommended."
|
||||
!ifndef NMAP_OEM
|
||||
LangString DESC_SecZenmap ${LANG_ENGLISH} "Installs Zenmap, the official Nmap graphical user interface, and Visual C++ 2008 runtime components. Recommended."
|
||||
Reference in New Issue
Block a user