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

Extend version to four numbers (5.x.y.z) #1247

Merged
merged 4 commits into from
Mar 6, 2024
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
3 changes: 3 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
trigger: pull_request
targets:
- fedora-all
actions:
get-current-version:
- bash -c 'rpmspec -q --queryformat "%{VERSION}\n" dnf5.spec | head -n1'
- job: tests
trigger: pull_request
identifier: "dnf5-tests"
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)


include(VERSION.cmake)
project(dnf5 LANGUAGES CXX C VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
project(dnf5 LANGUAGES CXX C VERSION ${VERSION_PRIME}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
cmake_policy(VERSION ${CMAKE_VERSION})

set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down Expand Up @@ -93,9 +93,10 @@ endif()
add_definitions(-DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}")
add_definitions(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")

add_definitions(-DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR})
add_definitions(-DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR})
add_definitions(-DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH})
add_definitions(-DPROJECT_VERSION_PRIME=${VERSION_PRIME})
add_definitions(-DPROJECT_VERSION_MAJOR=${VERSION_MAJOR})
add_definitions(-DPROJECT_VERSION_MINOR=${VERSION_MINOR})
add_definitions(-DPROJECT_VERSION_MICRO=${VERSION_MICRO})

# libsolv options
if(ENABLE_SOLV_URPMREORDER)
Expand Down
27 changes: 18 additions & 9 deletions VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
set(DEFAULT_PROJECT_VERSION_MAJOR 5)
set(DEFAULT_PROJECT_VERSION_MINOR 1)
set(DEFAULT_PROJECT_VERSION_PATCH 13)
set(DEFAULT_PROJECT_VERSION_PRIME 5)
set(DEFAULT_PROJECT_VERSION_MAJOR 2)
set(DEFAULT_PROJECT_VERSION_MINOR 0)
set(DEFAULT_PROJECT_VERSION_MICRO 0)

if(DEFINED PROJECT_VERSION_PRIME)
if(NOT ${DEFAULT_PROJECT_VERSION_PRIME} STREQUAL ${PROJECT_VERSION_PRIME})
message(FATAL_ERROR "Variable DEFAULT_PROJECT_VERSION_PRIME=" ${DEFAULT_PROJECT_VERSION_PRIME} " in VERSION.cmake differs from PROJECT_VERSION_PRIME=" ${PROJECT_VERSION_PRIME} " in spec")
endif()
else()
set (VERSION_PRIME ${DEFAULT_PROJECT_VERSION_PRIME})
endif()

if(DEFINED PROJECT_VERSION_MAJOR)
if(NOT ${DEFAULT_PROJECT_VERSION_MAJOR} STREQUAL ${PROJECT_VERSION_MAJOR})
message(FATAL_ERROR "Variable DEFAULT_PROJECT_VERSION_MAJOR=" ${DEFAULT_PROJECT_VERSION_MAJOR} " in VERSION.cmake differs from PROJECT_VERSION_MAJOR=" ${PROJECT_VERSION_MAJOR} " in spec")
endif()
else()
set (PROJECT_VERSION_MAJOR ${DEFAULT_PROJECT_VERSION_MAJOR})
set (VERSION_MAJOR ${DEFAULT_PROJECT_VERSION_MAJOR})
endif()

if(DEFINED PROJECT_VERSION_MINOR)
if(NOT ${DEFAULT_PROJECT_VERSION_MINOR} STREQUAL ${PROJECT_VERSION_MINOR})
message(FATAL_ERROR "Variable DEFAULT_PROJECT_VERSION_MINOR=" ${DEFAULT_PROJECT_VERSION_MINOR} " in VERSION.cmake differs from PROJECT_VERSION_MINOR=" ${PROJECT_VERSION_MINOR} " in spec")
endif()
else()
set (PROJECT_VERSION_MINOR ${DEFAULT_PROJECT_VERSION_MINOR})
set (VERSION_MINOR ${DEFAULT_PROJECT_VERSION_MINOR})
endif()

if(DEFINED PROJECT_VERSION_PATCH)
if(NOT ${DEFAULT_PROJECT_VERSION_PATCH} STREQUAL ${PROJECT_VERSION_PATCH})
message(FATAL_ERROR "Variable DEFAULT_PROJECT_VERSION_PATCH=" ${DEFAULT_PROJECT_VERSION_PATCH} " in VERSION.cmake differs from PROJECT_VERSION_PATCH=" ${PROJECT_VERSION_PATCH} " in spec")
if(DEFINED PROJECT_VERSION_MICRO)
if(NOT ${DEFAULT_PROJECT_VERSION_MICRO} STREQUAL ${PROJECT_VERSION_MICRO})
message(FATAL_ERROR "Variable DEFAULT_PROJECT_VERSION_MICRO=" ${DEFAULT_PROJECT_VERSION_MICRO} " in VERSION.cmake differs from PROJECT_VERSION_MICRO=" ${PROJECT_VERSION_MICRO} " in spec")
endif()
else()
set (PROJECT_VERSION_PATCH ${DEFAULT_PROJECT_VERSION_PATCH})
set (VERSION_MICRO ${DEFAULT_PROJECT_VERSION_MICRO})
endif()
16 changes: 9 additions & 7 deletions dnf5.spec
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
%global project_version_major 5
%global project_version_minor 1
%global project_version_patch 13
%global project_version_prime 5
%global project_version_major 2
%global project_version_minor 0
%global project_version_micro 0

