Skip to content

Commit

Permalink
3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Sep 5, 2024
1 parent d457379 commit c781efe
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 54 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/packaging/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ if [ -f "/usr/bin/systemctl" ];then
cp /opt/linupdate/service/linupdate.systemd.template /lib/systemd/system/linupdate.service
fi

# Delete service symlink if exists
if [ ! -L "/etc/systemd/system/linupdate.service" ];then
rm -f /etc/systemd/system/linupdate.service
fi

chmod 550 "$SERVICE"
chown root:root "$SERVICE"

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/packaging/deb/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if [ -f "/etc/linupdate/update.yml" ];then
cp /etc/linupdate/update.yml /tmp/update.yml.debsave
fi

# Delete service symlink if exists
rm -f /etc/systemd/system/linupdate.service

# Only if systemd is installed (not the case on github runners)
if [ -f "/usr/bin/systemctl" ];then
# Stop service if started
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/packaging/rpm/spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ if [ -f "/etc/linupdate/update.yml" ];then
cp /etc/linupdate/update.yml /tmp/update.yml.rpmsave
fi

# Delete service symlink if exists
rm -f /etc/systemd/system/linupdate.service

# Only if systemd is installed (not the case on github runners)
if [ -f "/usr/bin/systemctl" ];then
# Stop service if started
Expand Down Expand Up @@ -89,11 +92,6 @@ if [ -f "/usr/bin/systemctl" ];then
cp /opt/linupdate/service/linupdate.systemd.template /lib/systemd/system/linupdate.service
fi

# Delete service symlink if exists
if [ ! -L "/etc/systemd/system/linupdate.service" ];then
rm -f /etc/systemd/system/linupdate.service
fi

chmod 550 "$SERVICE"
chown root:root "$SERVICE"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
body: |
**Changes:**
- Fixed apt cache cleaning, again
- Another apt cache cleaning
draft: false
prerelease: false

Expand Down
4 changes: 0 additions & 4 deletions src/controllers/Module/Reposerver/Reposerver.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ 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()

# Send last 4 packages history entries to the reposerver
# status = Status()
# status.send_packages_history()


#-----------------------------------------------------------------------------------------------
#
Expand Down
52 changes: 28 additions & 24 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ def __init__(self):
# Create an instance of the apt cache
self.aptcache = apt.Cache()

# self.aptcache.update()
self.aptcache.open(None)

# Total count of success and failed package updates
self.summary = {
'update': {
Expand Down Expand Up @@ -44,6 +41,11 @@ def __init__(self):
def get_installed_packages(self):
list = []

# Clear, update cache and open it
# TODO to fix: cache is updated twice because of a weird bug I cannot fix. It seems that the cache is not updated correctly the first time and leads to an empty list of packages.
self.update_cache()
self.update_cache()

try:
# Loop through all installed packages
for pkg in self.aptcache:
Expand All @@ -69,29 +71,31 @@ def get_installed_packages(self):
#
#-----------------------------------------------------------------------------------------------
def get_available_packages(self, dist_upgrade: bool = False):
try:
list = []

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

# Loop through all packages marked for upgrade
for pkg in self.aptcache.get_changes():
# If the package is upgradable, add it to the list of available packages
if pkg.is_upgradable:
myPackage = {
'name': pkg.name,
'current_version': pkg.installed.version,
'available_version': pkg.candidate.version
}
list = []

list.append(myPackage)

# Sort the list by package name
list.sort(key=lambda x: x['name'])
# Clear, update cache and open it
# TODO to fix: cache is updated twice because of a weird bug I cannot fix. It seems that the cache is not updated correctly the first time and leads to an empty list of packages.
# Might be because /etc/apt/sources.list is empty
self.update_cache()
self.update_cache()

# Simulate an upgrade to get the list of available packages
self.aptcache.upgrade(dist_upgrade)

# Loop through all packages marked for upgrade
for pkg in self.aptcache.get_changes():
# If the package is upgradable, add it to the list of available packages
if pkg.is_upgradable:
myPackage = {
'name': pkg.name,
'current_version': pkg.installed.version,
'available_version': pkg.candidate.version
}

except Exception as e:
raise Exception('could not get available packages: ' + str(e))
list.append(myPackage)

# Sort the list by package name
list.sort(key=lambda x: x['name'])

return list

Expand Down
15 changes: 1 addition & 14 deletions src/controllers/Package/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ def get_installed_packages(self):
#-----------------------------------------------------------------------------------------------
def get_available_packages(self, dist_upgrade: bool = False):
try:
# Update package manager cache
self.myPackageManagerController.update_cache()

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

Expand Down Expand Up @@ -259,8 +256,7 @@ def update(self, assume_yes: bool = False, ignore_exclude: bool = False, check_u
self.summary['update']['status'] = 'done'

except Exception as e:
print(Fore.RED + ' ✕ ' + Style.RESET_ALL + str(e))
print('\n' + Fore.RED + ' Packages update failed ' + Style.RESET_ALL)
print('\n' + Fore.RED + ' Packages update failed: ' + str(e) + Style.RESET_ALL)
self.summary['update']['status'] = 'failed'

finally:
Expand Down Expand Up @@ -309,12 +305,3 @@ def get_history(self, order):
#-----------------------------------------------------------------------------------------------
def parse_history(self, entries, entries_limit):
return self.myPackageManagerController.parse_history(entries, entries_limit)


#-----------------------------------------------------------------------------------------------
#
# Clear package manager cache
#
#-----------------------------------------------------------------------------------------------
def clear_cache(self):
self.myPackageManagerController.clear_cache()
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.4
3.1.5

0 comments on commit c781efe

Please sign in to comment.