Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big buildsystem -> cargo rollup #2518

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Explicitly create a workspace since we have libdnf-sys as a path
# dependency, and in the future we may use other sub-crates.
[workspace]

[package]
name = "rpmostree-rust"
version = "0.1.0"
Expand All @@ -18,16 +22,7 @@ libarchive = "3.0"
jsonglib = { name = "json-glib-1.0", version = "1" }
polkitgobject = { name = "polkit-gobject-1", version = "0" }
rpm = "4"
# libdnf dependencies
librepo = "1"
libsolv = "0.7"
libsolvext = "0.7"
gpgme = "1"
openssl = "1"
libcurl = "7"
sqlite3 = "3"
modulemd = { name = "modulemd-2.0", version = "2" }
jsonc = { name = "json-c", version = "0" }

[dependencies]
anyhow = "1.0.38"
Expand Down
4 changes: 2 additions & 2 deletions Makefile-lib.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ librpmostree_1_la_SOURCES = \

librpmostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libpriv -I$(srcdir)/src/lib \
-fvisibility=hidden '-D_RPMOSTREE_EXTERN=__attribute((visibility("default"))) extern' \
$(PKGDEP_RPMOSTREE_CFLAGS)
$(PKGDEP_LIBRPMOSTREE_CFLAGS)
librpmostree_1_la_LDFLAGS = $(AM_LDFLAGS) -version-number 1:0:0 -Bsymbolic-functions
librpmostree_1_la_LIBADD = $(PKGDEP_RPMOSTREE_LIBS) libglnx.la
librpmostree_1_la_LIBADD = $(PKGDEP_LIBRPMOSTREE_LIBS) libglnx.la

# XXX: work around clang being passed -fstack-clash-protection which it doesn't understand
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# https://github.com/projectatomic/rpm-ostree/pull/1787#issuecomment-473971585
Expand Down
32 changes: 0 additions & 32 deletions Makefile-libdnf.am

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile-rpm-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ rpmostree_common_cflags = -I$(srcdir)/src/app -I$(srcdir)/src/daemon \
-I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
-DG_LOG_DOMAIN=\"rpm-ostreed\" \
-DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \
-I $(top_srcdir)/libdnf -I $(top_srcdir)/libdnf-build \
$(PKGDEP_RPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_RS_CFLAGS)
-I $(top_srcdir)/libdnf \
$(PKGDEP_LIBRPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS)
rpmostree_bin_common_cflags = $(rpmostree_common_cflags)
rpmostree_common_libs = libglnx.la librpmostree-1.la librpmostreecxxrs.la $(PKGDEP_RPMOSTREE_RS_LIBS) $(PKGDEP_RPMOSTREE_LIBS)
rpmostree_common_libs = libglnx.la librpmostree-1.la librpmostreecxxrs.la

rpmostree_bin_common_libs = librpmostreeinternals.la $(rpmostree_common_libs)
librpmostreeinternals_la_CFLAGS = $(AM_CFLAGS) $(rpmostree_common_cflags)
Expand Down
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ GITIGNOREFILES += "fastbuild*.qcow2" _kola_temp/
include libglnx/Makefile-libglnx.am.inc
noinst_LTLIBRARIES += libglnx.la
include Makefile-libpriv.am
include Makefile-libdnf.am
include Makefile-lib.am
include Makefile-daemon.am
include Makefile-rpm-ostree.am
Expand Down
2 changes: 0 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ fn main() -> Result<()> {
cwd
);
println!("cargo:rustc-link-lib=cap");
println!("cargo:rustc-link-search={}/libdnf-build/libdnf", cwd);
println!("cargo:rustc-link-lib=dnf");
println!("cargo:rustc-link-lib=rt");
println!("cargo:rustc-link-lib=stdc++");
// https://github.com/ostreedev/ostree/commit/1f832597fc83fda6cb8daf48c4495a9e1590774c
Expand Down
54 changes: 5 additions & 49 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,17 @@ AC_SUBST([RPM_OSTREE_FEATURES])

PKG_PROG_PKG_CONFIG

# Remember to update AM_CPPFLAGS in Makefile.am when bumping GIO req.
dnl Remember to update AM_CPPFLAGS in Makefile.am when bumping GIO req.
PKG_CHECK_MODULES(PKGDEP_GIO_UNIX, [gio-unix-2.0])
# librepo libsolv etc. are libdnf dependencies
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [gio-unix-2.0 >= 2.50.0 json-glib-1.0
ostree-1 >= 2020.7
libsystemd
polkit-gobject-1
rpm librepo libsolv libsolvext sqlite3 gpgme modulemd-2.0 json-c libcurl openssl
libarchive])

# We just keep rust-specific deps separate for better tracking
# The `libcurl` one is redundant since we already require it for libostree. `openssl`
# is required by libcurl anyway, but we need to link to it directly too because
# curl-rust uses it.
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE_RS, [libcurl openssl])
dnl These are the dependencies of the public librpmostree-1.0.0 shared library
PKG_CHECK_MODULES(PKGDEP_LIBRPMOSTREE, [gio-unix-2.0 >= 2.50.0 json-glib-1.0 ostree-1 >= 2020.7 rpm])
dnl And these additional ones are used by for the rpmostreeinternals C/C++ library
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [polkit-gobject-1 libarchive])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can clearly see this one with e.g.:

$ eu-readelf -a /usr/lib64/librpmostree-1.so.1.0.0 |grep NEEDED | wc -l
16
$ eu-readelf -a .libs/librpmostree-1.so.1.0.0 |grep NEEDED | wc -l
9


