Skip to content

Commit

Permalink
system-upgrade: Refactor, allow any offline transaction
Browse files Browse the repository at this point in the history
- Add the `dnf5 offline` command (not a plugin) with the same subcommands as the old `dnf4 system-upgrade`
- Make `dnf5 system-upgrade` a regular command, not a plugin, and have
  it share subcommands with `dnf5 offline` in addition to it
  implementing `system-upgrade download`
- Add `--offline` flag to `autoremove`, `distro-sync`, `downgrade`, `install`, `group
  install`, `group upgrade`, `reinstall`, `remove`, `swap`, and `upgrade` commands
- Change many references to "system upgrade" to "offline transaction"

For rpm-software-management#1052 and rpm-software-management#1224
  • Loading branch information
evan-goode committed Feb 27, 2024
1 parent 1dd933d commit 383f209
Show file tree
Hide file tree
Showing 28 changed files with 734 additions and 470 deletions.
1 change: 0 additions & 1 deletion dnf5-plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ add_subdirectory("config-manager_plugin")
add_subdirectory("copr_plugin")
add_subdirectory("needs_restarting_plugin")
add_subdirectory("repoclosure_plugin")
add_subdirectory("system_upgrade_plugin")
22 changes: 0 additions & 22 deletions dnf5-plugins/system_upgrade_plugin/CMakeLists.txt

This file was deleted.

166 changes: 0 additions & 166 deletions dnf5-plugins/system_upgrade_plugin/system_upgrade.hpp

This file was deleted.

72 changes: 0 additions & 72 deletions dnf5-plugins/system_upgrade_plugin/system_upgrade_cmd_plugin.cpp

This file was deleted.

5 changes: 3 additions & 2 deletions dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Provides: dnf5-command(advisory)
Provides: dnf5-command(clean)
Provides: dnf5-command(download)
Provides: dnf5-command(makecache)
Provides: dnf5-command(offline)
Provides: dnf5-command(system-upgrade)


# ========== build options ==========
Expand Down Expand Up @@ -654,14 +656,13 @@ Provides: dnf5-command(config-manager)
Provides: dnf5-command(copr)
Provides: dnf5-command(needs-restarting)
Provides: dnf5-command(repoclosure)
Provides: dnf5-command(system-upgrade)

%description -n dnf5-plugins
Core DNF5 plugins that enhance dnf5 with builddep, changelog,
config-manager, copr, and repoclosure commands.

%files -n dnf5-plugins -f dnf5-plugin-builddep.lang -f dnf5-plugin-changelog.lang -f dnf5-plugin-config-manager.lang -f dnf5-plugin-copr.lang -f dnf5-plugin-needs-restarting.lang -f dnf5-plugin-repoclosure.lang
%config %{_unitdir}/dnf5-system-upgrade.service
%config %{_unitdir}/dnf5-offline-transaction.service
%{_libdir}/dnf5/plugins/*.so
%{_mandir}/man8/dnf5-builddep.8.*
%{_mandir}/man8/dnf5-copr.8.*
Expand Down
13 changes: 11 additions & 2 deletions dnf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ if(NOT WITH_DNF5)
return()
endif()

set(SYSTEMD_SYSTEM_UNIT_DIR /usr/lib/systemd/system)

find_package(Threads)

# set gettext domain for translations
Expand Down Expand Up @@ -32,7 +34,10 @@ target_link_libraries(dnf5 PRIVATE common libdnf5 libdnf5-cli Threads::Threads)
install(TARGETS dnf5 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

pkg_check_modules(RPM REQUIRED rpm>=4.17.0)
target_link_libraries(dnf5 PRIVATE ${RPM_LIBRARIES})
pkg_check_modules(SDBUS_CPP REQUIRED sdbus-c++)
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)

target_link_libraries(dnf5 PRIVATE ${RPM_LIBRARIES} ${SDBUS_CPP_LIBRARIES} ${LIBSYSTEMD_LIBRARIES})


find_package(bash-completion)
Expand All @@ -47,7 +52,11 @@ install(FILES bash-completion/dnf5 DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR}
install(FILES "README.plugins" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/dnf5/plugins" RENAME "README")
install(DIRECTORY "config/usr/" DESTINATION "${CMAKE_INSTALL_PREFIX}" PATTERN ".gitkeep" EXCLUDE)
install(DIRECTORY "config/etc/" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}" PATTERN ".gitkeep" EXCLUDE)

install(DIRECTORY "config/systemd/system/" DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}" PATTERN ".gitkeep" EXCLUDE)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${SYSTEMD_SYSTEM_UNIT_DIR}/dnf5-offline-transaction.service
${SYSTEMD_SYSTEM_UNIT_DIR}/system-update.target.wants/dnf5-offline-transaction.service)"
)

add_subdirectory(po)
add_subdirectory("include")
2 changes: 2 additions & 0 deletions dnf5/commands/autoremove/autoremove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

#include "autoremove.hpp"

#include <dnf5/shared_options.hpp>
#include <libdnf5/rpm/package_query.hpp>

namespace dnf5 {
Expand All @@ -35,6 +36,7 @@ void AutoremoveCommand::set_parent_command() {
void AutoremoveCommand::set_argument_parser() {
get_argument_parser_command()->set_description(
"Remove all unneeded packages originally installed as dependencies.");
create_offline_option(*this);
}

void AutoremoveCommand::configure() {
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/distro-sync/distro-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void DistroSyncCommand::set_argument_parser() {
allow_erasing = std::make_unique<AllowErasingOption>(*this);
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
auto skip_broken = std::make_unique<SkipBrokenOption>(*this);
create_offline_option(*this);
}

void DistroSyncCommand::configure() {
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/downgrade/downgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void DowngradeCommand::set_argument_parser() {
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
auto skip_broken = std::make_unique<SkipBrokenOption>(*this);
create_allow_downgrade_options(*this);
create_offline_option(*this);
}

void DowngradeCommand::configure() {
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/group/group_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void GroupInstallCommand::set_argument_parser() {
auto skip_broken = std::make_unique<SkipBrokenOption>(*this);
create_allow_downgrade_options(*this);
create_downloadonly_option(*this);
create_offline_option(*this);
}

void GroupInstallCommand::configure() {
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/group/group_upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void GroupUpgradeCommand::set_argument_parser() {

auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
create_allow_downgrade_options(*this);
create_offline_option(*this);
}

void GroupUpgradeCommand::configure() {
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/install/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void InstallCommand::set_argument_parser() {
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
auto skip_broken = std::make_unique<SkipBrokenOption>(*this);
create_allow_downgrade_options(*this);
create_offline_option(*this);
}

void InstallCommand::configure() {
Expand Down
Loading

0 comments on commit 383f209

Please sign in to comment.