%bcond dnf5_obsoletes_dnf %[0%{?fedora} > 41 || 0%{?rhel} > 10]

Name: dnf5
Version: %{project_version_major}.%{project_version_minor}.%{project_version_patch}
Version: %{project_version_prime}.%{project_version_major}.%{project_version_minor}.%{project_version_micro}
Release: 1%{?dist}
Summary: Command-line package manager
License: GPL-2.0-or-later
Expand Down Expand Up @@ -758,9 +759,10 @@ automatically and regularly from systemd timers, cron jobs or similar.
-DWITH_PERFORMANCE_TESTS=%{?with_performance_tests:ON}%{!?with_performance_tests:OFF} \
-DWITH_DNF5DAEMON_TESTS=%{?with_dnf5daemon_tests:ON}%{!?with_dnf5daemon_tests:OFF} \
\
-DPROJECT_VERSION_MAJOR=%{project_version_major} \
-DPROJECT_VERSION_MINOR=%{project_version_minor} \
-DPROJECT_VERSION_PATCH=%{project_version_patch}
-DVERSION_PRIME=%{project_version_prime} \
-DVERSION_MAJOR=%{project_version_major} \
-DVERSION_MINOR=%{project_version_minor} \
-DVERSION_MICRO=%{project_version_micro}
%cmake_build
%if %{with man}
%cmake_build --target doc-man
Expand Down
5 changes: 5 additions & 0 deletions dnf5/include/dnf5/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ namespace dnf5 {

/// Application version
/// @since 5.0
/// PRIME version - completely changing API and everything in dnf (hopefully stays as a 5 for the foreseeable future)
/// MAJOR version - incompatible API changes
/// MINOR version - add functionality in a backward compatible manner
/// MICRO version - make backward compatible bug fixes
struct ApplicationVersion {
std::uint16_t prime;
ppisar marked this conversation as resolved.
Show resolved Hide resolved
std::uint16_t major;
std::uint16_t minor;
std::uint16_t micro;
Expand Down
10 changes: 7 additions & 3 deletions dnf5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,19 @@ static void print_versions(Context & context) {
constexpr const char * appl_name = "dnf5";
{
const auto & version = get_application_version();
std::cout << fmt::format("{} version {}.{}.{}", appl_name, version.major, version.minor, version.micro)
<< std::endl;
std::cout
<< fmt::format(
"{} version {}.{}.{}.{}", appl_name, version.prime, version.major, version.minor, version.micro)
<< std::endl;
const auto & api_version = get_plugin_api_version();
std::cout << fmt::format("{} plugin API version {}.{}", appl_name, api_version.major, api_version.minor)
<< std::endl;
}
{
const auto & version = libdnf5::get_library_version();
std::cout << fmt::format("libdnf5 version {}.{}.{}", version.major, version.minor, version.micro) << std::endl;
std::cout << fmt::format(
"libdnf5 version {}.{}.{}.{}", version.prime, version.major, version.minor, version.micro)
<< std::endl;
const auto & api_version = libdnf5::get_plugin_api_version();
std::cout << fmt::format("libdnf5 plugin API version {}.{}", api_version.major, api_version.minor) << std::endl;
}
Expand Down
5 changes: 4 additions & 1 deletion dnf5/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ namespace dnf5 {
namespace {

constexpr ApplicationVersion APPLICATION_VERSION{
.major = PROJECT_VERSION_MAJOR, .minor = PROJECT_VERSION_MINOR, .micro = PROJECT_VERSION_PATCH};
.prime = PROJECT_VERSION_PRIME,
.major = PROJECT_VERSION_MAJOR,
.minor = PROJECT_VERSION_MINOR,
.micro = PROJECT_VERSION_MICRO};

} // namespace

Expand Down
5 changes: 5 additions & 0 deletions include/libdnf5/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ namespace libdnf5 {

/// Library version
/// @since 5.0
/// PRIME version - completely changing API and everything in dnf (hopefully stays as a 5 for the foreseeable future)
/// MAJOR version - incompatible API changes
/// MINOR version - add functionality in a backward compatible manner
/// MICRO version - make backward compatible bug fixes
struct LibraryVersion {
std::uint16_t prime;
std::uint16_t major;
std::uint16_t minor;
std::uint16_t micro;
Expand Down
6 changes: 4 additions & 2 deletions libdnf5/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ namespace libdnf5 {
namespace {

constexpr LibraryVersion LIBRARY_VERSION{
.major = PROJECT_VERSION_MAJOR, .minor = PROJECT_VERSION_MINOR, .micro = PROJECT_VERSION_PATCH};

.prime = PROJECT_VERSION_PRIME,
.major = PROJECT_VERSION_MAJOR,
.minor = PROJECT_VERSION_MINOR,
.micro = PROJECT_VERSION_MICRO};
} // namespace


Expand Down
Loading