安装一个不同版本的软件包

我正在运行Lucid服务器,并已安装Tomcat。安装的版本是6.0.24-2ubuntu1.6。

这是我所绑定的版本吗?有可能安装更近期的版本吗?Maverick提供的版本是6.0.28。

也许我可以添加一个源以向我的Lucid安装提供该版本?在软件包管理器用户界面中,我可以使用"强制版本"选项。是否也可以通过命令行方式强制指定版本?

3个回答

简短回答:

通过固定软件包,您可以选择从Maverick获取哪些软件包,并通过软件包管理器自动获取它们的依赖项,并保持其最新状态。https://help.ubuntu.com/community/PinningHowto

长回答摘自https://askubuntu.com/a/103338/42024

You would be much better off exploring apt pinning, see man apt_preferences.

So lets assume you're on Oneiric and you want to get those packages from Precise.

If you read the man you'll see that I copy/pasted the relevant sections and just modified the release name

/etc/apt/preferences

Package: libccid
Pin: release n=precise
Pin-Priority: 990

Package: libpcsclite*
Pin: release n=precise
Pin-Priority: 990

Package: libusb*
Pin: release n=precise
Pin-Priority: 990

Package: opensc
Pin: release n=precise
Pin-Priority: 990

Package: pcscd
Pin: release n=precise
Pin-Priority: 990


Explanation: Uninstall or do not install any Ubuntu-originated
Explanation: package versions other than those in the oneiric release
Package: *
Pin: release n=oneiric
Pin-Priority: 900

Package: *
Pin: release o=Ubuntu
Pin-Priority: -10

Then, I copied my /etc/apt/sources.list to /etc/apt/sources.list.d/precise.list and replaced all occurrences of oneiric with precise. Then ran apt-get update and finally apt-get upgrade.

# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  libpcsclite1 libusb-0.1-4 libusb-1.0-0 libusbmuxd1
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 86.0 kB of archives.
After this operation, 88.1 kB disk space will be freed.
Do you want to continue [Y/n]? y
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libusb-0.1-4 amd64 2:0.1.12-20 [17.6 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/main libusb-1.0-0 amd64 2:1.0.9~rc3-2 [30.9 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise/main libpcsclite1 amd64 1.7.4-2ubuntu1 [23.5 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise/main libusbmuxd1 amd64 1.0.7-2 [14.1 kB]
Fetched 86.0 kB in 0s (124 kB/s) 

For some reason, pcscd and opensc didn't get installed, probably because it wasn't installed to begin with so there was nothing to upgrade, no big deal, I can install exactly that version using precise as the reference like this.

$ apt-get install opensc pcscd -t precise

Take note of the use of -t, packagename/precise would also work.

and there are the packages you want, from the latest release, and only those packages, they will also be updated automatically. If you don't want them anymore, just delete the entries from /etc/apt/preferences and the next time you run apt-get upgrade they'll be removed. Should you remove the entire prefs file be sure to delete that precise.list sources file as well our your system will try to update to the latest set of packages. Also if you decide to dist-upgrade later, you'll need to remove the entire prefs file and it would probably be a good idea to remove the other sources.list less the upgrade will find, thanks to the higher priority, that there are no packages to update.

Apt pinning isn't that hard, you just need to dig in a little and experiment. All the verbs for n= etc are found by examining apt-cache policy.

This is why seasoned admins rant and rave about apt vs yum. You can concisely update services and keep them up-to-date in a clean, deterministic, and maintainable manner.

No more compiling packages either.

I strongly suggest you read the entire man page and get comfortable with the concept and read other guides on apt pinning before continuing with this proposal. Good luck and have fun!

https://help.ubuntu.com/community/PinningHowto


这个链接给出了更完整的答案:http://askubuntu.com/questions/103320/install-packages-from-newer-release-without-building-apt-pinning - François Beausoleil

你可以在命令行上使用apt-get install somepackage=someversion来强制安装某个版本,但是你不能要求一个存储库中apt不知道的版本,这通常意味着你所使用的发行版。
你可以尝试从launchpad手动下载maverick deb包并安装它。有时候这样做是有效的,但有时候它依赖于各种较新版本的库,因此无法安装。另一种选择是下载最新的源代码并自己编译。

谢谢,我会尝试从Maverick那里获取它...这可能会很有效,因为它实际上没有任何依赖关系。 - Michael Wiles

lucid只有6.0.24版本可用,而且这个情况不太可能改变。像tomcat这样的软件很少会被回溯到旧版本。
但是你仍然可以通过使用tomcat二进制包来运行最新的tomcat。我就是在使用这种方式。