22

I'm running Ubuntu 10.04 across my entire environment. To make code deploys easier, we are implementing a private apt repository where we can deploy builds of our code.

One of the requirements of this repository will be that our QA department will be able to install any version of our application at any time.

Can I store multiple versions of the same package in an apt-repository (preferably in the same distribution)? If not, what are some possible workarounds that I could use to get the behavior described above?

GregB
  • 1,362
  • 2
  • 13
  • 21

1 Answers1

20

Yes, you can, and you don't need to do anything special. In fact, the usual Debian and Ubuntu repositories typically do have several versions of each package (from oldstable/stable/testing/unstable or dapper/hardy/lucid/maverick/natty). The distributions only have a single package in each version's index file (the Packages files), but you don't have to follow suit.

Of course, apt-get install myapp will only install the latest version (unless configured otherwise). You can run apt-get install myapp=1.42 to force the installation of version 1.42.

Caveat: if all the versions have the same package name, you can't have more than one installed at the same time. If this is important, give each version a different package name: myapp-1.42, myapp-1.43, etc. Debian and Ubuntu do this for major versions of libraries, where you may need more than one if you have executables linked with different libraries (e.g. libcap1 and libcap2), as well as for a few other packages such as the kernel.

  • 1
    Thanks for the excellent explanation. As a follow up, If I go down the path of appending version numbers to my packages, will that break "apt-get upgrade"? It seems to me that each time I upgraded my app, it would be treated as a fresh install and I'd lose my configs. I could work around this, but I'd like to get a grasp on what the limitations are before I make a decision one way or another. Thanks. – GregB Jun 13 '11 at 16:13
  • 2
    The usual way in this case is to have `myapp-1.42` and so on, plus a package `myapp` that just depends on the current `myapp-VERSION` (or even `myapp-stable`, `myapp-beta` and so on). – Gilles 'SO- stop being evil' Jun 13 '11 at 20:52
  • 1
    Just a caveat: be sure you don't forget `-m` when running `dpkg-scanpackages` to build your repository index. Otherwise, you won't get multiple package versions on your `Packages` files. – bruno nery Aug 16 '12 at 00:23
  • You can use `update-alternatives` in ubuntu to manage multiple versions of a package. – Diego Dias Jun 23 '20 at 12:56
  • @Gilles'SO-stopbeingevil' Hi! If I have debian package for same software but different versions. I use gdebi to install them. But how can I install both of them and add a suffix to indicate different binary name? – Porcupine Dec 03 '20 at 16:38
  • @Porcupine You can't install two packages with the same name but different versions. That's why when Debian packages multiple versions of the same software, they append the version number to the package name. If you want to install multiple versions of a package with the same name, you have to unpack the files manually and arrange for each version to find its own files. – Gilles 'SO- stop being evil' Dec 03 '20 at 17:53