From 4bd6f1f176baf465872da49a71cfe2d41122a0b8 Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:17:48 +0100 Subject: [PATCH] patch --- src/controllers/Package/Apt.py | 30 ++++++++++++++---------------- src/controllers/Package/Dnf.py | 16 +++++++++++----- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/controllers/Package/Apt.py b/src/controllers/Package/Apt.py index af1885d..9631fc6 100644 --- a/src/controllers/Package/Apt.py +++ b/src/controllers/Package/Apt.py @@ -329,26 +329,24 @@ def update(self, packagesList, exit_on_package_update_error: bool = True, dry_ru except Exception as e: raise Exception('Could not retrieve current version of package ' + pkg['name'] + ': ' + str(e)) - # If --keep-oldconf is True, then keep the old configuration file + # Define the command to update the package + cmd = '/usr/bin/apt-get install ' + pkg['name'] + '=' + pkg['target_version'] + ' -y' + + # If --keep-oldconf is True, then keep the old configuration files if self.keep_oldconf: - cmd = [ - 'apt-get', 'install', pkg['name'] + '=' + pkg['target_version'], '-y', - '-o', 'Dpkg::Options::=--force-confdef', - '-o', 'Dpkg::Options::=--force-confold', - # Debug only - # '--dry-run' - ] - else: - cmd = ['apt-get', 'install', pkg['name'] + '=' + pkg['target_version'], '-y', - # Debug only - # '--dry-run' - ] + cmd += ' -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold' # If --dry-run is True, then simulate the update if dry_run == True: - cmd.append('--dry-run') - - popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) + cmd += ' --dry-run' + + popen = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True, + shell = True + ) # Print lines as they are read for line in popen.stdout: diff --git a/src/controllers/Package/Dnf.py b/src/controllers/Package/Dnf.py index b3c328b..4634136 100644 --- a/src/controllers/Package/Dnf.py +++ b/src/controllers/Package/Dnf.py @@ -343,14 +343,20 @@ def update(self, packagesList, exit_on_package_update_error: bool = True, dry_ru continue # Define the command to update the package - cmd = ['dnf', 'update', pkg['name'] + '-' + pkg['target_version'], '-y'] + cmd = '/usr/bin/dnf update ' + pkg['name'] + '-' + pkg['target_version'] + ' -y' # If dry_run is True, add the --setopt tsflags=test option to simulate the update if dry_run == True: - cmd.append('--setopt') - cmd.append('tsflags=test') - - popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) + cmd += '--setopt tsflags=test' + + popen = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + bufsize=1, + universal_newlines=True, + shell = True + ) # Print lines as they are read for line in popen.stdout: