This repository was archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Make bundled tsh available outside of Connect #1445
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
34444ca
Rename assets to build_resources
ravicious 86c8bf2
Add resources\bin to Path during installation on Windows
ravicious 69cf815
Adjust docs related to USE_SYSTEM_FPM
ravicious c054254
Create symlink to bundled tsh on Linux targets
ravicious 324a842
after-install: Get rid of old symlink removal
ravicious 9132ab8
Expand story for QuickInput
ravicious 4459f9e
Make command suggestions stay in place
ravicious 18cf0ee
Align suggestion icons to the top rather than center
ravicious bef40b0
Add install & uninstall cmds to command bar
ravicious c331e62
Exclude new commands from OSes other than macOS
ravicious aecddd1
Implement commands for symlinking tsh
ravicious f065523
Add macos suffix to symlink IPC handlers
ravicious 5d6e4f9
Refactor QuickInput story into two separate stories
ravicious d3ed0c3
Use assertUnreachable
ravicious 49804dc
Refactor autocomplete commands
ravicious 2daafe9
Add MacOs suffix to MainProcessClient methods
ravicious b4500d5
Merge branch 'master' into ravicious/link-tsh
ravicious File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| This is the directory we use as the `buildResources` dir for electron-builder. | ||
|
|
||
| By default, electron-builder uses the `build` dir at the project root. However, we already use that | ||
| directory for webpack output. | ||
|
|
||
| If you see a path in electron-builder docs referring to `build`, you can assume that they meant the | ||
| `buildResources` directory. |
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # https://github.com/electron-userland/electron-builder/blob/v24.0.0-alpha.5/docs/configuration/nsis.md#custom-nsis-script | ||
|
|
||
| # electron-builder adds `BUILD_RESOURCES_DIR\x86-unicode` as a plugin dir. | ||
| # But that dir name isn't very descriptive, so we add a custom plugin dir. | ||
| !addplugindir "${BUILD_RESOURCES_DIR}\nsis-plugins" | ||
|
|
||
| # The EnVar plugin is recommended for env var modification as EnvVarUpdate doesn't handle long | ||
| # strings very well. | ||
| # https://nsis.sourceforge.io/Environmental_Variables:_append,_prepend,_and_remove_entries | ||
| # https://nsis.sourceforge.io/EnVar_plug-in | ||
|
|
||
| !macro customInstall | ||
| # Make EnVar define user env vars instead of system env vars. | ||
| EnVar::SetHKCU | ||
| EnVar::AddValue "Path" $INSTDIR\resources\bin | ||
| !macroend | ||
|
|
||
| !macro customUnInstall | ||
| EnVar::SetHKCU | ||
| # Inside the uninstaller, $INSTDIR is the directory where the uninstaller lies. | ||
| # Fortunately, electron-builder puts the uninstaller directly into the actual installation dir. | ||
| # https://nsis.sourceforge.io/Docs/Chapter4.html#varother | ||
| EnVar::DeleteValue "Path" $INSTDIR\resources\bin | ||
| !macroend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ## Differences between deb & RPM scripts | ||
|
|
||
| During an upgrade of a deb package from one version to another, the following steps happen: | ||
|
|
||
| 1. The new version is unpacked, with the new files overwriting the old files. | ||
| 2. The after-remove of the old version is called. | ||
| 3. The old files are removed. | ||
| 4. The after-install of the new version is called. | ||
|
|
||
| See: | ||
|
|
||
| - [Debian Policy Manual: Upgrading a package](https://www.debian.org/doc/debian-policy/ap-flowcharts.html#id5). | ||
| - [Debian Policy Manual: Details of unpack phase of installation or | ||
| upgrade](https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-unpack-phase-of-installation-or-upgrade) | ||
|
|
||
| However, when you upgrade an RPM package, the scriptlets are called in a reverse order: | ||
|
|
||
| 1. The new version is unpacked, with the new files overwriting the old files. | ||
| 2. The after-install of the new version is called. | ||
| 3. The old files are removed. | ||
| 4. The after-remove of the old version is called. | ||
|
|
||
| See [Fedora Docs: Scriptlets - Ordering](https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering). | ||
|
|
||
| This has direct consequences when attempting to use the same scripts for both targets. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
|
|
||
| ### | ||
| # Default after-install.tpl copied from electron-builder. | ||
| # https://github.com/electron-userland/electron-builder/blob/v24.0.0-alpha.5/packages/app-builder-lib/templates/linux/after-install.tpl | ||
| ### | ||
|
|
||
| # SUID chrome-sandbox for Electron 5+ | ||
| chmod 4755 "/opt/${sanitizedProductName}/chrome-sandbox" || true | ||
|
|
||
| update-mime-database /usr/share/mime || true | ||
| update-desktop-database /usr/share/applications || true | ||
|
|
||
| ### | ||
| # Custom after-install.tpl script. | ||
| ### | ||
|
|
||
| APP="/opt/${sanitizedProductName}" | ||
| BIN=/usr/local/bin | ||
| TSH_SYMLINK_SOURCE=$APP/resources/bin/tsh | ||
| TSH_SYMLINK_TARGET=$BIN/tsh | ||
|
|
||
| # Create $BIN if it doesn't exist. | ||
| [ ! -d "$BIN" ] && mkdir -p "$BIN" | ||
|
|
||
| # Link to the Electron app binary. | ||
| ln -sf "$APP/${executable}" "$BIN/${executable}" | ||
|
|
||
| # Link to the bundled tsh if the symlink doesn't exist already. Otherwise echo a message unless the | ||
| # link points to teleport-connect's tsh already. | ||
| # Does TSH_SYMLINK_TARGET not exist? | ||
| if [ ! -e "$TSH_SYMLINK_TARGET" ]; then | ||
| ln -s "$TSH_SYMLINK_SOURCE" "$TSH_SYMLINK_TARGET" | ||
| else | ||
| message="${executable}: Skipping symlinking $TSH_SYMLINK_TARGET to $TSH_SYMLINK_SOURCE" | ||
|
|
||
| # Is TSH_SYMLINK_TARGET a symlink? | ||
| if [ -L "$TSH_SYMLINK_TARGET" ]; then | ||
| # Does TSH_SYMLINK_TARGET point at something else than TSH_SYMLINK_SOURCE? | ||
| # If TSH_SYMLINK_TARGET exists and it points at TSH_SYMLINK_SOURCE already, don't do anything. | ||
| if [ ! "$TSH_SYMLINK_TARGET" -ef "$TSH_SYMLINK_SOURCE" ]; then | ||
| message+=" because the symlink already exists and it points to $(realpath $TSH_SYMLINK_TARGET)." | ||
| echo "$message" | ||
| fi | ||
| else | ||
| message+=" because $TSH_SYMLINK_TARGET already exists and it isn't a symlink." | ||
| echo "$message" | ||
| fi | ||
| fi | ||
|
|
||
| # vim: syntax=sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
|
|
||
| # Do not touch symlinks if the package is being upgraded. | ||
| # | ||
| # Why? | ||
| # | ||
| # During an upgrade, RPM packages call after-install of new version first followed by after-remove | ||
| # of the old version. deb packages do this in reverse order. See README.md in this directory for | ||
| # more details. | ||
| # | ||
| # So, for RPM packages we should not remove the symlinks if the package is being upgraded, otherwise | ||
| # the user would end up with no symlinks after an upgrade. | ||
| # | ||
| # How? | ||
| # | ||
| # Both deb and RPM pass arguments to the scripts. rpm passes the number of packages of the given | ||
| # name which will be left on the system when the action completes. deb passes "upgrade" during an | ||
| # upgrade. We can check those args to determine if the package is being upgraded or removed. | ||
| # | ||
| # https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#details-of-unpack-phase-of-installation-or-upgrade | ||
| # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax | ||
| # | ||
| # Is the first argument "upgrade" or "1"? | ||
| if [ "$1" = "upgrade" ] || [ "$1" = "1" ]; then | ||
| echo "${executable}: Upgrade detected, skipping symlink operations" | ||
| exit 0 | ||
| fi | ||
|
|
||
| BIN=/usr/local/bin | ||
| TSH_SYMLINK_TARGET=$BIN/tsh | ||
|
|
||
| # Remove the link to the Electron app binary. | ||
| rm -f "$BIN/${executable}" | ||
|
|
||
| # At this point, the app has already been removed from disk. If TSH_SYMLINK_TARGET used to point at | ||
| # tsh bundled with the teleport-connect package, it is a broken symlink now. | ||
| # | ||
| # Is TSH_SYMLINK_TARGET a link that points at a file which doesn't exist? | ||
| if [ -L "$TSH_SYMLINK_TARGET" ] && [ ! -e "$TSH_SYMLINK_TARGET" ]; then | ||
| rm -f "$TSH_SYMLINK_TARGET" | ||
| fi | ||
|
Comment on lines
+39
to
+42
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RFD says:
Here I've decided to not echo a message if Connect doesn't remove the symlink. Idk, it doesn't seem like a necessary thing to me and we already emit a message regarding symlinks during installation. I'm not even sure if I should emit a message during an upgrade. But I wanted to be able to tell what happened if someone sends logs from an upgrade. OTOH I don't think Linux packages echo stuff from within those scripts? |
||
|
|
||
| # vim: syntax=sh | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| By default, electron-builder adds `${buildResources}\x86-unicode` as the plugin dir. But that name | ||
| is not really that descriptive, so we put the plugins under nsis-plugins. | ||
|
|
||
| When you download a plugin, its `Plugins` folder is likely to contain .dlls for different | ||
| architectures and encodings such as amd64-unicode, x86-ansi, x86-unicode. You should use the .dlls | ||
| from the `x86-unicode` dir. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm just following what tsh.pkg does already.