leapp-repository/0036-target_userspace_creator-Use-MOVE-instead-of-copy-fo.patch
Petr Stodulka ee57901913 CTC2 build candidate
- Fix the calculation of the required free space on each partitions/volume for the upgrade transactions
- Create source overlay images with dynamic sizes to optimize disk space consumption
- Update GRUB2 when /boot resides on multiple devices aggregated in RAID
- Use new leapp CLI API which provides better report summary output
- Introduce possibility to add (custom) kernel drivers to initramfs
- Detect and report use of deprecated Xorg drivers
- Fix the generation of the report about hybrid images
- Inhibit the upgrade when unsupported x86-64 microarchitecture is detected
- Minor improvements and fixes of various reports
- Requires leapp-framework 4.0
- Update leapp data files
- Resolves: rhbz#2140011, rhbz#2144304, rhbz#2174095, rhbz#2219544, rhbz#2215997
2023-07-18 09:39:37 +02:00

67 lines
3.2 KiB
Diff

From e76e5cebeb41125a2075fafaba94faca66df5476 Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Thu, 13 Jul 2023 15:38:22 +0200
Subject: [PATCH 36/42] target_userspace_creator: Use MOVE instead of copy for
the persistent cache
If leapp is executed with LEAPP_DEVEL_USE_PERSISTENT_PACKAGE_CACHE=1,
the /var/dnf/cache from the target container has been copied under
/var/lib/leapp/persistent_package_cache
The negative effect was that it took too much space on the disk
(800+ MBs, depends on how much rpms have been downloaded before..)
which could lead easily to the consumed disk space on related partition,
which eventually could stop also the leapp execution as it cannot
do any meaningful operations when the disk is full (e.g. access the
database).
This is done now without nspawn context functions as the move operation
does not make so much sense to be implemented as it's more expected
to copy to/from the container than moving files/dirs.
---
.../libraries/userspacegen.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py b/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
index cad923fb..4cff7b30 100644
--- a/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
+++ b/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
@@ -1,5 +1,6 @@
import itertools
import os
+import shutil
from leapp import reporting
from leapp.exceptions import StopActorExecution, StopActorExecutionError
@@ -121,9 +122,12 @@ class _InputData(object):
def _restore_persistent_package_cache(userspace_dir):
if get_env('LEAPP_DEVEL_USE_PERSISTENT_PACKAGE_CACHE', None) == '1':
- if os.path.exists(PERSISTENT_PACKAGE_CACHE_DIR):
- with mounting.NspawnActions(base_dir=userspace_dir) as target_context:
- target_context.copytree_to(PERSISTENT_PACKAGE_CACHE_DIR, '/var/cache/dnf')
+ if not os.path.exists(PERSISTENT_PACKAGE_CACHE_DIR):
+ return
+ dst_cache = os.path.join(userspace_dir, 'var', 'cache', 'dnf')
+ if os.path.exists(dst_cache):
+ run(['rm', '-rf', dst_cache])
+ shutil.move(PERSISTENT_PACKAGE_CACHE_DIR, dst_cache)
# We always want to remove the persistent cache here to unclutter the system
run(['rm', '-rf', PERSISTENT_PACKAGE_CACHE_DIR])
@@ -132,9 +136,9 @@ def _backup_to_persistent_package_cache(userspace_dir):
if get_env('LEAPP_DEVEL_USE_PERSISTENT_PACKAGE_CACHE', None) == '1':
# Clean up any dead bodies, just in case
run(['rm', '-rf', PERSISTENT_PACKAGE_CACHE_DIR])
- if os.path.exists(os.path.join(userspace_dir, 'var', 'cache', 'dnf')):
- with mounting.NspawnActions(base_dir=userspace_dir) as target_context:
- target_context.copytree_from('/var/cache/dnf', PERSISTENT_PACKAGE_CACHE_DIR)
+ src_cache = os.path.join(userspace_dir, 'var', 'cache', 'dnf')
+ if os.path.exists(src_cache):
+ shutil.move(src_cache, PERSISTENT_PACKAGE_CACHE_DIR)
def _the_nogpgcheck_option_used():
--
2.41.0