Add nsis code from IDK. Update makefile to build an installer
This commit is contained in:
18
Makefile
18
Makefile
@ -1,4 +1,10 @@
|
||||
all: build/license-all.txt profile.tgz
|
||||
all: profile.tgz install.exe
|
||||
|
||||
install.exe: profile build/license-all.txt
|
||||
cp src/nsis/*.nsi build
|
||||
cp src/nsis/*.nsh build
|
||||
cp src/icons/*.ico build
|
||||
cd build && makensis i2pbrowser-installer.nsi && cp install.exe ../ && echo "built windows installer"
|
||||
|
||||
build/license-all.txt: build
|
||||
cat license/LICENSE.index LICENSE license/MPL2.txt license/LICENSE.tor license/HTTPS-Everywhere.txt license/NoScript.txt > build/license-all.txt
|
||||
@ -6,14 +12,16 @@ build/license-all.txt: build
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf build profile.tgz
|
||||
rm -rf build profile.tgz installer.exe
|
||||
|
||||
|
||||
build:
|
||||
@echo "creating build directory"
|
||||
mkdir build
|
||||
|
||||
profile.tgz: build/profile/user.js build/profile/bookmarks.html copy-xpi
|
||||
profile: build/profile/user.js build/profile/bookmarks.html copy-xpi
|
||||
|
||||
profile.tgz: profile
|
||||
@echo "building profile tarball"
|
||||
cd build && tar -czf profile.tgz profile && cp profile.tgz ../
|
||||
|
||||
@ -27,7 +35,7 @@ copy-xpi: build/NoScript.xpi build/HTTPSEverywhere.xpi build/profile/extensions
|
||||
cp build/NoScript.xpi "build/profile/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
|
||||
cp build/HTTPSEverywhere.xpi "build/profile/extensions/https-everywhere-eff@eff.org.xpi"
|
||||
|
||||
build/NoScript.xpi: build/ NoScript.url
|
||||
build/NoScript.xpi: build NoScript.url
|
||||
curl `cat NoScript.url` > build/NoScript.xpi
|
||||
|
||||
build/HTTPSEverywhere.xpi : build HTTPSEverywhere.url
|
||||
@ -36,5 +44,5 @@ build/HTTPSEverywhere.xpi : build HTTPSEverywhere.url
|
||||
build/profile/extensions: build/profile
|
||||
mkdir build/profile/extensions
|
||||
|
||||
build/profile:
|
||||
build/profile: build
|
||||
mkdir build/profile
|
||||
|
5
README
5
README
@ -7,4 +7,7 @@ To build this, you will need the following software packages (all available in D
|
||||
|
||||
Before you build, you should update the files "NoScript.url" and "HTTPSEverywhere.url" to point to the latest direct download links of the respective plugins. If those have changed, it's a good idea to check those files back in to keep them as current as possible.
|
||||
|
||||
After that just type "Make". This will produce a file called "profile.tgz" which is the raw firefox profile.
|
||||
After that just type "make". This will produce two files:
|
||||
|
||||
profile.tgz - the raw firefox profile.
|
||||
install.exe - the windows installer.
|
||||
|
BIN
src/icons/ui2pbrowser_icon.ico
Normal file
BIN
src/icons/ui2pbrowser_icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
227
src/nsis/i2pbrowser-installer.nsi
Normal file
227
src/nsis/i2pbrowser-installer.nsi
Normal file
@ -0,0 +1,227 @@
|
||||
!define APPNAME "I2PBrowser-Launcher"
|
||||
!define COMPANYNAME "I2P"
|
||||
!define DESCRIPTION "This launches Firefox with a browser profile pre-configured to use i2p"
|
||||
!define FIREFOX_MESSAGE "Select the location of your Firefox installation."
|
||||
!define I2P_MESSAGE "Select the location of your i2p installation."
|
||||
!define LAUNCH_TEXT "Launch the i2p browser?"
|
||||
!define LICENSE_TITLE "MIT License"
|
||||
|
||||
!include i2pbrowser-version.nsi
|
||||
|
||||
var FFINSTEXE
|
||||
var I2PINSTEXE
|
||||
var SHORTCUT
|
||||
|
||||
!define FFINSTEXE
|
||||
!define FFINSTEXE32 "$PROGRAMFILES32\Mozilla Firefox\"
|
||||
!define FFINSTEXE64 "$PROGRAMFILES64\Mozilla Firefox\"
|
||||
|
||||
!define I2PINSTEXE
|
||||
!define I2PINSTEXE32 "$PROGRAMFILES32\i2p\"
|
||||
!define I2PINSTEXE64 "$PROGRAMFILES64\i2p\"
|
||||
|
||||
!define RAM_NEEDED_FOR_64BIT 0x80000000
|
||||
|
||||
InstallDir "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}"
|
||||
|
||||
# rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n)
|
||||
LicenseData "license-all.txt"
|
||||
# This will be in the installer/uninstaller's title bar
|
||||
Name "${COMPANYNAME} - ${APPNAME}"
|
||||
Icon "ui2pbrowser_icon.ico"
|
||||
OutFile "install.exe"
|
||||
|
||||
RequestExecutionLevel admin
|
||||
|
||||
!include LogicLib.nsh
|
||||
!include x64.nsh
|
||||
!include i2pbrowser-strrep.nsh
|
||||
|
||||
PageEx license
|
||||
licensetext "${LICENSE_TITLE}"
|
||||
licensedata "license-all.txt"
|
||||
PageExEnd
|
||||
PageEx directory
|
||||
dirtext "${FIREFOX_MESSAGE}"
|
||||
dirvar $FFINSTEXE
|
||||
PageCallbacks firefoxDetect
|
||||
PageExEnd
|
||||
Page instfiles
|
||||
PageEx directory
|
||||
dirtext "${I2P_MESSAGE}"
|
||||
dirvar $I2PINSTEXE
|
||||
PageCallbacks routerDetect
|
||||
PageExEnd
|
||||
|
||||
|
||||
!include i2pbrowser-mozcompat.nsi
|
||||
|
||||
Function .onInit
|
||||
Call ShouldInstall64Bit
|
||||
${If} $0 == 1
|
||||
${If} ${FileExists} "${FFINSTEXE64}/firefox.exe"
|
||||
StrCpy $FFINSTEXE "${FFINSTEXE64}"
|
||||
${EndIf}
|
||||
${If} ${FileExists} "$PROFILE/OneDrive/Desktop/Tor Browser/Browser/firefox.exe"
|
||||
StrCpy $FFINSTEXE "$PROFILE/OneDrive/Desktop/Tor Browser/Browser/"
|
||||
${EndIf}
|
||||
${If} ${FileExists} "$PROFILE/Desktop/Tor Browser/Browser/firefox.exe"
|
||||
StrCpy $FFINSTEXE "$PROFILE/Desktop/Tor Browser/Browser/"
|
||||
${EndIf}
|
||||
${Else}
|
||||
${If} ${FileExists} "${FFINSTEXE32}/firefox.exe"
|
||||
StrCpy $FFINSTEXE "${FFINSTEXE32}"
|
||||
${EndIf}
|
||||
${If} ${FileExists} "$PROFILE/OneDrive/Desktop/Tor Browser/Browser/firefox.exe"
|
||||
StrCpy $FFINSTEXE "$PROFILE/OneDrive/Desktop/Tor Browser/Browser/"
|
||||
${EndIf}
|
||||
${If} ${FileExists} "$PROFILE/Desktop/Tor Browser/Browser/firefox.exe"
|
||||
StrCpy $FFINSTEXE "$PROFILE/Desktop/Tor Browser/Browser/"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${If} ${FileExists} "${I2PINSTEXE32}/i2p.exe"
|
||||
StrCpy $I2PINSTEXE "${I2PINSTEXE64}"
|
||||
${EndIf}
|
||||
${If} ${FileExists} "${I2PINSTEXE64}/i2p.exe"
|
||||
StrCpy $I2PINSTEXE "${I2PINSTEXE64}"
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function firefoxDetect
|
||||
${If} ${FileExists} "$FFINSTEXE/firefox.exe"
|
||||
Abort directory
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function routerDetect
|
||||
${If} ${FileExists} "$I2PINSTEXE/i2p.exe"
|
||||
Abort directory
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
# start default section
|
||||
Section Install
|
||||
|
||||
# set the installation directory as the destination for the following actions
|
||||
createDirectory $INSTDIR
|
||||
SetOutPath $INSTDIR
|
||||
File ui2pbrowser_icon.ico
|
||||
|
||||
# Install the launcher scripts: This will need to be it's own section, since
|
||||
# now I think we just need to let the user select if the user is using a non
|
||||
# default Firefox path.
|
||||
FileOpen $0 "$INSTDIR\i2pbrowser.bat" w
|
||||
FileWrite $0 "@echo off"
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileWrite $0 'start "" "$FFINSTEXE\firefox.exe" -no-remote -profile "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p"'
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileWrite $0 exit
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileClose $0
|
||||
|
||||
FileOpen $0 "$INSTDIR\i2pbrowser-private.bat" w
|
||||
FileWrite $0 "@echo off"
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileWrite $0 'start "" "$FFINSTEXE\firefox.exe" -no-remote -profile "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p" -private-window about:blank'
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileWrite $0 exit
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileClose $0
|
||||
|
||||
# Install the profile
|
||||
createDirectory "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p"
|
||||
SetOutPath "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p"
|
||||
File profile/user.js
|
||||
File profile/bookmarks.html
|
||||
|
||||
# Install the extensions
|
||||
createDirectory "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\extensions"
|
||||
SetOutPath "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\extensions"
|
||||
File "profile/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
|
||||
File profile/extensions/https-everywhere-eff@eff.org.xpi
|
||||
|
||||
SetOutPath "$INSTDIR"
|
||||
createDirectory "$SMPROGRAMS\${APPNAME}"
|
||||
CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "C:\Windows\system32\cmd.exe" "/c $\"$INSTDIR\i2pbrowser.bat$\"" "$INSTDIR\ui2pbrowser_icon.ico"
|
||||
CreateShortCut "$SMPROGRAMS\${APPNAME}\Private Browsing-${APPNAME}.lnk" "C:\Windows\system32\cmd.exe" "/c $\"$INSTDIR\i2pbrowser-private.bat$\"" "$INSTDIR\ui2pbrowser_icon.ico"
|
||||
CreateShortCut "$DESKTOP\${APPNAME}.lnk" "C:\Windows\system32\cmd.exe" "/c $\"$INSTDIR\i2pbrowser.bat$\"" "$INSTDIR\ui2pbrowser_icon.ico"
|
||||
CreateShortCut "$DESKTOP\Private Browsing-${APPNAME}.lnk" "C:\Windows\system32\cmd.exe" "/c $\"$INSTDIR\i2pbrowser-private.bat$\"" "$INSTDIR\ui2pbrowser_icon.ico"
|
||||
|
||||
${StrRep} $SHORTCUT "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" '\' '\\'
|
||||
|
||||
!define SHORTCUTPATH $SHORTCUT
|
||||
|
||||
SetShellVarContext current
|
||||
!define I2PAPPDATA "$APPDATA\I2P\"
|
||||
|
||||
SetOutPath "${I2PAPPDATA}"
|
||||
|
||||
;# Point the browser config setting
|
||||
FileOpen $0 "${I2PAPPDATA}\clients.config" a
|
||||
FileSeek $0 0 END
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileWrite $0 "browser=$\"${SHORTCUTPATH}$\""
|
||||
FileWriteByte $0 "13"
|
||||
FileWriteByte $0 "10"
|
||||
FileClose $0
|
||||
|
||||
SetOutPath "$INSTDIR"
|
||||
# create the uninstaller
|
||||
WriteUninstaller "$INSTDIR\uninstall-i2pbrowser.exe"
|
||||
|
||||
# create a shortcut to the uninstaller
|
||||
CreateShortCut "$SMPROGRAMS\${APPNAME}\Uninstall-${APPNAME}.lnk" "$INSTDIR\uninstall-i2pbrowser.exe"
|
||||
|
||||
SectionEnd
|
||||
|
||||
# uninstaller section start
|
||||
Section "uninstall"
|
||||
|
||||
# Uninstall the launcher scripts
|
||||
Delete $INSTDIR\i2pbrowser.bat
|
||||
Delete $INSTDIR\i2pbrowser-private.bat
|
||||
Delete $INSTDIR\ui2pbrowser_icon.ico
|
||||
|
||||
# Uninstall the profile
|
||||
Delete $LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\user.js
|
||||
Delete $LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\bookmarks.html
|
||||
|
||||
# Uninstall the extensions
|
||||
Delete "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\extensions\{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
|
||||
Delete "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\extensions\https-everywhere-eff@eff.org.xpi"
|
||||
|
||||
# Remove shortcuts and folders
|
||||
Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
|
||||
Delete "$SMPROGRAMS\${APPNAME}\Private Browsing-${APPNAME}.lnk"
|
||||
Delete "$SMPROGRAMS\Uninstall-${APPNAME}.lnk"
|
||||
Delete "$DESKTOP\${APPNAME}.lnk"
|
||||
Delete "$DESKTOP\Private Browsing-${APPNAME}.lnk"
|
||||
rmDir "$SMPROGRAMS\${APPNAME}"
|
||||
rmDir "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p\extensions"
|
||||
rmDir "$LOCALAPPDATA\${APPNAME}\firefox.profile.i2p"
|
||||
rmDir "$LOCALAPPDATA\${APPNAME}"
|
||||
rmDir "$INSTDIR"
|
||||
|
||||
# delete the uninstaller
|
||||
Delete "$INSTDIR\uninstall-i2pbrowser.exe"
|
||||
|
||||
# uninstaller section end
|
||||
|
||||
SectionEnd
|
||||
|
||||
!include "MUI2.nsh"
|
||||
!define MUI_FINISHPAGE_RUN
|
||||
!define MUI_FINISHPAGE_RUN_TEXT "${LAUNCH_TEXT}"
|
||||
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
Function LaunchLink
|
||||
ExecShell "" "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
|
||||
FunctionEnd
|
37
src/nsis/i2pbrowser-mozcompat.nsi
Normal file
37
src/nsis/i2pbrowser-mozcompat.nsi
Normal file
@ -0,0 +1,37 @@
|
||||
; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
; Returns 1 in $0 if we should install the 64-bit build, or 0 if not.
|
||||
; The requirements for selecting the 64-bit build to install are:
|
||||
; 1) Running a 64-bit OS (we've already checked the OS version).
|
||||
; 2) An amount of RAM strictly greater than RAM_NEEDED_FOR_64BIT
|
||||
; 3) No third-party products installed that cause issues with the 64-bit build.
|
||||
; Currently this includes Lenovo OneKey Theater and Lenovo Energy Management.
|
||||
Function ShouldInstall64Bit
|
||||
StrCpy $0 0
|
||||
|
||||
${IfNot} ${RunningX64}
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
System::Call "*(i 64, i, l 0, l, l, l, l, l, l)p.r1"
|
||||
System::Call "Kernel32::GlobalMemoryStatusEx(p r1)"
|
||||
System::Call "*$1(i, i, l.r2, l, l, l, l, l, l)"
|
||||
System::Free $1
|
||||
${If} $2 L<= ${RAM_NEEDED_FOR_64BIT}
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
; Lenovo OneKey Theater can theoretically be in a directory other than this
|
||||
; one, because some installer versions let you change it, but it's unlikely.
|
||||
${If} ${FileExists} "$PROGRAMFILES32\Lenovo\Onekey Theater\windowsapihookdll64.dll"
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
${If} ${FileExists} "$PROGRAMFILES32\Lenovo\Energy Management\Energy Management.exe"
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
StrCpy $0 1
|
||||
FunctionEnd
|
71
src/nsis/i2pbrowser-strrep.nsh
Normal file
71
src/nsis/i2pbrowser-strrep.nsh
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
;;
|
||||
;; TODO: Examine licensing for this function.
|
||||
;;https://nsis.sourceforge.io/StrRep
|
||||
|
||||
!define StrRep "!insertmacro StrRep"
|
||||
!macro StrRep output string old new
|
||||
Push `${string}`
|
||||
Push `${old}`
|
||||
Push `${new}`
|
||||
!ifdef __UNINSTALL__
|
||||
Call un.StrRep
|
||||
!else
|
||||
Call StrRep
|
||||
!endif
|
||||
Pop ${output}
|
||||
!macroend
|
||||
|
||||
!macro Func_StrRep un
|
||||
Function ${un}StrRep
|
||||
Exch $R2 ;new
|
||||
Exch 1
|
||||
Exch $R1 ;old
|
||||
Exch 2
|
||||
Exch $R0 ;string
|
||||
Push $R3
|
||||
Push $R4
|
||||
Push $R5
|
||||
Push $R6
|
||||
Push $R7
|
||||
Push $R8
|
||||
Push $R9
|
||||
|
||||
StrCpy $R3 0
|
||||
StrLen $R4 $R1
|
||||
StrLen $R6 $R0
|
||||
StrLen $R9 $R2
|
||||
loop:
|
||||
StrCpy $R5 $R0 $R4 $R3
|
||||
StrCmp $R5 $R1 found
|
||||
StrCmp $R3 $R6 done
|
||||
IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character
|
||||
Goto loop
|
||||
found:
|
||||
StrCpy $R5 $R0 $R3
|
||||
IntOp $R8 $R3 + $R4
|
||||
StrCpy $R7 $R0 "" $R8
|
||||
StrCpy $R0 $R5$R2$R7
|
||||
StrLen $R6 $R0
|
||||
IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string
|
||||
Goto loop
|
||||
done:
|
||||
|
||||
Pop $R9
|
||||
Pop $R8
|
||||
Pop $R7
|
||||
Pop $R6
|
||||
Pop $R5
|
||||
Pop $R4
|
||||
Pop $R3
|
||||
Push $R0
|
||||
Push $R1
|
||||
Pop $R0
|
||||
Pop $R1
|
||||
Pop $R0
|
||||
Pop $R2
|
||||
Exch $R1
|
||||
FunctionEnd
|
||||
!macroend
|
||||
!insertmacro Func_StrRep ""
|
||||
!insertmacro Func_StrRep "un."
|
3
src/nsis/i2pbrowser-version.nsi
Normal file
3
src/nsis/i2pbrowser-version.nsi
Normal file
@ -0,0 +1,3 @@
|
||||
!define VERSIONMAJOR 0
|
||||
!define VERSIONMINOR 1
|
||||
!define VERSIONBUILD a
|
Reference in New Issue
Block a user