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

Commits:

7 changed files:

Changes:

  • projects/browser/build
    ... ... @@ -320,6 +320,7 @@ done
    320 320
     
    
    321 321
       [% IF c('var/mullvad-browser') -%]
    
    322 322
         pushd $distdir/windows-installer
    
    323
    +    tar -xf $rootdir/[% c('input_files_by_name/firefox') %]/nsis-plugins.tar.[% c("compress_tar") %]
    
    323 324
         # While Firefox re-uses the uninstaller for this, we cannot do it, because
    
    324 325
         # we write the uninstaller from the installer.
    
    325 326
         # Instead, we need to write an updated postupdate.exe also when updating.
    

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

  • projects/browser/windows-installer/browser-install.nsi
    1
    +  !addplugindir nsis-plugins
    
    1 2
       !include "common.nsh"
    
    2 3
       !include "registry.nsh"
    
    4
    +  !include "Win\COM.nsh"
    
    3 5
     
    
    4 6
     ;--------------------------------
    
    5 7
       OutFile "browser-install.exe"
    
    ... ... @@ -219,7 +221,7 @@ Section "Browser" SecBrowser
    219 221
         ; Write the uninstaller
    
    220 222
         WriteUninstaller $INSTDIR\uninstall.exe
    
    221 223
     
    
    222
    -    !insertmacro UPDATE_REGISTRY
    
    224
    +    Call UpdateRegistry
    
    223 225
     
    
    224 226
         CreateShortCut "$SMPROGRAMS\${DISPLAY_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
    
    225 227
         ${If} $createDesktopShortcut == "true"
    
    ... ... @@ -238,24 +240,57 @@ FunctionEnd
    238 240
     
    
    239 241
     ;--------------------------------
    
    240 242
     ; Uninstaller
    
    243
    +
    
    244
    +Function un.GetPathFromString
    
    245
    +  !insertmacro GetPathFromStringImp
    
    246
    +FunctionEnd
    
    247
    +
    
    241 248
     Section "Uninstall"
    
    249
    +  ; Currently, the uninstaller is written by the installer, only in install
    
    250
    +  ; mode, and we do not have any way to update it.
    
    251
    +  ; However, we keep postupdate.exe updated, so we can use that instead.
    
    252
    +  ExecWait '"$INSTDIR\postupdate.exe" /Uninstall' $0
    
    253
    +
    
    242 254
       RMDir /r "$INSTDIR"
    
    243 255
       DeleteRegKey HKCU "${UNINST_KEY}"
    
    244 256
     
    
    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}
    
    257
    +  StrCpy $2 "$SMPROGRAMS\${DISPLAY_NAME}.lnk"
    
    258
    +  StrCpy $3 ""
    
    259
    +  ShellLink::GetShortCutTarget "$2"
    
    260
    +  Pop $3
    
    261
    +  ${If} $3 == "$INSTDIR\${EXE_NAME}"
    
    262
    +    ; https://stackoverflow.com/questions/42816091/nsis-remove-pinned-icon-from-taskbar-on-uninstall
    
    263
    +    !insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 ""
    
    264
    +    ${If} $0 P<> 0
    
    265
    +      System::Call 'SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' "$2"
    
    266
    +      ${If} $1 P<> 0
    
    267
    +        ${IStartMenuPinnedList::RemoveFromList} $0 '(r1)'
    
    268
    +        ${IUnknown::Release} $1 ""
    
    269
    +      ${EndIf}
    
    270
    +      ${IUnknown::Release} $0 ""
    
    271
    +    ${EndIf}
    
    251 272
     
    
    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"
    
    273
    +    Delete "$2"
    
    257 274
       ${EndIf}
    
    258 275
     
    
    276
    +  FindFirst $1 $2 "$DESKTOP\*.lnk"
    
    277
    +  loop:
    
    278
    +    IfErrors end
    
    279
    +    StrCpy $0 ""
    
    280
    +    ShellLink::GetShortCutTarget "$DESKTOP\$2"
    
    281
    +    ; Do not pop, and pass the value over
    
    282
    +    Call un.GetPathFromString
    
    283
    +    Pop $0
    
    284
    +    ${If} $0 == "$INSTDIR\${EXE_NAME}"
    
    285
    +      Delete "$DESKTOP\$2"
    
    286
    +    ${EndIf}
    
    287
    +    FindNext $1 $2
    
    288
    +    goto loop
    
    289
    +  end:
    
    290
    +  FindClose $1
    
    291
    +
    
    292
    +  ${RefreshShellIcons}
    
    293
    +
    
    259 294
       ; TODO: Optionally remove profiles.
    
    260 295
       ; This operation is not trivial, because it involes finding our installation
    
    261 296
       ; hash, its associated default profile and making sure it is not shared with
    

  • projects/browser/windows-installer/defines.nsh.in
    ... ... @@ -5,13 +5,7 @@
    5 5
     
    
    6 6
       ; Project and display name
    
    7 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 -%]
    
    8
    +  !define DISPLAY_NAME "[% c('var/display_name') %]"
    
    15 9
       !define NAME_NO_SPACES "[% c('var/ProjectName') %]"
    
    16 10
       !define UPDATE_CHANNEL "[% c('var/channel') FILTER ucfirst %]"
    
    17 11
     
    

  • projects/browser/windows-installer/postupdate.nsi
    1
    +!addplugindir nsis-plugins
    
    1 2
     !include "FileFunc.nsh"
    
    2 3
     !include "LogicLib.nsh"
    
    3 4
     
    
    ... ... @@ -9,9 +10,14 @@ Icon "${ICON_NAME}"
    9 10
     RequestExecutionLevel user
    
    10 11
     
    
    11 12
     Function .onInit
    
    13
    +  StrCpy $INSTDIR $EXEDIR
    
    14
    +
    
    12 15
       ${GetOptions} $CMDLINE "/Visible" $0
    
    13 16
       IfErrors 0 +2
    
    14 17
       SetSilent silent
    
    18
    +  ${GetOptions} $CMDLINE "/Uninstall" $0
    
    19
    +  IfErrors +2 0
    
    20
    +  Call Uninstall
    
    15 21
     FunctionEnd
    
    16 22
     
    
    17 23
     Section PostUpdate "PostUpdate"
    
    ... ... @@ -19,10 +25,14 @@ Section PostUpdate "PostUpdate"
    19 25
       IfFileExists $EXEDIR\system-install 0 +2
    
    20 26
       StrCpy $0 "true"
    
    21 27
       ${If} $0 == "true"
    
    22
    -    StrCpy $INSTDIR $EXEDIR
    
    23
    -    !insertmacro UPDATE_REGISTRY
    
    28
    +    Call UpdateRegistry
    
    24 29
         RMDir /r /REBOOTOK $EXEDIR\tobedeleted
    
    25 30
       ${Else}
    
    26 31
         RMDir /r $EXEDIR\tobedeleted
    
    27 32
       ${EndIf}
    
    28 33
     SectionEnd
    
    34
    +
    
    35
    +Function Uninstall
    
    36
    +  Call ClearRegistry
    
    37
    +  Quit
    
    38
    +FunctionEnd

  • projects/browser/windows-installer/registry.nsh
    1
    +; Utilities to update the registry values in installs.
    
    2
    +; Based on Firefox's NSIS scripts.
    
    3
    +;
    
    4
    +; This Source Code Form is subject to the terms of the Mozilla Public
    
    5
    +; License, v. 2.0. If a copy of the MPL was not distributed with this
    
    6
    +; file, You can obtain one at http://mozilla.org/MPL/2.0/.
    
    7
    +
    
    1 8
     !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME_NO_SPACES}${UPDATE_CHANNEL}"
    
    2 9
     
    
    3
    -!macro UPDATE_REGISTRY
    
    10
    +; The only "public" functions of this file are UpdateRegistry and ClearRegistry.
    
    11
    +
    
    12
    +var aumid
    
    13
    +
    
    14
    +; Compute the AUMID we will use for our links.
    
    15
    +; We use the same strategy as Firefox: we hash the path of the installation
    
    16
    +; directory with CityHash64.
    
    17
    +; See InitHashAppModelId in toolkit/mozapps/installer/windows/nsis/common.nsh.
    
    18
    +; While we could differentiate between channels (we force one install for each
    
    19
    +; channel), following Firefox has the advantage that we have to adapt/rework
    
    20
    +; less stuff.
    
    21
    +Function ComputeAumid
    
    22
    +  StrCpy $0 $INSTDIR
    
    23
    +  ; NSIS command will not convert from short form to the long one.
    
    24
    +  ; So, this is the way they suggest to get the long name in their docs.
    
    25
    +  System::Call 'kernel32::GetLongPathName(t r0, t .r1, i ${NSIS_MAX_STRLEN}) i .r2'
    
    26
    +  ${If} $2 != "error"
    
    27
    +    CityHash::GetCityHash64 $1
    
    28
    +    Pop $aumid
    
    29
    +  ${Else}
    
    30
    +    StrCpy $aumid "error"
    
    31
    +  ${EndIf}
    
    32
    +FunctionEnd
    
    33
    +
    
    34
    +; Set the installation details.
    
    35
    +; See https://nsis.sourceforge.io/Add_uninstall_information_to_Add/Remove_Programs.
    
    36
    +Function SetUninstallData
    
    4 37
       WriteRegStr HKCU "${UNINST_KEY}" "DisplayName" "${DISPLAY_NAME}"
    
    5 38
       WriteRegStr HKCU "${UNINST_KEY}" "DisplayIcon" "$\"$INSTDIR\${EXE_NAME}$\""
    
    6 39
       WriteRegStr HKCU "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
    
    ... ... @@ -16,4 +49,332 @@
    16 49
       WriteRegStr HKCU "${UNINST_KEY}" "URLInfoAbout" "${URL_ABOUT}"
    
    17 50
       WriteRegStr HKCU "${UNINST_KEY}" "URLUpdateInfo" "${URL_UPDATE}"
    
    18 51
       WriteRegStr HKCU "${UNINST_KEY}" "HelpLink" "${URL_HELP}"
    
    52
    +FunctionEnd
    
    53
    +
    
    54
    +; Register a certain class in the form $browserName$className-$aumid.
    
    55
    +; The classes registered by Firefox are URL, HTML and PDF.
    
    56
    +; The default browser agent checks them before registering anything.
    
    57
    +; See SetDefaultBrowserUserChoice in
    
    58
    +; toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp, FormatProgID and
    
    59
    +; CheckProgIDExists in browser/components/shell/WindowsUserChoice.cpp.
    
    60
    +; See also AddHandlerValues in
    
    61
    +; toolkit/mozapps/installer/windows/nsis/common.nsh.
    
    62
    +Function RegisterClass
    
    63
    +  ; Based on Firefox's AddHandlerValues
    
    64
    +  Pop $3 ; Is this a protocol?
    
    65
    +  Pop $2 ; Icon index
    
    66
    +  Pop $1 ; Description
    
    67
    +  Pop $0 ; Class name
    
    68
    +
    
    69
    +  StrCpy $R0 "${NAME_NO_SPACES}$0-$aumid" ; Expanded class name
    
    70
    +  StrCpy $R1 "${PROJECT_NAME} $1" ; Description with project name
    
    71
    +  StrCpy $R2 "$INSTDIR\${EXE_NAME}" ; Full path to the main executable
    
    72
    +  StrCpy $R3 "Software\Classes\$R0" ; Registry key to update
    
    73
    +
    
    74
    +  WriteRegStr HKCU $R3 "" "$R1"
    
    75
    +  WriteRegStr HKCU $R3 "FriendlyTypeName" "$R1"
    
    76
    +  ${If} $3 == "true"
    
    77
    +    WriteRegStr HKCU $R3 "URL Protocol" ""
    
    78
    +  ${EndIf}
    
    79
    +  ; Firefox sets EditFlags only when empty
    
    80
    +  ReadRegDWORD $R4 HKCU $R3 "EditFlags"
    
    81
    +  ${If} $R4 == ""
    
    82
    +    WriteRegDWORD HKCU $R3 "EditFlags" 0x00000002
    
    83
    +  ${EndIf}
    
    84
    +  WriteRegStr HKCU "$R3\DefaultIcon" "" "$R2,$2"
    
    85
    +  WriteRegStr HKCU "$R3\shell" "" "open"
    
    86
    +  WriteRegStr HKCU "$R3\shell\open\command" "" '"$R2" -osint -url "%1"'
    
    87
    +FunctionEnd
    
    88
    +
    
    89
    +; Register all the classes we need to handle.
    
    90
    +; See RegisterClass.
    
    91
    +Function RegisterClasses
    
    92
    +  Push "URL"
    
    93
    +  Push "URL"
    
    94
    +  Push 1
    
    95
    +  Push true
    
    96
    +  Call RegisterClass
    
    97
    +
    
    98
    +  Push "HTML"
    
    99
    +  Push "HTML Document"
    
    100
    +  Push 1
    
    101
    +  Push false
    
    102
    +  Call RegisterClass
    
    103
    +
    
    104
    +  Push "PDF"
    
    105
    +  Push "PDF Document"
    
    106
    +  Push 5
    
    107
    +  Push false
    
    108
    +  Call RegisterClass
    
    109
    +FunctionEnd
    
    110
    +
    
    111
    +; Register the start menu entry.
    
    112
    +; Microsoft's documentation says this is deprecated after Windows 8, however
    
    113
    +; these entries are still visible in the settings application.
    
    114
    +; See the SetStartMenuInternet macro in
    
    115
    +; browser/installer/windows/nsis/shared.nsh.
    
    116
    +; We do not add entries for features we do not support, such as the safe mode.
    
    117
    +; Also, the functionality to hide/show shortcuts should not apply to Windows 10,
    
    118
    +; so we did not implement that as well.
    
    119
    +Function RegisterStartMenu
    
    120
    +  StrCpy $0 "Software\Clients\StartMenuInternet\${NAME_NO_SPACES}-$aumid"
    
    121
    +  StrCpy $1 "$INSTDIR\${EXE_NAME}"
    
    122
    +  StrCpy $2 "${NAME_NO_SPACES}-$aumid"
    
    123
    +  StrCpy $3 "${NAME_NO_SPACES}URL-$aumid"
    
    124
    +  StrCpy $4 "${NAME_NO_SPACES}HTML-$aumid"
    
    125
    +  StrCpy $5 "${NAME_NO_SPACES}PDF-$aumid"
    
    126
    +
    
    127
    +  WriteRegStr HKCU "$0" "" "${DISPLAY_NAME}"
    
    128
    +  WriteRegStr HKCU "$0\DefaultItcon" "" "$1,0"
    
    129
    +  WriteRegStr HKCU "$0\shell\open\command" "" '"$1"'
    
    130
    +  WriteRegStr HKCU "$0\Capabilities\StartMenu" "StartMenuInternet" "$2"
    
    131
    +  ; Same as Firefox, see SetStartMenuInternet
    
    132
    +  ; URLs
    
    133
    +  WriteRegStr HKCU "$0\Capabilities\URLAssociations" "http" "$3"
    
    134
    +  WriteRegStr HKCU "$0\Capabilities\URLAssociations" "https" "$3"
    
    135
    +  ; mailto is currently unsupported, but we could enable it here, if needed.
    
    136
    +  ; WriteRegStr HKCU "$0\Capabilities\URLAssociations" "mailto" "$3"
    
    137
    +  ; No need to uninstall FTP here, since we had never installed it.
    
    138
    +  ; HTML + aumid
    
    139
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".htm" "$4"
    
    140
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".html" "$4"
    
    141
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".shtml" "$4"
    
    142
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".xht" "$4"
    
    143
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".xhtml" "$4"
    
    144
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".svg" "$4"
    
    145
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".webp" "$4"
    
    146
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".avif" "$4"
    
    147
    +  ; PDF + aumid
    
    148
    +  WriteRegStr HKCU "$0\Capabilities\FileAssociations" ".pdf" "$5"
    
    149
    +
    
    150
    +  WriteRegStr HKCU "Software\RegisteredApplications" "$2" "$0\Capabilities"
    
    151
    +FunctionEnd
    
    152
    +
    
    153
    +; Copied from toolkit/mozapps/installer/windows/nsis/common.nsh.
    
    154
    +; Implemented as a macro first so that we can use it both in the installer (to
    
    155
    +; update the registry) and in the uninstaller (to check which links we have to
    
    156
    +; remove). The macro is then expanded in an installer function, and in an
    
    157
    +; uninstaller function, to avoid multiple copies of the same code.
    
    158
    +!macro GetPathFromStringImp
    
    159
    +  Exch $R9
    
    160
    +  Push $R8
    
    161
    +  Push $R7
    
    162
    +
    
    163
    +  StrCpy $R7 0          ; Set the counter to 0.
    
    164
    +
    
    165
    +  ; Handle quoted paths with arguments.
    
    166
    +  StrCpy $R8 $R9 1      ; Copy the first char.
    
    167
    +  StrCmp $R8 '"' +2 +1  ; Is it a "?
    
    168
    +  StrCmp $R8 "'" +1 +9  ; Is it a '?
    
    169
    +  StrCpy $R9 $R9 "" 1   ; Remove the first char.
    
    170
    +  IntOp $R7 $R7 + 1     ; Increment the counter.
    
    171
    +  StrCpy $R8 $R9 1 $R7  ; Starting from the counter copy the next char.
    
    172
    +  StrCmp $R8 "" end +1  ; Are there no more chars?
    
    173
    +  StrCmp $R8 '"' +2 +1  ; Is it a " char?
    
    174
    +  StrCmp $R8 "'" +1 -4  ; Is it a ' char?
    
    175
    +  StrCpy $R9 $R9 $R7    ; Copy chars up to the counter.
    
    176
    +  GoTo end
    
    177
    +
    
    178
    +  ; Handle DefaultIcon paths. DefaultIcon paths are not quoted and end with
    
    179
    +  ; a , and a number.
    
    180
    +  IntOp $R7 $R7 - 1     ; Decrement the counter.
    
    181
    +  StrCpy $R8 $R9 1 $R7  ; Copy one char from the end minus the counter.
    
    182
    +  StrCmp $R8 '' +4 +1   ; Are there no more chars?
    
    183
    +  StrCmp $R8 ',' +1 -3  ; Is it a , char?
    
    184
    +  StrCpy $R9 $R9 $R7    ; Copy chars up to the end minus the counter.
    
    185
    +  GoTo end
    
    186
    +
    
    187
    +  ; Handle unquoted paths with arguments. An unquoted path with arguments
    
    188
    +  ; must be an 8dot3 path.
    
    189
    +  StrCpy $R7 -1          ; Set the counter to -1 so it will start at 0.
    
    190
    +  IntOp $R7 $R7 + 1      ; Increment the counter.
    
    191
    +  StrCpy $R8 $R9 1 $R7   ; Starting from the counter copy the next char.
    
    192
    +  StrCmp $R8 "" end +1   ; Are there no more chars?
    
    193
    +  StrCmp $R8 " " +1 -3   ; Is it a space char?
    
    194
    +  StrCpy $R9 $R9 $R7     ; Copy chars up to the counter.
    
    195
    +
    
    196
    +  end:
    
    197
    +  ClearErrors
    
    198
    +
    
    199
    +  Pop $R7
    
    200
    +  Pop $R8
    
    201
    +  Exch $R9
    
    19 202
     !macroend
    
    203
    +
    
    204
    +Function GetPathFromString
    
    205
    +  !insertmacro GetPathFromStringImp
    
    206
    +FunctionEnd
    
    207
    +
    
    208
    +; Create a Software\Classes\Applications\$exeName.exe entry, shared by all the
    
    209
    +; installs.
    
    210
    +; If this key has already been registered by another channel/install, we just
    
    211
    +; make sure the open entry has the expected command line flags.
    
    212
    +; See SetStartMenuInternet in browser/installer/windows/nsis/shared.nsh.
    
    213
    +Function RegisterTypes
    
    214
    +  StrCpy $0 "Software\Classes\Applications\${EXE_NAME}"
    
    215
    +  StrCpy $1 "$0\shell\open\command"
    
    216
    +  StrCpy $2 "$0\SupportedTypes"
    
    217
    +
    
    218
    +  ReadRegStr $3 HKCU "$1" ""
    
    219
    +  ${If} $3 != ""
    
    220
    +    ; If the user already has something, we just update it to make sure it
    
    221
    +    ; contains the -osint flag. This should not be a problem if we created these
    
    222
    +    ; entries, but we still check them in case they were added manually.
    
    223
    +    Push $3
    
    224
    +    Call GetPathFromString
    
    225
    +    Pop $3
    
    226
    +    WriteRegStr HKCU "$1" "" '"$3" -osint -url "%1"'
    
    227
    +  ${Else}
    
    228
    +    WriteRegStr HKCU "$1" "" '"$INSTDIR\${EXE_NAME}" -osint -url "%1"'
    
    229
    +    WriteRegStr HKCU "$0\DefaultIcon" "" "$INSTDIR\${EXE_NAME},1"
    
    230
    +
    
    231
    +    ; Same as Firefox, see SetStartMenuInternet
    
    232
    +    WriteRegStr HKCU "$2" ".apng" ""
    
    233
    +    WriteRegStr HKCU "$2" ".bmp" ""
    
    234
    +    WriteRegStr HKCU "$2" ".flac" ""
    
    235
    +    WriteRegStr HKCU "$2" ".gif" ""
    
    236
    +    WriteRegStr HKCU "$2" ".htm" ""
    
    237
    +    WriteRegStr HKCU "$2" ".html" ""
    
    238
    +    WriteRegStr HKCU "$2" ".ico" ""
    
    239
    +    WriteRegStr HKCU "$2" ".jfif" ""
    
    240
    +    WriteRegStr HKCU "$2" ".jpeg" ""
    
    241
    +    WriteRegStr HKCU "$2" ".jpg" ""
    
    242
    +    WriteRegStr HKCU "$2" ".json" ""
    
    243
    +    WriteRegStr HKCU "$2" ".m4a" ""
    
    244
    +    WriteRegStr HKCU "$2" ".mp3" ""
    
    245
    +    WriteRegStr HKCU "$2" ".oga" ""
    
    246
    +    WriteRegStr HKCU "$2" ".ogg" ""
    
    247
    +    WriteRegStr HKCU "$2" ".ogv" ""
    
    248
    +    WriteRegStr HKCU "$2" ".opus" ""
    
    249
    +    WriteRegStr HKCU "$2" ".pdf" ""
    
    250
    +    WriteRegStr HKCU "$2" ".pjpeg" ""
    
    251
    +    WriteRegStr HKCU "$2" ".pjp" ""
    
    252
    +    WriteRegStr HKCU "$2" ".png" ""
    
    253
    +    WriteRegStr HKCU "$2" ".rdf" ""
    
    254
    +    WriteRegStr HKCU "$2" ".shtml" ""
    
    255
    +    WriteRegStr HKCU "$2" ".svg" ""
    
    256
    +    WriteRegStr HKCU "$2" ".webm" ""
    
    257
    +    WriteRegStr HKCU "$2" ".avif" ""
    
    258
    +    WriteRegStr HKCU "$2" ".xht" ""
    
    259
    +    WriteRegStr HKCU "$2" ".xhtml" ""
    
    260
    +    WriteRegStr HKCU "$2" ".xml" ""
    
    261
    +  ${EndIf}
    
    262
    +FunctionEnd
    
    263
    +
    
    264
    +; Set the AUMID to all links pointing to our exe in a certain directory.
    
    265
    +; See RegisterAumid.
    
    266
    +Function RegisterAumidDirectory
    
    267
    +  Pop $0
    
    268
    +  FindFirst $1 $2 "$0\*.lnk"
    
    269
    +  loop:
    
    270
    +    IfErrors end
    
    271
    +    ShellLink::GetShortCutTarget "$0\$2"
    
    272
    +    ; Do not pop, and pass the value over
    
    273
    +    Call GetPathFromString
    
    274
    +    Pop $3
    
    275
    +    ${If} $3 == "$INSTDIR\${EXE_NAME}"
    
    276
    +      ApplicationID::Set "$0\$2" "$aumid" "true"
    
    277
    +    ${EndIf}
    
    278
    +    FindNext $1 $2
    
    279
    +    goto loop
    
    280
    +  end:
    
    281
    +  FindClose $1
    
    282
    +FunctionEnd
    
    283
    +
    
    284
    +; Firefox expects the installer to write its AUMID in the registry.
    
    285
    +; It is hardcoded to use Software\Mozilla\Firefox\TaskBarIDs, but we change it
    
    286
    +; in widget/windows/WinTaskbar.cpp in one of our patches.
    
    287
    +; See InitHashAppModelId in toolkit/mozapps/installer/windows/nsis/common.nsh.
    
    288
    +;
    
    289
    +; In addition to that, we need to associate the AUMID to every link as per
    
    290
    +; specifications:
    
    291
    +; https://learn.microsoft.com/en-us/windows/win32/shell/appids#application-defined-and-system-defined-appusermodelids
    
    292
    +Function RegisterAumid
    
    293
    +  StrCpy $0 "Software\${APP_DIR}\${PROJECT_NAME}\TaskBarIDs"
    
    294
    +  WriteRegStr HKCU "$0" "$INSTDIR" "$aumid"
    
    295
    +
    
    296
    +  Push $DESKTOP
    
    297
    +  Call RegisterAumidDirectory
    
    298
    +  Push "$QUICKLAUNCH\User Pinned\TaskBar"
    
    299
    +  Call RegisterAumidDirectory
    
    300
    +  Push "$QUICKLAUNCH\User Pinned\StartMenu"
    
    301
    +  Call RegisterAumidDirectory
    
    302
    +FunctionEnd
    
    303
    +
    
    304
    +; Sets all the needed registry keys during an install, or run all the needed
    
    305
    +; maintenance in the post update.
    
    306
    +Function UpdateRegistry
    
    307
    +  Call SetUninstallData
    
    308
    +  Call ComputeAumid
    
    309
    +  ${If} $aumid != "error"
    
    310
    +    Call RegisterClasses
    
    311
    +    Call RegisterStartMenu
    
    312
    +    Call RegisterTypes
    
    313
    +    Call RegisterAumid
    
    314
    +  ${EndIf}
    
    315
    +FunctionEnd
    
    316
    +
    
    317
    +;--------------------------------
    
    318
    +; Uninstall helper
    
    319
    +; We do not ship an uninstaller in the updates.
    
    320
    +; However, to be able to undo changes done during the post update step, we call
    
    321
    +; `postupdate.exe` with the `/Uninstall`. They are implemented here.
    
    322
    +; `postupdate.exe` always runs as it was an installer, which is the reason for
    
    323
    +; which the following functions do not have the `un.` prefix.
    
    324
    +; However, they have an `Un` suffix, and each `Un$function` function undoes the
    
    325
    +; changes done by the corresponding `$function` function.
    
    326
    +
    
    327
    +Function UnregisterClass
    
    328
    +  Pop $0 ; Class name
    
    329
    +  StrCpy $1 "${NAME_NO_SPACES}$0-$aumid" ; Expanded class name
    
    330
    +  DeleteRegKey HKCU "Software\Classes\$1"
    
    331
    +FunctionEnd
    
    332
    +
    
    333
    +Function UnregisterClasses
    
    334
    +  Push "URL"
    
    335
    +  Call UnregisterClass
    
    336
    +  Push "HTML"
    
    337
    +  Call UnregisterClass
    
    338
    +  Push "PDF"
    
    339
    +  Call UnregisterClass
    
    340
    +FunctionEnd
    
    341
    +
    
    342
    +Function UnregisterStartMenu
    
    343
    +  DeleteRegValue HKCU "Software\RegisteredApplications" "${NAME_NO_SPACES}-$aumid"
    
    344
    +  DeleteRegKey HKCU "Software\Clients\StartMenuInternet\${NAME_NO_SPACES}-$aumid"
    
    345
    +FunctionEnd
    
    346
    +
    
    347
    +Function UnregisterTypes
    
    348
    +  StrCpy $0 "Software\Classes\Applications\${EXE_NAME}"
    
    349
    +  StrCpy $1 "$0\shell\open\command"
    
    350
    +  ReadRegStr $2 HKCU "$1" ""
    
    351
    +  ${If} $2 != ""
    
    352
    +    Push $2
    
    353
    +    Call GetPathFromString
    
    354
    +    Pop $3
    
    355
    +    ; Do not do anything if we are not the installation that created the keys.
    
    356
    +    ${If} $3 == "$INSTDIR\${EXE_NAME}"
    
    357
    +      DeleteRegKey HKCU "$0"
    
    358
    +    ${EndIf}
    
    359
    +  ${EndIf}
    
    360
    +FunctionEnd
    
    361
    +
    
    362
    +Function UnregisterAumid
    
    363
    +  DeleteRegValue HKCU "Software\${APP_DIR}\${PROJECT_NAME}\TaskBarIDs" "$INSTDIR"
    
    364
    +  ; No need to do anything on the links, as they will be deleted.
    
    365
    +FunctionEnd
    
    366
    +
    
    367
    +; Remove all the registry changes we have done.
    
    368
    +Function ClearRegistry
    
    369
    +  Call ComputeAumid
    
    370
    +  ${If} $aumid != "error"
    
    371
    +    ; We take for granted we do not have conflicting aumids.
    
    372
    +    Call UnregisterClasses
    
    373
    +    Call UnregisterStartMenu
    
    374
    +    Call UnregisterAumid
    
    375
    +  ${EndIf}
    
    376
    +  ; The types do not depend on the AUMID. So, even though we add them only
    
    377
    +  ; when we have an AUMID (they would be useless otherwise), we always check if
    
    378
    +  ; we should remove them.
    
    379
    +  Call UnregisterTypes
    
    380
    +FunctionEnd

  • projects/firefox/build
    ... ... @@ -6,7 +6,8 @@
    6 6
           }) %]
    
    7 7
     distdir=/var/tmp/dist/[% project %]
    
    8 8
     mkdir -p /var/tmp/build
    
    9
    -mkdir -p [% dest_dir _ '/' _ c('filename') %]
    
    9
    +[% SET out_dir = dest_dir _ '/' _ c('filename') -%]
    
    10
    +mkdir -p [% out_dir %]
    
    10 11
     
    
    11 12
     [% IF c("var/windows") -%]
    
    12 13
       # Setting up fxc2
    
    ... ... @@ -276,6 +277,20 @@ cp -L obj-*/dist/bin/geckodriver* $distdir
    276 277
       [% END -%]
    
    277 278
     [% END -%]
    
    278 279
     
    
    280
    +[% IF c("var/mullvad-browser") && c("var/windows") -%]
    
    281
    +  function make_nsis_plugin {
    
    282
    +    pushd "other-licenses/nsis/Contrib/$1"
    
    283
    +    make CXX=[% c("arch") %]-w64-mingw32-clang++
    
    284
    +    cp "$1.dll" $distdir/nsis-plugins/
    
    285
    +    [% c("touch") %] "$distdir/nsis-plugins/$1.dll"
    
    286
    +    popd
    
    287
    +  }
    
    288
    +
    
    289
    +  mkdir -p $distdir/nsis-plugins
    
    290
    +  make_nsis_plugin ApplicationID
    
    291
    +  make_nsis_plugin CityHash
    
    292
    +[% END -%]
    
    293
    +
    
    279 294
     cd $distdir
    
    280 295
     
    
    281 296
     [% IF c("var/linux") -%]
    
    ... ... @@ -328,7 +343,7 @@ echo "Starting to package artifacts $(date)"
    328 343
     
    
    329 344
     [% c('tar', {
    
    330 345
             tar_src => [ browserdir ],
    
    331
    -        tar_args => '-caf ' _ dest_dir _ '/' _ c('filename') _ '/browser.tar.' _ c('compress_tar'),
    
    346
    +        tar_args => '-caf ' _ out_dir _ '/browser.tar.' _ c('compress_tar'),
    
    332 347
         }) %]
    
    333 348
     
    
    334 349
     # Debug symbols
    
    ... ... @@ -339,13 +354,13 @@ echo "Starting to package artifacts $(date)"
    339 354
       mv include [% c('var/project-name') %]/
    
    340 355
       [% c('tar', {
    
    341 356
           tar_src => [ c('var/project-name') ],
    
    342
    -      tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/browser-debug-symbols.tar.xz',
    
    357
    +      tar_args => '-cJf ' _ out_dir _ '/browser-debug-symbols.tar.xz',
    
    343 358
         }) %]
    
    344 359
       popd
    
    345 360
     [% ELSIF c("var/windows") -%]
    
    346 361
       [% c('zip', {
    
    347 362
           zip_src => [ 'Debug' ],
    
    348
    -      zip_args => dest_dir _ '/' _ c('filename') _ '/browser-debug-symbols.zip',
    
    363
    +      zip_args => out_dir _ '/browser-debug-symbols.zip',
    
    349 364
         }) %]
    
    350 365
     [% END -%]
    
    351 366
     
    
    ... ... @@ -354,12 +369,12 @@ llvm-strip geckodriver*
    354 369
     [% IF c("var/windows") -%]
    
    355 370
       [% c('zip', {
    
    356 371
           zip_src => [ 'geckodriver.exe' ],
    
    357
    -      zip_args => dest_dir _ '/' _ c('filename') _ '/geckodriver.zip',
    
    372
    +      zip_args => out_dir _ '/geckodriver.zip',
    
    358 373
         }) %]
    
    359 374
     [% ELSE -%]
    
    360 375
       [% c('tar', {
    
    361 376
           tar_src => [ 'geckodriver' ],
    
    362
    -      tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename') _ '/geckodriver.tar.xz',
    
    377
    +      tar_args => '-cJf ' _ out_dir _ '/geckodriver.tar.xz',
    
    363 378
         }) %]
    
    364 379
     [% END -%]
    
    365 380
     
    
    ... ... @@ -367,12 +382,19 @@ llvm-strip geckodriver*
    367 382
     [% IF c("var/updater_enabled") -%]
    
    368 383
       [% c('zip', {
    
    369 384
           zip_src => [ 'mar-tools' ],
    
    370
    -      zip_args => dest_dir _ '/' _ c('filename') _ '/' _ 'mar-tools-' _ c("var/osname") _ '-' _ c("var/torbrowser_version") _ '.zip',
    
    385
    +      zip_args => out_dir _ '/' _ 'mar-tools-' _ c("var/osname") _ '-' _ c("var/torbrowser_version") _ '.zip',
    
    386
    +    }) %]
    
    387
    +[% END -%]
    
    388
    +
    
    389
    +[% IF c("var/mullvad-browser") && c("var/windows") -%]
    
    390
    +  [% c('tar', {
    
    391
    +      tar_src => [ 'nsis-plugins' ],
    
    392
    +      tar_args => '-caf ' _ out_dir _ '/nsis-plugins.tar.' _ c('compress_tar'),
    
    371 393
         }) %]
    
    372 394
     [% END -%]
    
    373 395
     
    
    374 396
     [% IF c("var/build_infos_json") -%]
    
    375
    -  cat > "[% dest_dir _ '/' _ c('filename') _ '/build-infos.json' %]" << EOF_BUILDINFOS
    
    397
    +  cat > "[% out_dir _ '/build-infos.json' %]" << EOF_BUILDINFOS
    
    376 398
       {
    
    377 399
           "firefox_platform_version" : "[% c("var/firefox_platform_version") %]",
    
    378 400
           "firefox_buildid" : "$MOZ_BUILD_DATE"