⬆️ ⬇️

There was no sadness, updates pumped up

My house uses Debian Sid. Mostly he is very, very good, but in places he is too Bleeding too Edge. For example, when shipping packages that break the system. Yesterday came wpasupplicant, which broke my wifi. I rolled it back, but in the process I thought that many users do not know how to do it. The story "how to roll back a bad apt-get install / upgrade" is in this post.



Situation



We did apt-get install something, or apt-get upgrade, or even apt-get dist-upgrade, and after rebooting (or even immediately) we found out that this is not possible. The service does not start, the important feature is removed, someone falls, etc. We want to roll back. But here, bad luck - where exactly we do not know, because what was the version before the update, we do not know.



Where to find out what happened?



apt keeps very detailed logs in /var/log/apt . There is, in particular, history.log - there will be lines of the form:



 Upgrade: wpasupplicant:amd64 (2:2.6-8, 2:2.6-11) Install: libcaribou-gtk-module:amd64 (0.4.21-3, automatic) Remove: libapache2-mod-dnssd:amd64 (0.6-3.2) 


In the same place it will be written who made it and what team.



 Start-Date: 2017-12-03 12:14:58 Commandline: apt-get dist-upgrade Requested-By: amarao (1000) 


To understand which version was the previous one, you will have to look at the installation log. He is near - /var/log/apt/terminal.log . Unfortunately, with esc-sequences.

There we will see a line of the form:



 Unpacking wpasupplicant (2:2.6-11) over (2:2.6-8) ...  2:2.6-11 -  ,    ,  2:2.6-8 ,    . 


How to repair



To put back the package version, we specify it explicitly:



 apt-get install wpasupplicant=2:2.6-8 


Unfortunately, 90% of this will not work. Why? Because there is no such package in the repository.



In this case, we need to find the file to install. He can be in two places.



  1. / var / cache / apt / archives. For example, /var/cache/apt/archives/wpasupplicant_2%3a2.6-11_amd64.deb .
  2. snapshots.debian.org (about it just below).


When we have a file on disk, the installation is trivial:



 sudo dpkg -i /var/cache/apt/archives/wpasupplicant_2%3a2.6-11_amd64.deb 


... and I have internet again. There is a possibility that you will have to deal with dependencies, but the good news is that if the packages did not conflict before the upgrade, then they can be rolled back to the same set of versions. And what exactly this version can be seen in the output terminal.log.



If there is no archive (because someone has made an upgrade, and then apt-get autoclean), then you need to look for a version on the Internet. To do this, there is an archive of Mirror Debian. http://snapshot.debian.org/



How to connect it is written there, although more often it is easier to just download the package you need. Important: when looking for snapshots, check for versions in the logs. If the dependencies are nasty and complex, then it makes sense to automate the parsing of terminal.log .



Alternative way: you can try apt-cache policy wpasupplicant to look at the available versions and select one of them (also through the equal sign). In my case it was useless, because there was no Internet. Important: as soon as you start to roll back to the old versions, you risk making yourself a configuration based on dependencies that you can’t sort out so easily, so I recommend if you have dependent packages, first try to roll back to previous versions, and not look for adventures through downgrade on antiques.



How to live with this?



Further, we do not want to update until the problem is corrected. To fix the problem, it must be reported. https://bugs.debian.org - and there, perhaps, it is. If not - you need to report. reportbug name_utilities.



In order not to accidentally renew again, the package can be put on hold (prohibit updates):



 apt-mark hold wpasupplicant 


(unhold removes hold).



Best practices



I have long developed a habit for myself to do "dpkg -l> / var / log / dpkg_ date " before the update. In this form, it is easier to parse if you need to do a large number of downgrade.



')

Source: https://habr.com/ru/post/343906/



All Articles