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.1.3 #65

Merged
merged 1 commit into from
Sep 1, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ jobs:
body: |
**Changes:**

- Fixed linupdate service killing when updating linupdate package
- Various bug fixes
- Fixed cache not being cleared while retrieving available package updates
- Module reposerver: fixed profile repos retrieval
draft: false
prerelease: false

Expand Down
28 changes: 20 additions & 8 deletions src/controllers/Module/Reposerver/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,26 @@ def get_profile_repos(self):
if self.systemController.get_os_family() == 'Redhat':
reposRoot = '/etc/yum.repos.d'

# Insert description at the top of the file, then content
# Replace __ENV__ with current environment on the fly
with open(reposRoot + '/' + result['filename'], 'w') as file:
# Insert description
file.write('# ' + result['description'] + '\n' + result['content'].replace('__ENV__', env) + '\n')

# Set permissions
Path(reposRoot + '/' + result['filename']).chmod(0o660)
# Target repo file
repo_file = reposRoot + '/' + result['filename']

# If the file does not exist, create it and insert description at the top of the file, then content
if not Path(repo_file).is_file():
with open(repo_file, 'w') as file:
# Insert description
file.write('# ' + result['description'] + '\n')

# Add content to the file, if not already in it
with open(repo_file, 'r+') as file:
# Replace __ENV__ with current environment on the fly
content = result['content'].replace('__ENV__', env)

# If the content is not already in the file, add it
if content not in file.read():
file.write(content + '\n')

# Set file permissions
Path(repo_file).chmod(0o660)

# Clear cache
self.packageController.clear_cache()
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/Module/Reposerver/Status.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def sendAvailablePackagesStatus(self):

try:
# Retrieve available packages
packages = self.packageController.get_available_packages(True)
# Update cache => True
# Include package of dist upgrade => True
packages = self.packageController.get_available_packages(True, True)

if len(packages) > 0:
available_packages = ''
Expand Down
10 changes: 7 additions & 3 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_available_packages(self):
#-----------------------------------------------------------------------------------------------
def clear_cache(self):
result = subprocess.run(
["apt", "clean", "all"],
["apt", "clean"],
stdout = subprocess.PIPE, # subprocess.PIPE & subprocess.PIPE are alias of 'capture_output = True'
stderr = subprocess.PIPE,
universal_newlines = True # Alias of 'text = True'
Expand Down Expand Up @@ -351,6 +351,10 @@ def parse_history(self, history_files: list, entries_limit: int):

# Parse each apt history files
for history_file in history_files:
# If file is empty (e.g. file has been rotated), ignore it
if os.stat(history_file).st_size == 0:
continue

# Retrieve all Start-Date in the history file
result = subprocess.run(
['zgrep "^Start-Date:*" ' + history_file],
Expand All @@ -362,7 +366,7 @@ def parse_history(self, history_files: list, entries_limit: int):

# Quit if an error occurred
if result.returncode != 0:
raise Exception('could not retrieve Start-Date from ' + history_file + ': ' + result.stderr)
raise Exception('no result matching the pattern "Start-Date" in file ' + history_file)

# Split the result into a list
start_dates = result.stdout.strip().split('\n')
Expand Down Expand Up @@ -408,7 +412,7 @@ def parse_history(self, history_files: list, entries_limit: int):
)

if result.returncode != 0:
raise Exception('could not retrieve event for ' + start_date + ' in ' + history_file + ': ' + result.stderr)
raise Exception('no event found for date "' + start_date + '" in file ' + history_file)

# Retrieve event block lines
event = result.stdout.strip()
Expand Down
12 changes: 8 additions & 4 deletions src/controllers/Package/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ def get_installed_packages(self):
# Get available packages
#
#-----------------------------------------------------------------------------------------------
def get_available_packages(self, dist_upgrade: bool = False):
def get_available_packages(self, update_cache: bool = True, dist_upgrade: bool = False):
try:
# First, clear package manager cache
self.myPackageManagerController.update_cache(dist_upgrade)
# If cache update is enabled
if update_cache:
# First, clear package manager cache
self.myPackageManagerController.clear_cache()
self.myPackageManagerController.update_cache(dist_upgrade)

# Get a list of available packages
return self.myPackageManagerController.get_available_packages()
Expand Down Expand Up @@ -174,8 +177,9 @@ def update(self, assume_yes: bool = False, ignore_exclude: bool = False, check_u
self.remove_all_exclusions()

# Retrieve available packages,
# passing False for the update_cache parameter (which will not update the list of available packages) => maybe change this in the future
# passing the dist_upgrade parameter (which will, with apt, update the list of available packages including packages such as the kernel)
self.packagesToUpdateList = self.get_available_packages(dist_upgrade)
self.packagesToUpdateList = self.get_available_packages(True, dist_upgrade)

# Check for package exclusions
self.exclude(ignore_exclude)
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
3.1.3