个人工具

“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 to Pinning Packages ===
+
This wiki page will discuss some advanced things you can do to packages to accomplish specific goals. The first thing described is Pinning, this is useful if you want only some things from a newer version of Ubuntu. There is also package holding, which allows you to not update the package.
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.
+
== Introduction to Pinning ==
This guide will be when you need or want to install an older version of a program on a newer version of Ubuntu.
+
Pinning is a process that allows you to remain on a stable release of Ubuntu (or any other debian system) while grabbing packages from a more recent 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.  
+
Note however that the processes described below will only work if things like libc6 versions match, so you should probably not do this on an Ubuntu system. I strongly recommend you look at [[UbuntuHelp:UbuntuBackports|UbuntuBackports]] before doing this.
First way to pin a package is in Synaptic:  
+
=== Pinning Methods ===
 +
There are 2 main files you must edit for pinning to even function, the first file is:
 +
/etc/apt/sources.list
 +
An example configuration is as follows:
 
<pre><nowiki>
 
<pre><nowiki>
Open Synaptic
+
# official ubuntu sites
Click on Search and type the package name in the Search box
+
deb http://archive.ubuntu.com/ubuntu hardy main restricted universe multiverse
Highlight the version you want to pin '''Make sure its the version that is not broken'''
+
deb http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse
Click on the menu item Package than click on lock version
+
Close Synaptic
+
 
</nowiki></pre>
 
</nowiki></pre>
Second way is to pin it with Apt/Dpkg:
+
In this example, we're pulling from hardy and intrepid (the current development version of Ubuntu).
 +
The next file involved is:
 +
/etc/apt/preferences
 +
The 'preferences' file is where the actual pinning takes place. To pin a package, set its Pin-Priority to higher number. Here's an example:
 
<pre><nowiki>
 
<pre><nowiki>
Open a terminal
+
Package: firefox-3.0
sudo -s and hit enter
+
Pin: release a=hardy
Enter your password for sudo
+
Pin-Priority: -10
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
+
Package: firefox-3.0
 +
Pin: release a=intrepid
 +
Pin-Priority: 900
 
</nowiki></pre>
 
</nowiki></pre>
This part will be removing the pin that you used to pin the file. This should be when the package is fixed or removed.
+
In this example, we're giving a higher priority to Firefox from intrepid because we want rc1 instead of beta5. This of course can be done with any package, or even all packages - although in the above example, you likely want to change hardy and intrepid Pin-Priority values around so that hardy is default. For further information please read: man apt_preferences
You can check what the next version of the package is by using apt-cache policy packagename
+
==== Debugging Package Priorities ====
To remove the pin in Synaptic:
+
To print out the priorities of each source, run `apt-cache policy`. For priorities for packages, run `apt-cache policy packagename[s]`.
 +
=== Recommended alternative to pinning ===
 +
In Ubuntu, most times, the libc6 version is updated from version to version - it is not the purpose of this page to describe what libc6 is, but needless to say it breaks the above example.
 +
A better method for grabbing things from a development version while not committing your entire machine to that version is as follows:
 +
Add the following line to /etc/apt/sources.list
 
<pre><nowiki>
 
<pre><nowiki>
Open Synaptic
+
deb-src http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse
Search packagename
+
Click on package
+
Click on menu item packages
+
Now click unlock
+
Close Synaptic
+
 
</nowiki></pre>
 
</nowiki></pre>
To remove pin from Apt/Dpkg:
+
Then you'll need to update your repos:
 
<pre><nowiki>
 
<pre><nowiki>
Open a terminal
+
sudo apt-get update  
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
+
 
</nowiki></pre>
 
</nowiki></pre>
 +
Now we need to install some packages so we can build the desired software in intrepid:
 +
<pre><nowiki>
 +
sudo apt-get build-dep firefox-3.0
 +
</nowiki></pre>
 +
Now we can do the following to get the package built from intrepid on our hardy machine:
 +
<pre><nowiki>
 +
sudo apt-get -b source -t intrepid firefox-3.0
 +
</nowiki></pre>
 +
It will output lots of info on the screen, when it's done (could take a while), you will have rc1 instead of beta5!
 +
== Introduction to Holding Packages ==
 +
Holding a package basically means you're telling the package manager to keep the current version no matter what.  This is useful if more recent version of a currently working program breaks after an update.
 +
The following will describe the process of actually holding the package, there are several options to accomplish this:
 +
