个人工具

“UbuntuHelp:PinningHowto”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/PinningHowto}}
 
{{From|https://help.ubuntu.com/community/PinningHowto}}
 
{{Languages|UbuntuHelp:PinningHowto}}
 
{{Languages|UbuntuHelp:PinningHowto}}
=== Introduction and Pointers to better docs ===
+
=== Introduction to Pinning Packages ===
First of all, I want to recommand to remove the sections below this one - the explanantions below are, in my opinion, hard to understand and point into wrong directions - even for people who know how pinning works and have a working setup.
+
 
Pinning is a solution to be able to install packages from different Ubuntu releases on an Ubuntu system, without completely "polluting" your system with libraries and applications that are not meant for the version you are actually running.
 
Pinning is a solution to be able to install packages from different Ubuntu releases on an Ubuntu system, without completely "polluting" your system with libraries and applications that are not meant for the version you are actually running.
In other words: if you are running Ubuntu Dapper and need a newer version of a single program or want to run an app that is only available on Ubuntu Edgy, apt pinning might be the solution for you.
+
This guide will be when you need or want to install an older version of a program on a newer version of Ubuntu.
It helps you to only install the app you need, and, if needed its dependencies, from a repository that is made for another Ubuntu version.
+
This is important if you are running development versions of Ubuntu or any software that maybe in testing or unstable release -- example Firefox-3.0 in Hardy, it isn't stable so if a patch or new version causes something to break you can install the old version and pin the package so Apt or Synaptic doesn't keep wanting you to upgrade to the broken version.  
It might also work when you want to install an older version of a program on a newer version of ubuntu - just change the priorities/release appropriately.
+
First way to pin a package is in Synaptic:  
Pinning should not be used for installing Debian binary packages on Ubuntu.
+
I strongly recommend against using Debian binary packages on Ubuntu, unless you know very well what you are doing - in case a package you need is only available in Debian, you should definitely try to build the package from Debian sources on Ubuntu as a first priority. In this case you don't need pinning.
+
If you are new to the topic, here are two pointers to Howto's that get you up and running in some simple steps:
+
* This link contains a very good description of what pinning is and how it works: [http://wiki.serios.net/wiki/Apt-Pinning_on_Ubuntu]
+
* And this is a very good and short introduction to pinning on Debian - for using it in Ubuntu one will have to adapt the release names in the sources.list and in the preferences file to Ubuntu release names: [http://jaqque.sbih.org/kplug/apt-pinning.html]
+
One thing that's not mentioned in the Ubuntu Howto, is the Error:
+
 
<pre><nowiki>
 
<pre><nowiki>
Reading package lists... Error!
+
Open Synaptic
E: Dynamic MMap ran out of room
+
Click on Search and type the package name in the Search box
 +
Highlight the version you want to pin '''Make sure its the version that is not broken'''
 +
Click on the menu item Package than click on lock version
 +
Close Synaptic
 
</nowiki></pre>
 
</nowiki></pre>
and the amount of added cache described in the Debian Howto is not enough.
+
Second way is to pin it with Apt/Dpkg: 
 
<pre><nowiki>
 
<pre><nowiki>
echo "APT::Cache-Limit 16777216;" >> /etc/apt/apt.conf
+
Open a terminal
 +
sudo -s and hit enter
 +
Enter your password for sudo
 +
echo libxfont1 hold | dpkg --set-selections  '''Replace libfont1 with the package you want to pin'''
 +
Now run sudo apt-get update and than sudo apt-get upgrade
 
</nowiki></pre>
 
</nowiki></pre>
should help.
+
This part will be removing the pin that you used to pin the file. This should be when the package is fixed or removed.
Another thing that's not mentioned in the Howto is what pin-priorities you can use. Setting to high a priority may not result in the desired effect. See https://help.ubuntu.com/community/UbuntuBackports#head-0b2a1029f552e385c1af0dc485bf14bcc4ebd5bc for examples and explanations.
+
You can check what the next version of the package is by using apt-cache policy packagename 
=== here the ancient article on pinning starts ===
+
To remove the pin in Synaptic:
!!!!!!!!!!!!!!!!!!! Attention !!!!!!!!!!!!!!!!!!!
+
The nomenclature in the Release files (stored in /var/lib/apt/lists/) seems to have changed without notice and without the necessary adaptions of the man files as well as apt-show-versions.
+
This seems to lead to major implications with the apt package manager especially if you leave your old /etc/apt/preferences file untouched. How to edit it does not seem to be documented anywhere however!
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
Usually people follow one of the versions of Ubuntu, you either run Ubuntu 5.04 (Hoary Hedgehog) or Ubuntu 5.10 (Breezy Badger), but sometimes you would like to do more. Or despite the fact that everybody says you shoudn't do it, you want to add packages from Debian sid. If that is you, then read on...
+
=== Contents ===
+
* How to keep a mixed system
+
* How to upgrade packages from specific versions of Ubuntu
+
* How to keep specific versions of packages installed (complex)
+
* An example /etc/apt/sources.list
+
* Links
+
=== How to keep a mixed system ===
+
People are sometimes interested in using one of the Debian versions as its main system distribution and one or more packages from another branch.
+
To set up what is your main version of Ubuntu you should edit the /etc/apt/apt.conf to contain the following line (you may need to create it):
+
 
<pre><nowiki>
 
<pre><nowiki>
  APT::Default-Release "version";
+
Open Synaptic
 +
Search packagename
 +
Click on package
 +
Click on menu item packages
 +
Now click unlock
 +
Close Synaptic
 
</nowiki></pre>
 
</nowiki></pre>
Where version is the version of Ubuntu you want to use as the main distribution. The versions you can use are Ubuntu 5.04 (Hoary Hedgehog), Ubuntu 5.10 (Breezy Badger) or a later release name. To install packages from another version, then, you must use APT in the following way:
+
To remove pin from Apt/Dpkg:
 
<pre><nowiki>
 
<pre><nowiki>
  sudo apt-get -t <distribution> install package
+
Open a terminal
</nowiki></pre>
+
sudo -s and hit enter
For that to work, though, you need at least one APT source line in your /etc/apt/sources.list for the distribution you want the package from, and the package must exist on that source. See An example /etc/apt/sources.list, below.
+
Enter your password for sudo
You can also request a specific version of a package using the following syntax:
+
echo libxfont1 install | dpkg --set-selections '''Replace libfont1 with the package you want to pin'''
<pre><nowiki>
+
Now run sudo apt-get update and than sudo apt-get upgrade
  sudo apt-get install package=version
+
</nowiki></pre>
+
For example, the line below will install version 2.2.4-1 of the nautilus package.:
+
<pre><nowiki>
+
  sudo apt-get install nautilus=2.11.2-0ubuntu1
+
</nowiki></pre>
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconWarning3.png ''IMPORTANT:''
+
* the *unstable* version of Ubuntu is the version that is currently in development. This distribution sees all of the changes that packages go through, both small ones and more drastic ones which affect many packages or the whole system. For this reason, this version of the distribution should not be used by inexperienced users or by those who need proven stability.
+
=== How to upgrade packages from specific versions of Ubuntu ===
+
Apt-show-versions provides a safe way for users of mixed distributions to upgrade their systems without getting more of the less-stable distribution than they had in mind. For instance, it is possible to upgrade just your Hoary packages by running after having installed the apt-show-versions package:
+
To install apt-show-versions:
+
<pre><nowiki>
+
  sudo apt-get install apt-show-versions
+
</nowiki></pre>
+
To upgrade packages from hoary:
+
<pre><nowiki>
+
  sudo apt-get install `apt-show-versions -u -b | grep hoary`
+
</nowiki></pre>
+
=== How to keep specific versions of packages installed (complex) ===
+
You may have occasion to modify something in a package and don't have time or don't want to port those changes to a new version of the program. Or, for instance, you may have just upgraded your Ubuntu distribution to Ubuntu 5.10 (Breezy Badger), but want to continue with the version of a certain package from Ubuntu 5.04 (Hoary Hedgehog). You can "pin" the version you have installed so that it will not be upgraded.
+
Using this resource is simple. You just need to edit the file /etc/apt/preferences.
+
The format is simple:
+
<pre><nowiki>
+
  Package: <package>
+
  Pin: <pin definition>
+
  Pin-Priority: <pin's priority>
+
</nowiki></pre>
+
For example, to keep package sylpheed that I have modified to use "reply-to-list" at version 0.4.99, I add:
+
<pre><nowiki>
+
  Package: sylpheed
+
  Pin: version 0.4.99*
+
</nowiki></pre>
+
Note that I used an * (asterisk). This is a "wildcard"; it say that I want that this "pin" to be valid for all versions beginning with 0.4.99. This is because Ubuntu versions its packages with a "Ubuntu revision" and I don't want to avoid the installation of these revisions. So, for instance, versions 0.4.99-1 and 0.4.99-10 will be installed as soon as they are made available. Note that if you modified the package you won't want to do things this way.
+
The Pin-Priority field is optional; if not specified, it defaults to 989.
+
Let's take a look at how pin priorities work. A priority lower than 0 indicates that the package should never be installed. Priorities 0 to 100 denote packages that are not installed and that have no available versions. These won't come into the version-choosing process. Priority 100 is the priority assigned to an installed package - for the installed version of a package to be replaced by a different version, the replacement must have a priority greater than 100.
+
Priorities above 100 indicate that a package should be installed. Typically, the installed version of a package is changed only to upgrade it to a newer version. Any priority between 100 and 1000 (inclusive) indicates this typical behavior. A package with such a priority will not downgrade to an available version with a lower version number. For instance, if I have sylpheed 0.5.3 installed and define a pin on sylpheed 0.4.99 with priority 999, package 0.4.99 will not be installed to satisfy the pin. To make a package "downgradable", to satisfy the pin, it needs possess a priority greater than 1000.
+
A pin can be specified on a package's version, release or origin.
+
Pinning on a version, as we have seen, supports literal version numbers as well as wildcards to specify several versions at one time.
+
Option release depends on the Release file from an APT repository or from a CD. This option may be of no use at all if you're using package repositories that don't provide this file. You may see the contents of the Release files that you have on /var/lib/apt/lists/. The parameters for a release are: a (archive), c (components), v (version), o (origin) and l (label).
+
An example:
+
<pre><nowiki>
+
  Package: *
+
  Pin: release v=2.2*,a=stable,c=main,o=Debian,l=Debian
+
  Pin-Priority: 1001
+
</nowiki></pre>
+
In this example, we chose version 2.2* of Debian (which can be 2.2r2, 2.2r3 -- this accomodates "point releases" that typically include security fixes and other very important updates), the stable repository, section main (as opposed to contrib or non-free) and origin and label Debian. Origin (o=) defines who produced that Release file, the label (l=) defines the name of the distribution: Debian for Debian itself and Progeny for Progeny, for example. A sample Release file:
+
<pre><nowiki>
+
  $ cat /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_warty_main_binary-i386_Packages
+
  Archive: stable
+
  Version: 2.2r3
+
  Component: main
+
  Origin: Ubuntu
+
  Label: Debian
+
  Architecture: i386
+
</nowiki></pre>
+
To see which source you have and which priorities they are assigned you can run <code><nowiki>apt-cache policy</nowiki></code>
+
You can even find out which versions of a package you could install. Example for the "nautilus" package: <code><nowiki>apt-cache policy nautilus</nowiki></code>
+
=== An example /etc/apt/sources.list ===
+
<pre><nowiki>
+
  deb http://archive.ubuntu.com/ubuntu breezy universe
+
  deb-src http://archive.ubuntu.com/ubuntu breezy universe
+
 
+
  deb http://security.ubuntu.com/ubuntu breezy-security main restricted
+
  deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted
+
 
+
  deb http://archive.ubuntu.com/ubuntu/ hoary main restricted universe multiverse
+
  # deb-src http://archive.ubuntu.com/ubuntu/ hoary main restricted universe
+
 
+
  deb http://security.ubuntu.com/ubuntu/ hoary-security main restricted
+
  # deb-src http://security.ubuntu.com/ubuntu/ hoary-security main restricted
+
 
+
  #Mono
+
  deb http://www.getsweaaa.com/~tseng/ubuntu/debs ./
+
  deb-src http://www.getsweaaa.com/~tseng/ubuntu/debs ./
+
 
</nowiki></pre>
 
</nowiki></pre>
 +
'''NOTE'''
 +
At the time of the making this Wiki there is not a known way to Pin a package with Update Manager.
 +
Pinning should never be used for installing Debian binary packages on Ubuntu.
 +
Ubuntu strongly recommends against using Debian binary packages on Ubuntu,
 
=== Links ===
 
=== Links ===
 
These documents were used as a foundation for this page, and might give you more background information:
 
These documents were used as a foundation for this page, and might give you more background information:
 
* For Basic apt-get usage and instructions see [[UbuntuHelp:AptGetHowTo|AptGetHowTo]]
 
* For Basic apt-get usage and instructions see [[UbuntuHelp:AptGetHowTo|AptGetHowTo]]
* [http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html The official debian documentation]
+
* [http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html The official Debian documentation]
* [http://jaqque.sbih.org/kplug/apt-pinning.html John H. Robinson, IV, Apt-pinning for beginners]
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png Note:
+
Most of this document is taken from [http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html The official debian documentation]
+
 
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
 
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年5月9日 (五) 19:16的版本

Introduction to Pinning Packages

Pinning is a solution to be able to install packages from different Ubuntu releases on an Ubuntu system, without completely "polluting" your system with libraries and applications that are not meant for the version you are actually running. This guide will be when you need or want to install an older version of a program on a newer version of Ubuntu. This is important if you are running development versions of Ubuntu or any software that maybe in testing or unstable release -- example Firefox-3.0 in Hardy, it isn't stable so if a patch or new version causes something to break you can install the old version and pin the package so Apt or Synaptic doesn't keep wanting you to upgrade to the broken version. First way to pin a package is in Synaptic:

Open Synaptic
Click on Search and type the package name in the Search box
Highlight the version you want to pin '''Make sure its the version that is not broken'''
Click on the menu item Package than click on lock version
Close Synaptic

Second way is to pin it with Apt/Dpkg:

Open a terminal
sudo -s and hit enter
Enter your password for sudo
echo libxfont1 hold | dpkg --set-selections  '''Replace libfont1 with the package you want to pin'''
Now run sudo apt-get update and than sudo apt-get upgrade

This part will be removing the pin that you used to pin the file. This should be when the package is fixed or removed. You can check what the next version of the package is by using apt-cache policy packagename To remove the pin in Synaptic:

Open Synaptic
Search packagename
Click on package
Click on menu item packages 
Now click unlock
Close Synaptic

To remove pin from Apt/Dpkg:

Open a terminal
sudo -s and hit enter
Enter your password for sudo
echo libxfont1 install | dpkg --set-selections '''Replace libfont1 with the package you want to pin'''
Now run sudo apt-get update and than sudo apt-get upgrade

NOTE At the time of the making this Wiki there is not a known way to Pin a package with Update Manager. Pinning should never be used for installing Debian binary packages on Ubuntu. Ubuntu strongly recommends against using Debian binary packages on Ubuntu,

Links

These documents were used as a foundation for this page, and might give you more background information: