默认情况下工作路径为当前用户目录下的 rpmbuild 目录。如果你不想在用户目录下的rpmbuild目录制作rpm包,可以在当前用户目录下的 .rpmmacros 文件
(如果没有,则创建 touch ~/.rpmmacros , 加入 %_topdir /home/lili/workdir/rpmbuild)
中修改宏 %_topdir 的配置,例如:
%_topdir /home/lili/workdir(你的工作路径)
在卸载包之后运行
在 Ubuntu 下制作 rpm 包时,会默认将 BUILDROOT 目录下的 {name}-{version}-{release}-{arch} 的目录作为 {buildroot} 目录,所以要打包的文件必须放在该目录下才能完成打包,否则 rpmbuild 找不到文件。也就是说,我必须将要打包的 /usr/bin/ 目录下的所有文件 放到 /home/lili/workdir/rpmbuild/BUILDROOT/codeblocks-13.12-1.arm 目录下才能完成打包
1.mkdir -pv /home/lili/workdir/rpmbuild/BUILDROOT/codeblocks-13.12-1.arm/usr/bin/
2.touch /home/lili/workdir/rpmbuild/BUILDROOT/codeblocks-13.12-1.arm/usr/bin/document
得到的目录结构:
└── rpmbuild
├── BUILD
├── BUILDROOT
│ └── codeblocks-13.12-1.arm
│ └── usr
│ └── bin
│ └── document
├── RPMS
│ └── armv7l
│ └── codeblocks-13.12-1.armv7l.rpm
├── SOURCES
├── SPECS
│ └── codeblocks.spec
└── SRPMS
3.rpmbuild -bb --target=armv7l SPECS/codeblocks.spec
Building target platforms: armv7l
Building for target armv7l
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.dqIHUu
+ umask 022
+ cd /home/lili/workdir/rpmbuild/BUILD
+ exit 0
Processing files: codeblocks-13.12-1.armv7l
Provides: codeblocks = 13.12-1 codeblocks(armv7l-32) = 13.12-1
Requires(interp): /bin/sh /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Requires(preun): /bin/sh
Requires(postun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/lili/workdir/rpmbuild/BUILDROOT/codeblocks-13.12-1.arm
Wrote: /home/lili/workdir/rpmbuild/RPMS/armv7l/codeblocks-13.12-1.armv7l.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.YDo80Y
+ umask 022
+ cd /home/lili/workdir/rpmbuild/BUILD
+ /bin/rm -rf /home/lili/workdir/rpmbuild/BUILDROOT/codeblocks-13.12-1.arm
+ exit 0
Name: codeblocks
Version: 13.12
Release: 1
Summary: OpenSource Cross Platform Free C++ IDE
Group: Development/Tools/IDE
License: GPLv3+
URL: http://www.codeblocks.org/
Packager:Li Li
%define _bindir /usr/bin
%description
Code::Blocks is the open-source, cross-platform Integrated Development Environment (IDE).
It is based on a self-developed plugin framework allowing unlimited extensibility. Most of its functionality is already provided by plugins.
Plugins included in the base package are:
* Compiler frontend to many free compilers
* Debugger frontend for GDB (and CDB for windows platforms)
* Source formatter (based on AStyle)
* Wizard to create new C++ classes
* Code-completion / symbols-browser (work in progress)
* Default MIME handler
* Wizard to create new Code::Blocks plugins
* To-do list
* Extensible wizard based on scripts
* Autosave (saves your work in the unfortunate case of a crash)
%prep
%pre
echo -e '\033[0;31;5m'
echo "------------- Installation Statement -------------"
echo "Cdoeblocks depends on wxwidget 2.8.12 and above."
echo "And depends on boost, gamin, hunspell."
echo "Make sure the system has been installed them."
echo "Otherwise the program will not run properly"
echo -e '\033[0m'
%post
echo "--------- after Statement -------------"
echo "----------do post work--------"
/usr/bin/chmod a+x /usr/bin/document
%preun
%postun
%files
%defattr(-,root,root,-)
%{_bindir}
安装到arm板子上:
root@localhost:~# rpm -ivh /root/codeblocks-13.12-1.armv7l.rpm --force --nodeps
Preparing... ################################# [100%]
No manifest in this package. Creating default one
------------- Installation Statement -------------
Cdoeblocks depends on wxwidget 2.8.12 and above.
And depends on boost, gamin, hunspell.
Make sure the system has been installed them.
Otherwise the program will not run properly
Updating / installing...
1:codeblocks-13.12-1 ################################# [100%]
--------- after Statement -------------
----------do post work--------
查询arm板子上的rpm包
root@localhost:~# rpm -qa |grep codeblocks
codeblocks-13.12-1.armv7l
参考资料
http://blog.konghy.cn/2015/11/13/rpmbuild/
https://fedoraproject.org/wiki/How_to_create_an_RPM_package/zh-cn
http://blog.csdn.net/justlinux2010/article/details/9905425
http://blog.chinaunix.net/uid-23069658-id-3944462.html
http://www.jinbuguo.com/redhat/rpmbuild.html