I want to setup a new virtual machine with some specified packages (name and version), that are provided.
For example apache2 in version 2.2.20-1ubuntu1
with all dependencies. Even if there is a new version of this package on the servers this one should be installed.
The solution has to work/scale with multiple (n) "setups". Another virtual machine might need an older version of apache2.
I currently know of some possibilities that install the exact packages, but do not scale that good:
- Copy all required
*.deb
to every virtual machine manually and enter:dpkg -i
... -> Could work, but it is very error prone. (Manual scripts etc.) - Create and use a new Ubuntu repository for each setup. -> Does not work because I would need n repositories.
- Setup the machine once and copy the VM / create a snapshot. -> Does not work because I would need to store n VMs.
My problem could be labeled as patch management, but I do not want to update my packages to the current version. My goal is to install old packages.
You can use
apt-get
to install a specific version of the package a long as it is in an archive that apt knows about. From theapt-get
manpage:For example, you could do:
Note that you may need to do some dependency resolution on your own in this case, but if there are any problems apt-get will tell you what is causing them. On my 11.10 system I would need to do the following to get this to work:
You can display available package versions as follows:
To check which versions are available, you can check via:
If won't work, consider running
sudo apt-get update
before to update the package list.Then copy the version or use the following syntax:
To check which version you've installed, run:
If the version info is truncated, try:
I'll expand on earlier answers with other handy versioning commands in the
apt
family. To see which versions are available, runapt-cache policy
:Then, as mentioned elsewhere, install a specific version with
apt-get
:You can now see which version you have installed by running
apt-cache policy
again:If you don't want newer versions to be installed on updates, pin the package with
apt-mark
:Let's say a new version of apache2 is added to the package index and your machine is synced with
apt-get update
. You'll see this when you next runapt-get upgrade
:As psusi explains, old versions are not kept in the ubuntu repository, but apparently you can still find them on launchpad. So, you go to (replace trusty and amd64 with your ubuntu version and architecture):
https://launchpad.net/ubuntu/trusty/amd64/apache2
and select the version you desire. Then you download the deb as a file and install with:
Again, replace the filename to your file. This gets tedious if you have to downgrade a lot of packages but it's better than nothing if you're desperate.
Practically speaking, this isn't possible because the old versions are not kept in the archive, so unless you have a copy of the old version laying around somewhere, you can't install it. You should be asking yourself why you want to install an older version in the first place. On a stable release, the main reason for a new version being released is to correct a security vulnerability, and you don't want to be running a vulnerable server do you?
Also consider "wildcarding" the minor version
I've just learnt today that PPA minor versions are sometimes removed and replaced with another. E.g. it happened recently that the Git PPA https://launchpad.net/~git-core/+archive/ubuntu/ppa removed
1:2.36.0-0ppa1~ubuntu20.04.1
and replaced it with1:2.36.1-0ppa1~ubuntu20.04.1
. This then broke some Docker setup I had.Luckily, I've found that wildcards do work on
apt install
, so I replaced the broken:with:
Hopefully this will keep my scripts going for some longer.