summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-06-25 18:29:21 +0200
committerLinus Färnstrand <linus@mullvad.net>2018-06-25 23:37:34 +0200
commit1d848692a080935470cb27a6d3a7d212339c53b5 (patch)
tree0a25127e7032767d3e850ef62814818aa70c97cb
parent8a0c609994b967f1cdeca811527b6f42a7dfb8a1 (diff)
downloadmullvadvpn-1d848692a080935470cb27a6d3a7d212339c53b5.tar.xz
mullvadvpn-1d848692a080935470cb27a6d3a7d212339c53b5.zip
Make mullvad-daemon take version from own metadata
-rw-r--r--mullvad-daemon/Cargo.toml1
-rw-r--r--mullvad-daemon/build.rs25
-rw-r--r--mullvad-daemon/src/bin/problem-report.rs15
-rw-r--r--mullvad-daemon/src/cli.rs2
-rw-r--r--mullvad-daemon/src/main.rs8
-rw-r--r--mullvad-daemon/src/version.rs12
6 files changed, 22 insertions, 41 deletions
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index f985440a99..0b1cd9f14c 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -4,7 +4,6 @@ version = "0.1.0"
authors = ["Mullvad VPN <admin@mullvad.net>", "Linus Färnstrand <linus@mullvad.net>", "Erik Larkö <erik@mullvad.net>", "Andrej Mihajlov <and@mullvad.net>"]
description = "Mullvad VPN daemon. Runs and controls the VPN tunnels"
license = "GPL-3.0"
-build = "build.rs"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs
index 9e6c57fc96..f1f507670e 100644
--- a/mullvad-daemon/build.rs
+++ b/mullvad-daemon/build.rs
@@ -1,6 +1,5 @@
use std::env;
-use std::fs::File;
-use std::io::Write;
+use std::fs;
use std::path::PathBuf;
use std::process::Command;
@@ -8,25 +7,9 @@ use std::process::Command;
fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
- File::create(out_dir.join("git-commit-desc.txt"))
- .unwrap()
- .write_all(commit_description().as_bytes())
- .unwrap();
- File::create(out_dir.join("git-commit-date.txt"))
- .unwrap()
- .write_all(commit_date().as_bytes())
- .unwrap();
-}
-
-fn commit_description() -> String {
- let output = Command::new("git")
- .args(&["describe", "--dirty"])
- .output()
- .expect("Unable to get git commit description");
- ::std::str::from_utf8(&output.stdout)
- .unwrap()
- .trim()
- .to_owned()
+ 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();
}
fn commit_date() -> String {
diff --git a/mullvad-daemon/src/bin/problem-report.rs b/mullvad-daemon/src/bin/problem-report.rs
index dcd67ba227..063dbf0838 100644
--- a/mullvad-daemon/src/bin/problem-report.rs
+++ b/mullvad-daemon/src/bin/problem-report.rs
@@ -82,7 +82,7 @@ quick_main!(run);
fn run() -> Result<()> {
let app = clap::App::new("problem-report")
- .version(crate_version!())
+ .version(daemon_version())
.author(crate_authors!())
.about("Mullvad VPN problem report tool. Collects logs and sends them to Mullvad support.")
.setting(clap::AppSettings::SubcommandRequired)
@@ -441,15 +441,18 @@ fn read_file_lossy(path: &Path, max_bytes: usize) -> io::Result<String> {
fn collect_metadata() -> HashMap<String, String> {
let mut metadata = HashMap::new();
- metadata.insert(String::from("mullvad-daemon-version"), daemon_version());
+ metadata.insert(
+ String::from("mullvad-daemon-version"),
+ daemon_version().to_owned(),
+ );
metadata.insert(String::from("os"), os_version());
metadata
}
-fn daemon_version() -> String {
- format!(
- "{} {}",
- include_str!(concat!(env!("OUT_DIR"), "/git-commit-desc.txt")),
+fn daemon_version() -> &'static str {
+ concat!(
+ include_str!(concat!(env!("OUT_DIR"), "/product-version.txt")),
+ " ",
include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.txt"))
)
}
diff --git a/mullvad-daemon/src/cli.rs b/mullvad-daemon/src/cli.rs
index ffb4a62586..573236d797 100644
--- a/mullvad-daemon/src/cli.rs
+++ b/mullvad-daemon/src/cli.rs
@@ -37,7 +37,7 @@ pub fn get_config() -> Config {
fn create_app() -> App<'static, 'static> {
let app = App::new(crate_name!())
- .version(version::current())
+ .version(version::CURRENT)
.author(crate_authors!())
.about(crate_description!())
.arg(
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs
index 892c438188..37bfcb56a9 100644
--- a/mullvad-daemon/src/main.rs
+++ b/mullvad-daemon/src/main.rs
@@ -490,7 +490,7 @@ impl Daemon {
&mut self,
tx: OneshotSender<BoxFuture<AppVersionInfo, mullvad_rpc::Error>>,
) {
- let current_version = version::current().to_owned();
+ let current_version = version::CURRENT.to_owned();
let fut = self
.version_proxy
.latest_app_version()
@@ -506,7 +506,7 @@ impl Daemon {
}
fn on_get_current_version(&mut self, tx: OneshotSender<AppVersion>) {
- let current_version = version::current().to_owned();
+ let current_version = version::CURRENT.to_owned();
Self::oneshot_send(tx, current_version, "get_current_version response");
}
@@ -915,8 +915,8 @@ fn log_version() {
info!(
"Starting {} - {} {}",
env!("CARGO_PKG_NAME"),
- version::current(),
- version::commit_date(),
+ version::CURRENT,
+ version::COMMIT_DATE,
)
}
diff --git a/mullvad-daemon/src/version.rs b/mullvad-daemon/src/version.rs
index 2252406e5f..2c28c2bba4 100644
--- a/mullvad-daemon/src/version.rs
+++ b/mullvad-daemon/src/version.rs
@@ -1,9 +1,5 @@
-/// Returns a string that identifies the current version of the application
-pub fn current() -> &'static str {
- include_str!(concat!(env!("OUT_DIR"), "/git-commit-desc.txt"))
-}
+/// A string that identifies the current version of the application
+pub const CURRENT: &str = include_str!(concat!(env!("OUT_DIR"), "/product-version.txt"));
-/// Current description returns the current build date
-pub fn commit_date() -> &'static str {
- include_str!(concat!(env!("OUT_DIR"), "/git-commit-date.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"));