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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9271F68DC0 for ; Wed, 11 Nov 2020 15:27:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 85C58240FD for ; Wed, 11 Nov 2020 15:27:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C6DCF240EF for ; Wed, 11 Nov 2020 15:27:01 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 931634605D for ; Wed, 11 Nov 2020 15:27:01 +0100 (CET) Date: Wed, 11 Nov 2020 15:26:52 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20201105111759.20569-1-s.reiter@proxmox.com> <20201105111759.20569-2-s.reiter@proxmox.com> In-Reply-To: <20201105111759.20569-2-s.reiter@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1605104784.jihdehdt52.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.024 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [build.rs, proxmox.com] Subject: [pve-devel] applied: [PATCH proxmox-backup-qemu 1/3] include debian version and git rev in header file X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2020 14:27:03 -0000 a slightly simplified version On November 5, 2020 12:17 pm, Stefan Reiter wrote: > ...so we can get the library version a binary is currently running with. >=20 > Details are retrieved in build.rs by calling dpkg-parsechangelog and > git, then appended using 'with_after_include' to appear within the > include guard. >=20 > The version string in current-api.h is inconsequential, so ignore it in > diff. This way we only have to re-commit that file whenever the *actual* > API changes, not the version. >=20 > Signed-off-by: Stefan Reiter > --- > Makefile | 4 ++-- > build.rs | 26 ++++++++++++++++++++++++++ > current-api.h | 2 ++ > 3 files changed, 30 insertions(+), 2 deletions(-) >=20 > diff --git a/Makefile b/Makefile > index 8761298..bc5f1f0 100644 > --- a/Makefile > +++ b/Makefile > @@ -20,7 +20,7 @@ endif > all: > ifneq ($(BUILD_MODE), skip) > cargo build $(CARGO_BUILD_ARGS) > - diff -up current-api.h proxmox-backup-qemu.h > + diff -I 'PROXMOX_BACKUP_QEMU_VERSION' -up current-api.h proxmox-backup-= qemu.h > endif > =20 > # always re-create this dir > @@ -29,7 +29,7 @@ endif > build: > rm -rf build > cargo build --release > - diff -up current-api.h proxmox-backup-qemu.h > + diff -I 'PROXMOX_BACKUP_QEMU_VERSION' -up current-api.h proxmox-backup-= qemu.h > rsync -a debian Makefile Cargo.toml Cargo.lock build.rs proxmox-backup-= qemu.h src target current-api.h build/ > =20 > .PHONY: install > diff --git a/build.rs b/build.rs > index 46dbb7a..c49b2ab 100644 > --- a/build.rs > +++ b/build.rs > @@ -2,16 +2,42 @@ > extern crate cbindgen; > =20 > use std::env; > +use std::process::Command; > + > +fn capture_stdout(cmd: &str) -> String { > + let args: Vec<&str> =3D cmd.split(' ').collect(); > + let (exe, args) =3D (args[0], &args[1..]); > + > + let stdout =3D Command::new(exe) > + .args(args) > + .output() > + .expect(&format!("failed to run program: {}", exe)) > + .stdout; > + > + String::from_utf8(stdout) > + .expect(&format!("program {} produced invalid UTF-8 output", exe= )) > + .trim() > + .to_owned() > +} > =20 > fn main() { > let crate_dir =3D env::var("CARGO_MANIFEST_DIR").unwrap(); > let header =3D std::fs::read_to_string("header-preamble.c").unwrap()= ; > =20 > + let debver =3D capture_stdout("dpkg-parsechangelog -l debian/changel= og -SVersion"); > + let gitver =3D capture_stdout("git rev-parse --short=3D8 HEAD"); > + let version_define =3D format!( > + "\n#define PROXMOX_BACKUP_QEMU_VERSION \"{} ({})\"", > + debver, > + gitver, > + ); > + > cbindgen::Builder::new() > .with_language(cbindgen::Language::C) > .with_crate(&crate_dir) > .with_header(header) > .with_include_guard("PROXMOX_BACKUP_QEMU_H") > + .with_after_include(version_define) > .generate() > .unwrap() > .write_to_file("proxmox-backup-qemu.h"); > diff --git a/current-api.h b/current-api.h > index 77e8c4b..97c185f 100644 > --- a/current-api.h > +++ b/current-api.h > @@ -32,6 +32,8 @@ > #include > #include > =20 > +#define PROXMOX_BACKUP_QEMU_VERSION "0.7.1-1 (296da586)" > + > #define PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE ((1024 * 1024) * 4) > =20 > /** > --=20 > 2.20.1 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20 =