1 # meta spec file for cross-chroot setup
3 # Copyright (c) 2010 Jan-Simon Möller (jsmoeller@linuxfoundation.org)
9 ## 1) define name of original package (see oldname)
11 ## File binaries_to_prepare:
12 ## 2) fill in the binaries which need to be available to the foreign chroot
13 ## e.g. /bin/bash - this will make a i586 bash available
19 # The original package name
22 # The architectures this meta package is built on
23 %define myexclusive i586
25 ### no changes needed below this line
26 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32 # The new package name - convention is %oldname-x86
33 %define newname %{oldname}-x86
35 # The version of the original package is read from its rpm db info
36 %{expand:%%define newversion %(rpm -q --qf '[%{version}]' %oldname)}
38 # The license of the original package is read from its rpm db info
39 %{expand:%%define newlicense %(rpm -q --qf '[%{license}]' %oldname)}
41 # The group information of the original package
42 %{expand:%%define newgroup %(rpm -q --qf '[%{group}]' %oldname)}
44 # The summary of the original package
45 %{expand:%%define newsummary %(rpm -q --qf '[%{summary} - special version ]' %oldname)}
47 # New rpath to add to files on request
48 %define newrpath "/emul/ia32-linux/lib:/emul/ia32-linux/usr/lib"
49 %define newinterpreter /emul/ia32-linux/lib/ld-linux.so.2
51 # Some automatic checks for availability
53 %define binaries_to_prepare %{expand:%(test -e %{_sourcedir}/binaries_to_prepare && echo 1 || echo 0)}
54 %define libraries_to_prepare %{expand:%(test -e %{_sourcedir}/libraries_to_prepare && echo 1 || echo 0)}
55 %define special_script %{expand:%(test -e %{_sourcedir}/special_script && echo 1 || echo 0)}
56 %define files_to_ignore %{expand:%(test -e %{_sourcedir}/files_to_ignore && echo 1 || echo 0)}
58 ### no changes needed below this line
59 %define __strip /bin/true
61 %define _build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
69 BuildRequires: rpm grep tar patchelf sed -rpmlint-Moblin -rpmlint-mini -post-build-checks
70 BuildRequires: %oldname
72 # no auto requirements - they're generated
75 ExclusiveArch: %myexclusive
76 Summary: Don't use! %newsummary
77 BuildRoot: %{_tmppath}/%{name}-%{version}-build
78 %if %binaries_to_prepare
79 Source10: binaries_to_prepare
81 %if %libraries_to_prepare
82 Source20: libraries_to_prepare
85 Source30: special_script
88 Source40: files_to_ignore
90 Source100: baselibs.conf
93 This is a meta-package providing %name.
94 It is not intended to be used on a normal system/device!
96 %{expand:%(rpm -q --qf '[%{description}]' %oldname)}
109 rpm -ql %oldname > filestoinclude1
111 # ignore files - construct sed script
113 echo "s#^%{_docdir}.*##" >> $sedtmp
114 echo "s#^%{_mandir}.*##" >> $sedtmp
115 echo "s#^%{_infodir}.*##" >> $sedtmp
117 # evaluate files_to_ignore
119 for i in `cat %{_sourcedir}/files_to_ignore`; do
120 echo "Ignoring file: $i"
121 echo "s#^${i}.*##" >> $sedtmp
125 # ignore default filesystem files
126 for i in `rpm -ql filesystem`; do
127 echo "s#^${i}\$##" >> $sedtmp
131 echo "/^\$/d" >> $sedtmp
134 sed -f $sedtmp -i filestoinclude1
136 # tar copy to buildroot
137 tar -T filestoinclude1 -cpf - | ( cd %buildroot && tar -xpf - )
141 # no directories, in filelist
142 find %buildroot > filestoinclude2
143 cat filestoinclude2 | sed -e "s#%{buildroot}##g" | uniq | sort > filestoinclude1
144 for i in `cat filestoinclude1`; do
146 if ! test -d %buildroot/$i ; then
148 echo "$i" >> filestoinclude
154 # patchelf the binaries
155 %if %binaries_to_prepare
157 echo "[ .oO Preparing binaries Oo. ]"
159 mkdir %buildroot/%{_prefix}/share/applybinary/
160 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
161 echo "Processing binary: $binary"
168 ldd $binary | grep -v "ld-linux" | grep -v "linux-gate" | sed -e "s#=.*##g" -e "s#^\t*##g" > $tmp
169 deps=$(for i in `cat $tmp` ; do rpm -q --whatprovides "$i" | grep -v "no package"; done)
170 cleandeps=$(echo "$cleandeps" "$deps" | sort | uniq | sed -e "s/-[0-9].*//g")
171 patchelf $debug --set-rpath %newrpath %buildroot/$binary
172 patchelf $debug --set-interpreter %newinterpreter %buildroot/$binary
173 patchelf $debug --set-rpath %newrpath %buildroot/$binary
174 patchelf $debug --set-interpreter %newinterpreter %buildroot/$binary
175 if test -n "$debug"; then
176 patchelf --print-rpath %buildroot/$binary
177 patchelf --print-interpreter %buildroot/$binary
179 echo "$binary" >> %buildroot/%{_prefix}/share/applybinary/%name
185 %if %libraries_to_prepare
187 echo "[ .oO Preparing libraries Oo. ]"
194 echo "[ .oO Executing special script Oo. ]"
198 # lets start the shellquote nightmare ;)
203 # arg=${arg//\$/\$} # already needs quoting ;(
204 # arg=${arg/\"/\\\"} # dito
205 # arg=${arg//\`/\`} # dito
213 echo "Creating baselibs_new.conf"
215 rm -rRf /tmp/baselibs_new.conf || true
217 shellquote "%{name}" >> /tmp/baselibs_new.conf
218 shellquote " targettype x86 block!" >> /tmp/baselibs_new.conf
219 shellquote " targettype 32bit block!" >> /tmp/baselibs_new.conf
220 shellquote " targettype arm autoreqprov off" >> /tmp/baselibs_new.conf
222 # automagically fill in basic requirements
223 for i in $cleandeps ; do
224 shellquote " targettype arm requires \"${i}-x86-arm\"" >> /tmp/baselibs_new.conf
227 # we require the native version
228 shellquote " targettype arm requires \"%{oldname}\" " >> /tmp/baselibs_new.conf
229 shellquote " targettype arm prefix /emul/ia32-linux" >> /tmp/baselibs_new.conf
230 shellquote " targettype arm extension -arm" >> /tmp/baselibs_new.conf
231 shellquote " targettype arm +/" >> /tmp/baselibs_new.conf
233 # safe space and download time
234 shellquote " targettype arm -/%{_mandir}" >> /tmp/baselibs_new.conf
235 shellquote " targettype arm -/%{_docdir}" >> /tmp/baselibs_new.conf
236 shellquote " targettype arm requires \"tizen-accelerator\"" >> /tmp/baselibs_new.conf
238 # replace native with x86 binaries as defined in file
239 %if %binaries_to_prepare
240 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
241 shellquote " targettype arm post \" mv ${binary} ${binary}.orig-arm ; ln -s <prefix>${binary} ${binary} \"" >> /tmp/baselibs_new.conf
244 shellquote " " >> /tmp/baselibs_new.conf
245 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
246 shellquote " targettype arm preun \" rm -f ${binary} ; mv ${binary}.orig-arm ${binary}\"" >> /tmp/baselibs_new.conf
250 cat /tmp/baselibs_new.conf >> %{_sourcedir}/baselibs.conf
257 grep "requires" %{_sourcedir}/baselibs.conf
265 rm -rf $RPM_BUILD_ROOT
267 %files -f filestoinclude
268 %defattr(-,root,root)
269 %if %binaries_to_prepare
270 /%{_prefix}/share/applybinary/%name