Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Dec 18, 2024
1 parent d6f8d67 commit 4bd6f1f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
30 changes: 14 additions & 16 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 11 additions & 5 deletions src/controllers/Package/Dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4bd6f1f

Please sign in to comment.