基于RPM源碼包制作RPM包(以heat為例)
一、下載源碼包
yumdownloader --source openstack-heat
得到源碼包文件:openstack-heat-2015.1.1-1.el7.src.rpm
二、安裝工具包
yum grouplist
yum groupinstall Development
三、安裝源碼包
sudo rpm -ivh openstack-heat-2015.1.1-1.el7.src.rpm
Updating / installing...
1:openstack-heat-2015.1.2-1.el7.cen################################# [100%]
四、切換到rpmbuild目錄,并查看目錄結(jié)構(gòu)
[root@NFJD-TESTN-COMPUTE-1 rpmbuild]# tree
.
├── SOURCES
│ ├── 0001-Count-all-nested-stack-resources-with-DB-operations.patch
│ ├── 0002-Switch-total_resources-to-use-stack_count_total_reso.patch
│ ├── heat-2015.1.1.tar.gz
│ ├── heat.conf.sample
│ ├── heat-dist.conf
│ ├── heat.logrotate
│ ├── openstack-heat-api-cfn.service
│ ├── openstack-heat-api-cloudwatch.service
│ ├── openstack-heat-api.service
│ └── openstack-heat-engine.service
└── SPECS
└── openstack-heat.spec
2 directories, 11 files
五、修改SPECS/openstack-heat.spec文件
vim SPECS/openstack-heat.spec
在vim編輯器中執(zhí)行下面兩行命令
:%s/^%patch/#%patch/g
:%s/^Patch/#Patch
六、刪除SOURCE/*.patch文件
rm -f SOURCES/*.patch
七、基于舊的源碼更新代碼
cd /root/rpmbuild/SOURCES
tar -zxvf heat-2015.1.1.tar.gz
cp -rf heat-2015.1.1 heat-2015.1.2
拷貝修改的代碼到改目錄下
cp -rf /root/eldon/heat/heat heat-2015.1.2/
cp -rf /root/eldon/heat/setup.cfg heat-2015.1.2/
八、修改源碼權(quán)限
chmod -R 775 heat-2015.1.2
chown -R 3000:3000 heat-2015.1.2
九、打包源碼
rm -rf heat-2015.1.2.tar.gz
tar zcvf heat-2015.1.2.tar.gz heat-2015.1.2/
十、修改源碼包權(quán)限
chown mockbuild:mockbuild heat-2015.1.2.tar.gz
十一、編譯源碼包
rpmbuild -ba /root/rpmbuild/SPECS/openstack-heat.spec
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/openstack-heat-2015.1.2-1.el7.centos.x86_64
Wrote: /root/rpmbuild/SRPMS/openstack-heat-2015.1.2-1.el7.centos.src.rpm
Wrote: /root/rpmbuild/RPMS/noarch/openstack-heat-common-2015.1.2-1.el7.centos.noarch.rpm
Wrote: /root/rpmbuild/RPMS/noarch/openstack-heat-engine-2015.1.2-1.el7.centos.noarch.rpm
Wrote: /root/rpmbuild/RPMS/noarch/openstack-heat-api-2015.1.2-1.el7.centos.noarch.rpm
Wrote: /root/rpmbuild/RPMS/noarch/openstack-heat-api-cfn-2015.1.2-1.el7.centos.noarch.rpm
Wrote: /root/rpmbuild/RPMS/noarch/openstack-heat-api-cloudwatch-2015.1.2-1.el7.centos.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.LFiqMq
- umask 022
- cd /root/rpmbuild/BUILD
- cd heat-2015.1.2
- /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/openstack-heat-2015.1.2-1.el7.centos.x86_64
- exit 0
問題小結(jié)
1.安裝源碼包時缺少操作的用戶(組)
warning: openstack-heat-2015.1.1-1.el7.src.rpm: Header V4 RSA/SHA1 Signature, key ID 7d10ce81: NOKEY
Updating / installing...
1:openstack-heat-2015.1.1-1.el7 ################################# [100%]
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
- 解決方法:先添加缺少的用戶組,再安裝源碼包
groupadd mockbuild
useradd mockbuild -g mockbuild
sudo rpm -ivh openstack-heat-2015.1.1-1.el7.src.rpm
2.git history和setup.conf文件中版本不一致
- 解決方法:修改setup.conf中版本號為需要的版本
3.問題三
/var/tmp/rpm-tmp.9wVSLj: line 51: sphinx-build: command not found
- 解決方法:安裝Sphinx
sudo easy_install Sphinx
4.問題四
AttributeError: 'module' object has no attribute 'Cmd'
- 問題原因:替換heatpython代碼時沒有修改代碼文件權(quán)限