archlinux-downgrade / downgrade

Downgrade packages in Arch Linux
GNU General Public License v2.0
570 stars 24 forks source link

Downgrade system upgrade from pacman log #209

Open UltraBlackLinux opened 1 year ago

UltraBlackLinux commented 1 year ago

:rocket: Feature Request

Checklist

Background

Sometimes you don't have something like btrfs available to easily restore a previous snapshot if an update badly breaks some programs

Proposed feature

I think it would be really useful if you could rollback a whole update via downgrade. This could be parsed out of the pacman.log together with a given timeframe in minutes

atreyasha commented 1 year ago

Thanks for the feature request.

I like the idea and it could integrate well with the version filtering operators that downgrade already supports:

$ print_packages_before_upgrade -t 10  # within the last 10 minutes
foo=1.0.0
bar=2.0.0

$ print_packages_before_upgrade | downgrade -

The print_package_before_upgrade utility would parse pacman.log looking at both the timestamps and keywords such as upgraded to get the versions of packages before the upgrade (using regular expressions for example). This utility would have to be created and packaged as part of downgrade, either as a separate script or within the bin/downgrade script.

Caveats

  1. A full rollback would imply that we uninstall packages that were installed previously during the upgrade. This is something difficult to do via downgrade alone and I'm not sure if or how we could support this part.
  2. Features like this and #208 push the limits of what we'd want to write in bash. There was some concensus in #208 to use Python, so perhaps this feature could be written in Python too.

@pbrisbin WDYT?

atreyasha commented 1 year ago

A simpler alternative could be to rollback to a daily snapshot of the A.L.A. as described below:

https://wiki.archlinux.org/title/Arch_Linux_Archive#How_to_restore_all_packages_to_a_specific_date

This could be more easily done by downgrade in bash as it only involves an update of pacman.conf followed by a system update. But this alternative would not address the original feature request directly.

pbrisbin commented 1 year ago

I agree "rolling back a whole update" is probably going to work out much more reliably if you use the daily snapshot of ALA and choose a time before your update. That said, parsing package=version out of an upgrade log seems relatively easy to do. So I'd welcome a contribution like that.

Sadly, I've lost track a bit about where we stand on making it easy to write isolated code that plugs into downgrade to provide features like this, so I don't know how ready we are to accept a contribution that does it that way (vs just mucking about in downgrade internals itself).