Skip to content

Commit

Permalink
3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Sep 2, 2024
1 parent f41a8a2 commit 58e4ed5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
3 changes: 0 additions & 3 deletions src/controllers/Module/Reposerver/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,6 @@ def get_profile_repos(self):
# Set file permissions
Path(repo_file).chmod(0o660)

# Clear cache
self.packageController.clear_cache()

print('[' + Fore.GREEN + ' OK ' + Style.RESET_ALL + ']')


Expand Down
31 changes: 15 additions & 16 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def get_installed_packages(self):
# Return list of available apt packages, sorted by name
#
#-----------------------------------------------------------------------------------------------
def get_available_packages(self):
def get_available_packages(self, dist_upgrade: bool = False):
try:
list = []

# Simulate an upgrade
# self.aptcache.upgrade()
self.aptcache.upgrade(dist_upgrade)

# Loop through all packages marked for upgrade
for pkg in self.aptcache.get_changes():
Expand Down Expand Up @@ -102,28 +102,27 @@ def get_available_packages(self):
#
#-----------------------------------------------------------------------------------------------
def clear_cache(self):
result = subprocess.run(
["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'
)

if result.returncode != 0:
raise Exception('could not clear apt cache: ' + result.stderr)
try:
self.aptcache.clear()
except Exception as e:
raise Exception('could not clear apt cache: ' + str(e))


#-----------------------------------------------------------------------------------------------
#
# Update apt cache
#
#-----------------------------------------------------------------------------------------------
def update_cache(self, dist_upgrade: bool = False):
def update_cache(self):
try:
if dist_upgrade:
self.aptcache.upgrade(True)
else:
self.aptcache.upgrade()
# Clear cache
self.aptcache.clear()

# Update cache
self.aptcache.update()

# Reopen cache
self.aptcache.open(None)

except Exception as e:
raise Exception('could not update apt cache: ' + str(e))
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/Package/Dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_installed_packages(self):
# Return list of available dnf packages, sorted by name
#
#-----------------------------------------------------------------------------------------------
def get_available_packages(self):
def get_available_packages(self, useless_dist_upgrade: bool = False):
list = []

# Get list of packages to update sorted by name
Expand Down Expand Up @@ -156,7 +156,7 @@ def clear_cache(self):
# Update dnf cache
#
#-----------------------------------------------------------------------------------------------
def update_cache(self, useless_dist_upgrade: bool = False):
def update_cache(self):
# Useless because dnf update command already updates the cache
return

Expand Down
16 changes: 6 additions & 10 deletions src/controllers/Package/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,17 @@ def get_installed_packages(self):
# Get available packages
#
#-----------------------------------------------------------------------------------------------
def get_available_packages(self, update_cache: bool = True, dist_upgrade: bool = False):
def get_available_packages(self, dist_upgrade: bool = False):
try:
# If cache update is enabled
if update_cache:
# First, clear package manager cache
self.myPackageManagerController.clear_cache()
self.myPackageManagerController.update_cache(dist_upgrade)
# Update package manager cache
self.myPackageManagerController.update_cache()

# Get a list of available packages
return self.myPackageManagerController.get_available_packages()
return self.myPackageManagerController.get_available_packages(dist_upgrade)

except Exception as e:
raise Exception('error while retrieving available packages: ' + str(e))


#-----------------------------------------------------------------------------------------------
#
Expand Down Expand Up @@ -177,9 +174,8 @@ 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(True, dist_upgrade)
self.packagesToUpdateList = self.get_available_packages(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.3
3.1.4

0 comments on commit 58e4ed5

Please sign in to comment.