dnl RHEL8.1 has old libarchive
AS_IF([pkg-config --atleast-version=3.3.3 libarchive],
[AC_DEFINE([HAVE_LIBARCHIVE_ZSTD], 1, [Define if we have libarchive with zstd])])

dnl This is the current version in Fedora 25.
AS_IF([pkg-config --atleast-version=4.14.2 rpm], [], [AC_MSG_ERROR([librpm 4.14.2 required])])

dnl We don't *actually* use this ourself, but librepo does, and libdnf gets confused
dnl if librepo doesn't support it.
have_zchunk=no
Expand Down Expand Up @@ -163,38 +151,6 @@ AM_COND_IF([BUILDOPT_ROJIG], [
AC_DEFINE([BUILDOPT_ROJIG], 1, [Define if rojig is enabled])
])

dnl And propagate the release/debug type to cmake
cmake_args=-DCMAKE_BUILD_TYPE=RelWithDebugInfo
if test ${debug_release} = debug; then
cmake_args="-DCMAKE_BUILD_TYPE=Debug"
fi
if test x${have_zchunk} = xno; then
cmake_args="${cmake_args} -DWITH_ZCHUNK:BOOL=0"
fi
export cmake_args

dnl I picked /usr/libexec/rpm-ostree just because we need an
dnl arbitrary path - we don't actually install there.
dnl Use `WITH_GIR=0`; it's our private libdnf bundle and we don't need the bindings.
dnl -fPIE for hardening
(set -euo pipefail; mkdir -p libdnf-build && cd libdnf-build &&
set -x &&
export CXXFLAGS="-fPIE $CXXFLAGS" &&
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/libexec/rpm-ostree \
-DINCLUDE_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree/include \
-DLIB_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree \
-DSYSCONF_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree/etc \
-DSHARE_INSTALL_PREFIX:PATH=/usr/libexec/rpm-ostree/share \
-DENABLE_STATIC:BOOL=1 \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DWITH_SWDB:BOOL=0 \
-DWITH_BINDINGS:BOOL=0 \
-DWITH_HTML:BOOL=0 \
-DWITH_MAN:BOOL=0 \
-DWITH_GIR:BOOL=0 \
${cmake_args} ../libdnf) || exit 1

AC_CONFIG_FILES([
Makefile
api-doc/Makefile
Expand Down
20 changes: 20 additions & 0 deletions rust/libdnf-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,30 @@ name = "libdnf-sys"
version = "0.1.0"
authors = ["Colin Walters <[email protected]>", "Jonathan Lebon <[email protected]>"]
edition = "2018"
links = "dnf"

[dependencies]
libc = "0.2"

[lib]
name = "libdnf_sys"
path = "lib.rs"

[build-dependencies]
cmake = "0.1.45"
system-deps = "2.0"
anyhow = "1.0"

# This currently needs to duplicate the libraries from libdnf
[package.metadata.system-deps]
rpm = "4"
# libdnf dependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: guess this comment is redundant now that it lives in the libdnf crate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Will fix this in a followup, hoping to get this in and avoid restarting CI 3-4 times again)

librepo = "1"
libsolv = "0.7"
libsolvext = "0.7"
gpgme = "1"
openssl = "1"
libcurl = "7"
sqlite3 = "3"
modulemd = { name = "modulemd-2.0", version = "2" }
jsonc = { name = "json-c", version = "0" }
37 changes: 37 additions & 0 deletions rust/libdnf-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use anyhow::Result;

fn main() -> Result<()> {
system_deps::Config::new().probe()?;
use cmake::Config;
let libdnf = Config::new("../../libdnf")
// Needed for hardened builds
.cxxflag("-fPIC")
// I picked /usr/libexec/rpm-ostree just because we need an
// arbitrary path - we don't actually install there.
Comment on lines +9 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we drop these :PATH values now that we build statically, or does the build still error out if we omit them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd default to /usr/local then I think; the idea here is to use a should-be-nonexistent path so that if it ever shows up at runtime we know it's a bug. (And actually one thing we've broken is the libdnf translations, but ostree and rpm-ostree aren't translated, and we don't even expose a way to change the output language for our DBus API so...)

.define("CMAKE_INSTALL_PREFIX:PATH", "/usr/libexec/rpm-ostree")
.define(
"INCLUDE_INSTALL_DIR:PATH",
"/usr/libexec/rpm-ostree/include",
)
.define("LIB_INSTALL_DIR:PATH", "/usr/libexec/rpm-ostree")
.define("SYSCONF_INSTALL_DIR:PATH", "/usr/libexec/rpm-ostree/etc")
.define("SHARE_INSTALL_PREFIX:PATH", "/usr/libexec/rpm-ostree/share")
.define("ENABLE_STATIC:BOOL", "1")
.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON")
// rpm-ostree maintains its own state
.define("WITH_SWDB:BOOL", "0")
// We don't need docs
.define("WITH_HTML:BOOL", "0")
.define("WITH_MAN:BOOL", "0")
// Don't need bindings
.define("WITH_BINDINGS:BOOL", "0")
.define("WITH_GIR:BOOL", "0")
.build_target("all")
.build();
println!(
"cargo:rustc-link-search=native={}/build/libdnf",
libdnf.display()
);
println!("cargo:rustc-link-lib=static=dnf");
Ok(())
}
7 changes: 7 additions & 0 deletions src/libpriv/libdnf/dnf-version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This is an awful hack necessary because this header file
// is generated in the libdnf build, but we don't want to serialize
// our C++ build waiting for that. Since we don't define the macros
// like LIBDNF_MAJOR_VERSION, if anything depends on them it will
// fail at build time.
#pragma once