move build.rs and friends to pbs-buildcfg

with this the main crate won't be re-compiled every time a
*binary* is modified

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-07-19 14:59:17 +02:00
parent 4d04cd9ab9
commit a12b1be728
7 changed files with 24 additions and 19 deletions

View File

@ -15,7 +15,6 @@ 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"]

View File

@ -4,5 +4,6 @@ version = "0.1.0"
authors = ["Proxmox Support Team <support@proxmox.com>"]
edition = "2018"
description = "macros used for pbs related paths such as configdir and rundir"
build = "build.rs"
[dependencies]

View File

@ -1,5 +1,15 @@
//! Exports configuration data from the build system
pub const PROXMOX_PKG_VERSION: &str =
concat!(
env!("CARGO_PKG_VERSION_MAJOR"),
".",
env!("CARGO_PKG_VERSION_MINOR"),
);
pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH");
pub const PROXMOX_PKG_REPOID: &str = env!("REPOID");
/// The configured configuration directory
pub const CONFIGDIR: &str = "/etc/proxmox-backup";
pub const JS_DIR: &str = "/usr/share/javascript/proxmox-backup";

View File

@ -352,8 +352,8 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
packages.push(unknown_package("proxmox-backup".into(), Some(running_kernel)));
}
let version = crate::api2::version::PROXMOX_PKG_VERSION;
let release = crate::api2::version::PROXMOX_PKG_RELEASE;
let version = pbs_buildcfg::PROXMOX_PKG_VERSION;
let release = pbs_buildcfg::PROXMOX_PKG_RELEASE;
let daemon_version_info = Some(format!("running version: {}.{}", version, release));
if let Some(pkg) = pbs_packages.iter().find(|pkg| pkg.package == "proxmox-backup-server") {
let mut pkg = pkg.clone();

View File

@ -6,15 +6,6 @@ use serde_json::{json, Value};
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment, Permission};
use proxmox::api::schema::ObjectSchema;
pub const PROXMOX_PKG_VERSION: &str =
concat!(
env!("CARGO_PKG_VERSION_MAJOR"),
".",
env!("CARGO_PKG_VERSION_MINOR"),
);
pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH");
pub const PROXMOX_PKG_REPOID: &str = env!("REPOID");
fn get_version(
_param: Value,
_info: &ApiMethod,
@ -22,9 +13,9 @@ fn get_version(
) -> Result<Value, Error> {
Ok(json!({
"version": PROXMOX_PKG_VERSION,
"release": PROXMOX_PKG_RELEASE,
"repoid": PROXMOX_PKG_REPOID
"version": pbs_buildcfg::PROXMOX_PKG_VERSION,
"release": pbs_buildcfg::PROXMOX_PKG_RELEASE,
"repoid": pbs_buildcfg::PROXMOX_PKG_REPOID
}))
}

View File

@ -413,9 +413,9 @@ async fn api_version(param: Value) -> Result<(), Error> {
let mut version_info = json!({
"client": {
"version": version::PROXMOX_PKG_VERSION,
"release": version::PROXMOX_PKG_RELEASE,
"repoid": version::PROXMOX_PKG_REPOID,
"version": pbs_buildcfg::PROXMOX_PKG_VERSION,
"release": pbs_buildcfg::PROXMOX_PKG_RELEASE,
"repoid": pbs_buildcfg::PROXMOX_PKG_REPOID,
}
});
@ -429,7 +429,11 @@ async fn api_version(param: Value) -> Result<(), Error> {
}
}
if output_format == "text" {
println!("client version: {}.{}", version::PROXMOX_PKG_VERSION, version::PROXMOX_PKG_RELEASE);
println!(
"client version: {}.{}",
pbs_buildcfg::PROXMOX_PKG_VERSION,
pbs_buildcfg::PROXMOX_PKG_RELEASE,
);
if let Some(server) = version_info["server"].as_object() {
let server_version = server["version"].as_str().unwrap();
let server_release = server["release"].as_str().unwrap();