在Ubuntu下如何创建远程".deb"包仓库

在Ubuntu下如何创建远程".deb"包仓库

Reprepro是一款小巧的命令行工具来方便地创建并管理.deb仓库。今天我们会展示给你如何使用reprepro简单地创建一个Debian包仓库,并使用rsync上传到Sourceforge.net。

步骤 1: 安装Reprepro并生成key

首先,安装所有需要的包,使用下面的apt-get命令。


  1. $ sudo apt-get install reprepro gnupg

现在你需要使用gnupg生成一个gpg key,这里使用下面的命令。


  1. $ gpg --gen-key

它会询问你一些问题,比如你想要哪种key、key的有效期、如果你不知道如何回答,只需点击回车 来选择默认选项(建议)

当然,它会询问你用户名和密码,在脑海中记住这些,因为我们会在之后需要它。


  1. gpg (GnuPG) 1.4.14; Copyright (C) 2013 Free Software Foundation, Inc.
  2. This is free software: you are free to change and redistribute it.
  3. There is NO WARRANTY, to the extent permitted by law.
  4.  
  5. Please select what kind of key you want:
  6. (1) RSA and RSA (default)
  7. (2) DSA and Elgamal
  8. (3) DSA (sign only)
  9. (4) RSA (sign only)
  10. Your selection?
  11. RSA keys may be between 1024 and 4096 bits long.
  12. What keysize do you want? (2048)
  13. Requested keysize is 2048 bits
  14. Please specify how long the key should be valid.
  15. 0 = key does not expire
  16. = key expires in n days
  17. w = key expires in n weeks
  18. m = key expires in n months
  19. y = key expires in n years
  20. Key is valid for? (0)
  21. Key does not expire at all
  22. Is this correct? (y/N) Y
  23.  
  24. You need a user ID to identify your key; the software constructs the user ID
  25. from the Real Name, Comment and Email Address in this form:
  26. "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
  27.  
  28. Real name: ravisaive
  29. Email address: tecmint.com@gmail.com
  30. Comment: tecmint
  31. You selected this USER-ID:
  32. "Ravi Saive (tecmint) <tecmint.com@gmail.com>"
  33.  
  34. Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
  35. You need a Passphrase to protect your secret key.
  36.  
  37. We need to generate a lot of random bytes. It is a good idea to perform
  38. some other action (type on the keyboard, move the mouse, utilize the
  39. disks) during the prime generation; this gives the random number
  40. generator a better chance to gain enough entropy.
  41.  
  42. +++++
  43. gpg: key 2EB446DD marked as ultimately trusted
  44. public and secret key created and signed.
  45.  
  46. gpg: checking the trustdb
  47. gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
  48. gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
  49. pub 2048R/2EB446DD 2014-06-24
  50. Key fingerprint = D222 B1C9 342E 5911 02B1 9147 3BD6 7918 2EB4 46DD
  51. uid Ravi Saive (tecmint) <tecmint.com@gmail.com>
  52. sub 2048R/7EF2F750 2014-06-24

现在你的key已经生成了,要检查一下,用root权限运行这条命令。


  1. $ sudo gpg --list-keys

示例输出


  1. /home/ravisaive/.gnupg/pubring.gpg
  2. ----------------------------------
  3. pub 2048R/2EB446DD 2014-06-24
  4. uid ravisaive (tecmint) <tecmint.com@gmail.com>
  5. sub 2048R/7EF2F750 2014-06-24

步骤 2: 创建一个包仓库并导出key

我们现在要开始创建仓库,首先你需要创建一些文件夹,我们的仓库会放在/var/www/apt目录,让我们先创建这些目录。


  1. $ sudo su
  2. # cd /var/www
  3. # mkdir apt
  4. # mkdir -p ./apt/incoming
  5. # mkdir -p ./apt/conf
  6. # mkdir -p ./apt/key

你现在需要将key导出到仓库文件夹,运行:


  1. # gpg --armor --export username yourmail@mail.com >> /var/www/apt/key/deb.gpg.key

注意:用你之前步骤中输入的用户名代替username,用你的email代替上面的yourmail@mail.com。

我们需要在/var/www/apt/conf创建一个文件“distributions”。


  1. # touch /var/www/apt/conf/distributions

