-
Notifications
You must be signed in to change notification settings - Fork 404
feat(updater): support bundle-specific targets #2624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2
Are you sure you want to change the base?
Conversation
…gins-workspace into feature/fallback_targets
…gins-workspace into feature/fallback_targets # Conflicts: # plugins/updater/tests/app-updater/tests/update.rs
…gins-workspace into feature/fallback_targets
…gins-workspace into feature/fallback_targets
…ature/fallback_targets
Package Changes Through 5b4c1c1There are 2 changes which include deep-link with patch, deep-link-js with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Windows and Linux tests are failing because they require tauri-cli with tauri-apps/tauri#13209 change. MacOS test is failing because of some compliation issue. I will have access to a mac next week so I will fix it. |
It looks like you ran |
plugins/updater/src/lib.rs
Outdated
/// patching during build | ||
#[unsafe(no_mangle)] | ||
#[link_section = ".data.ta"] | ||
pub static __TAURI_BUNDLE_TYPE: &str = "UNK_BUNDLE"; |
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.
hmm, if possible it may make sense to move that into the main tauri crate (or utils idk) because a few people asked for this in the past regardless of the updater
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.
I had it in the main tauri crate originally but build (cargo test
) was failing during linking. I will try to move it to utils.
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.
ah yeah i remember you mentioning this
plugins/updater/src/updater.rs
Outdated
@@ -342,11 +383,21 @@ pub struct Updater { | |||
} | |||
|
|||
impl Updater { | |||
fn get_updater_installer(&self) -> Result<Option<Installer>> { | |||
match __TAURI_BUNDLE_TYPE { |
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.
__TAURI_BUNDLE_TYPE
shouldn't be exported from Tauri, but we should map it to a PackageFormat
type directly from tauri instead of doing the check here, it would make it type safe (instead of relying on string matching from tauri-cli)
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.
What do we want to do for Mac, iOS and Android? Or in general case when the binary was not patched and we don't know the bundle type? I think the simplest thing to do would be to return PackageFormat::Unknown in case the binary was not patched and use #[cfg(target_os = "macos")]
to return PackageFormat::Dmg for Mac.
We have BundleType in tauri::utils::config but if we want to return Unknown I would have to create new type. What would be the best place to put it? tauri::utils::config? some new module?
@@ -39,3 +39,6 @@ codegen-units = 1 | |||
lto = true | |||
incremental = false | |||
opt-level = "s" | |||
|
|||
[patch.crates-io] | |||
tauri = { git = "https://github.com/tauri-apps/tauri", rev = "232265c70e1c213bbb3f84b5541ddc07d330fce1" } |
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.
we must not forget to configure the minimum version once tauri was released. sadly we can't set a min cli version.
…gins-workspace into feature/fallback_targets
Signed-off-by: Krzysztof Andrelczyk <cristof@curiana.net>
fallback targets
@@ -48,7 +49,7 @@ struct Update { | |||
fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTarget) { | |||
let mut command = Command::new("cargo"); | |||
command | |||
.args(["tauri", "build", "--debug", "--verbose"]) | |||
.args(["tauri", "build", "--verbose"]) |
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.
Since we had issues with the bundle type variable being stripped in release mode but not in debug mode I changed this. We test this in tauri crate as well but not we only have a warning there, not an error. The test will take longer but it may catch some issues that otherwise would slip through. What do you think?
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.
Good idea to me
Ok, I've updated tauri version for updater plugin to 2.7 and the tests now pass with latest tauri-cli. Anything missing here? |
/// Neither the platform not the fallback platform was not found in the updater JSON response. | ||
#[error("the platform `{0}` and `{1}` were not found in the response `platforms` object")] | ||
TargetsNotFound(String, String), |
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.
The error message reads like both are required to be present. But it's either, right?
let mut download_url = release.download_url(&self.json_target); | ||
let mut signature = release.signature(&self.json_target); | ||
|
||
let installer = self.get_updater_installer(); | ||
if installer.is_none() && (download_url.is_err() || signature.is_err()) { | ||
return Err(Error::TargetNotFound(self.json_target.clone())); | ||
} |
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.
Because the updater is getting additional logic and decisions, can we add a few logs about those decisions?
download_url: download_url?.to_owned(), | ||
body: release.notes.clone(), | ||
signature: signature?.to_owned(), | ||
installer, |
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.
It looks like the installer would return Some
even when the corresponding entry does not get used for it's download_url or signature.
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.
I believe this is correct. We use this information later in install_inner
to determine installation method. So for example if the current binary was packaged as Deb but we didn't find specific download_url for deb and used the fallback we still assume that it points to deb package and will try to install it as deb. If we know the current binary was packaged as deb it doesn't make sense to try to install the update as AppImage. Only in case we don't know what the current bundle type is will we fallback to AppImage.
download_url = | ||
release | ||
.download_url(target) | ||
.or(download_url.or(Err(Error::TargetsNotFound( | ||
self.json_target.clone(), | ||
target.clone(), | ||
)))); | ||
signature = release | ||
.signature(target) | ||
.or(signature.or(Err(Error::TargetsNotFound( | ||
self.json_target.clone(), | ||
target.clone(), | ||
)))); |
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.
You can't fall back separately for the download URL and signature.
Either we select one target's signature + url, or the other.
Currently if the target download URL exists, but the signature is missing, it will use the wrong signature.
Here are the changes for updater to handle #2277
I'm using the patched __TAURI_BUNDLE_TYPE variable to download the proper installer with fallback as described in #2277.
I've added some additional test on both Linux and Windows. Not sure if something needs to be done on other platforms.