forked from rpms/leapp-repository
67 lines
3.2 KiB
Diff
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
|
||
|
|