一分钟学会将OpenStack Havana代码编译成DEB包

我想有以下有几个原因促使我写这篇Blog:

1、很多人开始OpenStack之旅是从Ubuntu开始,但是却没有一篇文章系统的介绍如何将修改后的代码重新编译回DEB包。

2、如果我们采用源代码直接安装的方式对OpenStack模块进行管理,一致性很难保证,难以维护。

3、Debian类系统的打包看起来比RPM包复杂很多。

 

Who

谁需要看这篇文章呢?

1、不了解如何编译DEB包

2、想把修改过的OpenStack源代码重新发布,供内部使用

3、希望改变直接维护源代码

 

当然,如果您已经是这方面的高手,欢迎给我指正我Blog中的不足,十分感谢。

Quick Start

我已经将整个的编译过程集成在Vagrant脚本中,你可以直接安装Vagrant后,下载我的源代码,启动后就能看到整个的编译过程。

Vagrant 版本要求为1.3.5,Virtualbox版本要求为4.1或者4.2均可。

Let's play some magic

git clone https://github.com/xiaoquqi/vagrant-build-openstack-deb

cd vagrant-build-openstack-deb

vagrant up

虚拟机启动后,将会自动从github(这里使用的是csdn code的镜像代码)同步最新代码,然后使用编译脚本,执行打包操作。如果不考虑下载的时间,整个过程大概持续5分钟左右的时间,编译好的Deb包将会存放在/root/build目录下。

vagrant ssh

即可登陆到虚拟机,切换到root目录就可以查看到所有打包好的DEB的情况了,当然你也可以直接使用dpkg -i命令进行安装。

sudo -s
cd /root/build
ls -lrt *.deb
dpkg -i Python-glance_2013.2.2.dev1.g5cd7a22~precise-0ubuntu1_all.deb

Step by Step

看过了整个的编译过程,下面来介绍一点点细节。

全部的编译部分代码都在这个文件中:https://github.com/xiaoquqi/vagrant-build-openstack-deb/blob/master/scripts/build.sh,下面让我们来仔细分析一下整个编译过程。

添加必要的源

这里面我们用的源包含sohu的Ubuntu 12.04源以及Ubuntu的Havana源

deb precise main restricted
deb precise-updates main restricted
deb precise universe
deb precise-updates universe
deb precise multiverse
deb precise-updates multiverse
deb precise-backports main restricted universe multiverse
deb precise-security main restricted
deb precise-security universe
deb precise-security multiverse
deb precise-updates/havana main

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c91f6911683be3cb507858f51061ccb6.html