加入下面这几行到distributions这个文件中并保存。


  1. Origin: (你的名字)
  2. Label: (库的名字)
  3. Suite: (stable 或 unstable)
  4. Codename: (发布的代码名,比如 trusty)
  5. Version: (发布的版本,比如 14.04)
  6. Architectures: (软件包所支持的架构, 比如 i386 或 amd64)
  7. Components: (包含的部件,比如 main restricted universe multiverse)
  8. Description: (描述)
  9. SignWith: yes

接下来我们会创建仓库树,运行这些命令:


  1. # reprepro --ask-passphrase -Vb /var/www/apt export

示例输出


  1. Created directory "/var/www/apt/db"
  2. Exporting Trusty...
  3. Created directory "/var/www/apt/dists"
  4. Created directory "/var/www/apt/dists/Trusty"
  5. Created directory "/var/www/apt/dists/Trusty/universe"
  6. Created directory "/var/www/apt/dists/Trusty/universe/binary-i386"
  7. FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
  8. Please enter passphrase:
  9. Successfully created '/var/www/apt/dists/Trusty/Release.gpg.new'
  10. FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
  11. Please enter passphrase:
  12. Successfully created '/var/www/apt/dists/Trusty/InRelease.new'

步骤 3: 在新创建的仓库中加入包

现在准备你的.deb包来加入到仓库中。进入 /var/www/apt目录,你每次要加包的时候都必须这么做。


  1. # cd /var/www/apt
  2. # reprepro --ask-passphrase -Vb . includedeb Trusty /home/ravisaive/packages.deb

注意:用你在distributions文件中输入的仓库代号来代替trusty ,并且用包的路径替换/home/username/package.deb,你会被要求输入密码。

示例输出


  1. /home/ravisaive/packages.deb : component guessed as 'universe'
  2. Created directory "./pool"
  3. Created directory "./pool/universe"
  4. Created directory "./pool/universe/o"
  5. Created directory "./pool/universe/o/ojuba-personal-lock"
  6. Exporting indices...
  7. FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
  8. Please enter passphrase:
  9. Successfully created './dists/Trusty/Release.gpg.new'
  10. FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
  11. Please enter passphrase:
  12. Successfully created './dists/Trusty/InRelease.new'

你的包已经加入了仓库,如果要移除它的话采用如下命令:


  1. # reprepro --ask-passphrase -Vb /var/www/apt remove trusty package.deb

当然你需要用你的包名与仓库代号来修改命令。

步骤 4: 上传仓库到Sourceforge.net

要上传仓库到Sourceforge.net,你当然需要一个可用的账号与一个可用的项目,让我假设你想要上传仓库到http://sourceforge.net/projects/myfoo/testrepository,这里的myfoo是项目名(UNIX上的名称,不是URL,不是标题),testrepository是你想要上传文件到这上面的目录,这里我们会使用rsync 命令。(LCTT译注:当然你也可以上传到其它的支持Http/Rsync的服务器上,以提供远程软件库的服务。)


  1. # rsync -avP -e ssh /var/www/apt/ username@frs.sourceforge.net:/home/frs/project/myfoo/testrepository/

注意:用你在sourceforge.net上的用户名代替username,用你的项目的UNIX名称代替myfoo,用你想要存储的文件夹代替testrepository。

现在你的仓库(包括设置和key等等)上传到了http://sourceforge.net/projects/myfoo/testrepository

要把它加入到一个已装好的系统,首先你需要导入仓库key,它实际上就是/var/www/apt/key/deb.gpg.key,但是这是一个本地路径,使用你的仓库的其它用户不能添加到他们的系统中,这就是为什么我们要导入来自sourceforge.net的key的原因。


  1. $ sudo su
  2. # wget -O - http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key | apt-key add -

你现在可以非常轻松地把仓库加入到系统中了,打开/etc/apt/sources.list,并加入下面这行:


  1. deb http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key trusty main

Note:用你的项目的UNIX类型名称代替myfoo,用你的仓库代码代替trusty,用你上传存储的文件夹代替testrepository,用你在distributionsj加入的仓库组件代替main。

接下来,运行下面的命令来更新仓库列表。


  1. $ sudo apt-get update

祝贺你! 你的软件仓库已经激活了!你现在可以非常简单地在你需要的时候安装包了。

