| 19 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 20 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 21 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 22 ## SUCH DAMAGE. |
21 ## SUCH DAMAGE. |
| 23 ## |
22 ## |
| |
23 |
| |
24 ## |
| 24 ## The purpose of this macro set is to override the default |
25 ## The purpose of this macro set is to override the default |
| 25 ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. |
26 ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. |
| 26 ## |
27 ## |
| 27 |
28 |
| |
29 # utility macro for "delayed one-time expansion" of macro bodies |
| |
30 # (works by redefining a macro in-place to its expanded body on its first usage) |
| |
31 %l_once() %{expand:%%global %{*}}%{expand:%%{%{1}}} |
| |
32 |
| 28 # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) |
33 # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) |
| 29 %l_openpkg_release(F:) %(%{l_prefix}/libexec/openpkg/release --release="%{?release}%{!?release:%(%{l_rpm} -q --qf '%{release}' openpkg)}" %{?-F:-F "%{-F*}"}%{!?-F:-F "OpenPKG-%%t"}) |
34 %l_openpkg_release(F:) %(%{l_prefix}/libexec/openpkg/release \\\ |
| |
35 --release="%{?release}%{!?release:%(%{l_rpm} -q --qf '%{release}' openpkg)}" \\\ |
| |
36 %{?-F:-F "%{-F*}"}%{!?-F:-F "OpenPKG-%%t"}) |
| 30 |
37 |
| 31 # the OpenPKG OIDs (root is officially registered at IANA) |
38 # the OpenPKG OIDs (root is officially registered at IANA) |
| 32 %l_openpkg_oid 1.3.6.1.4.1.18749 |
39 %l_openpkg_oid 1.3.6.1.4.1.18749 |
| 33 %l_openpkg_oid_bootstrap %{l_openpkg_oid}.4.1 |
40 %l_openpkg_oid_bootstrap %{l_openpkg_oid}.4.1 |
| 34 %l_openpkg_oid_instance %{l_openpkg_oid_bootstrap}.1 |
41 %l_openpkg_oid_instance %{l_openpkg_oid_bootstrap}.1 |
| 35 %l_openpkg_oid_platform %{l_openpkg_oid_bootstrap}.2 |
42 %l_openpkg_oid_platform %{l_openpkg_oid_bootstrap}.2 |
| 36 %l_openpkg_oid_tagfmtopt %{l_openpkg_oid_bootstrap}.3 |
43 %l_openpkg_oid_tagfmtopt %{l_openpkg_oid_bootstrap}.3 |
| 37 |
44 |
| 38 # the OpenPKG package tagging |
45 # the OpenPKG package tagging |
| 39 %l_tag_fmt @TAG@ |
46 %l_tag_fmt @TAG@ |
| 40 %l_tag_fmt_compat %(prefix="%{l_prefix_static}"; if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then loc=`echo $prefix | cut -c2-4`; else loc=`echo $prefix | sed -e 's;/\\(.\\)[^/]*;\\1;g' | cut -c1-3`; fi; echo $loc) |
47 %l_tag_fmt_compat %(prefix="%{l_prefix_static}"; \ |
| 41 %l_tag_fmt_loc %(echo "%{l_prefix_static}" | sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/][^/]\\).*;\\1;' -e 's;^/\\([^/][^/]\\).*;\\1;' -e 's;^/\\([^/]\\).*;\\1;') |
48 if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then \ |
| 42 %l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; %{l_uuid} -v3 $uuid_ns '%{?_options}') |
49 loc=`echo $prefix | cut -c2-4`; \ |
| |
50 else \ |
| |
51 loc=`echo $prefix | sed -e 's;/\\(.\\)[^/]*;\\1;g' | cut -c1-3`; \ |
| |
52 fi; \ |
| |
53 echo $loc) |
| |
54 %l_tag_fmt_loc %(echo "%{l_prefix_static}" | \\\ |
| |
55 sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' \\\ |
| |
56 -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' \\\ |
| |
57 -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ |
| |
58 -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ |
| |
59 -e 's;^/\\([^/][^/][^/]\\).*;\\1;' \\\ |
| |
60 -e 's;^/\\([^/][^/]\\).*;\\1;' \\\ |
| |
61 -e 's;^/\\([^/]\\).*;\\1;' \\\ |
| |
62 ) |
| |
63 %l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; \ |
| |
64 %{l_uuid} -v3 $uuid_ns '%{?_options}') |
| 43 %l_tag_fmt_uuid %(%{l_uuid} -v1) |
65 %l_tag_fmt_uuid %(%{l_uuid} -v1) |
| 44 %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') |
66 %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') |
| 45 %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') |
67 %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') |
| 46 %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') |
68 %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') |
| 47 %l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} |
69 %l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | \\\ |
| 48 %l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g') |
70 sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} |
| |
71 %l_tag %{l_once l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g')} |
| 49 |
72 |
| 50 # the OpenPKG instance location (backward compatibility only) |
73 # the OpenPKG instance location (backward compatibility only) |
| 51 %l_location %{l_tag} |
74 %l_location %{l_tag} |
| 52 |
75 |
| 53 # standard RPM host platform identification |
76 # standard RPM host platform identification |
| 90 %l_host_arch %{_host_cpu} |
113 %l_host_arch %{_host_cpu} |
| 91 %l_host_vendor %{_host_vendor} |
114 %l_host_vendor %{_host_vendor} |
| 92 %l_host_os %{_host_os} |
115 %l_host_os %{_host_os} |
| 93 %l_host %{_host_cpu}-%{_host_os} |
116 %l_host %{_host_cpu}-%{_host_os} |
| 94 |
117 |
| |
118 # host name or FQDN identification |
| |
119 %l_hostname(f) %(%{l_shtool} echo -n -e '%%h%{?-f:%%d}') |
| |
120 |
| 95 # new OpenPKG platform identification |
121 # new OpenPKG platform identification |
| 96 %l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then fmt="%{-F*}"; else T="%{?-c:c}%{?-p:p}%{?-t:t}"; [ ".$T" = . ] && T="p"; fmt="%%<a$T>-%%<s$T>"; fi; %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") |
122 %l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then \ |
| |
123 fmt="%{-F*}"; \ |
| |
124 else \ |
| |
125 T="%{?-c:c}%{?-p:p}%{?-t:t}"; \ |
| |
126 [ ".$T" = . ] && T="p"; \ |
| |
127 fmt="%%<a$T>-%%<s$T>"; \ |
| |
128 fi; \ |
| |
129 %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") |
| 97 |
130 |
| 98 # old OpenPKG platform identification |
131 # old OpenPKG platform identification |
| 99 %l_target %{l_platform -t} |
132 %l_target %{l_platform -t} |
| |
133 |
| |
134 # UID/GID lookup |
| |
135 %l_xuid_lookup() %(( getent passwd '%1'; \ |
| |
136 grep '^%1:' /etc/passwd; \ |
| |
137 ypmatch '%1' passwd; \ |
| |
138 nismatch '%1' passwd; \ |
| |
139 nidump passwd . | grep '^%1:' \ |
| |
140 ) 2>/dev/null | \ |
| |
141 sed -e 'q' | \\\ |
| |
142 awk -F: '{ print $3; }' \ |
| |
143 ) |
| |
144 %l_xgid_lookup() %(( getent group '%2'; \ |
| |
145 grep '^%2:' /etc/group; \ |
| |
146 ypmatch '%2' group; \ |
| |
147 nismatch '%2' group; \ |
| |
148 nidump group . | grep '^%1:' \ |
| |
149 ) 2>/dev/null | \ |
| |
150 sed -e 'q' | \\\ |
| |
151 awk -F: '{ print $3; }' \ |
| |
152 ) |
| 100 |
153 |
| 101 # the *S*uper-user user/group name/id pair |
154 # the *S*uper-user user/group name/id pair |
| 102 %l_susr @SUSR@ |
155 %l_susr @SUSR@ |
| 103 %l_sgrp @SGRP@ |
156 %l_sgrp @SGRP@ |
| 104 %l_suid %((getent passwd "%{l_susr}"; grep "^%{l_susr}:" /etc/passwd; ypmatch "%{l_susr}" passwd; nismatch "%{l_susr}" passwd; nidump passwd . | grep "^%{l_susr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
157 %l_suid %{expand:%%{l_xuid_lookup %{l_susr} %{l_sgrp}}} |
| 105 %l_sgid %((getent group "%{l_sgrp}"; grep "^%{l_sgrp}:" /etc/group; ypmatch "%{l_sgrp}" group; nismatch "%{l_sgrp}" group; nidump group . | grep "^%{l_susr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
158 %l_sgid %{expand:%%{l_xgid_lookup %{l_susr} %{l_sgrp}}} |
| 106 |
159 |
| 107 # the *M*anagement user/group name/id pair |
160 # the *M*anagement user/group name/id pair |
| 108 %l_musr @MUSR@ |
161 %l_musr @MUSR@ |
| 109 %l_mgrp @MGRP@ |
162 %l_mgrp @MGRP@ |
| 110 %l_muid %((getent passwd "%{l_musr}"; grep "^%{l_musr}:" /etc/passwd; ypmatch "%{l_musr}" passwd; nismatch "%{l_musr}" passwd; nidump passwd . | grep "^%{l_musr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
163 %l_muid %{expand:%%{l_xuid_lookup %{l_musr} %{l_mgrp}}} |
| 111 %l_mgid %((getent group "%{l_mgrp}"; grep "^%{l_mgrp}:" /etc/group; ypmatch "%{l_mgrp}" group; nismatch "%{l_mgrp}" group; nidump group . | grep "^%{l_musr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
164 %l_mgid %{expand:%%{l_xgid_lookup %{l_musr} %{l_mgrp}}} |
| 112 |
165 |
| 113 # the *R*restricted user/group name/id pair |
166 # the *R*restricted user/group name/id pair |
| 114 %l_rusr @RUSR@ |
167 %l_rusr @RUSR@ |
| 115 %l_rgrp @RGRP@ |
168 %l_rgrp @RGRP@ |
| 116 %l_ruid %((getent passwd "%{l_rusr}"; grep "^%{l_rusr}:" /etc/passwd; ypmatch "%{l_rusr}" passwd; nismatch "%{l_rusr}" passwd; nidump passwd . | grep "^%{l_rusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
169 %l_ruid %{expand:%%{l_xuid_lookup %{l_rusr} %{l_rgrp}}} |
| 117 %l_rgid %((getent group "%{l_rgrp}"; grep "^%{l_rgrp}:" /etc/group; ypmatch "%{l_rgrp}" group; nismatch "%{l_rgrp}" group; nidump group . | grep "^%{l_rusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
170 %l_rgid %{expand:%%{l_xgid_lookup %{l_rusr} %{l_rgrp}}} |
| 118 |
171 |
| 119 # the *N*on-privileged user/group name/id pair |
172 # the *N*on-privileged user/group name/id pair |
| 120 %l_nusr @NUSR@ |
173 %l_nusr @NUSR@ |
| 121 %l_ngrp @NGRP@ |
174 %l_ngrp @NGRP@ |
| 122 %l_nuid %((getent passwd "%{l_nusr}"; grep "^%{l_nusr}:" /etc/passwd; ypmatch "%{l_nusr}" passwd; nismatch "%{l_nusr}" passwd; nidump passwd . | grep "^%{l_nusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
175 %l_nuid %{expand:%%{l_xuid_lookup %{l_nusr} %{l_ngrp}}} |
| 123 %l_ngid %((getent group "%{l_ngrp}"; grep "^%{l_ngrp}:" /etc/group; ypmatch "%{l_ngrp}" group; nismatch "%{l_ngrp}" group; nidump group . | grep "^%{l_nusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
176 %l_ngid %{expand:%%{l_xgid_lookup %{l_nusr} %{l_ngrp}}} |
| 124 |
177 |
| 125 # backward compatibility (openpkg < 20020204) |
178 # backward compatibility (openpkg < 20020204) |
| 126 %l_fsusr %{l_musr} |
179 %l_fsusr %{l_musr} |
| 127 %l_fsgrp %{l_mgrp} |
180 %l_fsgrp %{l_mgrp} |
| 128 %l_npuid %{l_nuid} |
181 %l_npuid %{l_nuid} |
| 129 %l_npgid %{l_ngid} |
182 %l_npgid %{l_ngid} |
| |
183 |
| |
184 # whether we are intended to operate in an environment where |
| |
185 # only a single unprivileged user account can be used |
| |
186 %l_unprivileged @l_unprivileged@ |
| 130 |
187 |
| 131 # define the installation hierarchy (used parts) |
188 # define the installation hierarchy (used parts) |
| 132 %l_prefix @l_prefix@ |
189 %l_prefix @l_prefix@ |
| 133 %l_prefix_static @l_prefix_static@ |
190 %l_prefix_static @l_prefix_static@ |
| 134 |
191 |
| 249 %l_curl %{l_prefix}/lib/openpkg/curl |
355 %l_curl %{l_prefix}/lib/openpkg/curl |
| 250 %l_bash %{l_prefix}/lib/openpkg/bash |
356 %l_bash %{l_prefix}/lib/openpkg/bash |
| 251 %l_uuid %{l_prefix}/lib/openpkg/uuid |
357 %l_uuid %{l_prefix}/lib/openpkg/uuid |
| 252 |
358 |
| 253 # provide smart paths to tools |
359 # provide smart paths to tools |
| 254 %l_tool_locate() %(if [ ".%{expand:%%{?use_%1}}" != . ]; then tool="%{expand:%%{use_%1}}"; elif [ -f "%{l_prefix}/bin/%2" ]; then tool="%{l_prefix}/bin/%2"; elif [ -f "%{l_prefix}/lib/openpkg/%2" ]; then tool="%{l_prefix}/lib/openpkg/%2"; else tool="%2"; fi; echo $tool) |
360 %l_tool_locate() %{lua: \ |
| 255 %l_gzip %{l_tool_locate gzip gzip} |
361 if rpm.expand("%{expand:%%{?use_%1}}") ~= "" then \ |
| 256 %l_bzip2 %{l_tool_locate bzip2 bzip2} |
362 print(rpm.expand("%{expand:%%{use_%1}}")) \ |
| 257 %l_tar %{l_tool_locate tar tar} |
363 elseif posix.stat(rpm.expand("%{l_prefix}/bin/%2")) ~= nil then \ |
| 258 %l_make %{l_tool_locate make make} |
364 print(rpm.expand("%{l_prefix}/bin/%2")) \ |
| 259 %l_cc %{l_tool_locate cc cc} |
365 elseif posix.stat(rpm.expand("%{l_prefix}/lib/openpkg/%2")) ~= nil then \ |
| 260 %l_ar %{l_tool_locate ar ar} |
366 print(rpm.expand("%{l_prefix}/lib/openpkg/%2")) \ |
| 261 %l_ld %{l_tool_locate ld ld} |
367 else \ |
| 262 %l_as %{l_tool_locate as as} |
368 print(rpm.expand("%2")) \ |
| 263 %l_strip %{l_tool_locate strip strip} |
369 end } |
| 264 %l_cxx %{l_tool_locate cxx c++} |
370 %l_gzip %{l_once l_gzip %{l_tool_locate gzip gzip}} |
| 265 %l_patch %{l_tool_locate patch patch} |
371 %l_bzip2 %{l_once l_bzip2 %{l_tool_locate bzip2 bzip2}} |
| 266 %l_sed %{l_tool_locate sed sed} |
372 %l_xz %{l_once l_xz %{l_tool_locate xz xz}} |
| 267 %l_grep %{l_tool_locate grep grep} |
373 %l_tar %{l_once l_tar %{l_tool_locate tar tar}} |
| 268 %l_awk %{l_tool_locate awk awk} |
374 %l_make %{l_once l_make %{l_tool_locate make make}} |
| 269 %l_autoconf %{l_tool_locate autoconf autoconf} |
375 %l_cc %{l_once l_cc %{l_tool_locate cc cc}} |
| 270 %l_automake %{l_tool_locate automake automake} |
376 %l_ar %{l_once l_ar %{l_tool_locate ar ar}} |
| 271 %l_libtool %{l_tool_locate libtool libtool} |
377 %l_ld %{l_once l_ld %{l_tool_locate ld ld}} |
| 272 %l_flex %{l_tool_locate flex flex} |
378 %l_as %{l_once l_as %{l_tool_locate as as}} |
| 273 %l_bison %{l_tool_locate bison bison} |
379 %l_strip %{l_once l_strip %{l_tool_locate strip strip}} |
| 274 %l_perl %{l_tool_locate perl perl} |
380 %l_cxx %{l_once l_cxx %{l_tool_locate cxx c++}} |
| 275 %l_miniperl %{l_tool_locate miniperl miniperl} |
381 %l_patch %{l_once l_patch %{l_tool_locate patch patch}} |
| 276 %l_openssl %{l_tool_locate openssl openssl} |
382 %l_sed %{l_once l_sed %{l_tool_locate sed sed}} |
| 277 %l_xmkmf %{l_tool_locate xmkmf xmkmf} |
383 %l_grep %{l_once l_grep %{l_tool_locate grep grep}} |
| 278 %l_vcheck %{l_tool_locate vcheck vcheck} |
384 %l_awk %{l_once l_awk %{l_tool_locate awk awk}} |
| |
385 %l_autoconf %{l_once l_autoconf %{l_tool_locate autoconf autoconf}} |
| |
386 %l_automake %{l_once l_automake %{l_tool_locate automake automake}} |
| |
387 %l_libtool %{l_once l_libtool %{l_tool_locate libtool libtool}} |
| |
388 %l_flex %{l_once l_flex %{l_tool_locate flex flex}} |
| |
389 %l_bison %{l_once l_bison %{l_tool_locate bison bison}} |
| |
390 %l_perl %{l_once l_perl %{l_tool_locate perl perl}} |
| |
391 %l_miniperl %{l_once l_miniperl %{l_tool_locate miniperl miniperl}} |
| |
392 %l_openssl %{l_once l_openssl %{l_tool_locate openssl openssl}} |
| |
393 %l_xmkmf %{l_once l_xmkmf %{l_tool_locate xmkmf xmkmf}} |
| |
394 %l_vcheck %{l_once l_vcheck %{l_tool_locate vcheck vcheck}} |
| 279 |
395 |
| 280 # tool options |
396 # tool options |
| 281 %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") |
397 %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") |
| 282 %l_cflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cc}") |
398 %l_cflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cc}") |
| 283 %l_cxxflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cxx}") |
399 %l_cxxflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cxx}") |
| 284 %l_cppflags(i) %(%{l_sane_env}; %{l_rpmtool} cppflags -p%{l_prefix} %{-i:-i} -- %*) |
400 %l_cppflags(i) %(%{l_sane_env}; %{l_rpmtool} cppflags -p%{l_prefix} %{-i:-i} -- %*) |
| 285 %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) |
401 %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) |
| 286 |
402 |
| 287 # OSSP fake syslog library |
403 # OSSP fake syslog library |
| 288 %l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; else flags=''; fi; echo $flags) |
404 %l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then \ |
| 289 %l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --libs ) 2>/dev/null`; else flags=''; fi; echo $flags) |
405 flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; \ |
| |
406 else \ |
| |
407 flags=''; \ |
| |
408 fi; \ |
| |
409 echo $flags) |
| |
410 %l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then \ |
| |
411 flags=`(%{l_prefix}/bin/fsl-config --all --libs) 2>/dev/null`; \ |
| |
412 else \ |
| |
413 flags=''; \ |
| |
414 fi; \ |
| |
415 echo $flags) |
| 290 |
416 |
| 291 # determine the current username |
417 # determine the current username |
| 292 %l_whoami %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME) |
418 %l_whoami %{l_once l_whoami %((id -un) 2>/dev/null || \\\ |
| |
419 (whoami) 2>/dev/null || \\\ |
| |
420 (who am i | cut "-d " -f1) 2>/dev/null || \\\ |
| |
421 echo $LOGNAME)} |
| 293 |
422 |
| 294 # macros for dynamically generating a %files list |
423 # macros for dynamically generating a %files list |
| 295 %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' |
424 %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' |
| 296 %l_files_all '%{l_prefix}' |
425 %l_files_all '%{l_prefix}' |
| 297 %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' |
426 %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' |
| 298 %l_files_std() %l_files_defattr %l_files_all %l_files_noshared |
427 %l_files_std() %l_files_defattr %l_files_all %l_files_noshared |
| 299 |
428 |
| |
429 # default %defattr when rolling SRPMS |
| |
430 %_srcdefattr (-,openpkg,openpkg) |
| |
431 |
| 300 # path to local build root |
432 # path to local build root |
| 301 %l_buildroot %{_tmppath}/%{name}-%{version}-root |
433 %l_buildroot %{_tmppath}/%{name}-%{version}-%{release}-buildroot |
| 302 %buildroot %{l_buildroot} |
434 %buildroot %{l_buildroot} |
| 303 |
435 |
| 304 # path to local temporary location |
436 # path to local temporary location |
| 305 %l_tmpdir() %{_tmppath} |
437 %l_tmpdir() %{_tmppath} |
| 306 %l_tmpfile() %{l_tmpdir}/%{name}-%{version}-%{release}-tmp%{?1:-%1} |
438 %l_tmpfile() %{l_tmpdir}/%{name}-%{version}-%{release}-tmp%{?1:-%1} |
| 314 |
446 |
| 315 # override the name scheme for RPM files |
447 # override the name scheme for RPM files |
| 316 %_rpmfilename %{l_binrpmfilename} |
448 %_rpmfilename %{l_binrpmfilename} |
| 317 %_build_name_fmt %{l_binrpmfilename} |
449 %_build_name_fmt %{l_binrpmfilename} |
| 318 %_repackage_name_fmt %{l_binrpmfilename} |
450 %_repackage_name_fmt %{l_binrpmfilename} |
| 319 %_solve_name_fmt %{_solve_pkgsdir}/%{l_binrpmfilename} |
451 %_solve_name_fmt %{?_solve_pkgsdir}/%{l_binrpmfilename} |
| |
452 %_query_all_fmt %%{NAME}-%%{VERSION}-%%{RELEASE} |
| |
453 %___NVRA %%{NAME}-%%{VERSION}-%%{RELEASE} |
| |
454 |
| |
455 # do not repackage automatically |
| |
456 %_repackage_all_erasures 0 |
| 320 |
457 |
| 321 # override the payload compression for the CPIO parts of an RPM |
458 # override the payload compression for the CPIO parts of an RPM |
| 322 # (we use the equivalent of "bzip2 -9") |
459 # (we use the equivalent of "bzip2 -9") |
| 323 %_source_payload w9.bzdio |
460 %_source_payload w9.bzdio |
| 324 %_binary_payload w9.bzdio |
461 %_binary_payload w9.bzdio |
| 325 |
462 |
| 326 # package signature type is OpenPGP via GnuPG |
463 # package signature type is OpenPGP via GnuPG |
| 327 %__gpg %{l_prefix}/bin/gpg |
464 %__gpg %{l_tool_locate gpg gpg} |
| 328 %_signature gpg |
465 %_signature gpg |
| 329 %__vsflags 1 |
|
| 330 |
466 |
| 331 # two macro-processor add-ons (should be part of forthcoming RPM releases) |
467 # two macro-processor add-ons (should be part of forthcoming RPM releases) |
| 332 %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} |
468 %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} |
| 333 %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} |
469 %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} |
| 334 |
470 |
| 335 # macro for package option configuration |
471 # macro for package option configuration |
| 336 %option() %{expand:%%{!?%{1}:%%global %*}} %{expand:%%global _options %{?_options:%{_options}:}%{1}=%%%{1}} \ |
472 %option() %{lua: \ |
| 337 Provides: %{name}::%{1} = %(echo '%{expand:%%{%{1}}}' | sed -e 's;%%;%%%%;g' -e 's; ;%%20;g' -e 's; ;%%09;g') |
473 local package_name = rpm.expand("%{name}") \ |
| |
474 local option_name = rpm.expand("%1") \ |
| |
475 if rpm.expand("%{?" .. option_name .. ":defined}") ~= "defined" then \ |
| |
476 rpm.expand("%global " .. rpm.expand("%*")) \ |
| |
477 end \ |
| |
478 local option_value = rpm.expand("%{" .. option_name .. "}") \ |
| |
479 option_value = util.rsubst(option_value, "(?s)%", "%%%%") \ |
| |
480 option_value = util.rsubst(option_value, "(?s) ", "%%20") \ |
| |
481 option_value = util.rsubst(option_value, "(?s)\\t", "%%09") \ |
| |
482 rpm.expand("%global _options %{?_options:%{_options}:}" .. option_name .. "=" .. option_value) \ |
| |
483 print(string.format("Provides: %s::%s = %s\\n", package_name, option_name, option_value)) \ |
| |
484 } |
| 338 |
485 |
| 339 # macros for NoSource/NoPatch (distribution restriction) integrity handling |
486 # macros for NoSource/NoPatch (distribution restriction) integrity handling |
| 340 %NoSource() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoSource: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} |
487 %NoSource() %(if [ ".%{?restriction}" != ".no" ]; then \ |
| 341 %NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoPatch: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} |
488 echo "NoSource: %1"; \ |
| |
489 fi) \ |
| |
490 %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} |
| |
491 %NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then \ |
| |
492 echo "NoPatch: %1"; fi) \ |
| |
493 %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} |
| 342 %integrity() %{l_check_nosource} |
494 %integrity() %{l_check_nosource} |
| 343 |
495 |
| 344 # macros for checking build environment |
496 # macros for checking build environment |
| 345 %l_check_nosource() %(%{l_sane_env}; checkok=1; checkinfo=`echo "Sorry, this OpenPKG package contains a DISTRIBUTION RESTRICTED source file."; echo "Before you can proceed building this package, fetch missing files MANUALLY:"`; for url in . %{?_restricted}; do [ ".$url" = .. ] && continue; eval `echo "$url" | sed -e 's!^\\(.*\\)::/\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' -e 's!^\\([^:;][^:]*://.*/\\)\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' -e 's:^\\([^;].*\\)$:;url="(unknown location) "; file="\\1":' -e 's:^;::'`; if [ ! -f "%{_specdir}/$file" ] && [ ! -f "%{_sourcedir}/$file" ]; then checkok=0; checkinfo=`echo "${checkinfo}"; echo ""; echo "from ${url}"; echo "file ${file}"; echo "here %{_sourcedir}/$file"`; fi; done; if [ $checkok -ne 1 ]; then echo "set +x"; echo "$checkinfo" | %{l_rpmtool} msg -b -t error | sed -e 's;^;echo ";' -e 's;$;";'; echo "exit 1"; fi) |
497 %l_check_nosource() %(%{l_sane_env}; checkok=1; \ |
| 346 %l_check_class() %(%{l_sane_env}; class=`echo "@:%{?class}:%{?distribution}" | sed -e 's;^@:\\([^:][^:]*\\):.*$;\\1;' -e 's;^@:.*\\[\\(.*\\)\\].*$;\\1;' -e 's;^@:.*$;JUNK;'`; %{l_rpmtool} check-class "$class") |
498 checkinfo=`echo "Sorry, this OpenPKG package contains a DISTRIBUTION RESTRICTED source file."; \\\ |
| |
499 echo "Before you can proceed building this package, fetch missing files MANUALLY:"`; \ |
| |
500 for url in . %{?_restricted}; do \ |
| |
501 [ ".$url" = .. ] && continue; \ |
| |
502 eval `echo "$url" | \\\ |
| |
503 sed -e 's!^\\(.*\\)::/\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ |
| |
504 -e 's!^\\([^:;][^:]*://.*/\\)\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ |
| |
505 -e 's:^\\([^;].*\\)$:;url="(unknown location) "; file="\\1":' \\\ |
| |
506 -e 's:^;::'`; \ |
| |
507 if [ ! -f "%{_specdir}/$file" ] && [ ! -f "%{_sourcedir}/$file" ]; then \\\ |
| |
508 checkok=0; \ |
| |
509 checkinfo=`echo "${checkinfo}"; \\\ |
| |
510 echo ""; \\\ |
| |
511 echo "from ${url}"; \\\ |
| |
512 echo "file ${file}"; \\\ |
| |
513 echo "here %{_sourcedir}/$file"`; \ |
| |
514 fi; \ |
| |
515 done; \ |
| |
516 if [ $checkok -ne 1 ]; then \ |
| |
517 echo "set +x"; \ |
| |
518 echo "$checkinfo" | \\\ |
| |
519 %{l_rpmtool} msg -b -t error | \\\ |
| |
520 sed -e 's;^;echo ";' -e 's;$;";'; \ |
| |
521 echo "exit 1"; \ |
| |
522 fi) |
| |
523 %l_check_class() %(%{l_sane_env}; \ |
| |
524 class=`echo "@:%{?class}:%{?distribution}" | \\\ |
| |
525 sed -e 's;^@:\\([^:][^:]*\\):.*$;\\1;' \\\ |
| |
526 -e 's;^@:.*\\[\\(.*\\)\\].*$;\\1;' \\\ |
| |
527 -e 's;^@:.*$;JUNK;'`; \ |
| |
528 %{l_rpmtool} check-class "$class") |
| 347 %prep %%prep\ |
529 %prep %%prep\ |
| 348 %{l_check_nosource} \ |
530 %{l_check_nosource} \ |
| 349 %{l_check_class} \ |
531 %{l_check_class} \ |
| 350 %{nil} |
532 %{nil} |
| 351 |
533 |
| 352 # macro-processor add-on for testing external conditions |
534 # macro-processor add-on for testing external conditions |
| 353 %l_test(pfd) %(if [ ".%{?-p:yes}" = .yes ]; then %{l_rpm} -q %1 >/dev/null 2>&1; rc=$?; elif [ ".%{?-f:yes}" = .yes ]; then test -f %1; rc=$?; elif [ ".%{?-d:yes}" = .yes ]; then test -d %1; rc=$?; fi; if [ ".$rc" = .0 ]; then echo "yes"; else echo "no"; fi) |
535 %l_test(pfd) %(if [ ".%{?-p:yes}" = .yes ]; then \ |
| 354 |
536 %{l_rpm} -q %1 >/dev/null 2>&1; rc=$?; \ |
| 355 # default list of vendor source fetching locations |
537 elif [ ".%{?-f:yes}" = .yes ]; then \ |
| 356 %l_fetch_mirror_0 - |
538 test -f %1; rc=$?; \ |
| 357 %l_fetch_mirror_1 - |
539 elif [ ".%{?-d:yes}" = .yes ]; then \ |
| 358 %l_fetch_mirror_2 - |
540 test -d %1; rc=$?; \ |
| 359 %l_fetch_mirror_3 - |
541 fi; \ |
| 360 %l_fetch_mirror_4 - |
542 if [ ".$rc" = .0 ]; then \ |
| 361 %l_fetch_mirror_5 - |
543 echo "yes"; \ |
| 362 %l_fetch_mirror_6 - |
544 else \ |
| 363 %l_fetch_mirror_7 - |
545 echo "no"; \ |
| 364 %l_fetch_mirror_8 - |
546 fi) |
| 365 %l_fetch_mirror_9 - |
|
| 366 %l_fetch_backup_0 - |
|
| 367 %l_fetch_backup_1 - |
|
| 368 %l_fetch_backup_2 - |
|
| 369 %l_fetch_backup_3 - |
|
| 370 %l_fetch_backup_4 - |
|
| 371 %l_fetch_backup_5 - |
|
| 372 %l_fetch_backup_6 - |
|
| 373 %l_fetch_backup_7 - |
|
| 374 %l_fetch_backup_8 - |
|
| 375 %l_fetch_backup_9 ftp://ftp.openpkg.org/sources/DST/%{name}/ |
|
| 376 |
547 |
| 377 # sane build environment setup |
548 # sane build environment setup |
| 378 %l_build_path %(if [ -d %{l_prefix}/lib/openpkg/override ]; then echo "%{l_prefix}/lib/openpkg/override:"; fi)%{l_prefix}/bin:%{l_prefix}/sbin:@l_build_path@%(if [ -d %{l_prefix}/lib/openpkg/fallback ]; then echo ":%{l_prefix}/lib/openpkg/fallback"; fi) |
549 %l_build_path %{l_once l_build_path %(if [ -d %{l_prefix}/lib/openpkg/override ]; then \ |
| |
550 echo "%{l_prefix}/lib/openpkg/override:"; \ |
| |
551 fi)%{l_prefix}/bin:%{l_prefix}/sbin:@l_build_path@%(\ |
| |
552 if [ -d %{l_prefix}/lib/openpkg/fallback ]; then \ |
| |
553 echo ":%{l_prefix}/lib/openpkg/fallback"; \ |
| |
554 fi)} |
| 379 %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ |
555 %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ |
| 380 %l_build_ulim @l_build_ulim@ |
556 %l_build_ulim @l_build_ulim@ |
| 381 %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash |
557 %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash |
| 382 %l_build_shell_opt --norc --noprofile --posix |
558 %l_build_shell_opt --norc --noprofile --posix |
| 383 |
559 |
| 384 # sane build environment for manual usage in macros (currently just $PATH) |
560 # sane build environment for manual usage in macros (currently just $PATH) |
| 385 %l_sane_env PATH="%{l_build_path}"; export PATH; LD_LIBRARY_PATH="%{l_build_ldlp}"; export LD_LIBRARY_PATH |
561 %l_sane_env PATH="%{l_build_path}"; \ |
| |
562 export PATH; \ |
| |
563 LD_LIBRARY_PATH="%{l_build_ldlp}"; \ |
| |
564 export LD_LIBRARY_PATH |
| 386 |
565 |
| 387 # sane build environment for %prep/%build/%install |
566 # sane build environment for %prep/%build/%install |
| 388 %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} |
567 %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} |
| 389 %___build_pre \ |
568 %___build_pre HOME="%{l_prefix}"\ |
| 390 HOME="%{l_prefix}"\ |
569 SHELL="%{l_build_shell_cmd}"\ |
| 391 SHELL="%{l_build_shell_cmd}"\ |
570 TERM="%{getenv:TERM}"\ |
| 392 TERM="%(echo $TERM)"\ |
571 TMPDIR="%{_tmppath}"\ |
| 393 TMPDIR="%{_tmppath}"\ |
572 USER="%{getenv:USER}"\ |
| 394 USER="%(echo $USER)"\ |
573 LOGNAME="%{getenv:LOGNAME}"\ |
| 395 LOGNAME="%(echo $LOGNAME)"\ |
574 PATH="%{l_build_path}"\ |
| 396 PATH="%{l_build_path}"\ |
575 LD_LIBRARY_PATH="%{l_build_ldlp}"\ |
| 397 LD_LIBRARY_PATH="%{l_build_ldlp}"\ |
576 export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ |
| 398 export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ |
577 RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ |
| 399 RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ |
578 RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ |
| 400 RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ |
579 RPM_OPT_FLAGS=\"%{optflags}\"\ |
| 401 RPM_OPT_FLAGS=\"%{optflags}\"\ |
580 RPM_ARCH=\"%{l_host_arch}\"\ |
| 402 RPM_ARCH=\"%{l_host_arch}\"\ |
581 RPM_OS=\"%{l_host_os}\"\ |
| 403 RPM_OS=\"%{l_host_os}\"\ |
582 RPM_DOC_DIR=\"%{_docdir}\"\ |
| 404 RPM_DOC_DIR=\"%{_docdir}\"\ |
583 RPM_PACKAGE_NAME=\"%{name}\"\ |
| 405 RPM_PACKAGE_NAME=\"%{name}\"\ |
584 RPM_PACKAGE_VERSION=\"%{version}\"\ |
| 406 RPM_PACKAGE_VERSION=\"%{version}\"\ |
585 RPM_PACKAGE_RELEASE=\"%{release}\"\ |
| 407 RPM_PACKAGE_RELEASE=\"%{release}\"\ |
586 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ |
| 408 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ |
587 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ |
| 409 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ |
588 %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ |
| 410 %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ |
589 export RPM_BUILD_ROOT}\ |
| 411 export RPM_BUILD_ROOT}\ |
590 %{l_build_ulim}\ |
| 412 %{l_build_ulim}\ |
591 umask 022\ |
| 413 umask 022\ |
592 %{verbose:set -x}%{!verbose:exec >/dev/null}\ |
| 414 %{verbose:set -x}%{!verbose:exec >/dev/null}\ |
593 cd %{u2p:%{_builddir}} |
| 415 cd %{u2p:%{_builddir}} |
594 |
| |
595 # improved %patch macro |
| |
596 %patch(b:p:P:REz:F:d:e:m:) %{lua: \ |
| |
597 local subst = "" \ |
| |
598 local options = rpm.expand("%**") \ |
| |
599 local regex = "-e\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ |
| |
600 local pcre = rex_pcre.new(regex) \ |
| |
601 local n = 0 \ |
| |
602 while true do \ |
| |
603 local s, e, t = pcre:tfind(options, n) \ |
| |
604 if s == nil then break end \ |
| |
605 subst = subst .. " -e " .. t[1] \ |
| |
606 n = e + 1 \ |
| |
607 end \ |
| |
608 local regex = "-m\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ |
| |
609 local pcre = rex_pcre.new(regex) \ |
| |
610 local n = 0 \ |
| |
611 while true do \ |
| |
612 local s, e, t = pcre:tfind(options, n) \ |
| |
613 if s == nil then break end \ |
| |
614 subst = subst .. " -e 's;@" .. t[1] .. "@;%{" .. t[1] .. "};g'" \ |
| |
615 n = e + 1 \ |
| |
616 end \ |
| |
617 if subst ~= "" then \ |
| |
618 subst = "| sed" .. subst \ |
| |
619 rpm.define("__patch_subst " .. subst) \ |
| |
620 else \ |
| |
621 rpm.define("__patch_subst %{nil}") \ |
| |
622 end \ |
| |
623 }%{shrink: \ |
| |
624 %define __patch_number %{-P:%{-P*}}%{!-P:0} \ |
| |
625 %define __patch_file %{P:%{__patch_number}} \ |
| |
626 %define __patch_suffix %{-b:-b --suffix %{-b*}}%{!-b:-b --suffix .orig} %{-z:--suffix %{-z*}} \ |
| |
627 %define __patch_options -s %{-p:-p%{-p*}} %{-F:-F%{-F*}} %{-d:-d%{-d*}} %{-R} %{-E} %{__patch_suffix} \ |
| |
628 echo "Patch #%{__patch_number} (%{basename:%{__patch_file}}):"; \ |
| |
629 %{uncompress:%{__patch_file}} %{__patch_subst} | %{__patch} %{__patch_options}}\ |
| |
630 %{nil} |
| 416 |
631 |
| 417 # special %track section support |
632 # special %track section support |
| 418 %__spec_track_template VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.vc"\ |
633 %__spec_track_pre\ |
| |
634 VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.track.vc"\ |
| 419 rm -f $VCFILE\ |
635 rm -f $VCFILE\ |
| 420 set -o noclobber\ |
636 set -o noclobber\ |
| 421 sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ |
637 sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ |
| 422 %{nil} |
638 %{nil} |
| 423 %__spec_track_post EOF\ |
639 %__spec_track_post EOF\ |
| 432 exit 0\ |
648 exit 0\ |
| 433 fi\ |
649 fi\ |
| 434 ( echo "config = {"\ |
650 ( echo "config = {"\ |
| 435 echo "}"\ |
651 echo "}"\ |
| 436 ) >>$VCFILE\ |
652 ) >>$VCFILE\ |
| 437 %{l_vcheck} -v -f $VCFILE || true\ |
653 %{l_vcheck} %{verbose:--verbose}%{!verbose:--noverbose} -f $VCFILE || true\ |
| 438 fi\ |
654 fi\ |
| 439 rm -f $VCFILE\ |
655 rm -f $VCFILE\ |
| 440 %{nil} |
656 %{nil} |
| 441 |
657 |
| 442 # automatically include never changing RPM header text |
658 # support additional .spec tags |
| |
659 %_arbitrary_tags Class:Track:TrackProg:BuildDependency:BuildEnvironment:My*:Local* |
| |
660 |
| |
661 # disable /bin/sh dependency (which doesn't fit into OpenPKG's environment) |
| |
662 %_disable_shell_interpreter_deps 1 |
| |
663 |
| |
664 # support downloading files via cURL (instead of internal RPMIO) |
| |
665 # and optionally also from global and local mirror and backup location(s) |
| |
666 %__urlgetfile_urls_mirror() \ |
| |
667 %{nil} |
| |
668 %__urlgetfile_urls_backup() %{lua: \ |
| |
669 local url = rpm.expand("%1") \ |
| |
670 local name = rpm.expand("%{name}") \ |
| |
671 if name ~= "" and url ~= "" then \ |
| |
672 local cache = "http://download.openpkg.org/components/cache/" .. name .. "/" \ |
| |
673 url = util.rsubst(url, "^.+/([^/]+)$", cache .. "%1") \ |
| |
674 print(url) \ |
| |
675 end \ |
| |
676 } |
| |
677 %__urlgetfile_urls() \ |
| |
678 %{?__urlgetfile_urls_mirror %1} %1 %{?__urlgetfile_urls_backup %1} |
| |
679 %__urlgetfile() %{lua: \ |
| |
680 local url_orig = rpm.expand("%1") \ |
| |
681 local file = rpm.expand("%2") \ |
| |
682 local urls = util.rsplit(rpm.expand("%{?__urlgetfile_urls " .. url_orig .. "}"), "\\\\s+") \ |
| |
683 local result = "ERROR" \ |
| |
684 local type = "mirror" \ |
| |
685 for i, url in ipairs(urls) do \ |
| |
686 if url ~= "" then |
| |
687 if url == url_orig then \ |
| |
688 type = "original" \ |
| |
689 elseif type == "original" then \ |
| |
690 type = "backup" \ |
| |
691 end \ |
| |
692 io.stdout:write(string.format("Fetching(%s): %s\\n", type, url)) \ |
| |
693 local rc = rpm.expand( \ |
| |
694 "%(%{l_prefix}/bin/openpkg curl '-#' -L -R -k " .. \ |
| |
695 "-o '" .. file .. "'" .. " '" .. url .. "' 1>&2; echo $?)" \ |
| |
696 ) \ |
| |
697 if rc == "0" then \ |
| |
698 result = "OK" \ |
| |
699 break \ |
| |
700 end \ |
| |
701 end |
| |
702 end \ |
| |
703 print(result) \ |
| |
704 } |
| |
705 |
| |
706 # increase size of line buffer for .spec file parsing |
| |
707 # from 10KB to 4MB to support rather large BuildEnvironment tags |
| |
708 %_spec_line_buffer_size 4000000 |
| |
709 |
| |
710 # configure auto-generation of OpenPKG "BuildDependency" and "BuildEnvironment" tags |
| |
711 %__autogen_builddependency 0 |
| |
712 %__autogen_buildenvironment 0 |
| |
713 |
| |
714 # hook into %description |
| |
715 %description\ |
| |
716 %{?__hook_description_1}\ |
| |
717 %{?__hook_description_2}\ |
| |
718 %{?__hook_description_3}\ |
| |
719 %{?__hook_description_4}\ |
| |
720 %{?__hook_description_5}\ |
| |
721 %{?__hook_description_6}\ |
| |
722 %{?__hook_description_7}\ |
| |
723 %{?__hook_description_8}\ |
| |
724 %{?__hook_description_9}\ |
| |
725 %%description |
| |
726 |
| |
727 # magically provide additional tags which are required but are always the same |
| 443 %__hook_description_1 %{lua: \ |
728 %__hook_description_1 %{lua: \ |
| 444 local prefix = rpm.expand("%{l_prefix_static}") \ |
729 local prefix = rpm.expand("%{l_prefix_static}") \ |
| 445 if rpm.expand("%{?prefix}") ~= prefix then \ |
730 if rpm.expand("%{?prefix}") ~= prefix then \ |
| 446 print(string.format("Prefix: %s\\n", prefix)) \ |
731 print(string.format("Prefix: %s\\n", prefix)) \ |
| 447 end \ |
732 end \ |
| 448 print("AutoReq: no\\n") \ |
733 print("AutoReq: no\\n") \ |
| 449 print("AutoReqProv: no\\n") \ |
734 print("AutoReqProv: no\\n") \ |
| 450 } |
735 } |
| 451 |
736 |
| |
737 # auto-generate arbitrary tag "Marker" (via "rpm --marker <marker>") |
| |
738 %__hook_description_2 %{?__marker:Marker: %{__marker}}\ |
| |
739 %{nil} |
| |
740 |
| |
741 # auto-generate arbitrary tag "BuildDependency" from the standard tag(s) "BuildPreReq" |
| |
742 # in order to forward-carry this build-time information to the binary RPM and to the RPMDB. |
| |
743 %__hook_description_3 %{?__autogen_builddependency:%{?buildprereq:BuildDependency: %{@buildprereq:, }}}\ |
| |
744 %{nil} |
| |
745 |
| |
746 # magically pickup all patched packaging source files (.orig/.rej) |
| |
747 %__hook_description_4 %{lua: \ |
| |
748 -- assemble RPM's information about SourceN and PatchN \ |
| |
749 local sources = {} \ |
| |
750 local macros = rpm.macros() \ |
| |
751 for name, value in pairs(macros) do \ |
| |
752 local s, _, m = util.rmatch(name, "^(?i)(SOURCE|PATCH)((?:URL)?)(\\\\d+)$") \ |
| |
753 if s ~= nil and value["body"] ~= nil then \ |
| |
754 local n = string.upper(string.sub(m[1], 1, 1)) .. string.lower(string.sub(m[1], 2)) .. m[3] \ |
| |
755 if sources[n] == nil then \ |
| |
756 sources[n] = { url = "", file = "" } \ |
| |
757 end \ |
| |
758 if m[2] ~= nil and m[2] ~= "" then \ |
| |
759 sources[n].url = value["body"] \ |
| |
760 else \ |
| |
761 sources[n].file = value["body"] \ |
| |
762 end \ |
| |
763 end \ |
| |
764 end \ |
| |
765 \ |
| |
766 -- add implicit .spec source file \ |
| |
767 sources["Source999"] = { \ |
| |
768 url = rpm.expand("%{name}.spec"), \ |
| |
769 file = rpm.expand("%{_specdir}/%{name}.spec") \ |
| |
770 } \ |
| |
771 \ |
| |
772 -- auto-generate tags for local SourceN and PatchN files \ |
| |
773 -- where any corresponding .orig/.rej files exists \ |
| |
774 for id, s in pairs(sources) do \ |
| |
775 if util.rmatch(s.url, "^(?:ftp|https?)://.+") == nil then \ |
| |
776 for i, ext in ipairs({ ".orig", ".rej" }) do \ |
| |
777 if posix.access(s.file .. ext, "r") == 0 then \ |
| |
778 local _, _, m = util.rmatch(id, "^(?i)(Source|Patch)(\\\\d+)$") \ |
| |
779 local tag = string.format("%s%d: %s\\n", m[1], 10000 * i + m[2], s.url .. ext) \ |
| |
780 print(tag) \ |
| |
781 end \ |
| |
782 end \ |
| |
783 end \ |
| |
784 end \ |
| |
785 } |
| |
786 |
| |
787 # recursive package environment tracking configuration |
| |
788 %__environment_delete_nve_regex ^gpg-pubkey-[^-]+-[^-]+$ |
| |
789 %__environment_prune_nve_regex ^%{name}-[^-]+-[^-]+$ |
| |
790 %__environment_prune_depth_number 3 |
| |
791 %__environment_debug 0 |
| |
792 |
| |
793 # recursive package environment implementation |
| |
794 %__hook_description_5 %{nil} |
| |
795 %__hook_description_5_orig %{?__autogen_buildenvironment:%{lua: \ |
| |
796 -- determine current debug status quo |
| |
797 local debug = tonumber(rpm.expand("%{?__environment_debug}%{!?__environment_debug:0}")) \ |
| |
798 \ |
| |
799 -- determine current environment in serialized format \ |
| |
800 -- (which actually is the Lua table constructor syntax) \ |
| |
801 local result = {} \ |
| |
802 for _, line in ipairs(rpm.query( \ |
| |
803 "Q:\\\\[\\"%{name}-%{version}-%{release}\\"\\\\]=" .. \ |
| |
804 "%|buildenvironment?{%{buildenvironment}}:{\\\\{\\\\}}|,", \ |
| |
805 true, "*")) do \ |
| |
806 local s, _, m = util.rmatch(line, "(?s)^Q:(.+)$") \ |
| |
807 if s ~= nil then \ |
| |
808 table.insert(result, m[1]) \ |
| |
809 end \ |
| |
810 end \ |
| |
811 local constructor = "{" .. table.concat(result , "") .. "}" \ |
| |
812 \ |
| |
813 -- parse current environment \ |
| |
814 -- (by evaluating the constructor as a Lua script) \ |
| |
815 local environment = {} \ |
| |
816 local f = loadstring("return " .. constructor) \ |
| |
817 if f ~= nil then \ |
| |
818 environment = f() \ |
| |
819 else \ |
| |
820 io.stderr:write("rpm: WARNING: failed to parse Lua table constructor: " .. constructor .. "\\n") \ |
| |
821 end \ |
| |
822 if debug > 0 then \ |
| |
823 io.stdout:write("BuildEnvironment(original): " .. util.dump_object(environment, false) .. "\\n") \ |
| |
824 end |
| |
825 \ |
| |
826 -- prune environment according to configuration \ |
| |
827 function prune_environment (environment, depth) \ |
| |
828 local delete_nve_regex = tostring(rpm.expand("%{?__environment_delete_nve_regex}")) \ |
| |
829 local prune_nve_regex = tostring(rpm.expand("%{?__environment_prune_nve_regex}")) \ |
| |
830 local prune_depth_number = tonumber(rpm.expand("%{?__environment_prune_depth_number}")) \ |
| |
831 if type(environment) == "table" then \ |
| |
832 for nve, _ in pairs(environment) do \ |
| |
833 if (prune_depth_number ~= nil and prune_depth_number > 0 and depth > prune_depth_number) or \ |
| |
834 (delete_nve_regex ~= "" and util.rmatch(nve, delete_nve_regex) ~= nil) then \ |
| |
835 environment[nve] = nil \ |
| |
836 elseif prune_nve_regex ~= nil and util.rmatch(nve, prune_nve_regex) ~= nil then \ |
| |
837 environment[nve] = {} \ |
| |
838 else \ |
| |
839 prune_environment(environment[nve], depth + 1) \ |
| |
840 end \ |
| |
841 end \ |
| |
842 end \ |
| |
843 end \ |
| |
844 prune_environment(environment, 1) \ |
| |
845 if debug > 0 then \ |
| |
846 io.stdout:write("BuildEnvironment(pruned): " .. util.dump_object(environment, false) .. "\\n") \ |
| |
847 end \ |
| |
848 \ |
| |
849 -- export serialized environment as an RPM tag \ |
| |
850 if type(environment) == "table" then \ |
| |
851 local tag = "BuildEnvironment: " .. util.dump_object(environment, true) .. "\\n" \ |
| |
852 print(tag) \ |
| |
853 if debug > 0 then \ |
| |
854 io.stdout:write(tag) \ |
| |
855 end \ |
| |
856 end \ |
| |
857 }} |
| |
858 |
| |
859 # recursive package environment XML query support |
| |
860 %__environment_to_xml %{lua: \ |
| |
861 local lua = io.stdin:read("*all") \ |
| |
862 local f = loadstring("return " .. lua) \ |
| |
863 local xml = "" |
| |
864 if f ~= nil then \ |
| |
865 xml = xml .. "<?xml version=\\"1.0\\" encoding=\\"ISO-8859-1\\" standalone=\\"no\\"?>\\n" \ |
| |
866 xml = xml .. "<!DOCTYPE environment\\n" \ |
| |
867 xml = xml .. " PUBLIC \\"-//rpm5.org//DTD BuildEnvironment 1.0//EN\\"\\n" \ |
| |
868 xml = xml .. " \\"http://rpm5.org/dtd/environment-1.0.dtd\\">\\n" \ |
| |
869 function genxml (environment, prefix) \ |
| |
870 local xml = prefix .. "<environment>\\n" \ |
| |
871 for id, e in pairs(environment) do \ |
| |
872 xml = xml .. prefix .. " <package>\\n" \ |
| |
873 xml = xml .. prefix .. " <id>" .. id .. "</id>\\n" \ |
| |
874 if e ~= nil and next(e) ~= nil then \ |
| |
875 xml = xml .. genxml(e, prefix .. " ") \ |
| |
876 end \ |
| |
877 xml = xml .. prefix .. " </package>\\n" \ |
| |
878 end \ |
| |
879 xml = xml .. prefix .. "</environment>\\n" \ |
| |
880 return xml |
| |
881 end \ |
| |
882 local environment = f() \ |
| |
883 xml = xml .. genxml(environment, "") \ |
| |
884 end \ |
| |
885 print(xml) |
| |
886 } |
| |
887 |
| |
888 # PGP public key information |
| |
889 %l_pgpkey(n:F:) %{lua: \ |
| |
890 local name = rpm.expand("%{?-n:%{-n*}}%{!?-n:openpkg.org}") \ |
| |
891 local format = rpm.expand("%{?-F:%{-F*}}%{!?-F:%%f:%%i}") \ |
| |
892 local fn = "?" \ |
| |
893 local id = "?" \ |
| |
894 if name == "openpkg.com" then \ |
| |
895 fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.com.pgp") \ |
| |
896 id = "7D121A8FC05DC18A4329E9EF67042EC961B7AE34" \ |
| |
897 elseif name == "openpkg.net" then \ |
| |
898 fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.net.pgp") \ |
| |
899 id = "3BD10E1171B22598D7708C48AEBE764552197903" \ |
| |
900 elseif name == "openpkg.org" then \ |
| |
901 fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.org.pgp") \ |
| |
902 id = "6D96EFCFCF75328810DB40C2807593E063C4CB9F" \ |
| |
903 end \ |
| |
904 local result = util.rsubst(format, "%([nfi])", { ["n"] = name, ["f"] = fn, ["i"] = id }) \ |
| |
905 print(result) \ |
| |
906 } |
| |
907 |
| |
908 # integrity checking configuration |
| |
909 %_integrity_spec_cfg_idx %{l_prefix}/etc/openpkg/license |
| |
910 %_integrity_spec_cfg_dir %{l_prefix}/etc/openpkg/license.d |
| |
911 %_integrity_spec_cfg %{lua: \ |
| |
912 local idx = rpm.slurp(rpm.expand("%{_integrity_spec_cfg_idx}")) \ |
| |
913 idx = util.rsubst(idx, "(?s)\\\\s*(.+?)\\\\s*$", "%1") \ |
| |
914 local cfg = rpm.expand("%{_integrity_spec_cfg_dir}") .. "/" .. idx \ |
| |
915 print(cfg) \ |
| |
916 } |
| |
917 %_integrity_proc_lua %{l_prefix}/lib/openpkg/license.lua |
| |
918 %_integrity_pkey_pgp %{l_prefix}/etc/openpkg/openpkg.com.pgp |
| |
919 |
| |
920 ## |
| |
921 ## Support for OpenPKG Flexible Filesystem Layout |
| |
922 ## |
| |
923 |
| |
924 # layout definition: RPM to OpenPKG variable mapping |
| |
925 %_specdir %{expand:%%global _specdir %%{__openpkg_layout variable=specdir %{?openpkg_layout_specdir} %{!?openpkg_layout_specdir: %{openpkg_layout}}}}%{_specdir} |
| |
926 %_sourcedir %{expand:%%global _sourcedir %%{__openpkg_layout variable=sourcedir %{?openpkg_layout_sourcedir}%{!?openpkg_layout_sourcedir:%{openpkg_layout}}}}%{_sourcedir} |
| |
927 %_builddir %{expand:%%global _builddir %%{__openpkg_layout variable=builddir %{?openpkg_layout_builddir} %{!?openpkg_layout_builddir: %{openpkg_layout}}}}%{_builddir} |
| |
928 %_tmppath %{expand:%%global _tmppath %%{__openpkg_layout variable=tmppath %{?openpkg_layout_tmppath} %{!?openpkg_layout_tmppath: %{openpkg_layout}}}}%{_tmppath} |
| |
929 %_rpmdir %{expand:%%global _rpmdir %%{__openpkg_layout variable=rpmdir %{?openpkg_layout_rpmdir} %{!?openpkg_layout_rpmdir: %{openpkg_layout}}}}%{_rpmdir} |
| |
930 %_srcrpmdir %{expand:%%global _srcrpmdir %%{__openpkg_layout variable=srcrpmdir %{?openpkg_layout_srcrpmdir}%{!?openpkg_layout_srcrpmdir:%{openpkg_layout}}}}%{_srcrpmdir} |
| |
931 |
| |
932 # default OpenPKG filesystem layout |
| |
933 %openpkg_layout macrosfile=%{macrosfile} layout=global |
| |
934 |
| |
935 # layout determination: RPM macro to RPM Lua entry point |
| |
936 %__openpkg_layout() %{lua: print(openpkg.layout(rpm.expand("%*"))) } |
| |
937 |
| |
938 # calculated base directory (placeholder definition only) |
| |
939 %__openpkg_basedir %{l_prefix} |
| |
940 |
| |
941 # temporary path determination |
| |
942 %__openpkg_tmpdir %{lua: print(openpkg.tmpdir()) } |
| |
943 |
| |
944 # shared environment (SE) support |
| |
945 %__openpkg_SE_id %{l_hostname}-%{l_platform}-%{l_tag} |
| |
946 %__openpkg_SE_subdir %{?__openpkg_shared:/%{__openpkg_SE_id}} |
| |
947 |
| |
948 # layout definition: GLOBAL filesystem layout |
| |
949 %__openpkg_layout_global_specdir() %{l_prefix}/RPM/SRC/%{?name} |
| |
950 %__openpkg_layout_global_sourcedir() %{l_prefix}/RPM/SRC/%{?name} |
| |
951 %__openpkg_layout_global_builddir() %{l_prefix}/RPM/TMP |
| |
952 %__openpkg_layout_global_tmppath() %{l_prefix}/RPM/TMP |
| |
953 %__openpkg_layout_global_rpmdir() %{l_prefix}/RPM/PKG |
| |
954 %__openpkg_layout_global_srcrpmdir() %{l_prefix}/RPM/PKG |
| |
955 |
| |
956 # layout definition: LOCAL filesystem layout |
| |
957 %__openpkg_layout_local_specdir() %{__openpkg_basedir} |
| |
958 %__openpkg_layout_local_sourcedir() %{__openpkg_basedir} |
| |
959 %__openpkg_layout_local_builddir() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} |
| |
960 %__openpkg_layout_local_tmppath() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} |
| |
961 %__openpkg_layout_local_rpmdir() %{__openpkg_basedir} |
| |
962 %__openpkg_layout_local_srcrpmdir() %{__openpkg_basedir} |
| |
963 |
| |
964 # layout definition: SIMPLE local filesystem layout |
| |
965 %__openpkg_layout_simple_specdir() %{__openpkg_basedir} |
| |
966 %__openpkg_layout_simple_sourcedir() %{__openpkg_basedir} |
| |
967 %__openpkg_layout_simple_builddir() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
968 %__openpkg_layout_simple_tmppath() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
969 %__openpkg_layout_simple_rpmdir() %{realpath:%{__openpkg_basedir}/..} |
| |
970 %__openpkg_layout_simple_srcrpmdir() %{realpath:%{__openpkg_basedir}/..} |
| |
971 |
| |
972 # layout definition: STRUCTURED local filesystem layout |
| |
973 %__openpkg_layout_structured_specdir() %{__openpkg_basedir}/src |
| |
974 %__openpkg_layout_structured_sourcedir() %{__openpkg_basedir}/dst %{__openpkg_basedir}/src |
| |
975 %__openpkg_layout_structured_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
976 %__openpkg_layout_structured_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
977 %__openpkg_layout_structured_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} |
| |
978 %__openpkg_layout_structured_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} |
| |
979 |
| |
980 # layout definition: DISTRIBUTED local filesystem layout |
| |
981 %__openpkg_layout_distributed_specdir() %{__openpkg_basedir}/src/%{?name} |
| |
982 %__openpkg_layout_distributed_sourcedir() %{__openpkg_basedir}/dst/%{?name} %{__openpkg_basedir}/src/%{?name} |
| |
983 %__openpkg_layout_distributed_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
984 %__openpkg_layout_distributed_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} |
| |
985 %__openpkg_layout_distributed_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} |
| |
986 %__openpkg_layout_distributed_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} |
| |
987 |