Skip to content

Commit

Permalink
Improve installation on BSD
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Dec 16, 2023
1 parent 6e8110d commit baa4240
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
8 changes: 3 additions & 5 deletions extension/src/setup/instructions.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@

<div class="tab-pane fade" id="source-install-pane" role="tabpanel" aria-labelledby="source-install-tab">
<ol>
<li>Make sure <a href="https://github.com/sagiegurari/cargo-make" target="_blank"><kbd>cargo-make</kbd></a> and (on Windows) <a href="https://wixtoolset.org/releases/" target="_blank">WiX Toolset</a> are installed.</li>
<li>Make sure <a href="https://github.com/sagiegurari/cargo-make" target="_blank"><kbd>cargo-make</kbd></a> is installed and up to date.</li>
<li id="connector-source-install-wix">Make sure <a href="https://wixtoolset.org/docs/wix3/" target="_blank">WiX Toolset v3</a> is installed (Windows-only).</li>
<li>Clone the <a href="https://github.com/filips123/PWAsForFirefox" target="_blank">repository</a> and <kbd>cd</kbd> into the <kbd>native</kbd> directory.</li>
<li>Checkout the <kbd class="connector-repository-tag"></kbd> tag.</li>
<li>Prepare the source code for building: <kbd>makers set-version</kbd></li>
Expand All @@ -169,10 +170,7 @@
</div>

<div class="tab-pane fade" id="bsd-install-pane" role="tabpanel" aria-labelledby="bsd-install-tab">
<p>
To install the project on BSD, please follow the instructions from the source installation section.
However, before running <kbd>makers</kbd>, make sure to replace <kbd>/usr/</kbd> with <kbd>/usr/local/</kbd> inside <kbd>Makefile.toml</kbd>'s <kbd>[tasks.install.linux]</kbd> section.
</p>
<p>To install the project on BSD, please follow the instructions from the source installation section.</p>
<p><strong>Warning:</strong> Support for BSD relies on XDG Desktop Entry Specification (made for Linux) and is not regularly tested.</p>
</div>

Expand Down
45 changes: 38 additions & 7 deletions native/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,31 @@ args = ["build", "--release"]

### INSTALLERS ###

[tasks.install.windows]
[tasks.install]
description = "Install the project"
run_task = [
{ name = "install-windows", condition = { os = ["windows"] } },
{ name = "install-linux", condition = { os = ["linux"] } },
{ name = "install-macos", condition = { os = ["macos"] } },
{ name = "install-bsd", condition = { os = ["dragonfly", "freebsd", "openbsd", "netbsd"] } },
{ name = "install-unknown" }
]

[tasks.install-windows]
dependencies = ["build"]
private = true
install_script = [
"heat >nul 2>nul || echo FATAL: Make sure the WiX Toolset is installed and available in the PATH environment variable && exit 1",
"heat >nul 2>nul || echo FATAL: Make sure the WiX Toolset v3 is installed and available in the PATH environment variable && exit 1",
"cargo-wix help >nul 2>nul || cargo install cargo-wix --git https://github.com/volks73/cargo-wix.git --rev 032be8310f9aa9684e9524db54632792a9d85e28",
]
script = [
"heat dir userchrome -o packages/wix/userchrome.wxs -scom -srd -sreg -gg -cg UserChrome -dr UserChromeDir -var wix.UserChromeSource",
"cargo wix --verbose --no-build --nocapture --install"
]

[tasks.install.linux]
[tasks.install-linux]
dependencies = ["build"]
private = true
script = """
# Use sudo if it exists
SUDO=$(which sudo) || $(echo "")
Expand All @@ -40,8 +52,9 @@ $SUDO mkdir -p /usr/share/firefoxpwa/userchrome/
$SUDO cp -R userchrome/* /usr/share/firefoxpwa/userchrome/
"""

[tasks.install.mac]
[tasks.install-macos]
dependencies = ["build"]
private = true
script = """
# Use sudo if it exists
SUDO=$(which sudo) || $(echo "")
Expand All @@ -64,8 +77,26 @@ $SUDO mkdir -p /usr/local/share/firefoxpwa/userchrome/
$SUDO cp -R userchrome/* /usr/local/share/firefoxpwa/userchrome/
"""

[tasks.install]
description = "Install the project"
[tasks.install-bsd]
dependencies = ["build"]
private = true
script = """
# Use sudo if it exists
SUDO=$(which sudo) || $(echo "")
# Copy all files to the correct locations
$SUDO install -D target/release/firefoxpwa /usr/local/bin/firefoxpwa
$SUDO install -D target/release/firefoxpwa-connector /usr/local/libexec/firefoxpwa-connector
$SUDO install -D manifests/bsd.json /usr/local/lib/mozilla/native-messaging-hosts/firefoxpwa.json
$SUDO install -D manifests/bsd.json /usr/local/lib64/mozilla/native-messaging-hosts/firefoxpwa.json
# Copy the userchrome directory to the correct location
$SUDO mkdir -p /usr/local/share/firefoxpwa/userchrome/
$SUDO cp -R userchrome/* /usr/local/share/firefoxpwa/userchrome/
"""

[tasks.install-unknown]
private = true
script = [
"echo FATAL: This environment does not support automatic installation using cargo-make",
"exit 1"
Expand All @@ -75,5 +106,5 @@ script = [

[tasks.set-version]
description = "Set the version to a given version or the current Git tag"
script_runner="@duckscript"
script_runner = "@duckscript"
script = "!include_files ./scripts/set-version.ds"
2 changes: 1 addition & 1 deletion native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ First, you will need make sure you have the following tools installed:
* Git
* Rust
* [`cargo-make`](https://github.com/sagiegurari/cargo-make)
* Windows-only: [WiX Toolset](https://wixtoolset.org/releases/)
* Windows-only: [WiX Toolset v3](https://wixtoolset.org/docs/wix3/)

You can then run the following commands to build and install it using `cargo-make`:

Expand Down
9 changes: 9 additions & 0 deletions native/manifests/bsd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "firefoxpwa",
"description": "The native part of the PWAsForFirefox project",
"path": "/usr/local/libexec/firefoxpwa-connector",
"type": "stdio",
"allowed_extensions": [
"[email protected]"
]
}

0 comments on commit baa4240

Please sign in to comment.