From 819c89e49f16fbe53601b10f74d337b8925389ad Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 4 Jan 2024 14:35:53 +0100 Subject: [PATCH] New "static" feature for libxenstore static linking Now build linux release exe as static. freebsd static-build configs disabled because apparently libxenstore.a would need to be built with -fPIE. Signed-off-by: Yann Dirson --- .gitlab-ci.yml | 9 ++++++++- CHANGELOG.md | 5 +++++ Cargo.lock | 15 +++++++++++---- Cargo.toml | 8 +++++++- debian/control | 1 - xen-guest-agent.spec.in | 1 - 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b1ca48..a2d51e9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,6 +104,9 @@ clippy: - "--no-default-features -F xenstore" - "--no-default-features -F net_netlink" - "--no-default-features -F net_pnet" + # + - "--no-default-features -F xenstore,static" + - "-F static" .featurematrix.no-netlink: parallel: @@ -113,6 +116,10 @@ clippy: - "--no-default-features -F xenstore" - "--no-default-features -F net_pnet" - "--no-default-features -F xenstore,net_pnet" + ## this matrix is only by FreeBSD today, and we cannot link + ## statically on FreeBSD because libxenstore is not built as PIE + #- "--no-default-features -F xenstore,static" + #- "--no-default-features -F xenstore,static,net_pnet" ## standard jobs building with shipped Cargo.lock @@ -196,7 +203,7 @@ build-release-linux-x86_64: - .debian-build-template - .not-scheduled variables: - FEATURES: "" + FEATURES: "-F static" CARGO_FLAGS: "--release" artifacts: paths: diff --git a/CHANGELOG.md b/CHANGELOG.md index 083b88d..1b81374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ Changelog](https://keepachangelog.com/en/1.0.0/) ## 0.4.0 - unreleased +### new features + +* can be linked statically with libxenstore to distribute a more + standalone binary (`-F static`). Used for official Linux binary. + ### bugfixes * stale network information in xenstore is now removed on startup diff --git a/Cargo.lock b/Cargo.lock index 9c5aa6c..2c94924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -745,6 +745,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" + [[package]] name = "pnet_base" version = "0.34.0" @@ -1337,9 +1343,9 @@ dependencies = [ [[package]] name = "xenstore-rs" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c26625ab5ad3e480cf74a06d0595229eadac95029270461b8143d59dc00ea7ff" +checksum = "1a135aa89ea3a9c71af5448e1aae769ea8921e665d8acb6a5e9d098c5c6c1cc5" dependencies = [ "libc", "libloading", @@ -1349,9 +1355,10 @@ dependencies = [ [[package]] name = "xenstore-sys" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65a2d5fcc3634d9fdae6a388dbab071bf72ecf34ec530a705dca644dd60f543" +checksum = "47d65d6ab4f4ac05cd61e78dee7cdb2d448d147c593aedeccf383d361af032f7" dependencies = [ "bindgen", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index c4bb50e..0bbfaea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ netlink-packet-core = { version = "0.7.0", optional = true } netlink-packet-route = { version = "0.18.0", optional = true } netlink-proto = { version = "0.11.2", optional = true } rtnetlink = { version = "0.14.0", optional = true } -xenstore-rs = { version = ">=0.4, <0.6", default-features = false, optional = true } async-stream = "0.3.4" os_info = { version = "3", default-features = false } pnet_datalink = { version = "*", optional = true } @@ -24,6 +23,12 @@ log = "0.4.0" env_logger = ">=0.10.0" clap = { version = "4.4.8", features = ["derive"] } +[dependencies.xenstore-rs] +optional = true +version = "0.6.0" +#git = "https://github.com/Wenzel/xenstore.git" +default-features = false + [target.'cfg(unix)'.dependencies] uname = "0.1.1" syslog = "6.0" @@ -34,6 +39,7 @@ sysctl = "0.5.0" [features] default = ["xenstore", "net_netlink"] xenstore = ["dep:xenstore-rs"] +static = ["xenstore-rs/static"] net_netlink = ["dep:netlink-proto", "dep:netlink-packet-core", "dep:netlink-packet-route", "dep:rtnetlink"] net_pnet = ["dep:pnet_datalink", "dep:pnet_base", "dep:ipnetwork"] diff --git a/debian/control b/debian/control index 4ca9962..619c905 100644 --- a/debian/control +++ b/debian/control @@ -13,7 +13,6 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - libxenstore4 | libxenstore3.0, Conflicts: xe-guest-utilities Replaces: xe-guest-utilities Description: Guest Agent for Xen-based virtual machines diff --git a/xen-guest-agent.spec.in b/xen-guest-agent.spec.in index 02d8313..889785f 100644 --- a/xen-guest-agent.spec.in +++ b/xen-guest-agent.spec.in @@ -13,7 +13,6 @@ Source1: xen-guest-agent.service BuildRequires: systemd-devel -Requires: xen-libs Conflicts: xe-guest-utilities %global _description %{expand: -- 2.39.5