=== Synaptic ===
 +
{|border="1" cellspacing="0"
 +
| {{https://help.ubuntu.com/community/PinningHowto?action=AttachFile&do=get&target=lockver.png%7D%7D
 +
|}
 +
First way to hold a package is in Synaptic:
 +
*Open Synaptic:  System -> Administration -> Synaptic Package Manager
 +
*Click Search and type the package's name in the Search box
 +
*Highlight the version you want to pin '''Make sure that you select the correct version'''
 +
*Once the correct package is selected, Click Package -> Lock Version
 +
*Close Synaptic
 +
<<BR>>
 +
<<BR>>
 +
<<BR>>
 +
<<BR>>
 +
=== Apt/Dpkg ===
 +
Second way is to hold it with Apt/Dpkg: 
 +
*Open a terminal
 +
*sudo -s and hit enter
 +
*Enter your password for sudo
 +
*<pre><nowiki>
 +
echo libxfont1 hold | dpkg --set-selections
 +
</nowiki></pre>  '''Replace libxfont1 with the package you want to pin'''
 +
*Now run sudo apt-get update and then sudo apt-get upgrade
 +
== Removing a Hold ==
 +
To remove a package from hold, you can run "sudo apt-get install libxfont1" (replacing libxfont1 with the package you wish to remove). To see what the next version of the package is, use `apt-cache policy packagename` (see ''Debugging Package Priorities'' above).
 +
=== Synaptic ===
 +
To remove the pin in Synaptic:
 +
*Open Synaptic
 +
*Search for the correct package
 +
*Click on package to highlight it
 +
*Once the correct package is selected, Click Package -> Lock Version to remove the checkmark
 +
*Close Synaptic
 +
=== Apt/Dpkg ===
 +
To remove pin from Apt/Dpkg:
 +
*Open a terminal
 +
*sudo -s and hit enter
 +
*Enter your password for sudo
 +
*<pre><nowiki>
 +
echo libxfont1 install | dpkg --set-selections
 +
</nowiki></pre> '''Replace libxfont1 with the package you want to pin'''
 +
*Now run sudo apt-get update and then sudo apt-get upgrade
 
'''NOTE'''  
 
'''NOTE'''  
 
At the time of the making this Wiki there is not a known way to Pin a package with Update Manager.
 
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.
 
Pinning should never be used for installing Debian binary packages on Ubuntu.
 
Ubuntu strongly recommends against using 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]
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
+
[[category:CategoryDocumentation]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年10月19日 (日) 16:51的版本

This wiki page will discuss some advanced things you can do to packages to accomplish specific goals. The first thing described is Pinning, this is useful if you want only some things from a newer version of Ubuntu. There is also package holding, which allows you to not update the package.

Introduction to Pinning

Pinning is a process that allows you to remain on a stable release of Ubuntu (or any other debian system) while grabbing packages from a more recent version. Note however that the processes described below will only work if things like libc6 versions match, so you should probably not do this on an Ubuntu system. I strongly recommend you look at UbuntuBackports before doing this.

Pinning Methods

There are 2 main files you must edit for pinning to even function, the first file is: /etc/apt/sources.list An example configuration is as follows:

# official ubuntu sites
deb http://archive.ubuntu.com/ubuntu hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse

In this example, we're pulling from hardy and intrepid (the current development version of Ubuntu). The next file involved is: /etc/apt/preferences The 'preferences' file is where the actual pinning takes place. To pin a package, set its Pin-Priority to higher number. Here's an example:

Package: firefox-3.0
Pin: release a=hardy
Pin-Priority: -10

Package: firefox-3.0
Pin: release a=intrepid
Pin-Priority: 900

In this example, we're giving a higher priority to Firefox from intrepid because we want rc1 instead of beta5. This of course can be done with any package, or even all packages - although in the above example, you likely want to change hardy and intrepid Pin-Priority values around so that hardy is default. For further information please read: man apt_preferences

Debugging Package Priorities

To print out the priorities of each source, run `apt-cache policy`. For priorities for packages, run `apt-cache policy packagename[s]`.

Recommended alternative to pinning

In Ubuntu, most times, the libc6 version is updated from version to version - it is not the purpose of this page to describe what libc6 is, but needless to say it breaks the above example. A better method for grabbing things from a development version while not committing your entire machine to that version is as follows: Add the following line to /etc/apt/sources.list

deb-src http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse

Then you'll need to update your repos:

sudo apt-get update 

Now we need to install some packages so we can build the desired software in intrepid:

sudo apt-get build-dep firefox-3.0

Now we can do the following to get the package built from intrepid on our hardy machine:

sudo apt-get -b source -t intrepid firefox-3.0

It will output lots of info on the screen, when it's done (could take a while), you will have rc1 instead of beta5!

Introduction to Holding Packages

Holding a package basically means you're telling the package manager to keep the current version no matter what. This is useful if more recent version of a currently working program breaks after an update. The following will describe the process of actually holding the package, there are several options to accomplish this:

Synaptic

{{https://help.ubuntu.com/community/PinningHowto?action=AttachFile&do=get&target=lockver.png%7D%7D

First way to hold a package is in Synaptic:

  • Open Synaptic: System -> Administration -> Synaptic Package Manager
  • Click Search and type the package's name in the Search box
  • Highlight the version you want to pin Make sure that you select the correct version
  • Once the correct package is selected, Click Package -> Lock Version
  • Close Synaptic

<
> <
> <
> <
>

Apt/Dpkg

Second way is to hold it with Apt/Dpkg:

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

Removing a Hold

To remove a package from hold, you can run "sudo apt-get install libxfont1" (replacing libxfont1 with the package you wish to remove). To see what the next version of the package is, use `apt-cache policy packagename` (see Debugging Package Priorities above).

Synaptic

To remove the pin in Synaptic:

  • Open Synaptic
  • Search for the correct package
  • Click on package to highlight it
  • Once the correct package is selected, Click Package -> Lock Version to remove the checkmark
  • Close Synaptic

Apt/Dpkg

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 libxfont1 with the package you want to pin
  • Now run sudo apt-get update and then 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: