diff --git a/CMakeLists.txt b/CMakeLists.txt index abbe69bdf6..9ebc7a9c05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ project(dnf5 LANGUAGES CXX C VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_ cmake_policy(VERSION ${CMAKE_VERSION}) set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set (SYSTEMD_DIR "/usr/lib/systemd/system") message("Building ${PROJECT_NAME} version ${PROJECT_VERSION}") @@ -114,6 +115,7 @@ include_directories("${PROJECT_SOURCE_DIR}/common") # libdnf add_subdirectory("common") +add_subdirectory("etc") add_subdirectory("include") add_subdirectory("libdnf") add_subdirectory("libdnf-cli") diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt new file mode 100644 index 0000000000..534840cd9f --- /dev/null +++ b/etc/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory("systemd") diff --git a/etc/systemd/CMakeLists.txt b/etc/systemd/CMakeLists.txt new file mode 100644 index 0000000000..c043e391ec --- /dev/null +++ b/etc/systemd/CMakeLists.txt @@ -0,0 +1,5 @@ +set(systemd_FILES + dnf5-makecache.service + dnf5-makecache.timer) + +install(FILES ${systemd_FILES} DESTINATION ${SYSTEMD_DIR}) diff --git a/etc/systemd/dnf5-makecache.service b/etc/systemd/dnf5-makecache.service new file mode 100644 index 0000000000..783f321b7e --- /dev/null +++ b/etc/systemd/dnf5-makecache.service @@ -0,0 +1,15 @@ +[Unit] +Description=dnf5 makecache +# On systems managed by either rpm-ostree/ostree, dnf is read-only; +# while someone might theoretically want the cache updated, in practice +# anyone who wants that could override this via a file in /etc. +ConditionPathExists=!/run/ostree-booted + +After=network-online.target + +[Service] +Type=oneshot +Nice=19 +IOSchedulingClass=2 +IOSchedulingPriority=7 +ExecStart=/usr/bin/dnf5 makecache diff --git a/etc/systemd/dnf5-makecache.timer b/etc/systemd/dnf5-makecache.timer new file mode 100644 index 0000000000..d766ed618a --- /dev/null +++ b/etc/systemd/dnf5-makecache.timer @@ -0,0 +1,15 @@ +[Unit] +Description=dnf5 makecache +ConditionKernelCommandLine=!rd.live.image +# See comment in dnf5-makecache.service +ConditionPathExists=!/run/ostree-booted +Wants=network-online.target + +[Timer] +OnBootSec=10min +OnUnitInactiveSec=1h +RandomizedDelaySec=60m +Unit=dnf5-makecache.service + +[Install] +WantedBy=timers.target