Skip to content
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'tests'

on:
pull_request:
paths:
- '.github/workflows/tests.yml'
- '**.spec'
- '**CMakeLists.txt'
- 'contrib/test-spec-bconds.py'
# allow manual execution from the GitHub web interface
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
spec-bconds:
name: Test rebuilding spec with different --with bconds
runs-on: ubuntu-latest
container:
image: fedora:rawhide
steps:
- name: Install packages
run: |
dnf -y install ccache dnf-plugins-core git rpm-build

- name: Create ccache symlinks to prioritize it over gcc
run: |
ln -s /usr/bin/ccache /usr/local/bin/gcc
ln -s /usr/bin/ccache /usr/local/bin/g++
ln -s /usr/bin/ccache /usr/local/bin/cc
ln -s /usr/bin/ccache /usr/local/bin/c++

- name: Checkout sources
run: |
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY dnf5-pr
cd dnf5-pr
git fetch origin $GITHUB_REF:branch-pr
git switch branch-pr

- name: Run tests
run: |
cd dnf5-pr/contrib
./test-spec-bconds.py
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option(WITH_PYTHON_PLUGINS_LOADER "Build a special dnf5 plugin that loads Python
# build options - features
option(WITH_COMPS "Build with comps groups and environments support" ON)
option(WITH_MODULEMD "Build with modulemd modules support" ON)
option(WITH_STATIC_LIBSOLV "Link with dependencies of static libsolv" OFF)
option(WITH_ZCHUNK "Build with zchunk delta compression support" ON)

# build options - documentation
Expand Down
2 changes: 1 addition & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(SWIG_COMPILE_OPTIONS
-Wno-missing-declarations
-Wno-missing-field-initializers
-Wno-sign-compare
-Wno-sometimes-uninitialized
# -Wno-sometimes-uninitialized
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be no longer needed, the problem was fixed in glib.

-Wno-strict-aliasing
-Wno-unused-function
-Wno-unused-parameter
Expand Down
169 changes: 169 additions & 0 deletions contrib/test-spec-bconds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/usr/bin/python3


import os
import subprocess
import sys


FLAGS = {
"comps": {},
"dnf5": {
"with": ["libdnf-cli"],
},
"dnf5_plugins": {},
"dnf5daemon_client": {
"with": ["libdnf-cli"],
},
"dnf5daemon_server": {
"with": ["libdnf-cli"],
},
"dnf5daemon_tests": {},
"html": {},
# "libdnf_cli": {},
"modulemd": {},
"perl5": {},
"plugin_actions": {},
"python3": {},
"python_plugins_loader": {
# requires python3
"with": ["python3"],
},
"ruby": {},
"static_libsolv": {},
"zchunk": {},
}


FLAGS_ALWAYS_WITH = [
"libdnf_cli",
"tests",
]


FLAGS_ALWAYS_WITHOUT = [
# we don't care about a different compiler now
"clang",

# broken option
"go",

# man pages require nearly all other options on
"man",

# we don't care about performance tests now
"performance_tests",

# we don't care about code sanity now
"sanitizers",
]


TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
SPEC = os.path.abspath(os.path.join(TOPDIR, "dnf5.spec"))


def get_name_version():
cmd = ["rpmspec", "-q", SPEC, "--srpm", "--qf", "%{name}-%{version}"]
return subprocess.check_output(cmd, encoding="utf-8").strip()


def git_archive():
"""
Create a tarball named exactly as the tarball from the spec,
so we don't have to modify the spec at all.
"""
nv = get_name_version()
archive_path = f"{TOPDIR}/{nv}.tar.gz"
cmd = [
"git", "archive",
"--prefix", f"{nv}/",
"--output", archive_path,
"HEAD"
]
subprocess.run(cmd, check=True, cwd=TOPDIR)
print(f"Created archive {archive_path}")


def install_build_deps():
cmd = ["dnf", "-y", "builddep", SPEC]

flags = []
flags += list(FLAGS)
flags += list(FLAGS_ALWAYS_WITH)
for data in FLAGS.values():
flags += data.get("with", [])

for flag in flags:
cmd += ["--define", f"_with_{flag} 1"]

subprocess.run(cmd, check=True)


def build(with_flag):
data = FLAGS[with_flag]

cmd = ["rpmbuild", "--ba", SPEC]
cmd += [
# use tarball from git_archive()'s target location
"--define", f"_sourcedir {TOPDIR}",
# speedup: disable compression
"--define", "_source_payload w.ufdio",
"--define", "_binary_payload w.ufdio",
# speedup: disable debuginfo
"--define", "debug_package %{nil}",
]

# enable the current flag
cmd += ["--with", with_flag]

# disable the other flags
for without_flag in FLAGS:
if without_flag == with_flag:
continue

# enable deps instead of disabling
deps_with = data.get("with", [])
if without_flag in deps_with:
cmd += ["--with", without_flag]
continue

cmd += ["--without", without_flag]

# enable the flags that should be always on
for always_with_flag in FLAGS_ALWAYS_WITH:
cmd += ["--with", always_with_flag]

# disable the flags that should be always off
for always_without_flag in FLAGS_ALWAYS_WITHOUT:
cmd += ["--without", always_without_flag]

print(10 * "\n")
print(f"Building with flag '{with_flag}'...")
print("Running command:", cmd)
try:
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError:
print(f"Error: Failed to build with flag '{with_flag}'")
return False
return True


def main():
git_archive()
install_build_deps()

errors = []
for flag in FLAGS:
success = build(flag)
if not success:
errors.append(flag)

if errors:
print(10 * "\n")
print("Error: The following flags failed to build:", errors)
sys.exit(1)


if __name__ == "__main__":
main()
38 changes: 36 additions & 2 deletions dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Obsoletes: microdnf < 4
%bcond_without modulemd
%bcond_without zchunk

%if 0%{?is_opensuse}
%bcond_without static_libsolv
%else
%bcond_with static_libsolv
%endif

%bcond_with html
%if 0%{?rhel} == 8
%bcond_with man
Expand Down Expand Up @@ -84,6 +90,13 @@ BuildRequires: pkgconfig(rpm) >= 4.17.0
BuildRequires: pkgconfig(sqlite3)
BuildRequires: toml11-static

%if %{with static_libsolv}
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libzstd)
%endif

%if %{with clang}
BuildRequires: clang
%else
Expand Down Expand Up @@ -175,6 +188,7 @@ DNF5 is a command-line package manager that automates the process of installing,
upgrading, configuring, and removing computer programs in a consistent manner.
It supports RPM packages, modulemd modules, and comps groups & environments.

%if %{with dnf5}
%files
%{_bindir}/dnf5

Expand All @@ -191,14 +205,14 @@ It supports RPM packages, modulemd modules, and comps groups & environments.
%dir %{_libdir}/dnf5
%dir %{_libdir}/dnf5/plugins
%doc %{_libdir}/dnf5/plugins/README
%dir %{_libdir}/libdnf5/plugins
%dir %{_datadir}/bash-completion/
%dir %{_datadir}/bash-completion/completions/
%{_datadir}/bash-completion/completions/dnf5
%dir %{_prefix}/lib/sysimage/dnf
%verify(not md5 size mtime) %ghost %{_prefix}/lib/sysimage/dnf/*
%license COPYING.md
%license gpl-2.0.txt
%if %{with man}
%{_mandir}/man8/dnf5.8.*
%{_mandir}/man8/dnf5-advisory.8.*
%{_mandir}/man8/dnf5-clean.8.*
Expand Down Expand Up @@ -228,6 +242,9 @@ It supports RPM packages, modulemd modules, and comps groups & environments.
# TODO(jkolarik): modularity is not ready yet
# %%{_mandir}/man7/dnf5-modularity.7.*
%{_mandir}/man7/dnf5-specs.7.*
%endif
# with dnf5
%endif

# ========== libdnf5 ==========
%package -n libdnf5
Expand All @@ -242,6 +259,7 @@ Package management library.

%files -n libdnf5
%dir %{_libdir}/libdnf5
%dir %{_libdir}/libdnf5/plugins
%{_libdir}/libdnf5.so.1*
%license lgpl-2.1.txt
%{_var}/cache/libdnf/
Expand All @@ -265,6 +283,8 @@ Library for working with a terminal in a command-line package manager.

# ========== dnf5-devel ==========

%if %{with dnf5}

%package -n dnf5-devel
Summary: Development files for dnf5
License: LGPL-2.1-or-later
Expand All @@ -280,6 +300,9 @@ Develpment files for dnf5.
%license COPYING.md
%license lgpl-2.1.txt

# with dnf5
%endif


# ========== libdnf5-devel ==========

Expand Down Expand Up @@ -490,8 +513,10 @@ Command-line interface for dnf5daemon-server.
%{_bindir}/dnf5daemon-client
%license COPYING.md
%license gpl-2.0.txt
%if %{with man}
%{_mandir}/man8/dnf5daemon-client.8.*
%endif
%endif


# ========== dnf5daemon-server ==========
Expand Down Expand Up @@ -527,9 +552,11 @@ Package management service with a DBus interface.
%{_datadir}/polkit-1/actions/org.rpm.dnf.v0.policy
%license COPYING.md
%license gpl-2.0.txt
%if %{with man}
%{_mandir}/man8/dnf5daemon-server.8.*
%{_mandir}/man8/dnf5daemon-dbus-api.8.*
%endif
%endif


# ========== dnf5-plugins ==========
Expand Down Expand Up @@ -563,11 +590,13 @@ Core DNF5 plugins that enhance dnf5 with builddep and changelog commands.
-DWITH_DNF5DAEMON_SERVER=%{?with_dnf5daemon_server:ON}%{!?with_dnf5daemon_server:OFF} \
-DWITH_LIBDNF5_CLI=%{?with_libdnf_cli:ON}%{!?with_libdnf_cli:OFF} \
-DWITH_DNF5=%{?with_dnf5:ON}%{!?with_dnf5:OFF} \
-DWITH_DNF5_PLUGINS=%{?with_dnf5_plugins:ON}%{!?with_dnf5_plugins:OFF} \
-DWITH_PLUGIN_ACTIONS=%{?with_plugin_actions:ON}%{!?with_plugin_actions:OFF} \
-DWITH_PYTHON_PLUGINS_LOADER=%{?with_python_plugins_loader:ON}%{!?with_python_plugins_loader:OFF} \
\
-DWITH_COMPS=%{?with_comps:ON}%{!?with_comps:OFF} \
-DWITH_MODULEMD=%{?with_modulemd:ON}%{!?with_modulemd:OFF} \
-DWITH_STATIC_LIBSOLV=%{?with_static_libsolv:ON}%{!?with_static_libsolv:OFF} \
-DWITH_ZCHUNK=%{?with_zchunk:ON}%{!?with_zchunk:OFF} \
\
-DWITH_HTML=%{?with_html:ON}%{!?with_html:OFF} \
Expand Down Expand Up @@ -601,6 +630,9 @@ Core DNF5 plugins that enhance dnf5 with builddep and changelog commands.
%install
%cmake_install

install -d %{buildroot}/%{_libdir}/libdnf5/plugins

%if %{with dnf5}
# own dirs and files that dnf5 creates on runtime
mkdir -p %{buildroot}%{_prefix}/lib/sysimage/dnf
for files in \
Expand All @@ -611,11 +643,13 @@ for files in \
do
touch %{buildroot}%{_prefix}/lib/sysimage/dnf/$files
done
# with dnf5
%endif

#find_lang {name}

# Remove if condition when Fedora 37 is EOL
%if 0%{?fedora} > 37
%if %{with dnf5} && 0%{?fedora} > 37
ln -sr %{buildroot}%{_bindir}/dnf5 %{buildroot}%{_bindir}/microdnf
%endif

Expand Down
4 changes: 3 additions & 1 deletion dnf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ else()
endif()

install(FILES bash-completion/dnf5 DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR})
install(FILES "README.plugins" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/dnf5/plugins" RENAME "README")
if(WITH_DNF5_PLUGINS)
install(FILES "README.plugins" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/dnf5/plugins" RENAME "README")
endif()
install(DIRECTORY "config/usr/" DESTINATION "${CMAKE_INSTALL_PREFIX}")
install(DIRECTORY "config/etc/" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}")

Expand Down
Loading