franglais125 / apt-update-indicator

Apt Update Indicator
https://extensions.gnome.org/extension/1139/apt-update-indicator/
GNU General Public License v3.0
44 stars 17 forks source link

Do not warn about hold packages #29

Open brenard opened 4 years ago

brenard commented 4 years ago

Could you please add an option to ignore package marked as hold ? This APT feature is useful to avoid upgrade that we don't want. If this choice has been done by user, I think an extension like this one could ignore this upgrade (or offer a solution to ignore it).

Thanks for this great extension !

franglais125 commented 4 years ago

I'll look into it, but I don't know how long it could take. If something can propose a patch, that would be great too!

franglais125 commented 4 years ago

By the way, this is in a way already available as a setting, if you include the package name in the "Ignore" list. Would that be enough?

franglais125 commented 4 years ago

I'll close this bug, as the functionality can be achieved by adding the held package to the ignore list in the settings. Cheers!

brenard commented 4 years ago

By the way, this is in a way already available as a setting, if you include the package name in the "Ignore" list. Would that be enough?

Sorry for the late reply. For me, it's not the same functionality: the marking of packages is a native functionality of APT: all APT "client" respect it and by implementing such marking, we ensures that a package will not be updated automatically regardless of the APT client used. The possibility of ignoring a package offered by this extension is only effective within the extension.

I will take a look to the code of this extension to known how it will be possible to implement this functionality.

franglais125 commented 4 years ago

Oh, I see. You want for the package to not be upgraded. I thought you were asking about the extension not notifying the user about a possible upgrade (which is being held).

As for not performing the actual upgrade, this is not actually handled by the extension. When "applying updates", all the extension does is redirect the user to a specified command (by default this is handled by opening Gnome Software.

If you like, you can use a custom command (this is what I do), such that apt upgrade is executed. This will respect the apt configuration and your held packages.

Am I getting this right?

brenard commented 4 years ago

It's could easily be done by modify get-updates.sh : Just use the following command to list package :

aptitude search -q --disable-columns '~Uh' -F "%p|%V"|sed 's/|/\t/g'

Note : I do not find a way to filter it using apt list command but a message indicate : WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

brenard commented 4 years ago

Am I getting this right?

Not really. I will use an example to explain my problem. I use an old software written in Python which uses a library (python-vte) which is no longer available in Debian and which is therefore compatible only with an old version of the underlying lib (libvte9). To prevent apt commands from upgrading this library, I marked this package as hold (by using apt-mark hold libvte9).

However, this extension continues to tell me that this package (and related ones like libvte-common) need to be updated. So I would like this extensions to ignore them, as the apt upgrade command does.

franglais125 commented 4 years ago

However, this extension continues to tell me that this package (and related ones like libvte-common) need to be updated

This is what the ignore list is for. It will not tell you about packages that you add there, for whatever reason.

Screenshot from 2020-04-22 12-30-41

brenard commented 4 years ago

However, this extension continues to tell me that this package (and related ones like libvte-common) need to be updated

This is what the ignore list is for. It will not tell you about packages that you add there, for whatever reason.

Screenshot from 2020-04-22 12-30-41

Yes, it already tries this functionality and it works, but I have to maintain this list manually when I have already blocked the version of this package using the standard method of APT. It's would be great that this extension handle this standard method.

franglais125 commented 4 years ago

I see, great! It's clear now. I'll look into it when I find some time.

brenard commented 4 years ago

Do you want a pull-request for my solution ?

franglais125 commented 4 years ago

Actually, I don't want the extension to depend on aptitude.

franglais125 commented 4 years ago

Apparently we can use apt-mark showhold. What would the output of that be on your system?

brenard commented 4 years ago

apt-mark showhold just return the name of hold packages separated by line breaks.

See above for a working solution using only apt-list and apt-mark :

# Change Internal Field Separator (IFS) to line break
IFS="
"

# List hold packages
HOLD_PACKAGES=($( apt-mark showhold ))
function is_hold() {
  local e pkg="$1"
  shift
  for e in ${HOLD_PACKAGES[@]}; do [[ "$e" == "$pkg" ]] && return 0; done
  return 1
}

# Iter on available updates
#              Get updates list (ignore errors)   | Rm 1st line | "\" -> " "    | Package name and version
for line in $( apt list --upgradable 2> /dev/null | tail -n +2  | sed 's/\// /' | awk '{print $1 "\t" $3}' )
do
  is_hold "$( echo -e "$line"|cut -f 1 )" && continue
  echo -e "$line"
done