Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.8.2 #84

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,9 @@ jobs:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
body: |
**Changes**:
- Fixed an error when trying to manually update a package which is not installed
- Fixed `--update` parameter. When specifying a package which is not installed, it is now ignored
- Fixed https://github.com/lbr38/linupdate/issues/82
**Changes**
- Added --debug parameter
- Reposerver module: added a trigger to send packages information after an update
draft: false
prerelease: false

Expand Down
13 changes: 11 additions & 2 deletions linupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from datetime import datetime
from colorama import Fore, Style
import traceback

# Import classes
from src.controllers.Log import Log
Expand Down Expand Up @@ -124,14 +125,22 @@ def main():

# If an ArgsException is raised, print the error message and do not send an email
except ArgsException as e:
print('\n' + Fore.RED + ' ✕ ' + Style.RESET_ALL + str(e) + '\n')
send_mail = False
exit_code = 1

print('\n' + Fore.RED + ' ✕ ' + Style.RESET_ALL + str(e) + '\n')
# If debug mode is enabled, print the stack trace
if Args.debug:
print('Stack trace:' + '\n' + traceback.format_exc())

# If an exception is raised, print the error message and send an email
except Exception as e:
print('\n' + Fore.RED + ' ✕ ' + Style.RESET_ALL + str(e) + '\n')
exit_code = 1

print('\n' + Fore.RED + ' ✕ ' + Style.RESET_ALL + str(e) + '\n')
# If debug mode is enabled, print the stack trace
if Args.debug:
print('Stack trace:' + '\n' + traceback.format_exc())

# If the user presses Ctrl+C or the script is killed, do not send an email and exit with code 2
except KeyboardInterrupt as e:
Expand Down
4 changes: 2 additions & 2 deletions service/linupdate.systemd.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ After=network.target
[Service]
Type=simple
ExecStart=/opt/linupdate/service.py
# Limit CPU usage to 50% of CPU time
# CPUQuota=50%
# Limit CPU usage to 90% of CPU time
# CPUQuota=90%
# Set CPU weight to 50 (lower priority compared to the default of 100)
# CPUWeight=50
# Limit memory usage to 1 GB
Expand Down
16 changes: 16 additions & 0 deletions src/controllers/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def parse(self):
Args.dist_upgrade = False
Args.keep_oldconf = True
Args.dry_run = False
Args.debug = False

myApp = App()
myAppConfig = Config()
Expand All @@ -60,6 +61,8 @@ def parse(self):
parser.add_argument("--help", "-h", action="store_true", default="null")
# Version
parser.add_argument("--version", "-v", action="store_true", default="null")
# Debug
parser.add_argument("--debug", action="store_true", default="null")
# Show raw config
parser.add_argument("--show-config", "-sc", action="store_true", default="null")

Expand Down Expand Up @@ -189,6 +192,13 @@ def parse(self):
print(' Current version: ' + Fore.GREEN + myApp.get_version() + Style.RESET_ALL, end='\n\n')
myExit.clean_exit(0, False)

#
# If --debug param has been set
#
if args.debug != "null":
if args.debug:
Args.debug = True

#
# If --show-config param has been set
#
Expand Down Expand Up @@ -630,6 +640,12 @@ def help(self):
],
'description': 'Show version',
},
{
'args': [
'--debug'
],
'description': 'Enable debug mode',
},
{
'title': 'Global configuration options'
},
Expand Down
6 changes: 6 additions & 0 deletions src/controllers/Module/Reposerver/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ 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

# Trigger package-info sending
Trigger().create('package-info')

# 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-packages-update':
Expand Down Expand Up @@ -377,6 +380,9 @@ def websocket_on_message(self, ws, message):
# Send a summary to the reposerver, with the summary of the installation (number of packages installed or failed)
summary = self.packageController.summary

# Trigger package-info sending
Trigger().create('package-info')

# Case the request is 'update-profile', then retrieve profile configuration from the reposerver
elif message['request'] == 'update-profile':
print('[reposerver-agent] Reposerver requested to update profile configuration')
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/Module/Reposerver/Reposerver.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# coding: utf-8

# Import classes
from src.controllers.Package.Package import Package
from src.controllers.Module.Reposerver.Config import Config as Config
from src.controllers.Module.Reposerver.Args import Args
from src.controllers.App.Trigger import Trigger

class Reposerver:
def __init__(self):
self.packageController = Package()
self.configController = Config()
self.argsController = Args()

Expand Down Expand Up @@ -56,6 +58,7 @@ def post(self, updateSummary):

# Generaly "*-release" packages on Redhat/CentOS are resetting .repo files. So it is better to retrieve them again from the reposerver
self.configController.get_profile_repos()
self.packageController.update_cache()

# Trigger package-info sending
Trigger().create('package-info')
Expand Down
13 changes: 13 additions & 0 deletions src/controllers/Package/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ def get_available_packages(self, dist_upgrade: bool = False):
raise Exception('error while retrieving available packages: ' + str(e))


#-----------------------------------------------------------------------------------------------
#
# Update package cache
#
#-----------------------------------------------------------------------------------------------
def update_cache(self):
try:
self.myPackageManagerController.update_cache()

except Exception as e:
raise Exception('error while updating package cache: ' + str(e))


#-----------------------------------------------------------------------------------------------
#
# Update packages
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.1
3.8.2
Loading