diff --git a/ancert b/ancert index 0152b7794c2d295554286ee8a82a75c324a2eaba..b97d226f2408d536621256609f58febeb1fa7245 100755 --- a/ancert +++ b/ancert @@ -127,6 +127,9 @@ def main(args): if args.category == 'System': print(e) return 1 + except RunCommandError as e: + print(e) + return 1 else: save_device_info(selected_components, dstree, args, logdir) diff --git a/lib/utils.py b/lib/utils.py index 68258f563636711ab9b93b18df50e208c8b477f1..68b8499345bcfa595b7a7d0f39b8da365832f0d5 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -385,6 +385,14 @@ def get_os_version(): print('OS Relase: %s' % re.search('PRETTY_NAME.*', output.strip()).group().split('"')[-2]) +def get_dist_info(): + cmd = 'rpm -E %{?dist}' + _, output = run_local_cmd(cmd, exit_msg='Failed to get dist info!', shell=True) + if output: + return output.strip().replace('\n', '') + raise RunCommandError('Nothig to get, please check it by runnig %s manually' % cmd) + + def has_mount_partition(devname): cmd = 'mount | grep "^%s"' % devname rc, output = run_local_cmd(cmd, shell=True) @@ -394,7 +402,11 @@ def has_mount_partition(devname): def has_swap_partition(devpath): - cmd = 'lsblk %s -no MOUNTPOINTS | grep SWAP' % devpath + # Supports different Anolis OS version for getting mount points by lsblk + if int(get_dist_info().replace('.an', '')) < 23: + cmd = 'lsblk %s -no MOUNTPOINT | grep SWAP' % devpath + else: + cmd = 'lsblk %s -no MOUNTPOINTS | grep SWAP' % devpath rc, output = run_local_cmd(cmd, shell=True) if rc: return False