[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser-build][main] 2 commits: Bug 41076: Include the ShellLink plugin in NSIS.



Title: GitLab

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

Commits:

  • a382aeb7
    by Pier Angelo Vendrame at 2024-02-13T19:09:27+01:00
    Bug 41076: Include the ShellLink plugin in NSIS.
    
    We will need this plugin for the Mullvad Browser uninstaller.
    
  • 8deb68f2
    by Pier Angelo Vendrame at 2024-02-13T19:09:29+01:00
    Bug 41077: Draft the new installer for Mullvad Browser.
    
    The installer for Mullvad Browser is going to be different from Tor
    Browser's, because it will offer both a traditional installation
    (at the moment only for the current user, to avoid enabling privilege
    elevation code paths, but still with a control panel entry) and
    portable "installations".
    
    The traditional one will support also setting MB as the default
    browser and file associations. However, this is quite tricky, and
    having a base installer to start implementing the feature is helpful.
    Thus this commit, even though the final installer will be likely
    changed.
    

15 changed files:

Changes:

  • projects/browser/build
    ... ... @@ -303,9 +303,27 @@ done
    303 303
       export PATH="/var/tmp/dist/nsis/bin:$PATH"
    
    304 304
     
    
    305 305
       mv $rootdir/windows-installer $distdir/windows-installer
    
    306
    -  cat > $distdir/windows-installer/browser-portable.nsi << 'BROWSER_NSI'
    
    307
    -[% INCLUDE 'windows-installer.nsi' %]
    
    308
    -BROWSER_NSI
    
    306
    +  mv $rootdir/defines.nsh $distdir/windows-installer/
    
    307
    +  [% IF !c('var/testbuild') -%]
    
    308
    +    source $distdir/windows-installer/language-map.sh
    
    309
    +    supported_locales="[% tmpl(c('var/locales').join(' ')) %]"
    
    310
    +    for code in $supported_locales; do
    
    311
    +      if [[ -n ${nsis_languages[$code]} ]]; then
    
    312
    +        echo '!insertmacro MUI_LANGUAGE "'${nsis_languages[$code]}'"' >> $distdir/windows-installer/languages.nsh
    
    313
    +      fi
    
    314
    +    done
    
    315
    +  [% END -%]
    
    316
    +
    
    317
    +  [% IF c('var/mullvad-browser') -%]
    
    318
    +    pushd $distdir/windows-installer
    
    319
    +    # While Firefox re-uses the uninstaller for this, we cannot do it, because
    
    320
    +    # we write the uninstaller from the installer.
    
    321
    +    # Instead, we need to write an updated postupdate.exe also when updating.
    
    322
    +    makensis postupdate.nsi
    
    323
    +    mv postupdate.exe ${TB_STAGE_DIR}/Browser/
    
    324
    +    popd
    
    325
    +  [% END -%]
    
    326
    +
    
    309 327
       mv ${TB_STAGE_DIR} $distdir/windows-installer/"[% c('var/Project_Name') %]"
    
    310 328
       mv $distdir/windows-installer ${TB_STAGE_DIR}
    
    311 329
     [% END %]
    
    ... ... @@ -383,8 +401,13 @@ cd $distdir
    383 401
       pushd "$PKG_DIR"
    
    384 402
       makensis browser-portable.nsi
    
    385 403
       # Working around NSIS braindamage
    
    386
    -  python3 $rootdir/pe_checksum_fix.py browser-install.exe
    
    387
    -  mv browser-install.exe $OUTDIR/[% c("var/project-name") %]-[% c("var/osname") %]-portable-[% c("var/torbrowser_version") %].exe
    
    404
    +  python3 $rootdir/pe_checksum_fix.py browser-portable.exe
    
    405
    +  mv browser-portable.exe $OUTDIR/[% c("var/project-name") %]-[% c("var/osname") %]-portable-[% c("var/torbrowser_version") %].exe
    
    406
    +  [% IF c('var/mullvad-browser') -%]
    
    407
    +    makensis browser-install.nsi
    
    408
    +    python3 $rootdir/pe_checksum_fix.py browser-install.exe
    
    409
    +    mv browser-install.exe $OUTDIR/[% c("var/project-name") %]-[% c("var/osname") %]-install-[% c("var/torbrowser_version") %].exe
    
    410
    +  [% END -%]
    
    388 411
       popd
    
    389 412
     [% END %]
    
    390 413
     rm -rf $distdir/${PKG_DIR}
    

  • projects/browser/config
    ... ... @@ -120,6 +120,9 @@ input_files:
    120 120
         enable: '[% c("var/windows") %]'
    
    121 121
       - filename: windows-installer
    
    122 122
         enable: '[% c("var/windows") %]'
    
    123
    +  - filename: 'defines.nsh'
    
    124
    +    content: '[% INCLUDE "windows-installer/defines.nsh.in" %]'
    
    125
    +    refresh_input: 1
    
    123 126
       - filename: pe_checksum_fix.py
    
    124 127
         enable: '[% c("var/windows") %]'
    
    125 128
       # To generate a new keystore, see how-to-generate-keystore.txt
    

  • projects/browser/windows-installer.nsi deleted
    1
    -; NSIS Installer for Tor/Base/Mullvad Browser
    
    2
    -; Based on NSIS examples by Joost Verburg.
    
    3
    -; Originally adapted to Tor Browser by Moritz Bartl
    
    4
    -; https://github.com/moba/tbb-windows-installer
    
    5
    -; Released under the zlib/libpng license.
    
    6
    -
    
    7
    -;--------------------------------
    
    8
    -  !include "FileFunc.nsh"
    
    9
    -  !include "LogicLib.nsh"
    
    10
    -  !include "MUI2.nsh"
    
    11
    -  !include "WinVer.nsh"
    
    12
    -
    
    13
    -;--------------------------------
    
    14
    -; General
    
    15
    -  ; Location of Tor/Base/Mullvad Browser to put into installer
    
    16
    -  !define PROGRAM_SOURCE ".\[% c('var/Project_Name') %]\"
    
    17
    -
    
    18
    -[% IF c("var/channel") == "release";
    
    19
    -      SET display_name = c('var/Project_Name');
    
    20
    -   ELSIF c("var/testbuild");
    
    21
    -      SET display_name = c('var/Project_Name') _ " Testbuild";
    
    22
    -   ELSE;
    
    23
    -      SET display_name = c('var/Project_Name_Channel');
    
    24
    -   END
    
    25
    --%]
    
    26
    -  Name "[% display_name %]"
    
    27
    -  OutFile "browser-install.exe"
    
    28
    -
    
    29
    -  ; Default installation folder
    
    30
    -  InstallDir "$DESKTOP\[% display_name %]"
    
    31
    -
    
    32
    -  ; Best (but slowest) compression
    
    33
    -  SetCompressor /SOLID lzma
    
    34
    -  SetCompressorDictSize 32
    
    35
    -
    
    36
    -  ; Do not require elevated privileges
    
    37
    -  RequestExecutionLevel user
    
    38
    -
    
    39
    -  ; Support HiDPI displays
    
    40
    -  ManifestDPIAware true
    
    41
    -
    
    42
    -;--------------------------------
    
    43
    -; Metadata
    
    44
    -  VIProductVersion "[% pc('firefox', 'var/browser_series') %].0.0"
    
    45
    -  VIAddVersionKey "ProductName" "[% display_name %]"
    
    46
    -  VIAddVersionKey "ProductVersion" "[% c('var/torbrowser_version') %]"
    
    47
    -  VIAddVersionKey "FileDescription" "[% display_name %] Portable Installer"
    
    48
    -  VIAddVersionKey "LegalCopyright" "© [% pc('firefox', 'var/copyright_year') %] [% IF c('var/mullvad-browser') %]Mullvad, Tor Browser and Mozilla Developers[% ELSE %]The Tor Project[% END %]"
    
    49
    -
    
    50
    -;--------------------------------
    
    51
    -; Interface Configuration
    
    52
    -  !define MUI_ICON "[% c('var/projectname') %][% IF !c('var/base-browser') %]-[% c('var/channel') %][% END %].ico"
    
    53
    -  !define MUI_ABORTWARNING
    
    54
    -
    
    55
    -;--------------------------------
    
    56
    -; Modern UI settings
    
    57
    -  !define MUI_FINISHPAGE_NOREBOOTSUPPORT ; Reboot not required
    
    58
    -  !define MUI_FINISHPAGE_RUN
    
    59
    -  !define MUI_FINISHPAGE_RUN_FUNCTION "StartBrowser"
    
    60
    -
    
    61
    -  ; Misuse the option to show the readme to create the shortcuts.
    
    62
    -  ; Less ugly than MUI_PAGE_COMPONENTS.
    
    63
    -  !define MUI_FINISHPAGE_SHOWREADME
    
    64
    -  !define MUI_FINISHPAGE_SHOWREADME_TEXT "&Add Start Menu && Desktop shortcuts"
    
    65
    -  !define MUI_FINISHPAGE_SHOWREADME_FUNCTION "CreateShortCuts"
    
    66
    -
    
    67
    -;--------------------------------
    
    68
    -; Pages
    
    69
    -  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckIfTargetDirectoryExists
    
    70
    -  !insertmacro MUI_PAGE_DIRECTORY
    
    71
    -  !insertmacro MUI_PAGE_INSTFILES
    
    72
    -  !insertmacro MUI_PAGE_FINISH
    
    73
    -
    
    74
    -;--------------------------------
    
    75
    -; Languages
    
    76
    -  !insertmacro MUI_LANGUAGE "English" ; First language is the default language
    
    77
    -  !insertmacro MUI_LANGUAGE "Arabic" ; ar
    
    78
    -  !insertmacro MUI_LANGUAGE "Catalan" ; ca
    
    79
    -  !insertmacro MUI_LANGUAGE "Czech" ; cs
    
    80
    -  !insertmacro MUI_LANGUAGE "Danish" ; da
    
    81
    -  !insertmacro MUI_LANGUAGE "German" ; de
    
    82
    -  !insertmacro MUI_LANGUAGE "Greek" ; el
    
    83
    -  !insertmacro MUI_LANGUAGE "Spanish" ; es-ES
    
    84
    -  !insertmacro MUI_LANGUAGE "Farsi" ; fa
    
    85
    -  !insertmacro MUI_LANGUAGE "Finnish" ; fi
    
    86
    -  !insertmacro MUI_LANGUAGE "French" ; fr
    
    87
    -  !insertmacro MUI_LANGUAGE "ScotsGaelic" ; ga-IE
    
    88
    -  !insertmacro MUI_LANGUAGE "Hebrew" ; he
    
    89
    -  !insertmacro MUI_LANGUAGE "Hungarian" ; hu
    
    90
    -  !insertmacro MUI_LANGUAGE "Indonesian"; id
    
    91
    -  !insertmacro MUI_LANGUAGE "Icelandic" ; is
    
    92
    -  !insertmacro MUI_LANGUAGE "Italian" ; it
    
    93
    -  !insertmacro MUI_LANGUAGE "Japanese" ; ja
    
    94
    -  !insertmacro MUI_LANGUAGE "Georgian" ; ka
    
    95
    -  !insertmacro MUI_LANGUAGE "Korean" ; ko
    
    96
    -  !insertmacro MUI_LANGUAGE "Lithuanian" ; lt
    
    97
    -  !insertmacro MUI_LANGUAGE "Macedonian" ; mk
    
    98
    -  !insertmacro MUI_LANGUAGE "Malay" ; ms
    
    99
    -  ; Burmese - my: not available on NSIS
    
    100
    -  !insertmacro MUI_LANGUAGE "Norwegian" ; nb-NO
    
    101
    -  !insertmacro MUI_LANGUAGE "Dutch" ; nl
    
    102
    -  !insertmacro MUI_LANGUAGE "Polish" ; pl
    
    103
    -  !insertmacro MUI_LANGUAGE "PortugueseBR" ; pt-BR
    
    104
    -  !insertmacro MUI_LANGUAGE "Romanian" ; ro
    
    105
    -  !insertmacro MUI_LANGUAGE "Russian" ; ru
    
    106
    -  !insertmacro MUI_LANGUAGE "Albanian" ; sq
    
    107
    -  !insertmacro MUI_LANGUAGE "Swedish" ; sv-SE
    
    108
    -  !insertmacro MUI_LANGUAGE "Thai" ; th
    
    109
    -  !insertmacro MUI_LANGUAGE "Turkish" ; tr
    
    110
    -  !insertmacro MUI_LANGUAGE "Ukrainian" ; uk
    
    111
    -  !insertmacro MUI_LANGUAGE "Vietnamese" ; vi
    
    112
    -  !insertmacro MUI_LANGUAGE "SimpChinese" ; zh-hans, zh-cn
    
    113
    -  !insertmacro MUI_LANGUAGE "TradChinese" ; zh-hant, zh-tw
    
    114
    -
    
    115
    -;--------------------------------
    
    116
    -; Reserve Files
    
    117
    -
    
    118
    -  ; If you are using solid compression, files that are required before
    
    119
    -  ; the actual installation should be stored first in the data block,
    
    120
    -  ; because this will make your installer start faster.
    
    121
    -
    
    122
    -  !insertmacro MUI_RESERVEFILE_LANGDLL
    
    123
    -
    
    124
    -;--------------------------------
    
    125
    -; Installer Sections
    
    126
    -
    
    127
    -Section "Browser" SecBrowser
    
    128
    -  SetOutPath "$INSTDIR"
    
    129
    -  File /r "${PROGRAM_SOURCE}\*.*"
    
    130
    -  CreateShortCut "$INSTDIR\[% display_name %].lnk" "$INSTDIR\Browser\[% c('var/exe_name') %].exe"
    
    131
    -SectionEnd
    
    132
    -
    
    133
    -;--------------------------------
    
    134
    -; Installer Functions
    
    135
    -
    
    136
    -Function .onInit
    
    137
    -  ${IfNot} ${AtLeastWin7}
    
    138
    -    MessageBox MB_USERICON|MB_OK "[% c('var/Project_Name') %] requires at least Windows 7"
    
    139
    -    SetErrorLevel 1
    
    140
    -    Quit
    
    141
    -  ${EndIf}
    
    142
    -
    
    143
    -  ; Don't install on systems that don't support SSE2. The parameter value of
    
    144
    -  ; 10 is for PF_XMMI64_INSTRUCTIONS_AVAILABLE which will check whether the
    
    145
    -  ; SSE2 instruction set is available.
    
    146
    -  System::Call "kernel32::IsProcessorFeaturePresent(i 10)i .R7"
    
    147
    -  ${If} "$R7" == "0"
    
    148
    -    MessageBox MB_OK|MB_ICONSTOP "Sorry, [% c('var/Project_Name') %] can't be installed. This version of [% c('var/Project_Name') %] requires a processor with SSE2 support."
    
    149
    -    Abort
    
    150
    -  ${EndIf}
    
    151
    -
    
    152
    -  !insertmacro MUI_LANGDLL_DISPLAY
    
    153
    -FunctionEnd
    
    154
    -
    
    155
    -Function CheckIfTargetDirectoryExists
    
    156
    -  ${If} ${FileExists} "$INSTDIR\*.*"
    
    157
    -    MessageBox MB_YESNO "The destination directory already exists. Do you want to continue anyway?" IDYES +2
    
    158
    -    Abort
    
    159
    -  ${EndIf}
    
    160
    -FunctionEnd
    
    161
    -
    
    162
    -Function CreateShortcuts
    
    163
    -  CreateShortCut "$SMPROGRAMS\[% display_name %].lnk" "$INSTDIR\[% IF !system_install_mode -%]Browser\[% END -%][% c('var/exe_name') %].exe"
    
    164
    -  CreateShortCut "$DESKTOP\[% display_name %].lnk" "$INSTDIR\[% IF !system_install_mode -%]Browser\[% END -%][% c('var/exe_name') %].exe"
    
    165
    -FunctionEnd
    
    166
    -
    
    167
    -Function StartBrowser
    
    168
    -  ExecShell "open" "$INSTDIR/[% display_name %].lnk"
    
    169
    -FunctionEnd

  • projects/browser/windows-installer/browser-install.nsi
    1
    +  !include "common.nsh"
    
    2
    +  !include "registry.nsh"
    
    3
    +
    
    4
    +;--------------------------------
    
    5
    +  OutFile "browser-install.exe"
    
    6
    +  VIAddVersionKey "FileDescription" "${DISPLAY_NAME} Installer"
    
    7
    +
    
    8
    +  !define DEFAULT_INSTALL_DIR "$LocalAppdata\${APP_DIR}\${NAME_NO_SPACES}\${UPDATE_CHANNEL}"
    
    9
    +  InstallDir "${DEFAULT_INSTALL_DIR}"
    
    10
    +
    
    11
    +;--------------------------------
    
    12
    +; Pages
    
    13
    +  Page custom SetupType SetupTypeLeave
    
    14
    +  Page custom CustomSetup CustomSetupLeave
    
    15
    +  ; Disable the directory selection when updating
    
    16
    +  !define MUI_PAGE_CUSTOMFUNCTION_PRE CustomPageDirectory
    
    17
    +  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckIfTargetDirectoryExists
    
    18
    +  !insertmacro MUI_PAGE_DIRECTORY
    
    19
    +  !insertmacro MUI_PAGE_INSTFILES
    
    20
    +  !insertmacro MUI_PAGE_FINISH
    
    21
    +
    
    22
    +  !insertmacro MUI_UNPAGE_CONFIRM
    
    23
    +  !insertmacro MUI_UNPAGE_INSTFILES
    
    24
    +  !insertmacro MUI_UNPAGE_FINISH
    
    25
    +
    
    26
    +  ; Languages must be defined after pages
    
    27
    +  !include "languages.nsh"
    
    28
    +
    
    29
    +;--------------------------------
    
    30
    +; Installer
    
    31
    +
    
    32
    +; Path to an existing install. If not empty we are in update mode.
    
    33
    +var existingInstall
    
    34
    +
    
    35
    +; Installation settings
    
    36
    +var isCustomMode
    
    37
    +var isPortableMode
    
    38
    +var createDesktopShortcut
    
    39
    +
    
    40
    +; Variable used by the setup type page
    
    41
    +var typeRadioStandard
    
    42
    +var typeRadioCustom
    
    43
    +var typeRadioClicked
    
    44
    +var typeNextButton
    
    45
    +
    
    46
    +; Variables used in the custom setup page
    
    47
    +var customCheckboxPortable
    
    48
    +var customCheckboxDesktop
    
    49
    +
    
    50
    +Function .onInit
    
    51
    +  Call CheckRequirements
    
    52
    +
    
    53
    +  !insertmacro MUI_LANGDLL_DISPLAY
    
    54
    +
    
    55
    +  ReadRegStr $existingInstall HKCU "${UNINST_KEY}" "InstallLocation"
    
    56
    +  StrCpy $createDesktopShortcut "true"
    
    57
    +FunctionEnd
    
    58
    +
    
    59
    +Function SetupType
    
    60
    +  !insertmacro MUI_HEADER_TEXT "Setup Type" "Choose setup options"
    
    61
    +  nsDialogs::Create 1018
    
    62
    +  Pop $0
    
    63
    +  ${If} $0 == error
    
    64
    +    Abort
    
    65
    +  ${EndIf}
    
    66
    +
    
    67
    +  ${NSD_CreateLabel} 0 0 100% 18% "Choose the type of setup you prefer."
    
    68
    +  ${If} $existingInstall == ""
    
    69
    +    ${NSD_CreateRadioButton} 0 18% 100% 6% "Standard"
    
    70
    +    Pop $typeRadioStandard
    
    71
    +    ${NSD_CreateRadioButton} 0 30% 100% 6% "Custom"
    
    72
    +    Pop $typeRadioCustom
    
    73
    +  ${Else}
    
    74
    +    ${NSD_CreateRadioButton} 0 18% 100% 6% "Update your existing installation"
    
    75
    +    Pop $typeRadioStandard
    
    76
    +    ${NSD_CreateRadioButton} 0 30% 100% 6% "Portable installation"
    
    77
    +    Pop $typeRadioCustom
    
    78
    +  ${EndIf}
    
    79
    +  ${NSD_OnClick} $typeRadioStandard SetupTypeRadioClick
    
    80
    +  ${NSD_OnClick} $typeRadioCustom SetupTypeRadioClick
    
    81
    +
    
    82
    +  GetDlgItem $typeNextButton $HWNDPARENT 1
    
    83
    +
    
    84
    +  ; Re-check radios if the user presses back
    
    85
    +  ${If} $isCustomMode == "true"
    
    86
    +    StrCpy $typeRadioClicked $typeRadioCustom
    
    87
    +  ${Else}
    
    88
    +    StrCpy $typeRadioClicked $typeRadioStandard
    
    89
    +  ${EndIf}
    
    90
    +  ${NSD_Check} $typeRadioClicked
    
    91
    +  Call SetupTypeUpdate
    
    92
    +
    
    93
    +  nsDialogs::Show
    
    94
    +FunctionEnd
    
    95
    +
    
    96
    +Function SetupTypeRadioClick
    
    97
    +  Pop $typeRadioClicked
    
    98
    +  Call SetupTypeUpdate
    
    99
    +FunctionEnd
    
    100
    +
    
    101
    +Function SetupTypeUpdate
    
    102
    +  ${If} $typeRadioClicked == $typeRadioCustom
    
    103
    +    StrCpy $isCustomMode "true"
    
    104
    +    SendMessage $typeNextButton ${WM_SETTEXT} 0 "STR:$(^NextBtn)"
    
    105
    +  ${ElseIf} $typeRadioClicked == $typeRadioStandard
    
    106
    +    StrCpy $isCustomMode "false"
    
    107
    +    StrCpy $isPortableMode "false"
    
    108
    +    ${If} $existingInstall == ""
    
    109
    +      SendMessage $typeNextButton ${WM_SETTEXT} 0 "STR:$(^InstallBtn)"
    
    110
    +    ${Else}
    
    111
    +      SendMessage $typeNextButton ${WM_SETTEXT} 0 "STR:&Update"
    
    112
    +    ${EndIf}
    
    113
    +  ${EndIf}
    
    114
    +FunctionEnd
    
    115
    +
    
    116
    +Function SetupTypeLeave
    
    117
    +  ${If} $typeRadioClicked == $typeRadioCustom
    
    118
    +    StrCpy $isCustomMode "true"
    
    119
    +  ${ElseIf} $typeRadioClicked == $typeRadioStandard
    
    120
    +    StrCpy $isCustomMode "false"
    
    121
    +    StrCpy $isPortableMode "false"
    
    122
    +  ${Else}
    
    123
    +    Abort
    
    124
    +  ${EndIf}
    
    125
    +FunctionEnd
    
    126
    +
    
    127
    +Function CustomSetup
    
    128
    +  ${If} $isCustomMode != "true"
    
    129
    +    Return
    
    130
    +  ${EndIf}
    
    131
    +
    
    132
    +  !insertmacro MUI_HEADER_TEXT "Custom Setup" "Customize your setup options"
    
    133
    +  nsDialogs::Create 1018
    
    134
    +  Pop $0
    
    135
    +  ${If} $0 == error
    
    136
    +    Abort
    
    137
    +  ${EndIf}
    
    138
    +
    
    139
    +  ${NSD_CreateCheckbox} 0 18% 100% 6% "Portable installation"
    
    140
    +  Pop $customCheckboxPortable
    
    141
    +  ${NSD_CreateCheckbox} 0 30% 100% 6% "Create a desktop shortcut"
    
    142
    +  Pop $customCheckboxDesktop
    
    143
    +  ${NSD_OnClick} $customCheckboxPortable CustomSetupCheckboxClick
    
    144
    +  ${NSD_OnClick} $customCheckboxDesktop CustomSetupCheckboxClick
    
    145
    +
    
    146
    +  ${If} $existingInstall != ""
    
    147
    +    ; If we already have an installation, this is already portable mode.
    
    148
    +    StrCpy $isPortableMode "true"
    
    149
    +    ${NSD_Check} $customCheckboxPortable
    
    150
    +    EnableWindow $customCheckboxPortable 0
    
    151
    +  ${ElseIf} $isPortableMode == "true"
    
    152
    +    ${NSD_Check} $customCheckboxPortable
    
    153
    +  ${EndIf}
    
    154
    +  ${If} $createDesktopShortcut == "true"
    
    155
    +    ${NSD_Check} $customCheckboxDesktop
    
    156
    +  ${EndIf}
    
    157
    +
    
    158
    +  nsDialogs::Show
    
    159
    +FunctionEnd
    
    160
    +
    
    161
    +Function CustomSetupUpdate
    
    162
    +  ${NSD_GetState} $customCheckboxPortable $0
    
    163
    +  ${If} $0 == "${BST_CHECKED}"
    
    164
    +    StrCpy $isPortableMode "true"
    
    165
    +  ${Else}
    
    166
    +    StrCpy $isPortableMode "false"
    
    167
    +  ${EndIf}
    
    168
    +
    
    169
    +  ${NSD_GetState} $customCheckboxDesktop $0
    
    170
    +  ${If} $0 == "${BST_CHECKED}"
    
    171
    +    StrCpy $createDesktopShortcut "true"
    
    172
    +  ${Else}
    
    173
    +    StrCpy $createDesktopShortcut "false"
    
    174
    +  ${EndIf}
    
    175
    +FunctionEnd
    
    176
    +
    
    177
    +Function CustomSetupCheckboxClick
    
    178
    +  Pop $0
    
    179
    +  Call CustomSetupUpdate
    
    180
    +FunctionEnd
    
    181
    +
    
    182
    +Function CustomSetupLeave
    
    183
    +  Call CustomSetupUpdate
    
    184
    +FunctionEnd
    
    185
    +
    
    186
    +Function CustomPageDirectory
    
    187
    +  ${If} $isPortableMode == "true"
    
    188
    +    StrCpy $INSTDIR "${DEFAULT_PORTABLE_DIR}"
    
    189
    +    ; Always go through this page in portable mode.
    
    190
    +    Return
    
    191
    +  ${ElseIf} $existingInstall != ""
    
    192
    +    ; When updating, force the old directory and skip the page.
    
    193
    +    StrCpy $INSTDIR $existingInstall
    
    194
    +    Abort
    
    195
    +  ${Else}
    
    196
    +    StrCpy $INSTDIR "${DEFAULT_INSTALL_DIR}"
    
    197
    +  ${EndIf}
    
    198
    +
    
    199
    +  ${If} $isCustomMode != "true"
    
    200
    +    ; Standard install, use the default directory and skip the page.
    
    201
    +    Abort
    
    202
    +  ${EndIf}
    
    203
    +FunctionEnd
    
    204
    +
    
    205
    +Section "Browser" SecBrowser
    
    206
    +  SetOutPath "$INSTDIR"
    
    207
    +
    
    208
    +  ${If} $isPortableMode == "true"
    
    209
    +    File /r "${PROGRAM_SOURCE}\*.*"
    
    210
    +    CreateShortCut "$INSTDIR\${DISPLAY_NAME}.lnk" "$INSTDIR\Browser\${EXE_NAME}"
    
    211
    +  ${Else}
    
    212
    +    ; Do not use a Browser directory for installs.
    
    213
    +    File /r "${PROGRAM_SOURCE}\Browser\*.*"
    
    214
    +
    
    215
    +    ; Tell the browser we are not in portable mode anymore.
    
    216
    +    FileOpen $0 "$INSTDIR\system-install" w
    
    217
    +    FileClose $0
    
    218
    +
    
    219
    +    ; Write the uninstaller
    
    220
    +    WriteUninstaller $INSTDIR\uninstall.exe
    
    221
    +
    
    222
    +    !insertmacro UPDATE_REGISTRY
    
    223
    +
    
    224
    +    CreateShortCut "$SMPROGRAMS\${DISPLAY_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
    
    225
    +    ${If} $createDesktopShortcut == "true"
    
    226
    +      CreateShortCut "$DESKTOP\${DISPLAY_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
    
    227
    +    ${EndIf}
    
    228
    +  ${EndIf}
    
    229
    +SectionEnd
    
    230
    +
    
    231
    +Function StartBrowser
    
    232
    +  ${If} $isPortableMode == "true"
    
    233
    +    ExecShell "open" "$INSTDIR\${DISPLAY_NAME}.lnk"
    
    234
    +  ${Else}
    
    235
    +    ExecShell "open" "$INSTDIR\${EXE_NAME}"
    
    236
    +  ${EndIf}
    
    237
    +FunctionEnd
    
    238
    +
    
    239
    +;--------------------------------
    
    240
    +; Uninstaller
    
    241
    +Section "Uninstall"
    
    242
    +  RMDir /r "$INSTDIR"
    
    243
    +  DeleteRegKey HKCU "${UNINST_KEY}"
    
    244
    +
    
    245
    +  StrCpy $0 ""
    
    246
    +  ShellLink::GetShortCutTarget "$SMPROGRAMS\${DISPLAY_NAME}.lnk"
    
    247
    +  Pop $0
    
    248
    +  ${If} $0 == "$INSTDIR\${EXE_NAME}"
    
    249
    +    Delete "$SMPROGRAMS\${DISPLAY_NAME}.lnk"
    
    250
    +  ${EndIf}
    
    251
    +
    
    252
    +  StrCpy $0 ""
    
    253
    +  ShellLink::GetShortCutTarget "$DESKTOP\${DISPLAY_NAME}.lnk"
    
    254
    +  Pop $0
    
    255
    +  ${If} $0 == "$INSTDIR\${EXE_NAME}"
    
    256
    +    Delete "$DESKTOP\${DISPLAY_NAME}.lnk"
    
    257
    +  ${EndIf}
    
    258
    +
    
    259
    +  ; TODO: Optionally remove profiles.
    
    260
    +  ; This operation is not trivial, because it involes finding our installation
    
    261
    +  ; hash, its associated default profile and making sure it is not shared with
    
    262
    +  ; another channel/installation.
    
    263
    +SectionEnd

  • projects/browser/windows-installer/browser-portable.nsi
    1
    +  !include "common.nsh"
    
    2
    +
    
    3
    +;--------------------------------
    
    4
    +  OutFile "browser-portable.exe"
    
    5
    +  VIAddVersionKey "FileDescription" "${DISPLAY_NAME} Portable Installer"
    
    6
    +  InstallDir "$DESKTOP\${DISPLAY_NAME}"
    
    7
    +
    
    8
    +;--------------------------------
    
    9
    +; Pages
    
    10
    +  ; Misuse the option to show the readme to create the shortcuts.
    
    11
    +  ; Less ugly than MUI_PAGE_COMPONENTS.
    
    12
    +  !define MUI_FINISHPAGE_SHOWREADME
    
    13
    +  !define MUI_FINISHPAGE_SHOWREADME_TEXT "&Add Start Menu && Desktop shortcuts"
    
    14
    +  !define MUI_FINISHPAGE_SHOWREADME_FUNCTION "CreateShortcuts"
    
    15
    +
    
    16
    +  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckIfTargetDirectoryExists
    
    17
    +  !insertmacro MUI_PAGE_DIRECTORY
    
    18
    +  !insertmacro MUI_PAGE_INSTFILES
    
    19
    +  !insertmacro MUI_PAGE_FINISH
    
    20
    +
    
    21
    +  ; Languages must be defined after pages
    
    22
    +  !include "languages.nsh"
    
    23
    +
    
    24
    +;--------------------------------
    
    25
    +; Installer
    
    26
    +Function .onInit
    
    27
    +  Call CheckRequirements
    
    28
    +
    
    29
    +  !insertmacro MUI_LANGDLL_DISPLAY
    
    30
    +FunctionEnd
    
    31
    +
    
    32
    +Section "Browser" SecBrowser
    
    33
    +  SetOutPath "$INSTDIR"
    
    34
    +  File /r "${PROGRAM_SOURCE}\*.*"
    
    35
    +  CreateShortCut "$INSTDIR\${DISPLAY_NAME}.lnk" "$INSTDIR\Browser\${EXE_NAME}"
    
    36
    +SectionEnd
    
    37
    +
    
    38
    +Function CreateShortcuts
    
    39
    +  CreateShortCut "$SMPROGRAMS\${DISPLAY_NAME}.lnk" "$INSTDIR\Browser\${EXE_NAME}"
    
    40
    +  CreateShortCut "$DESKTOP\${DISPLAY_NAME}.lnk" "$INSTDIR\Browser\${EXE_NAME}"
    
    41
    +FunctionEnd
    
    42
    +
    
    43
    +Function StartBrowser
    
    44
    +  ExecShell "open" "$INSTDIR/${DISPLAY_NAME}.lnk"
    
    45
    +FunctionEnd

  • projects/browser/windows-installer/common.nsh
    1
    +; Common code for the NSIS Installers for Tor/Base/Mullvad Browser.
    
    2
    +; Based on NSIS examples by Joost Verburg.
    
    3
    +; Originally adapted to Tor Browser by Moritz Bartl
    
    4
    +; https://github.com/moba/tbb-windows-installer
    
    5
    +; Released under the zlib/libpng license.
    
    6
    +
    
    7
    +;--------------------------------
    
    8
    +  !include "FileFunc.nsh"
    
    9
    +  !include "LogicLib.nsh"
    
    10
    +  !include "MUI2.nsh"
    
    11
    +  !include "WinVer.nsh"
    
    12
    +
    
    13
    +  !include "defines.nsh"
    
    14
    +
    
    15
    +;--------------------------------
    
    16
    +; General settings
    
    17
    +  Name "${DISPLAY_NAME}"
    
    18
    +
    
    19
    +  ; Best (but slowest) compression
    
    20
    +  SetCompressor /SOLID lzma
    
    21
    +  SetCompressorDictSize 32
    
    22
    +
    
    23
    +  ; Do not require elevated privileges.
    
    24
    +  ; Even for the installer, we install only for the current user, so we do not
    
    25
    +  ; need high privileges.
    
    26
    +  RequestExecutionLevel user
    
    27
    +
    
    28
    +  ; Support HiDPI displays
    
    29
    +  ManifestDPIAware true
    
    30
    +
    
    31
    +;--------------------------------
    
    32
    +; Version information
    
    33
    +  VIProductVersion "${VERSION_WINDOWS}"
    
    34
    +  VIAddVersionKey "ProductName" "${DISPLAY_NAME}"
    
    35
    +  VIAddVersionKey "ProductVersion" "${VERSION}"
    
    36
    +  VIAddVersionKey "FileVersion" "${VERSION}"
    
    37
    +  VIAddVersionKey "LegalCopyright" "${COPYRIGHT_STRING}"
    
    38
    +
    
    39
    +;--------------------------------
    
    40
    +; Interface Configuration
    
    41
    +  ; Installer icon
    
    42
    +  !define MUI_ICON "${ICON_NAME}"
    
    43
    +  !define MUI_ABORTWARNING
    
    44
    +
    
    45
    +;--------------------------------
    
    46
    +; Modern UI settings
    
    47
    +  !define MUI_FINISHPAGE_NOREBOOTSUPPORT ; Reboot not required
    
    48
    +  !define MUI_FINISHPAGE_RUN
    
    49
    +  !define MUI_FINISHPAGE_RUN_FUNCTION "StartBrowser"
    
    50
    +
    
    51
    +;--------------------------------
    
    52
    +; Reserve Files
    
    53
    +  ; If you are using solid compression, files that are required before
    
    54
    +  ; the actual installation should be stored first in the data block,
    
    55
    +  ; because this will make your installer start faster.
    
    56
    +  !insertmacro MUI_RESERVEFILE_LANGDLL
    
    57
    +
    
    58
    +;--------------------------------
    
    59
    +; Helper functions
    
    60
    +Function CheckRequirements
    
    61
    +  ${IfNot} ${AtLeastWin7}
    
    62
    +    MessageBox MB_USERICON|MB_OK "${PROJECT_NAME} requires at least Windows 7"
    
    63
    +    SetErrorLevel 1
    
    64
    +    Quit
    
    65
    +  ${EndIf}
    
    66
    +
    
    67
    +  ; Don't install on systems that don't support SSE2. The parameter value of
    
    68
    +  ; 10 is for PF_XMMI64_INSTRUCTIONS_AVAILABLE which will check whether the
    
    69
    +  ; SSE2 instruction set is available.
    
    70
    +  System::Call "kernel32::IsProcessorFeaturePresent(i 10)i .R7"
    
    71
    +  ${If} "$R7" == "0"
    
    72
    +    MessageBox MB_OK|MB_ICONSTOP "${PROJECT_NAME} requires a processor with SSE2 support."
    
    73
    +    Quit
    
    74
    +  ${EndIf}
    
    75
    +FunctionEnd
    
    76
    +
    
    77
    +Function CheckIfTargetDirectoryExists
    
    78
    +  ${If} ${FileExists} "$INSTDIR\*.*"
    
    79
    +    MessageBox MB_YESNO "The destination directory already exists. Do you want to continue anyway?" IDYES +2
    
    80
    +    Abort
    
    81
    +  ${EndIf}
    
    82
    +FunctionEnd

  • projects/browser/windows-installer/defines.nsh.in
    1
    +;--------------------------------
    
    2
    +; Defines
    
    3
    +  ; Location of Tor/Base/Mullvad Browser to put into installer
    
    4
    +  !define PROGRAM_SOURCE ".\[% c('var/Project_Name') %]\"
    
    5
    +
    
    6
    +  ; Project and display name
    
    7
    +  !define PROJECT_NAME "[% c('var/Project_Name') %]"
    
    8
    +[% IF c("var/channel") == "release" -%]
    
    9
    +  !define DISPLAY_NAME "[% c('var/Project_Name') %]"
    
    10
    +[% ELSIF c("var/testbuild") -%]
    
    11
    +  !define DISPLAY_NAME "[% c('var/Project_Name') %] Testbuild"
    
    12
    +[% ELSE -%]
    
    13
    +  !define DISPLAY_NAME "[% c('var/Project_Name_Channel') %]"
    
    14
    +[% END -%]
    
    15
    +  !define NAME_NO_SPACES "[% c('var/ProjectName') %]"
    
    16
    +  !define UPDATE_CHANNEL "[% c('var/channel') FILTER ucfirst %]"
    
    17
    +
    
    18
    +  ; Version
    
    19
    +  !define VERSION "[% c('var/torbrowser_version') %]"
    
    20
    +  ; String for use with Windows's Product Version.
    
    21
    +  ; It must be 4 integers separated by a dot.
    
    22
    +  !define VERSION_WINDOWS "[% pc('firefox', 'var/browser_series') %].0.0"
    
    23
    +
    
    24
    +  !define DEFAULT_PORTABLE_DIR "$DESKTOP\${DISPLAY_NAME}"
    
    25
    +  !define EXE_NAME "[% c('var/exe_name') %].exe"
    
    26
    +[% IF !c("var/base-browser") -%]
    
    27
    +  !define ICON_NAME "[% c('var/projectname') %]-[% c('var/channel') %].ico"
    
    28
    +[% ELSE -%]
    
    29
    +  !define ICON_NAME "[% c('var/projectname') %].ico"
    
    30
    +[% END -%]
    
    31
    +
    
    32
    +[% IF c('var/mullvad-browser') -%]
    
    33
    +  ; Firefox's --with-user-appdir
    
    34
    +  !define APP_DIR "Mullvad"
    
    35
    +
    
    36
    +  !define PUBLISHER "Mullvad VPN"
    
    37
    +  !define COPYRIGHT_STRING "© [% pc('firefox', 'var/copyright_year') %] Mullvad, Tor Browser and Mozilla Developers"
    
    38
    +
    
    39
    +  !define URL_ABOUT "https://mullvad.net/en/browser"
    
    40
    +  !define URL_UPDATE "https://github.com/mullvad/mullvad-browser/releases/[% c('var/torbrowser_version') %]"
    
    41
    +  !define URL_HELP "https://mullvad.net/help/tag/browser/"
    
    42
    +[% ELSE -%]
    
    43
    +  ; Not defined for Tor Browser
    
    44
    +  !define APP_DIR "TorProject"
    
    45
    +
    
    46
    +  !define PUBLISHER "The Tor Project"
    
    47
    +  !define COPYRIGHT_STRING "© [% pc('firefox', 'var/copyright_year') %] The Tor Project"
    
    48
    +
    
    49
    +  !define URL_ABOUT "https://www.torproject.org/"
    
    50
    +  !define URL_UPDATE "https://blog.torproject.org/new[% IF c('var/alpha') %]-alpha[% END %]-release-tor-browser-[% c('var/torbrowser_version') FILTER remove('\.') %]"
    
    51
    +  !define URL_HELP "https://tb-manual.torproject.org/"
    
    52
    +[% END -%]

  • projects/browser/windows-installer/language-map.sh
    1
    +#!/bin/bash
    
    2
    +declare -A nsis_languages
    
    3
    +nsis_languages[ar]="Arabic"
    
    4
    +nsis_languages[ca]="Catalan"
    
    5
    +nsis_languages[cs]="Czech"
    
    6
    +nsis_languages[da]="Danish"
    
    7
    +nsis_languages[de]="German"
    
    8
    +nsis_languages[el]="Greek"
    
    9
    +nsis_languages[es-ES]="Spanish"
    
    10
    +nsis_languages[fa]="Farsi"
    
    11
    +nsis_languages[fi]="Finnish"
    
    12
    +nsis_languages[fr]="French"
    
    13
    +nsis_languages[ga-IE]="ScotsGaelic"
    
    14
    +nsis_languages[he]="Hebrew"
    
    15
    +nsis_languages[hu]="Hungarian"
    
    16
    +nsis_languages[d]="Indonesian"
    
    17
    +nsis_languages[is]="Icelandic"
    
    18
    +nsis_languages[it]="Italian"
    
    19
    +nsis_languages[ja]="Japanese"
    
    20
    +nsis_languages[ka]="Georgian"
    
    21
    +nsis_languages[ko]="Korean"
    
    22
    +nsis_languages[lt]="Lithuanian"
    
    23
    +nsis_languages[mk]="Macedonian"
    
    24
    +nsis_languages[ms]="Malay"
    
    25
    +# nsis_languages[my]="Burmese" # Not available on NSIS
    
    26
    +nsis_languages[nb-NO]="Norwegian"
    
    27
    +nsis_languages[nl]="Dutch"
    
    28
    +nsis_languages[pl]="Polish"
    
    29
    +nsis_languages[pt-BR]="PortugueseBR"
    
    30
    +nsis_languages[ro]="Romanian"
    
    31
    +nsis_languages[ru]="Russian"
    
    32
    +nsis_languages[sq]="Albanian"
    
    33
    +nsis_languages[sv-SE]="Swedish"
    
    34
    +nsis_languages[th]="Thai"
    
    35
    +nsis_languages[tr]="Turkish"
    
    36
    +nsis_languages[uk]="Ukrainian"
    
    37
    +nsis_languages[vi]="Vietnamese"
    
    38
    +nsis_languages[zh-CN]="SimpChinese"
    
    39
    +nsis_languages[zh-TW]="TradChinese"

  • projects/browser/windows-installer/languages.nsh
    1
    +;--------------------------------
    
    2
    +; Additional languages
    
    3
    +  !insertmacro MUI_LANGUAGE "English" ; Always available
    
    4
    +  ; The rest of the languages will be added here during the build.

  • projects/browser/windows-installer/postupdate.nsi
    1
    +!include "FileFunc.nsh"
    
    2
    +!include "LogicLib.nsh"
    
    3
    +
    
    4
    +!include "defines.nsh"
    
    5
    +!include "registry.nsh"
    
    6
    +
    
    7
    +OutFile "postupdate.exe"
    
    8
    +Icon "${ICON_NAME}"
    
    9
    +RequestExecutionLevel user
    
    10
    +
    
    11
    +Function .onInit
    
    12
    +  ${GetOptions} $CMDLINE "/Visible" $0
    
    13
    +  IfErrors 0 +2
    
    14
    +  SetSilent silent
    
    15
    +FunctionEnd
    
    16
    +
    
    17
    +Section PostUpdate "PostUpdate"
    
    18
    +  StrCpy $0 "false"
    
    19
    +  IfFileExists $EXEDIR\system-install 0 +2
    
    20
    +  StrCpy $0 "true"
    
    21
    +  ${If} $0 == "true"
    
    22
    +    StrCpy $INSTDIR $EXEDIR
    
    23
    +    !insertmacro UPDATE_REGISTRY
    
    24
    +    RMDir /r /REBOOTOK $EXEDIR\tobedeleted
    
    25
    +  ${Else}
    
    26
    +    RMDir /r $EXEDIR\tobedeleted
    
    27
    +  ${EndIf}
    
    28
    +SectionEnd

  • projects/browser/windows-installer/registry.nsh
    1
    +!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME_NO_SPACES}${UPDATE_CHANNEL}"
    
    2
    +
    
    3
    +!macro UPDATE_REGISTRY
    
    4
    +  WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${DISPLAY_NAME}"
    
    5
    +  WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$\"$INSTDIR\${EXE_NAME}$\""
    
    6
    +  WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
    
    7
    +  WriteRegStr HKCU "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
    
    8
    +  WriteRegStr HKCU "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
    
    9
    +  WriteRegDWORD HKCU "${UNINST_KEY}" "NoModify" "1"
    
    10
    +  WriteRegDWORD HKCU "${UNINST_KEY}" "NoRepair" "1"
    
    11
    +  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
    
    12
    +  IntFmt $0 "0x%08X" $0
    
    13
    +  WriteRegDWORD HKCU "${UNINST_KEY}" "EstimatedSize" "$0"
    
    14
    +  WriteRegStr HKCU "${UNINST_KEY}" "InstallLocation" "$INSTDIR"
    
    15
    +    WriteRegStr HKCU "${UNINST_KEY}" "Publisher" "${PUBLISHER}"
    
    16
    +  WriteRegStr HKCU "${UNINST_KEY}" "URLInfoAbout" "${URL_ABOUT}"
    
    17
    +  WriteRegStr HKCU "${UNINST_KEY}" "URLUpdateInfo" "${URL_UPDATE}"
    
    18
    +  WriteRegStr HKCU "${UNINST_KEY}" "HelpLink" "${URL_HELP}"
    
    19
    +!macroend

  • projects/nsis/ShellLink.cpp
    1
    +/*
    
    2
    +Module : ShellLink.cpp
    
    3
    +Purpose: NSIS Plug-in for retriving shell link information
    
    4
    +Created: 12/16/2003
    
    5
    +Last Update: 01/14/2004
    
    6
    +                          
    
    7
    +Copyright (c) 2004 Angelo Mandato.  
    
    8
    +See ShellLink.html for more information
    
    9
    +
    
    10
    +
    
    11
    +Modified: 21/09/2005
    
    12
    +Author:   Shengalts Aleksander aka Instructor (Shengalts@xxxxxxx)
    
    13
    +Changes:  -code has been rewritten
    
    14
    +          -added functions to change shell link information
    
    15
    +          -reduced dll size 44Kb -> 4Kb
    
    16
    +
    
    17
    +Modified by The Tor Project to remove the unneeded ConvFunc.h and updated the
    
    18
    +include for pluginapi.h.
    
    19
    +The original plugin is available at https://nsis.sourceforge.io/ShellLink_plug-in.
    
    20
    +
    
    21
    +© 2004 Angelo Mandato
    
    22
    +
    
    23
    +This software is provided 'as-is', without any express or implied warranty. In
    
    24
    +no event will the authors be held liable for any damages arising from the use of
    
    25
    +this software.
    
    26
    +
    
    27
    +Permission is granted to anyone to use this software for any purpose, including
    
    28
    +commercial applications, and to alter it and redistribute it freely, subject to
    
    29
    +the following restrictions:
    
    30
    +
    
    31
    +1. The origin of this software must not be misrepresented; you must not claim
    
    32
    +   that you wrote the original software. If you use this software in a product,
    
    33
    +   an acknowledgment in the product documentation would be appreciated but is
    
    34
    +   not required.
    
    35
    +2. Altered versions must be plainly marked as such, and must not be
    
    36
    +   misrepresented as being the original software.
    
    37
    +3. This notice may not be removed or altered from any distribution.
    
    38
    +
    
    39
    +*/
    
    40
    +
    
    41
    +//  Uncomment for debugging message boxes
    
    42
    +//#define SHELLLINK_DEBUG
    
    43
    +
    
    44
    +#include <windows.h>
    
    45
    +#include <shlobj.h>
    
    46
    +
    
    47
    +#define xatoi
    
    48
    +#include "nsis/pluginapi.h"
    
    49
    +
    
    50
    +#define NSISFUNC(name) extern "C" void __declspec(dllexport) name(HWND hWndParent, int string_size, TCHAR* variables, stack_t** stacktop, extra_parameters* extra)
    
    51
    +
    
    52
    +#define SHELLLINKTYPE_GETARGS 1
    
    53
    +#define SHELLLINKTYPE_GETDESC 2
    
    54
    +#define SHELLLINKTYPE_GETHOTKEY 3
    
    55
    +#define SHELLLINKTYPE_GETICONLOC 4
    
    56
    +#define SHELLLINKTYPE_GETICONINDEX 5
    
    57
    +#define SHELLLINKTYPE_GETPATH 6
    
    58
    +#define SHELLLINKTYPE_GETSHOWMODE 7
    
    59
    +#define SHELLLINKTYPE_GETWORKINGDIR 8
    
    60
    +#define SHELLLINKTYPE_SETARGS 9
    
    61
    +#define SHELLLINKTYPE_SETDESC 10
    
    62
    +#define SHELLLINKTYPE_SETHOTKEY 11
    
    63
    +#define SHELLLINKTYPE_SETICONLOC 12
    
    64
    +#define SHELLLINKTYPE_SETICONINDEX 13
    
    65
    +#define SHELLLINKTYPE_SETPATH 14
    
    66
    +#define SHELLLINKTYPE_SETSHOWMODE 15
    
    67
    +#define SHELLLINKTYPE_SETWORKINGDIR 16
    
    68
    +#define SHELLLINKTYPE_SETRUNASADMIN 17
    
    69
    +
    
    70
    +void ShortCutData(int nType);
    
    71
    +
    
    72
    +//Get
    
    73
    +NSISFUNC(GetShortCutArgs)
    
    74
    +{
    
    75
    +  EXDLL_INIT();
    
    76
    +	ShortCutData(SHELLLINKTYPE_GETARGS);
    
    77
    +}
    
    78
    +
    
    79
    +NSISFUNC(GetShortCutDescription)
    
    80
    +{
    
    81
    +  EXDLL_INIT();
    
    82
    +	ShortCutData(SHELLLINKTYPE_GETDESC);
    
    83
    +}
    
    84
    +
    
    85
    +NSISFUNC(GetShortCutHotkey)
    
    86
    +{
    
    87
    +  EXDLL_INIT();
    
    88
    +	ShortCutData(SHELLLINKTYPE_GETHOTKEY);
    
    89
    +}
    
    90
    +
    
    91
    +NSISFUNC(GetShortCutIconLocation)
    
    92
    +{
    
    93
    +  EXDLL_INIT();
    
    94
    +	ShortCutData(SHELLLINKTYPE_GETICONLOC);
    
    95
    +}
    
    96
    +
    
    97
    +NSISFUNC(GetShortCutIconIndex)
    
    98
    +{
    
    99
    +  EXDLL_INIT();
    
    100
    +	ShortCutData(SHELLLINKTYPE_GETICONINDEX);
    
    101
    +}
    
    102
    +
    
    103
    +NSISFUNC(GetShortCutTarget)
    
    104
    +{
    
    105
    +  EXDLL_INIT();
    
    106
    +	ShortCutData(SHELLLINKTYPE_GETPATH);
    
    107
    +}
    
    108
    +
    
    109
    +NSISFUNC(GetShortCutShowMode)
    
    110
    +{
    
    111
    +  EXDLL_INIT();
    
    112
    +	ShortCutData(SHELLLINKTYPE_GETSHOWMODE);
    
    113
    +}
    
    114
    +
    
    115
    +NSISFUNC(GetShortCutWorkingDirectory)
    
    116
    +{
    
    117
    +  EXDLL_INIT();
    
    118
    +	ShortCutData(SHELLLINKTYPE_GETWORKINGDIR);
    
    119
    +}
    
    120
    +
    
    121
    +//Set
    
    122
    +NSISFUNC(SetShortCutArgs)
    
    123
    +{
    
    124
    +  EXDLL_INIT();
    
    125
    +	ShortCutData(SHELLLINKTYPE_SETARGS);
    
    126
    +}
    
    127
    +
    
    128
    +NSISFUNC(SetShortCutDescription)
    
    129
    +{
    
    130
    +  EXDLL_INIT();
    
    131
    +	ShortCutData(SHELLLINKTYPE_SETDESC);
    
    132
    +}
    
    133
    +
    
    134
    +NSISFUNC(SetShortCutHotkey)
    
    135
    +{
    
    136
    +  EXDLL_INIT();
    
    137
    +	ShortCutData(SHELLLINKTYPE_SETHOTKEY);
    
    138
    +}
    
    139
    +
    
    140
    +NSISFUNC(SetShortCutIconLocation)
    
    141
    +{
    
    142
    +  EXDLL_INIT();
    
    143
    +	ShortCutData(SHELLLINKTYPE_SETICONLOC);
    
    144
    +}
    
    145
    +
    
    146
    +NSISFUNC(SetShortCutIconIndex)
    
    147
    +{
    
    148
    +  EXDLL_INIT();
    
    149
    +	ShortCutData(SHELLLINKTYPE_SETICONINDEX);
    
    150
    +}
    
    151
    +
    
    152
    +NSISFUNC(SetShortCutTarget)
    
    153
    +{
    
    154
    +  EXDLL_INIT();
    
    155
    +	ShortCutData(SHELLLINKTYPE_SETPATH);
    
    156
    +}
    
    157
    +
    
    158
    +NSISFUNC(SetShortCutShowMode)
    
    159
    +{
    
    160
    +  EXDLL_INIT();
    
    161
    +	ShortCutData(SHELLLINKTYPE_SETSHOWMODE);
    
    162
    +}
    
    163
    +
    
    164
    +NSISFUNC(SetShortCutWorkingDirectory)
    
    165
    +{
    
    166
    +  EXDLL_INIT();
    
    167
    +	ShortCutData(SHELLLINKTYPE_SETWORKINGDIR);
    
    168
    +}
    
    169
    +
    
    170
    +NSISFUNC(SetRunAsAdministrator)
    
    171
    +{
    
    172
    +  EXDLL_INIT();
    
    173
    +	ShortCutData(SHELLLINKTYPE_SETRUNASADMIN);
    
    174
    +}
    
    175
    +
    
    176
    +void ShortCutData(int nType)
    
    177
    +{
    
    178
    +	HRESULT hRes;
    
    179
    +	IShellLink* psl;
    
    180
    +	IPersistFile* ppf;
    
    181
    +
    
    182
    +  int nBuf;
    
    183
    +  WORD wHotkey;
    
    184
    +  TCHAR* szBuf = (TCHAR*)LocalAlloc(LPTR, sizeof(TCHAR)*MAX_PATH);
    
    185
    +  TCHAR* szBuf2 = (TCHAR*)LocalAlloc(LPTR, sizeof(TCHAR)*MAX_PATH);
    
    186
    +
    
    187
    +	popstring(szBuf);
    
    188
    +	if (nType > SHELLLINKTYPE_GETWORKINGDIR) popstring(szBuf2);
    
    189
    +
    
    190
    +	hRes=CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &psl);
    
    191
    +	if (hRes == S_OK)
    
    192
    +	{
    
    193
    +		hRes=psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
    
    194
    +		if (hRes == S_OK)
    
    195
    +		{
    
    196
    +#ifdef UNICODE
    
    197
    +			hRes=ppf->Load(szBuf, STGM_READWRITE);
    
    198
    +#else
    
    199
    +      WCHAR* wszPath = (WCHAR*)LocalAlloc(LPTR, sizeof(WCHAR)*MAX_PATH);
    
    200
    +			MultiByteToWideChar(CP_ACP, 0, szBuf, -1, wszPath, MAX_PATH);
    
    201
    +			hRes=ppf->Load(wszPath, STGM_READWRITE);
    
    202
    +      LocalFree(wszPath);
    
    203
    +#endif
    
    204
    +			if (hRes == S_OK)
    
    205
    +			{
    
    206
    +				if (nType <= SHELLLINKTYPE_GETWORKINGDIR)
    
    207
    +				{
    
    208
    +					//Get
    
    209
    +					switch(nType)
    
    210
    +					{
    
    211
    +						case SHELLLINKTYPE_GETARGS:
    
    212
    +						{
    
    213
    +							hRes=psl->GetArguments(szBuf, MAX_PATH);
    
    214
    +							if (hRes != S_OK) szBuf[0]='\0';
    
    215
    +						}; break;
    
    216
    +						case SHELLLINKTYPE_GETDESC: 
    
    217
    +						{
    
    218
    +							hRes=psl->GetDescription(szBuf, MAX_PATH);
    
    219
    +							if (hRes != S_OK) szBuf[0]='\0';
    
    220
    +						}; break;
    
    221
    +						case SHELLLINKTYPE_GETHOTKEY: 
    
    222
    +						{
    
    223
    +							hRes=psl->GetHotkey(&wHotkey);
    
    224
    +							if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), wHotkey);
    
    225
    +							else szBuf[0]='\0';
    
    226
    +						}; break;
    
    227
    +						case SHELLLINKTYPE_GETICONLOC: 
    
    228
    +						{
    
    229
    +							hRes=psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
    
    230
    +							if (hRes != S_OK) szBuf[0]='\0';
    
    231
    +						}; break;
    
    232
    +						case SHELLLINKTYPE_GETICONINDEX: 
    
    233
    +						{
    
    234
    +							hRes=psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
    
    235
    +							if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), nBuf);
    
    236
    +							else szBuf[0]='\0';
    
    237
    +						}; break;
    
    238
    +						case SHELLLINKTYPE_GETPATH: 
    
    239
    +						{
    
    240
    +							WIN32_FIND_DATA fd;
    
    241
    +
    
    242
    +							hRes=psl->GetPath(szBuf, MAX_PATH, &fd, SLGP_UNCPRIORITY);
    
    243
    +							if (hRes != S_OK) szBuf[0]='\0';
    
    244
    +						}; break;
    
    245
    +						case SHELLLINKTYPE_GETSHOWMODE: 
    
    246
    +						{
    
    247
    +							hRes=psl->GetShowCmd(&nBuf);
    
    248
    +							if (hRes == S_OK) wsprintf(szBuf, TEXT("%d"), nBuf);
    
    249
    +							else szBuf[0]='\0';
    
    250
    +						}; break;
    
    251
    +						case SHELLLINKTYPE_GETWORKINGDIR:
    
    252
    +						{ 
    
    253
    +							hRes=psl->GetWorkingDirectory(szBuf, MAX_PATH);
    
    254
    +							if (hRes != S_OK) szBuf[0]='\0';
    
    255
    +						}; break;
    
    256
    +					}
    
    257
    +				}
    
    258
    +				else
    
    259
    +				{
    
    260
    +					//Set
    
    261
    +					switch(nType)
    
    262
    +					{
    
    263
    +						case SHELLLINKTYPE_SETARGS:
    
    264
    +						{
    
    265
    +							hRes=psl->SetArguments(szBuf2);
    
    266
    +						}; break;
    
    267
    +						case SHELLLINKTYPE_SETDESC: 
    
    268
    +						{
    
    269
    +							hRes=psl->SetDescription(szBuf2);
    
    270
    +						}; break;
    
    271
    +						case SHELLLINKTYPE_SETHOTKEY:
    
    272
    +						{
    
    273
    +							wHotkey=(unsigned short)myatoi(szBuf2);
    
    274
    +							hRes=psl->SetHotkey(wHotkey);
    
    275
    +						}; break;
    
    276
    +						case SHELLLINKTYPE_SETICONLOC:
    
    277
    +						{
    
    278
    +							hRes=psl->GetIconLocation(szBuf, MAX_PATH, &nBuf);
    
    279
    +							if (hRes == S_OK)
    
    280
    +								hRes=psl->SetIconLocation(szBuf2, nBuf);
    
    281
    +						}; break;
    
    282
    +						case SHELLLINKTYPE_SETICONINDEX: 
    
    283
    +						{
    
    284
    +							int nBuf2;
    
    285
    +							nBuf=myatoi(szBuf2);
    
    286
    +
    
    287
    +							hRes=psl->GetIconLocation(szBuf, MAX_PATH, &nBuf2);
    
    288
    +							if (hRes == S_OK)
    
    289
    +								hRes=psl->SetIconLocation(szBuf, nBuf);
    
    290
    +						}; break;
    
    291
    +						case SHELLLINKTYPE_SETPATH: 
    
    292
    +						{
    
    293
    +							hRes=psl->SetPath(szBuf2);
    
    294
    +						}; break;
    
    295
    +						case SHELLLINKTYPE_SETSHOWMODE: 
    
    296
    +						{
    
    297
    +							nBuf=myatoi(szBuf2);
    
    298
    +							hRes=psl->SetShowCmd(nBuf);
    
    299
    +						}; break;
    
    300
    +						case SHELLLINKTYPE_SETWORKINGDIR:
    
    301
    +						{
    
    302
    +							hRes=psl->SetWorkingDirectory(szBuf2);
    
    303
    +						}; break;
    
    304
    +						case SHELLLINKTYPE_SETRUNASADMIN:
    
    305
    +						{
    
    306
    +              IShellLinkDataList* pdl;
    
    307
    +              hRes=psl->QueryInterface(IID_IShellLinkDataList, (void**)&pdl);
    
    308
    +              if (hRes == S_OK)
    
    309
    +              {
    
    310
    +                DWORD dwFlags = 0;
    
    311
    +							  hRes=pdl->GetFlags(&dwFlags);
    
    312
    +                if (hRes == S_OK && (dwFlags & SLDF_RUNAS_USER) != SLDF_RUNAS_USER)
    
    313
    +                  hRes=pdl->SetFlags(dwFlags | SLDF_RUNAS_USER);
    
    314
    +                pdl->Release();
    
    315
    +              }
    
    316
    +						}; break;
    
    317
    +					}
    
    318
    +					if (hRes == S_OK) hRes=ppf->Save(NULL, FALSE);
    
    319
    +					#ifdef SHELLLINK_DEBUG
    
    320
    +					else MessageBox(hwndParent, TEXT("ERROR: Save()"), TEXT("ShellLink plug-in"), MB_OK);
    
    321
    +					#endif
    
    322
    +				}
    
    323
    +			}
    
    324
    +			#ifdef SHELLLINK_DEBUG
    
    325
    +			else MessageBox(hwndParent, TEXT("ERROR: Load()"), TEXT("ShellLink plug-in"), MB_OK);
    
    326
    +			#endif
    
    327
    +		}
    
    328
    +		#ifdef SHELLLINK_DEBUG
    
    329
    +		else MessageBox(hwndParent, TEXT("CShellLink::Initialise, Failed in call to QueryInterface for IPersistFile, HRESULT was %x\n"), TEXT("ShellLink plug-in"), MB_OK);
    
    330
    +		#endif
    
    331
    +
    
    332
    +		// Cleanup:
    
    333
    +		if (ppf) ppf->Release();
    
    334
    +		if (psl) psl->Release();
    
    335
    +	}
    
    336
    +	#ifdef SHELLLINK_DEBUG
    
    337
    +	else MessageBox(hwndParent, TEXT("ERROR: CoCreateInstance()"), TEXT("ShellLink plug-in"), MB_OK);
    
    338
    +	#endif
    
    339
    +
    
    340
    +	if (hRes == S_OK)
    
    341
    +	{
    
    342
    +		if (nType <= SHELLLINKTYPE_GETWORKINGDIR) pushstring(szBuf);
    
    343
    +		else pushstring(TEXT("0"));
    
    344
    +	}
    
    345
    +	else
    
    346
    +	{
    
    347
    +		if (nType <= SHELLLINKTYPE_GETWORKINGDIR) pushstring(TEXT(""));
    
    348
    +		else pushstring(TEXT("-1"));
    
    349
    +	}
    
    350
    +
    
    351
    +  LocalFree(szBuf);
    
    352
    +  LocalFree(szBuf2);
    
    353
    +}
    
    354
    +
    
    355
    +BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
    
    356
    +{
    
    357
    +	return TRUE;
    
    358
    +}

  • projects/nsis/build
    ... ... @@ -30,7 +30,8 @@ EOF
    30 30
     chmod +x "$compiler_prefix-gcc"
    
    31 31
     ln -s "$compiler_prefix-clang++" "$compiler_prefix-g++"
    
    32 32
     
    
    33
    -cd /var/tmp/build/nsis-[% c('version') %]-src
    
    33
    +builddir=/var/tmp/build/nsis-[% c('version') %]-src
    
    34
    +cd "$builddir"
    
    34 35
     
    
    35 36
     # These two sed commands also come from build-mingw32-nsis.sh
    
    36 37
     sed -i 's/-Wl,--exclude-libs,msvcrt.a/-Wl,-Xlink=-fixed/' SCons/Config/gnu
    
    ... ... @@ -60,6 +61,22 @@ patch -p1 < "$rootdir/resource-reproducible.diff"
    60 61
     scons [% scons_args %] -j[% c("num_procs") %] || true
    
    61 62
     scons [% scons_args %]
    
    62 63
     scons [% scons_args %] install
    
    64
    +
    
    65
    +# Plugins
    
    66
    +target="[% target %]-unicode"
    
    67
    +plugins="/var/tmp/dist/nsis/share/nsis/Plugins/$target"
    
    68
    +plugin_lib="$builddir/build/urelease/api/nsis/libpluginapi-$target.a"
    
    69
    +
    
    70
    +# This is not needed to build installers, but it makes easier to adapt plugins
    
    71
    +# outside our build system.
    
    72
    +mkdir /var/tmp/dist/nsis/share/nsis/Lib
    
    73
    +cp $plugin_lib /var/tmp/dist/nsis/share/nsis/Lib/
    
    74
    +
    
    75
    +$compiler_prefix-clang++ -I "$builddir/build/urelease/api" -O2 $plugin_lib \
    
    76
    +  -DUNICODE "$rootdir/ShellLink.cpp" \
    
    77
    +  -Wl,--no-insert-timestamp -lole32 -luuid -shared -o "$plugins/ShellLink.dll"
    
    78
    +llvm-strip "$plugins/ShellLink.dll"
    
    79
    +
    
    63 80
     cd /var/tmp/dist
    
    64 81
     [% c('tar', {
    
    65 82
             tar_src => [ project ],
    

  • projects/nsis/config
    ... ... @@ -24,3 +24,4 @@ input_files:
    24 24
       - name: zlib
    
    25 25
         project: zlib
    
    26 26
       - filename: resource-reproducible.diff
    
    27
    +  - filename: ShellLink.cpp

  • rbm.conf
    ... ... @@ -112,6 +112,8 @@ var:
    112 112
       Project_Name_Channel: '[% c("var/Project_Name") %] [% c("var/channel") FILTER ucfirst %]'
    
    113 113
       exe_name: firefox
    
    114 114
       locale_ja: ja
    
    115
    +  # When adding new languages, add the equivalent NSIS name to
    
    116
    +  # projects/browser/windows-installer/language-map.sh.
    
    115 117
       locales:
    
    116 118
         - ar
    
    117 119
         - ca
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits