1010from leapp .libraries .common .config import get_env , get_product_type
1111from leapp .libraries .common .config .version import get_target_major_version
1212from leapp .libraries .common .gpg import get_path_to_gpg_certs , is_nogpgcheck_set
13- from leapp .libraries .common .cln_switch import cln_switch
13+ from leapp .libraries .common .cln_switch import override_channel
1414from leapp .libraries .stdlib import api , CalledProcessError , config , run
1515from leapp .models import RequiredTargetUserspacePackages # deprecated
1616from leapp .models import TMPTargetRepositoriesFacts # deprecated all the time
@@ -330,14 +330,6 @@ def prepare_target_userspace(context, userspace_dir, enabled_repos, packages):
330330
331331 raise StopActorExecutionError (message = message , details = details )
332332
333- api .current_logger ().debug ('Checking the CLN registration status' )
334- context .call (['rhn_check' ], callback_raw = utils .logging_handler )
335-
336- # To get packages from Spacewalk repos (aka CLN) we need to switch the CLN channel.
337- # localonly flag switches channel only inside of the overlayfs
338- api .current_logger ().debug ('Switching channel to %s' % target_major_version )
339- context .call (['cln-switch-channel' , '-t' , str (target_major_version ), '--localonly' ])
340-
341333
342334def _query_rpm_for_pkg_files (context , pkgs ):
343335 files_owned_by_rpm = set ()
@@ -689,11 +681,7 @@ def _prep_repository_access(context, target_userspace):
689681 run (['rm' , '-rf' , os .path .join (target_etc , 'rhsm' )])
690682 context .copytree_from ('/etc/rhsm' , os .path .join (target_etc , 'rhsm' ))
691683
692- # Copy RHN data independent from RHSM config
693684 if os .path .isdir ('/etc/sysconfig/rhn' ):
694- context .call (['/usr/sbin/rhn_check' ], callback_raw = utils .logging_handler )
695- run (['rm' , '-rf' , os .path .join (target_etc , 'sysconfig/rhn' )])
696- context .copytree_from ('/etc/sysconfig/rhn' , os .path .join (target_etc , 'sysconfig/rhn' ))
697685 # Set up spacewalk plugin config
698686 with open (os .path .join (target_etc , 'dnf/plugins/spacewalk.conf' ), 'r' ) as f :
699687 lines = f .readlines ()
@@ -1182,6 +1170,11 @@ def _create_target_userspace(context, packages, files, target_repoids):
11821170 _copy_files (target_context , files )
11831171 dnfplugin .install (_get_target_userspace ())
11841172
1173+ # do not switch channel before this stage because _copy_files above copies
1174+ # related configuration files from host to target userspace
1175+ target_major_version = get_target_major_version ()
1176+ override_channel (os .path .join (_get_target_userspace (), 'etc/sysconfig/rhn/up2date' ), target_major_version )
1177+
11851178 # and do not forget to set the rhsm into the container mode again
11861179 with mounting .NspawnActions (_get_target_userspace ()) as target_context :
11871180 rhsm .set_container_mode (target_context )
@@ -1283,4 +1276,4 @@ def perform():
12831276 api .produce (TargetUserSpaceInfo (
12841277 path = _get_target_userspace (),
12851278 scratch = constants .SCRATCH_DIR ,
1286- mounts = constants .MOUNTS_DIR ))
1279+ mounts = constants .MOUNTS_DIR ))
0 commit comments