个人工具

“UbuntuHelp:Repositories/Personal/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
目录
The Script update-mydebs
第26行: 第26行:
 
如果你安装了apt-cacher 还有一些额外的包驻留在他的 /packages 目录里。
 
如果你安装了apt-cacher 还有一些额外的包驻留在他的 /packages 目录里。
  
=== The Script update-mydebs ===
+
=== 升级自己的软件库的脚本 ===
It's a simple three liner:
+
这是一个简单的三 liner (It's a simple three liner:)
 
<pre><nowiki>
 
<pre><nowiki>
 
  #! /bin/bash
 
  #! /bin/bash
  cd /usr/local/mydebs
+
  cd /usr/local/mydebs #用你之前方包的目录
 
  dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
 
  dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
 
</nowiki></pre>
 
</nowiki></pre>
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:
+
复制到 gedit, 保存为 '''update-mydebs''' ~/bin. ( '~' 指你的目录.) 如果 ~/bin 不存在, 创建它: Ubuntu 将把这个目录放到PATH. 这是一个存放个人脚本的好地方). 接下来, 赋予文件运行权限:
 
<pre><nowiki>
 
<pre><nowiki>
 
chmod u+x ~/bin/update-mydebs
 
chmod u+x ~/bin/update-mydebs
第39行: 第39行:
 
'''How the script works:'''
 
'''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. See deb-override(5) if you want to know about it.
 
'''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. See deb-override(5) if you want to know about it.
 +
 
=== Sources.list ===
 
=== Sources.list ===
 
add the line
 
add the line

2009年6月22日 (一) 14:45的版本

General information: Repositories in Ubuntu

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 local repository, such as Debarchiver or 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 (not for an entire repository that you want to use without Internet connection; for this use AptGet/Offline/Repository). 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 4 steps to setting up a simple repository for yourself

  1. Install dpkg-dev
  2. Put the packages in a directory
  3. Create a script that will scan the packages and create a file apt-get update can read
  4. Add a line to your sources.list pointing at your repository

=== 安装 dpkg-dev ===(一般情况下已安装)

在终端下运行

sudo apt-get install dpkg-dev

目录

创建你需要保存软件包的目录. 例如,我(原文作者)将会用 /usr/local/mydebs.(本人建议使用~/下的目录,以防权限问题)

mkdir /usr/local/mydebs

现在,把你的包移动到之前创建的目录里。 装机后所有下载的包都驻留在 /var/cache/apt/archives 目录里。 如果你安装了apt-cacher 还有一些额外的包驻留在他的 /packages 目录里。

升级自己的软件库的脚本

这是一个简单的三 liner (It's a simple three liner:)

 #! /bin/bash
 cd /usr/local/mydebs #用你之前方包的目录
 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

复制到 gedit, 保存为 update-mydebs 在 ~/bin. ( '~' 指你的目录.) 如果 ~/bin 不存在, 创建它: Ubuntu 将把这个目录放到PATH. 这是一个存放个人脚本的好地方). 接下来, 赋予文件运行权限:

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. See deb-override(5) if you 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. See Repositories/Ubuntu.

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