原文发布时间:2014-07-14

本文来自云栖合作伙伴“linux中国”

时间: 2024-09-20 06:10:13

在Ubuntu下如何创建远程".deb"包仓库的相关文章

为什么在ubuntu下我创建一个文件老是报错?

问题描述 为什么在ubuntu下我创建一个文件老是报错? 3C 这是代码 File f= new File(""/home/my.xml""); System.out.println(""创建新文件""); if(!f.exists()){ try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printS

ubuntu系统如何卸截deb包安装的文件

今天风信网(http://www.ithov.com)使用Ubuntu系统安装了一个webmin,安装方式采用deb的包,现在需要将该deb包软件进行卸载,我们可以利用以下命令即可: sudo apt-get remove webmin 此外webmin为你所安装的软件名称,当然如果使用deb包安装的其它软件,也可以使用该方法,另外也可以使用新立德软件包管理或是sudo dpkg --remove webmin来完成! 方法很简单,但却很实用!

ubuntu下使用SSH远程登录与禁止登录方法

一,允许用户ssh远程登录 ubuntu默认是不启用root用户也不允许root远程登录的.所以需要先启用root用户 启用root用户:sudo passwd root //修改密码后就启用了. 安装OpenSSH server: 1. 使用apt命令安装openssh server $ sudo apt-get install openssh-server 2. 可以对 openssh server进行配置 $ sudo vi /etc/ssh/sshd_config 找到PermitRoo

解决ubuntu下mysql不能远程连接数据库的问题

Ubuntu10.04上自带的MySQL,执行了 root@ubuntu:~#sudo apt-get install mysql 安装完mysql-server 启动mysql root@ubuntu:~#/etc/init.d/mysql start 本地可以连接进入数据库. root@ubuntu:~#mysql -uroot -p 设置了远程访问权限: mysql> grant all PRIVILEGES on *.* to admin@'%' identified by '12345

ubuntu下mysql不能远程连接数据库

MySQL远程访问的命令 格式: mysql -h主机地址 -u用户名 -p用户密码 示例: yanggang@host:~$ mysql -h192.168.1.11 -uroot -p123456 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.11' (111) 出现错误!无法连接远程的MySQL数据库 MySQL远程连接数据库,有两种方式: mysql.sock和TCP/IP,前者比后者连接访问速度更快,但仅

ubuntu下如何开启远程连接服务

如何安装 telnet服务器来远程遥控管理系统? sudo apt-get install telnetd 如何安装 SSH 服务器来远程遥控管理系统? sudo apt-get install ssh ==================== 请参阅 如何新增其他的软件库 (extra Repositories)?

Ubuntu系统中deb包本地源的添加

DEB是http://www.aliyun.com/zixun/aggregation/33836.html">Debian软件包格式的文件扩展名,跟Debian的命名一样,DEB也是因Debra Murdock而得名,她是Debian创始人Ian Murdock的太太.Debian包是Unixar的标准归档,将包文件信息以及包内容,经过gzip和tar打包而成.处理这些包的经典程序是dpkg,经常是通过Debian的apt-get来运作. 通过Alien工具,可以将deb包转换成rpm.

如何在Debian和Ubuntu下重新打包Deb文件

以下教程将会为Ubuntu.Linux Mint和Debian GUN/Linux用户讲述,如何在它们基于Debian的Linux操作系统上轻松的解压和重新打包.deb文件. 有时候你在生活中会碰到这样的问题,你想要修改.deb文件的部分内容,然后重新打包.不过只有你真正深入了解计算机才能完成这样的黑客技巧. 下面的例子是刚发生在我身上的真实经历.一位Linux开发者为一个软件构建了一个Debian包(.deb),我也成功地将它安装在我的装载Ubuntu的电脑上. 当我试图从一个Git库中检索一

打deb包、创建 apt源仓库

  如何制作Deb包和相应的软件仓库,其实这个很简单.这里推荐使用dpkg来进行deb包的创建.编辑和制作. 首先了解一下deb包的文件结构: deb 软件包里面的结构,它具有DEBIAN和软件具体安装目录(如etc, usr, opt, tmp等).在DEBIAN目录中起码具有control文件,其次还可能具有postinst (postinstallation).postrm (postremove).preinst(preinstallation).prerm (preremove).co