Skip to content

Commit

Permalink
3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Nov 12, 2024
1 parent fb71a35 commit 4750fa4
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion linupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():
# Execute packages update
my_package.update(my_args.packages_to_update,
my_args.assume_yes,
my_args.ignore_exclude,
my_args.ignore_exclusions,
my_args.check_updates,
my_args.dist_upgrade,
my_args.keep_oldconf,
Expand Down
11 changes: 11 additions & 0 deletions src/controllers/App/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ def clean_log(self, text):
text = text.strip()

return text

#-----------------------------------------------------------------------------------------------
#
# Convert a string to a boolean
#
#-----------------------------------------------------------------------------------------------
def stringToBoolean(self, value: str):
if value == 'true' or value == 'True':
return True

return False
12 changes: 6 additions & 6 deletions src/controllers/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse(self):
# Default values
Args.assume_yes = False
Args.check_updates = False
Args.ignore_exclude = False
Args.ignore_exclusions = False
Args.packages_to_update = []
Args.dist_upgrade = False
Args.keep_oldconf = True
Expand Down Expand Up @@ -95,7 +95,7 @@ def parse(self):
# Check updates
parser.add_argument("--check-updates", "-cu", action="store_true", default="null")
# Ignore exclude
parser.add_argument("--ignore-exclude", "-ie", action="store_true", default="null")
parser.add_argument("--ignore-exclusions", "-ie", action="store_true", default="null")
# Exit on package update error
parser.add_argument("--exit-on-package-update-error", action="store", nargs='?', default="null")

Expand Down Expand Up @@ -367,10 +367,10 @@ def parse(self):
Args.dry_run = True

#
# If --ignore-exclude param has been set
# If --ignore-exclusions param has been set
#
if args.ignore_exclude != "null":
Args.ignore_exclude = True
if args.ignore_exclusions != "null":
Args.ignore_exclusions = True

#
# If --check-updates param has been set
Expand Down Expand Up @@ -742,7 +742,7 @@ def help(self):
},
{
'args': [
'--ignore-exclude',
'--ignore-exclusions',
'-ie'
],
'description': 'Ignore all package exclusions'
Expand Down
35 changes: 27 additions & 8 deletions src/controllers/Module/Reposerver/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ def websocket_on_message(self, ws, message):
status = None
error = None

# Update parameters default values
dry_run = False
ignore_exclusions = False
keep_oldconf = True
full_upgrade = False

# Decode JSON message
message = json.loads(message)

Expand Down Expand Up @@ -327,8 +333,8 @@ def websocket_on_message(self, ws, message):
with Log(log):
self.reposerverStatusController.send_packages_info()

# Case the request is 'update-all-packages', then update all packages
elif message['request'] == 'update-all-packages':
# Case the request is 'request-all-packages-update', then update all packages
elif message['request'] == 'request-all-packages-update':
print('[reposerver-agent] Reposerver requested all packages update')

# Send a response to the reposerver to make the request as running
Expand All @@ -346,19 +352,31 @@ def websocket_on_message(self, ws, message):
# Send a summary to the reposerver, with the summary of the update (number of packages updated or failed)
summary = self.packageController.summary

# Case the request is 'request-specific-packages-installation', then update a list of packages
# Case the request is 'request-packages-update', then update a list of specific packages
# A list of packages must be provided in the message
elif message['request'] == 'request-specific-packages-installation':
elif message['request'] == 'request-packages-update':
if 'data' in message:
# If a list of packages is provided, then the update can be performed
if 'packages' in message['data'] and len(message['data']['packages']) > 0:
# Try to retrieve the update params
if 'update-params' in message['data']:
if 'dry-run' in message['data']['update-params']:
dry_run = Utils().stringToBoolean(message['data']['update-params']['dry-run'])
if 'ignore-exclusions' in message['data']['update-params']:
ignore_exclusions = Utils().stringToBoolean(message['data']['update-params']['ignore-exclusions'])
if 'keep-config-files' in message['data']['update-params']:
keep_oldconf = Utils().stringToBoolean(message['data']['update-params']['keep-config-files'])
if 'full-upgrade' in message['data']['update-params']:
full_upgrade = Utils().stringToBoolean(message['data']['update-params']['full-upgrade'])

print('[reposerver-agent] Reposerver requested to update a list of packages')

# Send a response to the reposerver to make the request as running
self.set_request_status(request_id, 'running')

# Log everything to the log file
with Log(log):
self.packageController.update(message['data']['packages'], True)
self.packageController.update(message['data']['packages'], True, ignore_exclusions, False, full_upgrade, keep_oldconf, dry_run)

# Send a summary to the reposerver, with the summary of the installation (number of packages installed or failed)
summary = self.packageController.summary
Expand Down Expand Up @@ -555,9 +573,10 @@ def main(self):
# 3600 / 5sec (sleep 5) = 720
if counter == 0 or counter == 720:
# Sending full status
print('[reposerver-agent] Periodically sending informations about this host to the repomanager server')
self.reposerverStatusController.send_general_info()
self.reposerverStatusController.send_packages_info()
# TODO debug
# print('[reposerver-agent] Periodically sending informations about this host to the repomanager server')
# self.reposerverStatusController.send_general_info()
# self.reposerverStatusController.send_packages_info()

# Reset counter
counter = 0
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def update(self, packagesList, exit_on_package_update_error: bool = True, dry_ru
cmd = ['apt-get', 'install', pkg['name'] + '=' + pkg['available_version'], '-y']

# If --dry-run is True, then simulate the update
if dry_run:
if dry_run == True:
cmd.append('--dry-run')

popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/Package/Dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def update(self, packagesList, exit_on_package_update_error: bool = True, dry_ru
cmd = ['dnf', 'update', pkg['name'] + '-' + pkg['available_version'], '-y']

# If dry_run is True, add the --setopt tsflags=test option to simulate the update
if dry_run:
if dry_run == True:
cmd.append('--setopt')
cmd.append('tsflags=test')

Expand Down
10 changes: 5 additions & 5 deletions src/controllers/Package/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):
# Check for package exclusions
#
#-----------------------------------------------------------------------------------------------
def exclude(self, ignore_exclude):
def exclude(self, ignore_exclusions):
try:
# Create a new empty list of packages to update
packagesToUpdateList = []
Expand All @@ -50,8 +50,8 @@ def exclude(self, ignore_exclude):
for package in self.packagesToUpdateList:
excluded = False

# Check for exclusions and exclude packages only if the ignore_exclude parameter is False
if not ignore_exclude:
# Check for exclusions and exclude packages only if the ignore_exclusions parameter is False
if not ignore_exclusions:
# If the package is in the list of packages to exclude (on major update), check if the available version is a major update
if excludeOnMajorUpdate:
# There can be regex in the excludeOnMajorUpdate list (e.g. apache.*), so we need to convert it to a regex pattern
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_available_packages(self, dist_upgrade: bool = False):
# This can be a list of specific packages or all packages
#
#-----------------------------------------------------------------------------------------------
def update(self, packages_list: list = [], assume_yes: bool = False, ignore_exclude: bool = False, check_updates: bool = False, dist_upgrade: bool = False, keep_oldconf: bool = True, dry_run: bool = False):
def update(self, packages_list: list = [], assume_yes: bool = False, ignore_exclusions: bool = False, check_updates: bool = False, dist_upgrade: bool = False, keep_oldconf: bool = True, dry_run: bool = False):
restart_file = '/tmp/linupdate.restart-needed'

# Package update summary
Expand Down Expand Up @@ -206,7 +206,7 @@ def update(self, packages_list: list = [], assume_yes: bool = False, ignore_excl
self.packagesToUpdateList = self.get_available_packages(dist_upgrade)

# Check for package exclusions
self.exclude(ignore_exclude)
self.exclude(ignore_exclusions)

# Count packages to update and packages excluded
self.packagesToUpdateCount = 0
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
3.6.0

0 comments on commit 4750fa4

Please sign in to comment.