diff options
| -rw-r--r-- | Cargo.lock | 5 | ||||
| -rw-r--r-- | mullvad-cli/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-cli/build.rs | 8 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/beta_program.rs | 4 | ||||
| -rw-r--r-- | mullvad-cli/src/main.rs | 3 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/build.rs | 5 | ||||
| -rw-r--r-- | mullvad-daemon/src/cli.rs | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/version.rs | 7 | ||||
| -rw-r--r-- | mullvad-daemon/src/version_check.rs | 19 | ||||
| -rw-r--r-- | mullvad-problem-report/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-problem-report/build.rs | 9 | ||||
| -rw-r--r-- | mullvad-problem-report/src/main.rs | 4 | ||||
| -rw-r--r-- | mullvad-problem-report/src/metadata.rs | 4 | ||||
| -rw-r--r-- | mullvad-setup/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad-setup/build.rs | 7 | ||||
| -rw-r--r-- | mullvad-setup/src/main.rs | 6 | ||||
| -rw-r--r-- | talpid-openvpn-plugin/Cargo.toml | 1 | ||||
| -rw-r--r-- | talpid-openvpn-plugin/build.rs | 3 | ||||
| -rwxr-xr-x | version-metadata.sh | 28 |
21 files changed, 37 insertions, 89 deletions
diff --git a/Cargo.lock b/Cargo.lock index f060301543..77a447ec8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1606,6 +1606,7 @@ dependencies = [ "mullvad-management-interface", "mullvad-paths", "mullvad-types", + "mullvad-version", "natord", "serde", "talpid-types", @@ -1639,6 +1640,7 @@ dependencies = [ "mullvad-paths", "mullvad-relay-selector", "mullvad-types", + "mullvad-version", "nix 0.23.1", "parking_lot 0.11.2", "rand 0.8.5", @@ -1736,6 +1738,7 @@ dependencies = [ "log", "mullvad-api", "mullvad-paths", + "mullvad-version", "regex", "talpid-platform-metadata", "talpid-types", @@ -1780,6 +1783,7 @@ dependencies = [ "mullvad-management-interface", "mullvad-paths", "mullvad-types", + "mullvad-version", "talpid-core", "talpid-types", "tokio", @@ -3184,6 +3188,7 @@ dependencies = [ "env_logger 0.8.4", "err-derive", "log", + "mullvad-version", "openvpn-plugin", "parity-tokio-ipc", "prost", diff --git a/mullvad-cli/Cargo.toml b/mullvad-cli/Cargo.toml index 7f0deefb9f..b82e675ad6 100644 --- a/mullvad-cli/Cargo.toml +++ b/mullvad-cli/Cargo.toml @@ -24,6 +24,7 @@ itertools = "0.10" mullvad-types = { path = "../mullvad-types" } mullvad-paths = { path = "../mullvad-paths" } +mullvad-version = { path = "../mullvad-version" } talpid-types = { path = "../talpid-types" } mullvad-management-interface = { path = "../mullvad-management-interface" } @@ -34,6 +35,7 @@ clap_complete = { version = "3.0" } [target.'cfg(windows)'.build-dependencies] winres = "0.1" +mullvad-version = { path = "../mullvad-version" } [target.'cfg(windows)'.build-dependencies.windows-sys] version = "0.42.0" diff --git a/mullvad-cli/build.rs b/mullvad-cli/build.rs index b2cc9c3d9a..de110d3a76 100644 --- a/mullvad-cli/build.rs +++ b/mullvad-cli/build.rs @@ -1,19 +1,13 @@ -use std::{env, fs, path::PathBuf}; - #[cfg(windows)] fn make_lang_id(p: u16, s: u16) -> u16 { (s << 10) | p } fn main() { - let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); - fs::write(out_dir.join("product-version.txt"), &product_version).unwrap(); - #[cfg(windows)] { let mut res = winres::WindowsResource::new(); - res.set("ProductVersion", &product_version); + res.set("ProductVersion", mullvad_version::VERSION); res.set_icon("../dist-assets/icon.ico"); res.set_language(make_lang_id( windows_sys::Win32::System::SystemServices::LANG_ENGLISH as u16, diff --git a/mullvad-cli/src/cmds/beta_program.rs b/mullvad-cli/src/cmds/beta_program.rs index 8f659ec9b9..3fdcdb30f4 100644 --- a/mullvad-cli/src/cmds/beta_program.rs +++ b/mullvad-cli/src/cmds/beta_program.rs @@ -1,4 +1,4 @@ -use crate::{new_rpc_client, Command, Error, Result, PRODUCT_VERSION}; +use crate::{new_rpc_client, Command, Error, Result}; pub struct BetaProgram; @@ -41,7 +41,7 @@ impl Command for BetaProgram { let enable_str = matches.value_of("policy").expect("missing policy"); let enable = enable_str == "on"; - if !enable && PRODUCT_VERSION.contains("beta") { + if !enable && mullvad_version::VERSION.contains("beta") { return Err(Error::InvalidCommand( "The beta program must be enabled while running a beta version", )); diff --git a/mullvad-cli/src/main.rs b/mullvad-cli/src/main.rs index df7ef0a04c..39479d4054 100644 --- a/mullvad-cli/src/main.rs +++ b/mullvad-cli/src/main.rs @@ -15,7 +15,6 @@ mod location; mod state; pub const BIN_NAME: &str = "mullvad"; -pub const PRODUCT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")); pub type Result<T> = std::result::Result<T, Error>; @@ -132,7 +131,7 @@ async fn run() -> Result<()> { fn build_cli(commands: &HashMap<&'static str, Box<dyn Command>>) -> clap::App<'static> { clap::App::new(BIN_NAME) - .version(PRODUCT_VERSION) + .version(mullvad_version::VERSION) .author(crate_authors!()) .about(crate_description!()) .setting(clap::AppSettings::SubcommandRequiredElseHelp) diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index e4c90591ba..5069a38f2a 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -33,6 +33,7 @@ mullvad-paths = { path = "../mullvad-paths" } mullvad-relay-selector = { path = "../mullvad-relay-selector" } mullvad-types = { path = "../mullvad-types" } mullvad-api = { path = "../mullvad-api" } +mullvad-version = { path = "../mullvad-version" } talpid-core = { path = "../talpid-core" } talpid-dbus = { path = "../talpid-dbus" } talpid-types = { path = "../talpid-types" } @@ -71,6 +72,7 @@ features = [ [target.'cfg(windows)'.build-dependencies] winres = "0.1" +mullvad-version = { path = "../mullvad-version" } [target.'cfg(windows)'.build-dependencies.windows-sys] version = "0.42.0" diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs index a0d50577e7..ef84845f74 100644 --- a/mullvad-daemon/build.rs +++ b/mullvad-daemon/build.rs @@ -7,15 +7,12 @@ fn make_lang_id(p: u16, s: u16) -> u16 { fn main() { let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - - let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); - fs::write(out_dir.join("product-version.txt"), &product_version).unwrap(); fs::write(out_dir.join("git-commit-date.txt"), commit_date()).unwrap(); #[cfg(windows)] { let mut res = winres::WindowsResource::new(); - res.set("ProductVersion", &product_version); + res.set("ProductVersion", mullvad_version::VERSION); res.set_icon("../dist-assets/icon.ico"); res.set_language(make_lang_id( windows_sys::Win32::System::SystemServices::LANG_ENGLISH as u16, diff --git a/mullvad-daemon/src/cli.rs b/mullvad-daemon/src/cli.rs index 22adf4427c..09412f4196 100644 --- a/mullvad-daemon/src/cli.rs +++ b/mullvad-daemon/src/cli.rs @@ -1,7 +1,5 @@ use clap::{crate_authors, crate_description, crate_name, App, Arg}; -use crate::version; - #[derive(Debug)] pub struct Config { pub log_level: log::LevelFilter, @@ -72,7 +70,7 @@ lazy_static::lazy_static! { fn create_app() -> App<'static> { let mut app = App::new(crate_name!()) - .version(version::PRODUCT_VERSION) + .version(mullvad_version::VERSION) .author(crate_authors!(", ")) .about(crate_description!()) .after_help(ENV_DESC.as_str()) diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 959e3222da..4f22c7244c 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1498,7 +1498,7 @@ where fn on_get_current_version(&mut self, tx: oneshot::Sender<AppVersion>) { Self::oneshot_send( tx, - version::PRODUCT_VERSION.to_owned(), + mullvad_version::VERSION.to_owned(), "get_current_version response", ); } diff --git a/mullvad-daemon/src/version.rs b/mullvad-daemon/src/version.rs index b80ea9d03e..19e6dfa134 100644 --- a/mullvad-daemon/src/version.rs +++ b/mullvad-daemon/src/version.rs @@ -1,18 +1,15 @@ -/// A string that identifies the current version of the application -pub const PRODUCT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")); - /// Contains the date of the git commit this was built from pub const COMMIT_DATE: &str = include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.txt")); pub fn is_beta_version() -> bool { - PRODUCT_VERSION.contains("beta") + mullvad_version::VERSION.contains("beta") } pub fn log_version() { log::info!( "Starting {} - {} {}", env!("CARGO_PKG_NAME"), - PRODUCT_VERSION, + mullvad_version::VERSION, COMMIT_DATE, ) } diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs index 4afa7ab44b..4c0271729b 100644 --- a/mullvad-daemon/src/version_check.rs +++ b/mullvad-daemon/src/version_check.rs @@ -1,7 +1,4 @@ -use crate::{ - version::{is_beta_version, PRODUCT_VERSION}, - DaemonEventSender, -}; +use crate::{version::is_beta_version, DaemonEventSender}; use futures::{ channel::{mpsc, oneshot}, stream::FusedStream, @@ -24,7 +21,7 @@ use tokio::fs::{self, File}; const VERSION_INFO_FILENAME: &str = "version-info.json"; lazy_static::lazy_static! { - static ref APP_VERSION: ParsedAppVersion = ParsedAppVersion::from_str(PRODUCT_VERSION).unwrap(); + static ref APP_VERSION: ParsedAppVersion = ParsedAppVersion::from_str(mullvad_version::VERSION).unwrap(); static ref IS_DEV_BUILD: bool = APP_VERSION.is_dev(); } @@ -58,7 +55,7 @@ impl From<AppVersionInfo> for CachedAppVersionInfo { fn from(version_info: AppVersionInfo) -> CachedAppVersionInfo { CachedAppVersionInfo { version_info, - cached_from_version: PRODUCT_VERSION.to_owned(), + cached_from_version: mullvad_version::VERSION.to_owned(), } } } @@ -190,7 +187,7 @@ impl VersionUpdater { let download_future_factory = move || { version_proxy .version_check( - PRODUCT_VERSION.to_owned(), + mullvad_version::VERSION.to_owned(), PLATFORM, platform_version.clone(), ) @@ -228,7 +225,7 @@ impl VersionUpdater { let download_future_factory = move || { let when_available = api_handle.wait_background(); let request = version_proxy.version_check( - PRODUCT_VERSION.to_owned(), + mullvad_version::VERSION.to_owned(), PLATFORM, platform_version.clone(), ); @@ -450,7 +447,7 @@ async fn try_load_cache(cache_dir: &Path) -> Result<AppVersionInfo, Error> { let version_info: CachedAppVersionInfo = serde_json::from_str(&content).map_err(Error::Deserialize)?; - if version_info.cached_from_version == PRODUCT_VERSION { + if version_info.cached_from_version == mullvad_version::VERSION { Ok(version_info.version_info) } else { Err(Error::CacheVersionMismatch) @@ -475,8 +472,8 @@ fn dev_version_cache() -> AppVersionInfo { AppVersionInfo { supported: false, - latest_stable: PRODUCT_VERSION.to_owned(), - latest_beta: PRODUCT_VERSION.to_owned(), + latest_stable: mullvad_version::VERSION.to_owned(), + latest_beta: mullvad_version::VERSION.to_owned(), suggested_upgrade: None, // Use WireGuard on 75% of dev builds. So we can manually modify // wg_migration_rand_num in the settings and verify that the migration diff --git a/mullvad-problem-report/Cargo.toml b/mullvad-problem-report/Cargo.toml index abc2922a08..4b9cc07398 100644 --- a/mullvad-problem-report/Cargo.toml +++ b/mullvad-problem-report/Cargo.toml @@ -20,6 +20,7 @@ tokio = { version = "1.8", features = ["rt"] } mullvad-paths = { path = "../mullvad-paths" } mullvad-api = { path = "../mullvad-api" } +mullvad-version = { path = "../mullvad-version" } talpid-types = { path = "../talpid-types" } talpid-platform-metadata = { path = "../talpid-platform-metadata" } @@ -30,6 +31,7 @@ duct = "0.13" [target.'cfg(windows)'.build-dependencies] winres = "0.1" +mullvad-version = { path = "../mullvad-version" } [target.'cfg(windows)'.build-dependencies.windows-sys] version = "0.42.0" diff --git a/mullvad-problem-report/build.rs b/mullvad-problem-report/build.rs index 1da519a32e..de110d3a76 100644 --- a/mullvad-problem-report/build.rs +++ b/mullvad-problem-report/build.rs @@ -1,20 +1,13 @@ -use std::{env, fs, path::PathBuf}; - #[cfg(windows)] fn make_lang_id(p: u16, s: u16) -> u16 { (s << 10) | p } fn main() { - let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - - let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); - fs::write(out_dir.join("product-version.txt"), &product_version).unwrap(); - #[cfg(windows)] { let mut res = winres::WindowsResource::new(); - res.set("ProductVersion", &product_version); + res.set("ProductVersion", mullvad_version::VERSION); res.set_icon("../dist-assets/icon.ico"); res.set_language(make_lang_id( windows_sys::Win32::System::SystemServices::LANG_ENGLISH as u16, diff --git a/mullvad-problem-report/src/main.rs b/mullvad-problem-report/src/main.rs index 09d681fd25..85f0143bee 100644 --- a/mullvad-problem-report/src/main.rs +++ b/mullvad-problem-report/src/main.rs @@ -1,7 +1,7 @@ #![deny(rust_2018_idioms)] use clap::{crate_authors, crate_name}; -use mullvad_problem_report::{collect_report, metadata, Error}; +use mullvad_problem_report::{collect_report, Error}; use std::{env, path::Path, process}; use talpid_types::ErrorExt; @@ -18,7 +18,7 @@ fn main() { fn run() -> Result<(), Error> { env_logger::init(); let app = clap::App::new(crate_name!()) - .version(metadata::PRODUCT_VERSION) + .version(mullvad_version::VERSION) .author(crate_authors!()) .about("Mullvad VPN problem report tool. Collects logs and sends them to Mullvad support.") .setting(clap::AppSettings::SubcommandRequiredElseHelp) diff --git a/mullvad-problem-report/src/metadata.rs b/mullvad-problem-report/src/metadata.rs index ac4b8c9255..ab9fe53a91 100644 --- a/mullvad-problem-report/src/metadata.rs +++ b/mullvad-problem-report/src/metadata.rs @@ -1,13 +1,11 @@ use std::collections::BTreeMap; -pub const PRODUCT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")); - pub fn collect() -> BTreeMap<String, String> { let mut metadata = BTreeMap::new(); metadata.insert("id".to_owned(), uuid::Uuid::new_v4().to_string()); metadata.insert( "mullvad-product-version".to_owned(), - PRODUCT_VERSION.to_owned(), + mullvad_version::VERSION.to_owned(), ); metadata.insert("os".to_owned(), talpid_platform_metadata::version()); metadata.extend(talpid_platform_metadata::extra_metadata()); diff --git a/mullvad-setup/Cargo.toml b/mullvad-setup/Cargo.toml index 91d23b80b2..d47ed796ed 100644 --- a/mullvad-setup/Cargo.toml +++ b/mullvad-setup/Cargo.toml @@ -25,6 +25,7 @@ mullvad-daemon = { path = "../mullvad-daemon" } mullvad-paths = { path = "../mullvad-paths" } mullvad-api = { path = "../mullvad-api" } mullvad-types = { path = "../mullvad-types" } +mullvad-version = { path = "../mullvad-version" } talpid-core = { path = "../talpid-core" } talpid-types = { path = "../talpid-types" } diff --git a/mullvad-setup/build.rs b/mullvad-setup/build.rs deleted file mode 100644 index 7cc0a0a5de..0000000000 --- a/mullvad-setup/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -use std::{env, fs, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); - fs::write(out_dir.join("product-version.txt"), &product_version).unwrap(); -} diff --git a/mullvad-setup/src/main.rs b/mullvad-setup/src/main.rs index 9d353b78a6..2f210ebb76 100644 --- a/mullvad-setup/src/main.rs +++ b/mullvad-setup/src/main.rs @@ -9,10 +9,8 @@ use talpid_core::{ }; use talpid_types::ErrorExt; -pub const PRODUCT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")); - lazy_static::lazy_static! { - static ref APP_VERSION: ParsedAppVersion = ParsedAppVersion::from_str(PRODUCT_VERSION).unwrap(); + static ref APP_VERSION: ParsedAppVersion = ParsedAppVersion::from_str(mullvad_version::VERSION).unwrap(); static ref IS_DEV_BUILD: bool = APP_VERSION.is_dev(); } @@ -101,7 +99,7 @@ async fn main() { ]; let app = clap::App::new(crate_name!()) - .version(PRODUCT_VERSION) + .version(mullvad_version::VERSION) .author(crate_authors!()) .about(crate_description!()) .setting(clap::AppSettings::SubcommandRequiredElseHelp) diff --git a/talpid-openvpn-plugin/Cargo.toml b/talpid-openvpn-plugin/Cargo.toml index 0c04b3250f..12db76343b 100644 --- a/talpid-openvpn-plugin/Cargo.toml +++ b/talpid-openvpn-plugin/Cargo.toml @@ -30,6 +30,7 @@ tonic-build = { version = "0.8", default-features = false, features = ["transpor [target.'cfg(windows)'.build-dependencies] winres = "0.1" +mullvad-version = { path = "../mullvad-version" } [target.'cfg(windows)'.build-dependencies.windows-sys] version = "0.42.0" diff --git a/talpid-openvpn-plugin/build.rs b/talpid-openvpn-plugin/build.rs index b3f12019a0..06d3f260a4 100644 --- a/talpid-openvpn-plugin/build.rs +++ b/talpid-openvpn-plugin/build.rs @@ -10,9 +10,8 @@ fn main() { #[cfg(windows)] { - let product_version = env!("CARGO_PKG_VERSION").replacen(".0", "", 1); let mut res = winres::WindowsResource::new(); - res.set("ProductVersion", &product_version); + res.set("ProductVersion", mullvad_version::VERSION); res.set_icon("../dist-assets/icon.ico"); res.set_language(make_lang_id( windows_sys::Win32::System::SystemServices::LANG_ENGLISH as u16, diff --git a/version-metadata.sh b/version-metadata.sh index e7001e19af..5cf27d72be 100755 --- a/version-metadata.sh +++ b/version-metadata.sh @@ -8,16 +8,6 @@ set -eu SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPT_DIR" -INCLUDED_CRATES=( - "mullvad-daemon" - "mullvad-cli" - "mullvad-problem-report" - "mullvad-setup" - "mullvad-exclude" - "talpid-openvpn-plugin" -) -MANIFESTS=( "${INCLUDED_CRATES[@]/%//Cargo.toml}" ) - # Parse arguments COMMAND="$1" shift 1 @@ -60,14 +50,6 @@ function inject_version { local semver_minor=${BASH_REMATCH[2]} local semver_patch="0" - echo "Setting Rust crate versions to $semver_version" - # Rust crates - for toml in "${MANIFESTS[@]}"; do - cp "$toml" "$toml.bak" - awk "BEGIN { matches=0; } matches==0 && /^version = \"[^\"]+\"$/ \ - { print \"version = \\\"$semver_version\\\"\"; matches++; next; } { print }" "$toml.bak" > "$toml" - done - if [[ "$DESKTOP" == "true" ]]; then echo "Setting desktop version to $semver_version" @@ -110,11 +92,6 @@ EOF function restore_backup { set +e - # Rust crates - for toml in "${MANIFESTS[@]}"; do - mv "${toml}.bak" "${toml}" - done - if [[ "$DESKTOP" == "true" ]]; then # Electron GUI mv gui/package.json.bak gui/package.json @@ -134,11 +111,6 @@ function restore_backup { function delete_backup { set +e - # Rust crates - for toml in "${MANIFESTS[@]}"; do - rm "${toml}.bak" - done - if [[ "$DESKTOP" == "true" ]]; then # Electron GUI rm gui/package.json.bak |
