How to make my own local repository in Ubuntu?

Steps to setting up a simple repository for testing

Let's take logstash as an example:

1.Install dpkg-dev

sudo apt-get install dpkg-dev


2.Put the packages in a directory

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

sudo mkdir -p /usr/local/mydebs 

Then download logstash 1.5.2 from official website and put it in the packages directory:

https://download.elastic.co/logstash/logstash/packages/debian/logstash_1.5.2-1_all.deb


3.Create a script that will scan the packages and create a file apt-get update can read

Let's create file ~/bin/update-mydebs ('~' means your home directory). Ubuntu will puth ~/bin in your PATH.

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

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.

Next, make the script executable:

chmod u+x ~/bin/update-mydebs

 

4. Add a line to your sources.list pointing at your repository

add the line

deb file:/usr/local/mydebs ./

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

 

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.

BTW, previously downloaded Packages by apt-get are generally stored on your system in the /var/cache/apt/archives directory.

If you have installed apt-cacher you will have additional packages stored in its /packages directory.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值