Skip to content

Commit

Permalink
Extend version to four numbers (5.x.y.z)
Browse files Browse the repository at this point in the history
We want to keep the most important version number stable (as a 5 because
we are calling the project dnf5) however we also want to mostly adhere
to the SEMVER system. Therefore we switch to a 4 number scheme,
incrementing the:

PRIME version when completely changing API and everything in dnf
MAJOR version when you make incompatible API changes
MINOR version when you add functionality in a backward compatible manner
MICRO version when you make backward compatible bug fixes

The PRIME version should hopefully stay as a 5 for the foreseeable future.
  • Loading branch information
kontura committed Feb 14, 2024
1 parent 1b61919 commit 3ddd3fd
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
3 changes: 2 additions & 1 deletion 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 ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
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,6 +93,7 @@ endif()
add_definitions(-DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}")
add_definitions(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")

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})
Expand Down
15 changes: 12 additions & 3 deletions VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
set(DEFAULT_PROJECT_VERSION_MAJOR 5)
set(DEFAULT_PROJECT_VERSION_MINOR 1)
set(DEFAULT_PROJECT_VERSION_MICRO 11)
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})
Expand Down
10 changes: 6 additions & 4 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_micro 11
%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} > 40 || 0%{?rhel} > 10]

Name: dnf5
Version: %{project_version_major}.%{project_version_minor}.%{project_version_micro}
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 @@ -712,6 +713,7 @@ config-manager, copr, and repoclosure commands.
-DWITH_PERFORMANCE_TESTS=%{?with_performance_tests:ON}%{!?with_performance_tests:OFF} \
-DWITH_DNF5DAEMON_TESTS=%{?with_dnf5daemon_tests:ON}%{!?with_dnf5daemon_tests:OFF} \
\
-DVERSION_PRIME=%{project_version_prime} \
-DVERSION_MAJOR=%{project_version_major} \
-DVERSION_MINOR=%{project_version_minor} \
-DVERSION_MICRO=%{project_version_micro}
Expand Down
1 change: 1 addition & 0 deletions dnf5/include/dnf5/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace dnf5 {
/// Application version
/// @since 5.0
struct ApplicationVersion {
std::uint16_t prime;
std::uint16_t major;
std::uint16_t minor;
std::uint16_t micro;
Expand Down
4 changes: 2 additions & 2 deletions dnf5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,15 @@ 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::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_MICRO};
.prime = PROJECT_VERSION_PRIME,
.major = PROJECT_VERSION_MAJOR,
.minor = PROJECT_VERSION_MINOR,
.micro = PROJECT_VERSION_MICRO};

} // namespace

Expand Down
1 change: 1 addition & 0 deletions include/libdnf5/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace libdnf5 {
/// Library version
/// @since 5.0
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_MICRO};

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


Expand Down

0 comments on commit 3ddd3fd

Please sign in to comment.