Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

3 changed files:

Changes:

  • projects/browser/build
    ... ... @@ -285,9 +285,14 @@ done
    285 285
       export PATH="/var/tmp/dist/nsis/bin:$PATH"
    
    286 286
     
    
    287 287
       mv $rootdir/windows-installer $distdir/windows-installer
    
    288
    -  cat > $distdir/windows-installer/browser.nsi << 'BROWSER_NSI'
    
    288
    +  cat > $distdir/windows-installer/browser-portable.nsi << 'BROWSER_NSI'
    
    289 289
     [% INCLUDE 'windows-installer.nsi' %]
    
    290 290
     BROWSER_NSI
    
    291
    +  [% IF c('var/privacy-browser') -%]
    
    292
    +    cat > $distdir/windows-installer/browser-system.nsi << 'BROWSER_NSI'
    
    293
    +[% INCLUDE 'windows-installer.nsi' system_install_mode = 1 %]
    
    294
    +BROWSER_NSI
    
    295
    +  [% END -%]
    
    291 296
       mv ${TB_STAGE_DIR} $distdir/windows-installer/"[% c('var/Project_Name') %]"
    
    292 297
       mv $distdir/windows-installer ${TB_STAGE_DIR}
    
    293 298
     [% END %]
    
    ... ... @@ -357,13 +362,15 @@ cd $distdir
    357 362
     [% ELSIF c("var/windows") %]
    
    358 363
       find "$PKG_DIR" -exec [% c("touch") %] {} \;
    
    359 364
       pushd "$PKG_DIR"
    
    360
    -  makensis browser.nsi
    
    365
    +  makensis browser-portable.nsi
    
    361 366
       # Working around NSIS braindamage
    
    362
    -  mv [% c("var/projectname") %]-install.exe browser-install-tmp.exe
    
    363
    -  python3 $rootdir/pe_checksum_fix.py
    
    364
    -  mv browser-install-tmp2.exe [% c("var/projectname") %]-install.exe
    
    365
    -  rm browser-install-tmp.exe
    
    366
    -  mv [% c("var/projectname") %]-install.exe $OUTDIR/[% c("var/projectname") %]-install[% IF c("var/windows-x86_64") %]-win64[% END %]-[% c("var/torbrowser_version") %]_${PKG_LOCALE}.exe
    
    367
    +  python3 $rootdir/pe_checksum_fix.py browser-install.exe
    
    368
    +  mv browser-install.exe $OUTDIR/[% c("var/projectname") %]-install[% IF c("var/windows-x86_64") %]-win64[% END %]-[% c("var/torbrowser_version") %]_${PKG_LOCALE}.exe
    
    369
    +  [% IF c('var/privacy-browser') -%]
    
    370
    +    makensis browser-system.nsi
    
    371
    +    python3 $rootdir/pe_checksum_fix.py browser-install.exe
    
    372
    +    mv browser-install.exe $OUTDIR/[% c("var/projectname") %]-systeminstall[% IF c("var/windows-x86_64") %]-win64[% END %]-[% c("var/torbrowser_version") %]_${PKG_LOCALE}.exe
    
    373
    +  [% END -%]
    
    367 374
       popd
    
    368 375
     [% END %]
    
    369 376
     rm -rf $distdir/${PKG_DIR}
    

  • projects/browser/pe_checksum_fix.py
    ... ... @@ -43,14 +43,20 @@ recalculates the PE-file checksum. Details of the discussion can be found in bug
    43 43
     Thanks to a cypherpunk for this workaround idea.
    
    44 44
     """
    
    45 45
     
    
    46
    -import pefile;
    
    46
    +import pefile
    
    47
    +import sys
    
    47 48
     
    
    48
    -f = open('browser-install-tmp.exe', 'rb')
    
    49
    -exe = f.read()
    
    50
    -f.close()
    
    49
    +
    
    50
    +if len(sys.argv) < 2:
    
    51
    +    print('Usage: {} exe-name'.format(sys.argv[0]))
    
    52
    +    sys.exit(1)
    
    53
    +
    
    54
    +exename = sys.argv[1]
    
    55
    +with open(exename, 'rb') as f:
    
    56
    +    exe = f.read()
    
    51 57
     remainder = len(exe) % 8
    
    52 58
     if remainder > 0:
    
    53
    -    exe += bytes('\0' * (8 - remainder), 'utf-8')
    
    59
    +    exe += b'\0' * (8 - remainder)
    
    54 60
     pef = pefile.PE(data=exe, fast_load=True)
    
    55 61
     pef.OPTIONAL_HEADER.CheckSum = pef.generate_checksum()
    
    56
    -pef.write(filename='browser-install-tmp2.exe')
    62
    +pef.write(filename=exename)

  • projects/browser/windows-installer.nsi
    ... ... @@ -5,6 +5,7 @@
    5 5
     ;--------------------------------
    
    6 6
     ;Modern UI
    
    7 7
     
    
    8
    +  !include "FileFunc.nsh"
    
    8 9
       !include "MUI2.nsh"
    
    9 10
       !include "LogicLib.nsh"
    
    10 11
       !include "WinVer.nsh"
    
    ... ... @@ -12,25 +13,38 @@
    12 13
     ;--------------------------------
    
    13 14
     ;General
    
    14 15
     
    
    15
    -  ; location of Tor/Base/Privacy Browser to put into installer
    
    16
    +  ;Location of Tor/Base/Privacy Browser to put into installer
    
    16 17
       !define PROGRAM_SOURCE ".\[% c('var/Project_Name') %]\"
    
    17 18
     
    
    18 19
       Name "[% c('var/Project_Name') %]"
    
    19
    -  OutFile "[% c('var/projectname') %]-install.exe"
    
    20
    +  OutFile "browser-install.exe"
    
    20 21
     
    
    21 22
       ;Default installation folder
    
    23
    +[% IF system_install_mode -%]
    
    24
    +  InstallDir "$PROGRAMFILES\[% c('var/Project_Name') %]"
    
    25
    +[% ELSE -%]
    
    22 26
       InstallDir "$DESKTOP\[% c('var/Project_Name') %]"
    
    27
    +[% END -%]
    
    23 28
     
    
    24 29
       ;Best (but slowest) compression
    
    25 30
       SetCompressor /SOLID lzma
    
    26 31
       SetCompressorDictSize 32
    
    27 32
     
    
    28 33
       ;Request application privileges for Windows Vista
    
    34
    +[% IF system_install_mode -%]
    
    35
    +  RequestExecutionLevel admin
    
    36
    +[% ELSE -%]
    
    29 37
       RequestExecutionLevel user
    
    38
    +[% END -%]
    
    30 39
     
    
    31 40
       ;Support HiDPI displays
    
    32 41
       ManifestDPIAware true
    
    33 42
     
    
    43
    +[% IF system_install_mode -%]
    
    44
    +  ;Registry keys to uninstall system-wide installs
    
    45
    +  !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\[% c('var/ProjectName') %]"
    
    46
    +[% END -%]
    
    47
    +
    
    34 48
     ;--------------------------------
    
    35 49
     ;Interface Configuration
    
    36 50
     
    
    ... ... @@ -133,16 +147,49 @@
    133 147
     Section "[% c('var/Project_Name') %]" SecBrowser
    
    134 148
     
    
    135 149
       SetOutPath "$INSTDIR"
    
    150
    +[% IF !system_install_mode -%]
    
    136 151
       File /r "${PROGRAM_SOURCE}\*.*"
    
    137
    -  SetOutPath "$INSTDIR\Browser"
    
    138 152
       CreateShortCut "$INSTDIR\Start [% c('var/Project_Name') %].lnk" "$INSTDIR\Browser\[% c('var/exe_name') %].exe"
    
    153
    +[% ELSE -%]
    
    154
    +  File /r "${PROGRAM_SOURCE}\Browser\*.*"
    
    155
    +
    
    156
    +  ;Enable system-wide install in the browser
    
    157
    +  FileOpen $0 "$INSTDIR\system-install" w
    
    158
    +  FileClose $0
    
    159
    +
    
    160
    +  ;Write the uninstaller
    
    161
    +  WriteUninstaller $INSTDIR\uninstall.exe
    
    162
    +
    
    163
    +  ;Add the uninstaller to the control panel
    
    164
    +  WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "[% c('var/Project_Name') %]"
    
    165
    +  WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
    
    166
    +  WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
    
    167
    +  WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$\"$INSTDIR\[% c('var/exe_name') %].exe$\""
    
    168
    +  WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" "1"
    
    169
    +  WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" "1"
    
    170
    +  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
    
    171
    +  IntFmt $0 "0x%08X" $0
    
    172
    +  WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" "$0"
    
    173
    +[% END -%]
    
    139 174
     
    
    140 175
     SectionEnd
    
    141 176
     
    
    142
    -Function CreateShortcuts
    
    177
    +[% IF system_install_mode -%]
    
    178
    +Section "Uninstall"
    
    179
    +  RMDir /r "$INSTDIR"
    
    180
    +  DeleteRegKey HKLM "${UNINST_KEY}"
    
    181
    +  SetShellVarContext all
    
    182
    +  Delete "$SMPROGRAMS\[% c('var/Project_Name') %].lnk"
    
    183
    +  Delete "$DESKTOP\[% c('var/Project_Name') %].lnk"
    
    184
    +SectionEnd
    
    185
    +[% END -%]
    
    143 186
     
    
    144
    -  CreateShortCut "$SMPROGRAMS\Start [% c('var/Project_Name') %].lnk" "$INSTDIR\Browser\[% c('var/exe_name') %].exe"
    
    145
    -  CreateShortCut "$DESKTOP\Start [% c('var/Project_Name') %].lnk" "$INSTDIR\Browser\[% c('var/exe_name') %].exe"
    
    187
    +Function CreateShortcuts
    
    188
    +[% IF system_install_mode -%]
    
    189
    +  SetShellVarContext all
    
    190
    +[% END -%]
    
    191
    +  CreateShortCut "$SMPROGRAMS\[% c('var/Project_Name') %].lnk" "$INSTDIR\[% IF !system_install_mode -%]Browser\[% END -%][% c('var/exe_name') %].exe"
    
    192
    +  CreateShortCut "$DESKTOP\[% c('var/Project_Name') %].lnk" "$INSTDIR\[% IF !system_install_mode -%]Browser\[% END -%][% c('var/exe_name') %].exe"
    
    146 193
     
    
    147 194
     FunctionEnd
    
    148 195
     ;--------------------------------
    
    ... ... @@ -181,7 +228,6 @@ ${If} ${FileExists} "$INSTDIR\*.*"
    181 228
     ${EndIf}
    
    182 229
     FunctionEnd
    
    183 230
     
    
    184
    -
    
    185 231
     Function StartBrowser
    
    186 232
     ExecShell "open" "$INSTDIR/Start [% c('var/Project_Name') %].lnk"
    
    187 233
     FunctionEnd