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

Show Number Of Available Updates via APT #71

Closed
codeclinic opened this issue Jan 27, 2023 · 12 comments
Closed

Show Number Of Available Updates via APT #71

codeclinic opened this issue Jan 27, 2023 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@codeclinic
Copy link

Is your feature request related to a problem? Please describe.
It would be great if this library could also show the number of available system updates on a system.

Describe the solution you'd like
The MQTT message should include the number of available system (apt) updates, so that it can be displayed in Home Assistant.

Describe alternatives you've considered
This info can be grabbed in python using the following code:
import apt
cache = apt.Cache()
cache.open(None)
cache.upgrade()
return str(cache.get_changes().len())

Additional context
The solution given above should work in this project. It would just need to be added to the posted MQTT message(s) for retrieval in Home Assistant

@ironsheep ironsheep added the enhancement New feature or request label Feb 9, 2023
@ironsheep ironsheep self-assigned this Feb 9, 2023
@ironsheep
Copy link
Owner

While non-ubuntu Debian distros don't have the update notifier as they don't distinguish between security updates and others there is a simple means to ask the packaging system what updates are available.

I'll put this in as a slow poll (maybe update the values every 4 hours?) and then push the count of packages needing an update. So this will be a single count, not two counts.

Sound ok?

@codeclinic
Copy link
Author

Sure, I just need to be able to look at the info in Home Assistant and see which rPi devices need an apt upgrade

@ironsheep
Copy link
Owner

ironsheep commented Feb 18, 2023

Well, this is problematic as getting this info so far required root access. I don't want to have us all give the Daemon account root access... so I need to find another way.

One thought I have is to provide a script that gets this data and deposits it as a tiny text file. The user can then set up this script to run under root cron say every 4 hours or so. The daemon reporter can simply forward this small text to the card.

Also, the user would run this script as part of the update run as well:

sudo apt-get update
sudo apt-get dist-upgrade
sudo {this tiny script}  # which then creates the tiny file saying no more updates are pending

oh.. and the tiny script appears to be:

sudo apt-get update
sudo apt-get --assume-no dist-upgrade >>{tiny-file}.txt 2>&1

(well there's probably more filtering on the output to reduce to only that which is useful but you get what I'm doing)

Thoughts?

@codeclinic
Copy link
Author

Personally I'd prefer the setup to be as simple as possible without installing extra bits. The code snippet I provided would cover my needs.

However, I appreicate that you want this to be functional for as many systems as possible. So, perhaps I'm not the best person to comment.

Since, you already grab the OS info would it be an option to automatically deploy the python example I gave but prompt users of other OS's to add the extra script if their OS / system is detected as being none RPi ?

@bsimmo
Copy link

bsimmo commented Feb 19, 2023 via email

@codeclinic
Copy link
Author

I really don't wish my Pi's to be connecting to apt repositories to see if there are any updates, not only does it take resources from whatever it is doing but also takes time to update each repository. It may well be a low power device etc.

I was a contributer to a project very similar to this one that was abandoned about a year ago. In that project we used the python script given in my first post and there were no reported issues from any users regarding this particular function. I had it running on several different RPi devices including a couple of the original RPi Zeros.

The script literally only needs to be called once per week or even monthly. It's just to give you a heads-up that updates are available for the device. Any impact is negligable in my experience.

@ironsheep
Copy link
Owner

@codeclinic Jeez... I completely missed the fact the you have the small snippet of code at the head of this issue. I'm trying it out and and will push a set of releases (Daemon, card) when I get it all understood and implemented.

More soon.

@bsimmo
Copy link

bsimmo commented Feb 20, 2023 via email

@codeclinic
Copy link
Author

I completely missed the fact the you have the small snippet of code at the head of this issue.

No, problem. I thought you were saying you wanted a universally implementable option and so my suggestion wouldn't work. ;-)

@ironsheep
Copy link
Owner

ok, will appear in next release!

@codeclinic
Copy link
Author

ok, will appear in next release!

Excellent!

@ironsheep
Copy link
Owner

Changes committed and now avail. in v1.8.0 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants