个人工具

UbuntuHelp:Repositories/Personal

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年5月24日 (四) 15:06的版本 (新页面: {{From|https://help.ubuntu.com/community/Repositories/Personal}} {{Languages|UbuntuHelp:Repositories/Personal}} == Introduction == There are often a few packages that you want to instal...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索


Introduction

There are often a few packages that you want to install that don't exist in the Ubuntu repositories. If they have any dependencies on other packages, trying to using dpkg can drop you into "dpkg hell", and having apt resolve those dependencies for you would really help. There are full blown methods of creating your own repository, such as UbuntuHelp:Debarchiver or UbuntuHelp:Dak. These are overkill, when all you want is a means of resolving dependencies of the handful of packages you've downloaded from the web. A simple solution is to use dpkg-scanpackages, which will build a repository you can add to your sources.list.

Creating a Personal Repository

There are 3 steps to setting up a simple repository for yourself

  • Put the packages in a directory
  • Create a script that will scan the packages and create a file apt-get update can read
  • Add a line to your sources.list pointing at your repository

The Directory

Create a directory where you will keep your packages. For this example, we'll use /usr/local/mydebs.

mkdir /usr/local/mydebs

Now move your packages into the directory you've just created.

The Script

It's a simple two liner:

#! /bin/bash
cd /usr/local/mydebs
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Cut and paste the above into gedit, and save it as update-mydebs in ~/bin. (the tilde '~' means your home directory. If ~/bin does not exist, create it: Ubuntu will put that directory in your PATH. It's a good place to put personal scripts). Next, make the script executable:

chmod u+x ~/bin/update-mydebs

How the script works:

dpkg-scanpackages looks at all the packages in mydebs, and the output is compressed and written to a file (Packages.gz) that apt-get update can read (see below for a reference that explains this in excruciating detail). /dev/null is an empty file; it is a substitute for an override file which holds some additional information about the packages, which in this case is not really needed. Again, see the reference at the bottom if you really want to know about it.

Sources.list

add the line

deb file:/usr/local/mydebs ./

to your /etc/apt/sources.list, and you're done.

Using the Repository

Whenever you put a new deb in the mydebs directory, run

sudo update-mydebs
sudo apt-get update

Now your local packages can be manipulated with synaptic, aptitude and the apt commands: apt-get, apt-cache, etc. When you attempt to apt-get install, any dependencies will be resolved for you, as long as they can be met.

Badly made packages will probably fail, but you won't have endured dpkg hell.

References

AptGetHowto

Debian New Maintainers Guide (this is the exruciating one)