1 %define __strip /bin/true
2 %define _build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
3 # meta spec file for cross-chroot setup
5 # Copyright (c) 2010 Jan-Simon Möller (jsmoeller@linuxfoundation.org)
11 ## 1) define name of original package (see oldname)
13 ## File binaries_to_prepare:
14 ## 2) fill in the binaries which need to be available to the foreign chroot
15 ## e.g. /bin/bash - this will make a i586 bash available
21 # The original package name
24 # The architectures this meta package is built on
25 %define myexclusive i586
27 ### no changes needed below this line
28 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34 # The new package name - convention is %oldname-x86
35 %define newname %{oldname}-x86
37 # The version of the original package is read from its rpm db info
38 %{expand:%%define newversion %(rpm -q --qf '[%{version}]' %oldname)}
40 # The license of the original package is read from its rpm db info
41 %{expand:%%define newlicense %(rpm -q --qf '[%{license}]' %oldname)}
43 # The group information of the original package
44 %{expand:%%define newgroup %(rpm -q --qf '[%{group}]' %oldname)}
46 # The summary of the original package
47 %{expand:%%define newsummary %(rpm -q --qf '[%{summary} - special version ]' %oldname)}
49 # New rpath to add to files on request
50 %define newrpath "/emul/ia32-linux/lib:/emul/ia32-linux/usr/lib"
51 %define newinterpreter /emul/ia32-linux/lib/ld-linux.so.2
53 # Some automatic checks for availability
55 %define binaries_to_prepare %{expand:%(test -e %{_sourcedir}/binaries_to_prepare && echo 1 || echo 0)}
56 %define libraries_to_prepare %{expand:%(test -e %{_sourcedir}/libraries_to_prepare && echo 1 || echo 0)}
57 %define special_script %{expand:%(test -e %{_sourcedir}/special_script && echo 1 || echo 0)}
58 %define files_to_ignore %{expand:%(test -e %{_sourcedir}/files_to_ignore && echo 1 || echo 0)}
60 ### no changes needed below this line
61 %define __strip /bin/true
63 %define _build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
71 BuildRequires: rpm grep tar patchelf sed -rpmlint-Moblin -rpmlint-mini -post-build-checks
72 BuildRequires: %oldname
74 # no auto requirements - they're generated
77 ExclusiveArch: %myexclusive
78 Summary: Don't use! %newsummary
79 BuildRoot: %{_tmppath}/%{name}-%{version}-build
80 %if %binaries_to_prepare
81 Source10: binaries_to_prepare
83 %if %libraries_to_prepare
84 Source20: libraries_to_prepare
87 Source30: special_script
90 Source40: files_to_ignore
92 Source100: baselibs.conf
95 This is a meta-package providing %name.
96 It is not intended to be used on a normal system/device!
98 %{expand:%(rpm -q --qf '[%{description}]' %oldname)}
111 rpm -ql %oldname > filestoinclude1
113 # ignore files - construct sed script
115 echo "s#^%{_docdir}.*##" >> $sedtmp
116 echo "s#^%{_mandir}.*##" >> $sedtmp
117 echo "s#^%{_infodir}.*##" >> $sedtmp
119 # evaluate files_to_ignore
121 for i in `cat %{_sourcedir}/files_to_ignore`; do
122 echo "Ignoring file: $i"
123 echo "s#^${i}.*##" >> $sedtmp
127 # ignore default filesystem files
128 for i in `rpm -ql filesystem`; do
129 echo "s#^${i}\$##" >> $sedtmp
133 echo "/^\$/d" >> $sedtmp
136 sed -f $sedtmp -i filestoinclude1
138 # tar copy to buildroot
139 tar -T filestoinclude1 -cpf - | ( cd %buildroot && tar -xpf - )
143 # no directories, in filelist
144 find %buildroot > filestoinclude2
145 cat filestoinclude2 | sed -e "s#%{buildroot}##g" | uniq | sort > filestoinclude1
146 for i in `cat filestoinclude1`; do
148 if ! test -d %buildroot/$i ; then
150 echo "$i" >> filestoinclude
156 # patchelf the binaries
157 %if %binaries_to_prepare
159 echo "[ .oO Preparing binaries Oo. ]"
161 mkdir -p %buildroot/%{_prefix}/share/applybinary/
162 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
163 echo "Processing binary: $binary"
170 ldd $binary | grep -v "ld-linux" | grep -v "linux-gate" | sed -e "s#=.*##g" -e "s#^\t*##g" > $tmp
171 deps=$(for i in `cat $tmp` ; do rpm -q --whatprovides "$i" | grep -v "no package"; done)
172 cleandeps=$(echo "$cleandeps" "$deps" | sort | uniq | sed -e "s/-[0-9].*//g")
173 patchelf $debug --set-rpath %newrpath %buildroot/$binary
174 patchelf $debug --set-interpreter %newinterpreter %buildroot/$binary
175 patchelf $debug --set-rpath %newrpath %buildroot/$binary
176 patchelf $debug --set-interpreter %newinterpreter %buildroot/$binary
177 if test -n "$debug"; then
178 patchelf --print-rpath %buildroot/$binary
179 patchelf --print-interpreter %buildroot/$binary
181 echo "$binary" >> %buildroot/%{_prefix}/share/applybinary/%name
187 %if %libraries_to_prepare
189 echo "[ .oO Preparing libraries Oo. ]"
196 echo "[ .oO Executing special script Oo. ]"
200 # lets start the shellquote nightmare ;)
205 # arg=${arg//\$/\$} # already needs quoting ;(
206 # arg=${arg/\"/\\\"} # dito
207 # arg=${arg//\`/\`} # dito
215 echo "Creating baselibs_new.conf"
217 rm -rRf /tmp/baselibs_new.conf || true
219 shellquote "%{name}" >> /tmp/baselibs_new.conf
220 shellquote " targettype x86 block!" >> /tmp/baselibs_new.conf
221 shellquote " targettype 32bit block!" >> /tmp/baselibs_new.conf
222 shellquote " targettype arm autoreqprov off" >> /tmp/baselibs_new.conf
224 # automagically fill in basic requirements
225 for i in $cleandeps ; do
226 shellquote " targettype arm requires \"${i}-x86-arm\"" >> /tmp/baselibs_new.conf
229 # we require the native version
230 shellquote " targettype arm requires \"%{oldname}\" " >> /tmp/baselibs_new.conf
231 shellquote " targettype arm prefix /emul/ia32-linux" >> /tmp/baselibs_new.conf
232 shellquote " targettype arm extension -arm" >> /tmp/baselibs_new.conf
233 shellquote " targettype arm +/" >> /tmp/baselibs_new.conf
235 # safe space and download time
236 shellquote " targettype arm -/%{_mandir}" >> /tmp/baselibs_new.conf
237 shellquote " targettype arm -/%{_docdir}" >> /tmp/baselibs_new.conf
238 shellquote " targettype arm requires \"tizen-accelerator\"" >> /tmp/baselibs_new.conf
240 # replace native with x86 binaries as defined in file
241 %if %binaries_to_prepare
242 # Todo: error handling if .orig-arm is present
243 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
244 shellquote " targettype arm post \" mv ${binary} ${binary}.orig-arm ; ln -s <prefix>${binary} ${binary} \"" >> /tmp/baselibs_new.conf
247 shellquote " " >> /tmp/baselibs_new.conf
248 for binary in `cat %{_sourcedir}/binaries_to_prepare` ; do
249 shellquote " targettype arm preun \" rm -f ${binary} ; mv ${binary}.orig-arm ${binary}\"" >> /tmp/baselibs_new.conf
253 cat /tmp/baselibs_new.conf >> %{_sourcedir}/baselibs.conf
255 echo "################################################################################"
259 grep "requires" %{_sourcedir}/baselibs.conf | sort | uniq | sed -e "s# targettype.*requires ##g" | while read k ; do
262 echo "Runscripts: %{newname}-arm"
265 echo "################################################################################"
269 rm -rf $RPM_BUILD_ROOT
271 %files -f filestoinclude
272 %defattr(-,root,root)
273 %if %binaries_to_prepare
274 /%{_prefix}/share/applybinary/%name