diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11c67da..7847546 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/src/controllers/Module/Reposerver/Config.py b/src/controllers/Module/Reposerver/Config.py index 28b18b4..3f0d5a2 100644 --- a/src/controllers/Module/Reposerver/Config.py +++ b/src/controllers/Module/Reposerver/Config.py @@ -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() diff --git a/src/controllers/Module/Reposerver/Status.py b/src/controllers/Module/Reposerver/Status.py index 42fa5c9..c30c6c3 100644 --- a/src/controllers/Module/Reposerver/Status.py +++ b/src/controllers/Module/Reposerver/Status.py @@ -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 = '' diff --git a/src/controllers/Package/Apt.py b/src/controllers/Package/Apt.py index 546b2f8..da540ac 100644 --- a/src/controllers/Package/Apt.py +++ b/src/controllers/Package/Apt.py @@ -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' diff --git a/src/controllers/Package/Package.py b/src/controllers/Package/Package.py index bdb42ae..0848117 100644 --- a/src/controllers/Package/Package.py +++ b/src/controllers/Package/Package.py @@ -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() @@ -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) diff --git a/version b/version index 6ebad14..711ee4f 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.1.2 \ No newline at end of file +3.1.3 \ No newline at end of file