基于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目录,并查看目录结构
[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编辑器中执行下面两行命令
:%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/
八、修改源码权限
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/
十、修改源码包权限
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
问题小结
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代码时没有修改代码文件权限
网友评论