From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 26BBE7A40B for ; Fri, 7 May 2021 10:41:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1BFFD28588 for ; Fri, 7 May 2021 10:41:22 +0200 (CEST) Received: from elsa.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP id 611292857F for ; Fri, 7 May 2021 10:41:21 +0200 (CEST) Received: by elsa.proxmox.com (Postfix, from userid 0) id 46239AEB2E8; Fri, 7 May 2021 10:41:15 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Fri, 7 May 2021 10:41:13 +0200 Message-Id: <20210507084113.7712-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.406 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, version.rs, build.rs] Subject: [pbs-devel] [PATCH proxmox-backup] use build.rs to pass REPOID to rustc-env X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 08:41:22 -0000 --- Cargo.toml | 1 + build.rs | 24 ++++++++++++++++++++++++ src/api2/version.rs | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index be6c7da9..246b8e07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ edition = "2018" license = "AGPL-3" description = "Proxmox Backup" homepage = "https://www.proxmox.com" +build = "build.rs" exclude = [ "build", "debian", "tests/catar_data/test_symlink/symlink1"] diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..754966b6 --- /dev/null +++ b/build.rs @@ -0,0 +1,24 @@ +// build.rs +use std::env; +use std::process::Command; + +fn main() { + let repoid = match env::var("REPOID") { + Ok(repoid) => repoid, + Err(_) => { + match Command::new("git") + .args(&["rev-parse", "HEAD"]) + .output() + { + Ok(output) => { + String::from_utf8(output.stdout).unwrap() + } + Err(err) => { + panic!("git rev-parse failed: {}", err); + } + } + } + }; + + println!("cargo:rustc-env=REPOID={}", repoid); +} diff --git a/src/api2/version.rs b/src/api2/version.rs index ca156402..d18d0cf4 100644 --- a/src/api2/version.rs +++ b/src/api2/version.rs @@ -13,7 +13,7 @@ pub const PROXMOX_PKG_VERSION: &str = env!("CARGO_PKG_VERSION_MINOR"), ); pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH"); -pub const PROXMOX_PKG_REPOID: &str = env!("CARGO_PKG_REPOSITORY"); +pub const PROXMOX_PKG_REPOID: &str = env!("REPOID"); fn get_version( _param: Value, -- 2.20.1