pbs build config: rust fmt

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-06 16:57:36 +02:00
parent 40ea990c05
commit c650378a39
2 changed files with 40 additions and 27 deletions

View File

@ -5,19 +5,12 @@ use std::process::Command;
fn main() { fn main() {
let repoid = match env::var("REPOID") { let repoid = match env::var("REPOID") {
Ok(repoid) => repoid, Ok(repoid) => repoid,
Err(_) => { Err(_) => match Command::new("git").args(&["rev-parse", "HEAD"]).output() {
match Command::new("git") Ok(output) => String::from_utf8(output.stdout).unwrap(),
.args(&["rev-parse", "HEAD"]) Err(err) => {
.output() panic!("git rev-parse failed: {}", err);
{
Ok(output) => {
String::from_utf8(output.stdout).unwrap()
}
Err(err) => {
panic!("git rev-parse failed: {}", err);
}
} }
} },
}; };
println!("cargo:rustc-env=REPOID={}", repoid); println!("cargo:rustc-env=REPOID={}", repoid);

View File

@ -1,15 +1,13 @@
//! Exports configuration data from the build system //! Exports configuration data from the build system
pub const PROXMOX_PKG_VERSION: &str = pub const PROXMOX_PKG_VERSION: &str = concat!(
concat!( env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MAJOR"), ".",
".", env!("CARGO_PKG_VERSION_MINOR"),
env!("CARGO_PKG_VERSION_MINOR"), );
);
pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH"); pub const PROXMOX_PKG_RELEASE: &str = env!("CARGO_PKG_VERSION_PATCH");
pub const PROXMOX_PKG_REPOID: &str = env!("REPOID"); pub const PROXMOX_PKG_REPOID: &str = env!("REPOID");
/// The configured configuration directory /// The configured configuration directory
pub const CONFIGDIR: &str = "/etc/proxmox-backup"; pub const CONFIGDIR: &str = "/etc/proxmox-backup";
pub const JS_DIR: &str = "/usr/share/javascript/proxmox-backup"; pub const JS_DIR: &str = "/usr/share/javascript/proxmox-backup";
@ -20,20 +18,38 @@ pub const BACKUP_USER_NAME: &str = "backup";
pub const BACKUP_GROUP_NAME: &str = "backup"; pub const BACKUP_GROUP_NAME: &str = "backup";
#[macro_export] #[macro_export]
macro_rules! PROXMOX_BACKUP_RUN_DIR_M { () => ("/run/proxmox-backup") } macro_rules! PROXMOX_BACKUP_RUN_DIR_M {
() => {
"/run/proxmox-backup"
};
}
#[macro_export] #[macro_export]
macro_rules! PROXMOX_BACKUP_STATE_DIR_M { () => ("/var/lib/proxmox-backup") } macro_rules! PROXMOX_BACKUP_STATE_DIR_M {
() => {
"/var/lib/proxmox-backup"
};
}
#[macro_export] #[macro_export]
macro_rules! PROXMOX_BACKUP_LOG_DIR_M { () => ("/var/log/proxmox-backup") } macro_rules! PROXMOX_BACKUP_LOG_DIR_M {
() => {
"/var/log/proxmox-backup"
};
}
#[macro_export] #[macro_export]
macro_rules! PROXMOX_BACKUP_CACHE_DIR_M { () => ("/var/cache/proxmox-backup") } macro_rules! PROXMOX_BACKUP_CACHE_DIR_M {
() => {
"/var/cache/proxmox-backup"
};
}
#[macro_export] #[macro_export]
macro_rules! PROXMOX_BACKUP_FILE_RESTORE_BIN_DIR_M { macro_rules! PROXMOX_BACKUP_FILE_RESTORE_BIN_DIR_M {
() => ("/usr/lib/x86_64-linux-gnu/proxmox-backup/file-restore") () => {
"/usr/lib/x86_64-linux-gnu/proxmox-backup/file-restore"
};
} }
/// namespaced directory for in-memory (tmpfs) run state /// namespaced directory for in-memory (tmpfs) run state
@ -65,8 +81,10 @@ pub const PROXMOX_BACKUP_INITRAMFS_FN: &str =
concat!(PROXMOX_BACKUP_CACHE_DIR_M!(), "/file-restore-initramfs.img"); concat!(PROXMOX_BACKUP_CACHE_DIR_M!(), "/file-restore-initramfs.img");
/// filename of the cached initramfs to use for debugging single file restore /// filename of the cached initramfs to use for debugging single file restore
pub const PROXMOX_BACKUP_INITRAMFS_DBG_FN: &str = pub const PROXMOX_BACKUP_INITRAMFS_DBG_FN: &str = concat!(
concat!(PROXMOX_BACKUP_CACHE_DIR_M!(), "/file-restore-initramfs-debug.img"); PROXMOX_BACKUP_CACHE_DIR_M!(),
"/file-restore-initramfs-debug.img"
);
/// filename of the kernel to use for booting single file restore VMs /// filename of the kernel to use for booting single file restore VMs
pub const PROXMOX_BACKUP_KERNEL_FN: &str = pub const PROXMOX_BACKUP_KERNEL_FN: &str =
@ -82,7 +100,9 @@ pub const PROXMOX_BACKUP_KERNEL_FN: &str =
/// ``` /// ```
#[macro_export] #[macro_export]
macro_rules! configdir { macro_rules! configdir {
($subdir:expr) => (concat!("/etc/proxmox-backup", $subdir)) ($subdir:expr) => {
concat!("/etc/proxmox-backup", $subdir)
};
} }
/// Prepend the run directory to a file name. /// Prepend the run directory to a file name.