Blimey that was close…

So… it was a really stupid situation but I can’t believe I had not realised this before today; when using apt-get any use of * is not working as a wild-card, and of course it’s not, I’ve just been too long on the Windows train lately, but it is in fact working in the regular expression fashion, well, a mix of both… Almost like *.* in a regular expression.

Now this might not seem to be a big difference but I will give you my situation to help show how massive a problem this misunderstanding could cause:

Here I was, just trying to get a trading tool to run with wine but it cannot run with the current stable version in the default Debian repositories… already, the more sleuth-like of you will be groaning with understanding of what happened, but let me go on.

Basically I needed to install a newer version of wine but it was not allowing me to do so while the current version was installed, something that did not surprise me. So the first step was to remove my current instance… but lo, due to the failed last installation, aptitude want me to first complete it with the ‘force’ command (sudo apt-get -f install), which will not work because of the instance clash with the previous version.

“No problem!” says me… and I just go to remove the partly installed newer wine version (it was only a dependency which was not correctly installed) with a full purge (sudo apt-get purge wine) but this refuses to complete due to the exact dependency issue I am trying to remove now. As frustrating as this was, there is of course a stronger way to impose one’s will: sudo dpkg --force-depends --purge wine1.8 (I was removing 1.6 aiming to replace it with 1.8).

All good then, the issue is sorted but I am still stuck with the older wine version blocking the way. This is where it happened… taking the lazy way out and not just removing each version (386, smd64 etc.) of wine1.6, this idiot decides to just remove everything wine…

Another lot of you are groaning now but let me go on for completeness… I ran this: sudo apt-get purge wine*

And that was it…. to make matters worse I even had sudo apt-get autoremove queued. Long story short for anyone still thinking I managed to do what I had planned (and I assure you I did not) the * here did not mean “wine” and anything else… it essentially meant “win” and anything else!!!

Yes… chaos… luckily, oh so luckily, I was there to see the screen removing gnome packages, important libraries, all sorts of rather important tool including the entire window manager! but as I saw this, I did not reboot, I did not do anything but sit down to some corrective action.

After the panicking subsided (the panicking involving scrolling up through the terminal and trying to find a way to copy the lists of tools listed as they were removed to a reinstall command, of course not working as many were just dependencies themselves and so would not have solved the actual issues) I realised there was in fact a solution there for me.

Again, luckily, I has actually run a particular command before all this to have a look at the wine tools currently installed: dpkg --list (and only afterwards dpkg --list 'wine*')

Having run dpkg --list, I had a report of all applications installed but more importantly, including apps removed which still have config files installed. A wonderful column which very nearly brought a tear to the eye…

So easy from here, I just had to run the command again: dpkg --list that is, and compare the outputs (some fancy LibreOffice Calc work here) and all I needed to do was check the first column and any tools previously showing ii (for installed) which now show cf (for config-files) were the exact list I needed to reinstall. Simply appending them to the apt-get install command and I was saved 🙂

So, to help ensure I have this backup in the future (yes, I know, I should rather ensure I don’t do it again, but the more solutions the better) I threw a quick command together that you could script to start-up or something so that you always have a history of installations:

dpkg --list > installed_`date "+%Y-%m-%d"`.txt

When run, this will create a file with the date in the name, but filled with a list of your installed apps. Of course if you remove the `date "+%Y-%m-%d"` it will just replace the file with the latest view.

And so here I am, on the saved system having learnt a small yet vital lesson… Okay, actually a whole bunch! Hope this helps prevent anyone else going through the same lesson the hard way.

Happy hacking!

Leave a Reply

Your email address will not be published. Required fields are marked *