Skip to content

Commit

Permalink
refactor: remove bootstrapper, closes #3786 (#3832)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Mar 31, 2022
1 parent 985d250 commit 6a5ff08
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 249 deletions.
6 changes: 6 additions & 0 deletions .changes/remove-bootstrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-bundler": patch
"tauri-utils": patch
---

**Breaking change:** Removed the `useBootstrapper` option. Use https://github.com/tauri-apps/fix-path-env-rs instead.
7 changes: 0 additions & 7 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ impl BundleTarget {
pub struct DebConfig {
/// The list of deb dependencies your application relies on.
pub depends: Option<Vec<String>>,
/// Enable the boostrapper script.
#[serde(default)]
pub use_bootstrapper: bool,
/// The files to include on the package.
#[serde(default)]
pub files: HashMap<PathBuf, PathBuf>,
Expand Down Expand Up @@ -136,9 +133,6 @@ pub struct MacConfig {
pub exception_domain: Option<String>,
/// The path to the license file to add to the DMG bundle.
pub license: Option<String>,
/// Enable the boostrapper script.
#[serde(default)]
pub use_bootstrapper: bool,
/// Identity to use for code signing.
pub signing_identity: Option<String>,
/// Provider short name for notarization.
Expand All @@ -154,7 +148,6 @@ impl Default for MacConfig {
minimum_system_version: minimum_system_version(),
exception_domain: None,
license: None,
use_bootstrapper: false,
signing_identity: None,
provider_short_name: None,
entitlements: None,
Expand Down
4 changes: 1 addition & 3 deletions examples/commands/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/helloworld/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/isolation/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": "",
"signingIdentity": null,
"entitlements": null
Expand Down
4 changes: 1 addition & 3 deletions examples/navigation/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/resources/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/sidecar/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/state/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/streaming/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/tauri-dynamic-lib/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions examples/updater/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"signingIdentity": null,
"entitlements": "../entitlements.plist",
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
},
"windows": {
Expand Down
4 changes: 1 addition & 3 deletions tooling/bench/tests/cpu_intensive/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions tooling/bench/tests/files_transfer/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
4 changes: 1 addition & 3 deletions tooling/bench/tests/helloworld/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
"depends": []
},
"macOS": {
"frameworks": [],
"useBootstrapper": false,
"exceptionDomain": ""
}
},
Expand Down
8 changes: 2 additions & 6 deletions tooling/bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ These settings are used only when bundling `deb` packages.
* `depends`: A list of strings indicating other packages (e.g. shared
libraries) that this package depends on to be installed. If present, this
forms the `Depends:` field of the `deb` package control file.
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.

### Mac OS X-specific settings

Expand All @@ -75,7 +74,6 @@ These settings are used only when bundling `app` and `dmg` packages.
you want) to ensure that the compiled binary has the same minimum version.
* `license`: Path to the license file for the DMG bundle.
* `exception_domain`: The exception domain to use on the macOS .app bundle. Allows communication to the outside world e.g. a web server you're shipping.
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.
* `provider_short_name`: If your Apple ID is connected to multiple teams, you have to specify the provider short name of the team you want to use to notarize your app. See [Customizing the notarization workflow](https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow) and search for `--list-providers` for more information how to obtain your provider short name.

### Example `tauri.conf.json`:
Expand All @@ -102,14 +100,12 @@ These settings are used only when bundling `app` and `dmg` packages.
],
"resources": ["./assets/**/*.png"],
"deb": {
"depends": ["debian-dependency1", "debian-dependency2"],
"useBootstrapper": true
"depends": ["debian-dependency1", "debian-dependency2"]
},
"macOS": {
"frameworks": [],
"minimumSystemVersion": "10.11",
"license": "./LICENSE",
"useBootstrapper": true
"license": "./LICENSE"
},
"externalBin": ["./sidecar-app"]
}
Expand Down
83 changes: 1 addition & 82 deletions tooling/bundler/src/bundle/linux/debian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use anyhow::Context;
use heck::ToKebabCase;
use image::{self, codecs::png::PngDecoder, GenericImageView, ImageDecoder};
use libflate::gzip;
use std::process::{Command, Stdio};
use walkdir::WalkDir;

use std::{
Expand Down Expand Up @@ -128,80 +127,9 @@ pub fn generate_data(
generate_icon_files(settings, &data_dir).with_context(|| "Failed to create icon files")?;
generate_desktop_file(settings, &data_dir).with_context(|| "Failed to create desktop file")?;

let use_bootstrapper = settings.deb().use_bootstrapper.unwrap_or_default();
if use_bootstrapper {
generate_bootstrap_file(settings, &data_dir)
.with_context(|| "Failed to generate bootstrap file")?;
}

Ok((data_dir, icons))
}

/// Generates the bootstrap script file.
fn generate_bootstrap_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
let bin_name = settings.main_binary_name();
let bin_dir = data_dir.join("usr/bin");

let bootstrap_file_name = format!("__{}-bootstrapper", bin_name);
let bootstrapper_file_path = bin_dir.join(bootstrap_file_name.clone());
let bootstrapper_file = &mut common::create_file(&bootstrapper_file_path)?;
write!(
bootstrapper_file,
"#!/usr/bin/env sh
# This bootstraps the environment for Tauri, so environments are available.
export NVM_DIR=\"$([ -z \"${{XDG_CONFIG_HOME-}}\" ] && printf %s \"${{HOME}}/.nvm\" || printf %s \"${{XDG_CONFIG_HOME}}/nvm\")\"
[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"
if [ -e ~/.bash_profile ]
then
source ~/.bash_profile
fi
if [ -e ~/.zprofile ]
then
source ~/.zprofile
fi
if [ -e ~/.profile ]
then
source ~/.profile
fi
if [ -e ~/.bashrc ]
then
source ~/.bashrc
fi
if [ -e ~/.zshrc ]
then
source ~/.zshrc
fi
echo $PATH
source /etc/profile
if pidof -x \"{}\" >/dev/null; then
exit 0
else
Exec=/usr/bin/env /usr/bin/{} $@ & disown
fi
exit 0",
bootstrap_file_name, bin_name
)?;
bootstrapper_file.flush()?;

let status = Command::new("chmod")
.arg("+x")
.arg(bootstrap_file_name)
.current_dir(&bin_dir)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.status()?;

if !status.success() {
return Err(anyhow::anyhow!("failed to make the bootstrapper an executable",).into());
}

Ok(())
}

/// Generate the application desktop file and store it under the `data_dir`.
fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
let bin_name = settings.main_binary_name();
Expand All @@ -221,16 +149,7 @@ fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<
if !settings.short_description().is_empty() {
writeln!(file, "Comment={}", settings.short_description())?;
}
let use_bootstrapper = settings.deb().use_bootstrapper.unwrap_or_default();
writeln!(
file,
"Exec={}",
if use_bootstrapper {
format!("__{}-bootstrapper", bin_name)
} else {
bin_name.to_string()
}
)?;
writeln!(file, "Exec={}", bin_name)?;
writeln!(file, "Icon={}", bin_name)?;
writeln!(file, "Name={}", settings.product_name())?;
writeln!(file, "Terminal=false")?;
Expand Down
Loading

0 comments on commit 6a5ff08

Please sign in to comment.