在Fedora环境下制作交叉编译RPM包(build系统使用)
时间:2007-03-13 来源:hellwolf
目标
将软件编译成RPM,做成交叉编译repository。不过注意,这个repository是给build系统,而不是host系统用的。(注:什么是build/host/target系统,见附录)
环境
测试环境Fedora 6,交叉编译目标arm-linux
toolchain,arm-linux-gcc 4.1.x, glibc 2.5.x。
问题
1、最好只需要有限的修改就能移植现有的spec文件。
2、交叉编译的结果应该是noarch的包(否则无法在build系统安装),noarch的包如何正确生成debuginfo包。
步骤
将软件编译成RPM,做成交叉编译repository。不过注意,这个repository是给build系统,而不是host系统用的。(注:什么是build/host/target系统,见附录)
环境
测试环境Fedora 6,交叉编译目标arm-linux
toolchain,arm-linux-gcc 4.1.x, glibc 2.5.x。
问题
1、最好只需要有限的修改就能移植现有的spec文件。
2、交叉编译的结果应该是noarch的包(否则无法在build系统安装),noarch的包如何正确生成debuginfo包。
步骤
建立ycross.macros文件:
%{expand: %(cat /path/to/ycross.macros)}
编译包用这样的命令即可:
rpmbuild --define "ycross_target \"arm-linux\"" -bb xxx.spec
下一步
结合ybuild把这些整合起来,做成交叉软件repository。基于这个在build系统上的repository,然后设计一个轻量级的包管理,对安装后的RPM进行第二次剪裁,导出用于host系统的repository。
附录
交叉编译中经常会遇到这几个术语:host build target。
一般来说,在交叉编译时,你会遇到这两种软件,交叉编译工具(binutils, gcc等)和一般软件。
当编译交叉编译工具时,你需要定义host和target系统。host是指编译工具运行的环境,target是编译工具需要生成代码的目标环境。
当编译一般软件的时候,你需要定义host和build系统。host是指软件即将运行的环境,build是指编译软件的环境。这种情况又称为Canadian Cross。
%if %{ycross_target}然后只要在你的spec文件中加入这样一行:
%define ycross_enabled 1
##################################################
#### tools setup
##################################################
%define __ar %{ycross_target}-ar
%define __as %{ycross_target}-as
%define __cc %{ycross_target}-gcc
%define __cxx %{ycross_target}-g++
%define __cpp %{ycross_target}-gcc -E
%define __ld %{ycross_target}-ld
%define __nm %{ycross_target}-nm
%define __objcopy %{ycross_target}-objcopy
%define __objdump %{ycross_target}-objdump
%define __strip %{ycross_target}-strip
%define __ranlib %{ycross_target}-ranlib
##################################################
#### canadian cross setup
##################################################
%define _host %{ycross_target}
%define _build %{_host_cpu}-%{_host_vendor}-%{_host_os}
%define _target_platform %{ycross_target}
##################################################
#### debug package hack for noarch package
##################################################
%define debug_package \
%global __debug_package 1 \
%package debuginfo \
Summary: Debug information for package %{name} \
Group: Development/Debug \
%description debuginfo \
This package provides debug information for package %{name}. \
Debug information is useful when developing applications that use this \
package or when debugging this package. \
(ycross hack for noarch package) \
%files debuginfo -f debugfiles.list \
%defattr(-,root,root)
%else
%{error: ycross_target is not defined}
%endif
%{expand: %(cat /path/to/ycross.macros)}
编译包用这样的命令即可:
rpmbuild --define "ycross_target \"arm-linux\"" -bb xxx.spec
下一步
结合ybuild把这些整合起来,做成交叉软件repository。基于这个在build系统上的repository,然后设计一个轻量级的包管理,对安装后的RPM进行第二次剪裁,导出用于host系统的repository。
附录
交叉编译中经常会遇到这几个术语:host build target。
一般来说,在交叉编译时,你会遇到这两种软件,交叉编译工具(binutils, gcc等)和一般软件。
当编译交叉编译工具时,你需要定义host和target系统。host是指编译工具运行的环境,target是编译工具需要生成代码的目标环境。
当编译一般软件的时候,你需要定义host和build系统。host是指软件即将运行的环境,build是指编译软件的环境。这种情况又称为Canadian Cross。
相关阅读 更多 +