Note 1: At the end of the post I explain why I think this is not a duplicate of this or this question.
Note 2: If you want to avoid wasting too much time in reading the question, you can just read the problem and, if you want, what I tried. The rest of the post just contains details for completeness.
The problem
In the past I upraded, by mistake, a package for which I realized later that I needed to keep the older version I used to have.
Then I downgraded the package, but apparently the newer version stayed in some cache and the aptitude
tool is upgrading it periodically (every 75 minutes more precisely).
How can I prevent this?
Perhaps I should find a way to remove the new version from some cache ?
What I tried
I tried all the most common approaches to hold the package, which are described here and here, with no success.
For example, I tried using dpkg --set-selections
apt-mark hold
, aptitude hold
and the Lock version
feature in Synaptic
.
In particular, the Synaptic
tool even reports the package as locked, but aptitude
still upgrades it, and of course I tried to hold the package using the very aptitude
tool, but the same happens.
After some investigation, I realized that aptitude
installs the newer version by running dpkg
to install a .deb
file in /var/cache/apt/archives/
. Desperately, I even tried the dirty approach to just delete that file, but it is even regenerated (thus I guess it may be downloaded from the web or extracted from some tar/zip file).
Finally, I also tried to completely remove the newer version using apt-get purge
and to install the older version afterwards using apt-get install
and to hold it afterwards. Nothing, it is still upgraded automatically...
Details
Context
Because of compatibility issues in writing some code, after upgrading a package, let's call it thepackage
, I had to change mind and I needed to downgrade it, from a newer version to an older version, say from 1.1
to 1.0
.
Therefore I run something like
dpkg -i thepackage_1.0.deb
But every 75 minutes the files from this package are automatically deleted and replaced with files from the newer version 1.1
, as if some system script is upgrading the package automatically.
What is happening
Then, in order to investigate about the cause, I replaced the rm
tool to delete files with a script I wrote which, before calling the actual rm
(which has been renamed as real_rm
), prints the chain of commands which ended up calling rm
(I did this by getting the PID of each process parent).
Then the log file generated by this script of mine prints something like:
COMMAND: /bin/bash /bin/rm -rf -- /var/lib/dpkg/tmp.ci
CAUSAL CHAIN:
/sbin/init
-> /usr/sbin/cron -f
-> /usr/sbin/CRON -f
-> /bin/sh -c /sbin/maint --mode=cron > /dev/null 2>&1
-> /usr/bin/perl /sbin/maint --mode=cron
-> /usr/bin/perl -I /var/cache/sysmaint/production/vol/linux/ubuntu/16.04/lib/perl /var/cache/sysmaint/production/vol/linux/ubuntu/16.04/maint/017aptitude/maint --nodebug --nosilent --nodryrun --nologperline --colour --nomachineread --trace=none --mode=cron
-> /usr/bin/aptitude -o Dpkg::Options::=--force-confdef -v -y -f install
-> /usr/bin/dpkg --force-confdef --status-fd 57 --unpack --auto-deconfigure /var/cache/apt/archives/thepackage_1.1.deb
From this log, we can see that cron
is periodically running aptitude
by executing
/usr/bin/aptitude -o Dpkg::Options::=--force-confdef -v -y -f install
and this command executes the following subcommand
/usr/bin/dpkg --force-confdef --status-fd 57 --unpack --auto-deconfigure /var/cache/apt/archives/thepackage_1.1.deb
Therefore it seems that aptitude
is being periodically executed to automatically upgrade some packages via dpkg
stored in a cache folder, and one of those packages is thepackage_1.1.deb
.
Note: why I think this is not a duplicate anymore.
I tried all solutions to hold the package described here and here, but they just don't work. I suspect this is a different problem because the package is already in the cache and this may be the reason why the attempts to hold the older version do not work. Perhaps I should find a way to remove it from the cache?
1.0
that I installed manually (when downgrading) instead of automatically upgrading it to1.1
. – GeekInDisguise Jun 13 '18 at 12:23apt-mark hold
solution did not solve the problem, the package is still upgraded, perhaps because as I say in the question theinstall
aptitude command is executed instead ofupgrade
? Or perhaps because a copy of the.deb
file is already in the cache? What do you think? Should I try to edit the question? As I said, the solutions suggested in the questions you linked here do not work, then perhaps this is not a duplicate ? – GeekInDisguise Jun 13 '18 at 13:04apt-mark hold
. – Terrance Jun 13 '18 at 13:06apt-mark hold
a second time solved the issue, I don't know why it didn't work the first time. Thanks for the support, you are great as always. – GeekInDisguise Jun 13 '18 at 16:03.deb
file from the cache, but it is even re-generated automatically... so frustrating... – GeekInDisguise Jun 28 '18 at 18:05aptitude
... perhaps you may be right and some program is just tellingaptitude
to do this, but should aptitude 'refuse' to do the upgrade since the package is marked with 'hold'? – GeekInDisguise Jun 28 '18 at 21:20inotifywait
in an endless loop to automatically downgrade in case it detects deletion of the older version... but I would really like to avoid this kind of approach... @muru many thanks for you suggestions, do you have other recommendations? What do you think about my edit of the question? Now it seems the problem may be different and perhaps not a duplicate anymore... – GeekInDisguise Jun 28 '18 at 21:29