1.1 --- a/openpkg/rpmmacros Tue Jul 31 12:12:54 2012 +0200 1.2 +++ b/openpkg/rpmmacros Tue Jul 31 12:23:42 2012 +0200 1.3 @@ -1,14 +1,13 @@ 1.4 ## 1.5 ## rpmmacros -- OpenPKG RPM Macros 1.6 -## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/> 1.7 -## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/> 1.8 +## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/> 1.9 ## 1.10 -## Permission to use, copy, modify, and distribute this software for 1.11 -## any purpose with or without fee is hereby granted, provided that 1.12 -## the above copyright notice and this permission notice appear in all 1.13 -## copies. 1.14 +## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. 1.15 +## All rights reserved. Licenses which grant limited permission to use, 1.16 +## copy, modify and distribute this software are available from the 1.17 +## OpenPKG GmbH. 1.18 ## 1.19 -## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.20 +## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 1.21 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.22 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.23 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.24 @@ -21,12 +20,20 @@ 1.25 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.26 ## SUCH DAMAGE. 1.27 ## 1.28 + 1.29 +## 1.30 ## The purpose of this macro set is to override the default 1.31 ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. 1.32 ## 1.33 1.34 +# utility macro for "delayed one-time expansion" of macro bodies 1.35 +# (works by redefining a macro in-place to its expanded body on its first usage) 1.36 +%l_once() %{expand:%%global %{*}}%{expand:%%{%{1}}} 1.37 + 1.38 # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) 1.39 -%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"}) 1.40 +%l_openpkg_release(F:) %(%{l_prefix}/libexec/openpkg/release \\\ 1.41 + --release="%{?release}%{!?release:%(%{l_rpm} -q --qf '%{release}' openpkg)}" \\\ 1.42 + %{?-F:-F "%{-F*}"}%{!?-F:-F "OpenPKG-%%t"}) 1.43 1.44 # the OpenPKG OIDs (root is officially registered at IANA) 1.45 %l_openpkg_oid 1.3.6.1.4.1.18749 1.46 @@ -37,15 +44,31 @@ 1.47 1.48 # the OpenPKG package tagging 1.49 %l_tag_fmt @TAG@ 1.50 -%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) 1.51 -%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;') 1.52 -%l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; %{l_uuid} -v3 $uuid_ns '%{?_options}') 1.53 +%l_tag_fmt_compat %(prefix="%{l_prefix_static}"; \ 1.54 + if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then \ 1.55 + loc=`echo $prefix | cut -c2-4`; \ 1.56 + else \ 1.57 + loc=`echo $prefix | sed -e 's;/\\(.\\)[^/]*;\\1;g' | cut -c1-3`; \ 1.58 + fi; \ 1.59 + echo $loc) 1.60 +%l_tag_fmt_loc %(echo "%{l_prefix_static}" | \\\ 1.61 + sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' \\\ 1.62 + -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' \\\ 1.63 + -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ 1.64 + -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ 1.65 + -e 's;^/\\([^/][^/][^/]\\).*;\\1;' \\\ 1.66 + -e 's;^/\\([^/][^/]\\).*;\\1;' \\\ 1.67 + -e 's;^/\\([^/]\\).*;\\1;' \\\ 1.68 + ) 1.69 +%l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; \ 1.70 + %{l_uuid} -v3 $uuid_ns '%{?_options}') 1.71 %l_tag_fmt_uuid %(%{l_uuid} -v1) 1.72 %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') 1.73 %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') 1.74 %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') 1.75 -%l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} 1.76 -%l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g') 1.77 +%l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | \\\ 1.78 + sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} 1.79 +%l_tag %{l_once l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g')} 1.80 1.81 # the OpenPKG instance location (backward compatibility only) 1.82 %l_location %{l_tag} 1.83 @@ -92,35 +115,65 @@ 1.84 %l_host_os %{_host_os} 1.85 %l_host %{_host_cpu}-%{_host_os} 1.86 1.87 +# host name or FQDN identification 1.88 +%l_hostname(f) %(%{l_shtool} echo -n -e '%%h%{?-f:%%d}') 1.89 + 1.90 # new OpenPKG platform identification 1.91 -%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") 1.92 +%l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then \ 1.93 + fmt="%{-F*}"; \ 1.94 + else \ 1.95 + T="%{?-c:c}%{?-p:p}%{?-t:t}"; \ 1.96 + [ ".$T" = . ] && T="p"; \ 1.97 + fmt="%%<a$T>-%%<s$T>"; \ 1.98 + fi; \ 1.99 + %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") 1.100 1.101 # old OpenPKG platform identification 1.102 %l_target %{l_platform -t} 1.103 1.104 +# UID/GID lookup 1.105 +%l_xuid_lookup() %(( getent passwd '%1'; \ 1.106 + grep '^%1:' /etc/passwd; \ 1.107 + ypmatch '%1' passwd; \ 1.108 + nismatch '%1' passwd; \ 1.109 + nidump passwd . | grep '^%1:' \ 1.110 + ) 2>/dev/null | \ 1.111 + sed -e 'q' | \\\ 1.112 + awk -F: '{ print $3; }' \ 1.113 + ) 1.114 +%l_xgid_lookup() %(( getent group '%2'; \ 1.115 + grep '^%2:' /etc/group; \ 1.116 + ypmatch '%2' group; \ 1.117 + nismatch '%2' group; \ 1.118 + nidump group . | grep '^%1:' \ 1.119 + ) 2>/dev/null | \ 1.120 + sed -e 'q' | \\\ 1.121 + awk -F: '{ print $3; }' \ 1.122 + ) 1.123 + 1.124 # the *S*uper-user user/group name/id pair 1.125 %l_susr @SUSR@ 1.126 %l_sgrp @SGRP@ 1.127 -%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; }') 1.128 -%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; }') 1.129 +%l_suid %{expand:%%{l_xuid_lookup %{l_susr} %{l_sgrp}}} 1.130 +%l_sgid %{expand:%%{l_xgid_lookup %{l_susr} %{l_sgrp}}} 1.131 1.132 # the *M*anagement user/group name/id pair 1.133 %l_musr @MUSR@ 1.134 %l_mgrp @MGRP@ 1.135 -%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; }') 1.136 -%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; }') 1.137 +%l_muid %{expand:%%{l_xuid_lookup %{l_musr} %{l_mgrp}}} 1.138 +%l_mgid %{expand:%%{l_xgid_lookup %{l_musr} %{l_mgrp}}} 1.139 1.140 # the *R*restricted user/group name/id pair 1.141 %l_rusr @RUSR@ 1.142 %l_rgrp @RGRP@ 1.143 -%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; }') 1.144 -%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; }') 1.145 +%l_ruid %{expand:%%{l_xuid_lookup %{l_rusr} %{l_rgrp}}} 1.146 +%l_rgid %{expand:%%{l_xgid_lookup %{l_rusr} %{l_rgrp}}} 1.147 1.148 # the *N*on-privileged user/group name/id pair 1.149 %l_nusr @NUSR@ 1.150 %l_ngrp @NGRP@ 1.151 -%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; }') 1.152 -%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; }') 1.153 +%l_nuid %{expand:%%{l_xuid_lookup %{l_nusr} %{l_ngrp}}} 1.154 +%l_ngid %{expand:%%{l_xgid_lookup %{l_nusr} %{l_ngrp}}} 1.155 1.156 # backward compatibility (openpkg < 20020204) 1.157 %l_fsusr %{l_musr} 1.158 @@ -128,6 +181,10 @@ 1.159 %l_npuid %{l_nuid} 1.160 %l_npgid %{l_ngid} 1.161 1.162 +# whether we are intended to operate in an environment where 1.163 +# only a single unprivileged user account can be used 1.164 +%l_unprivileged @l_unprivileged@ 1.165 + 1.166 # define the installation hierarchy (used parts) 1.167 %l_prefix @l_prefix@ 1.168 %l_prefix_static @l_prefix_static@ 1.169 @@ -159,11 +216,49 @@ 1.170 # ";" for "-s" and ";" for "-b" and "-c". You can either specify one 1.171 # or more names of variables to expand or use "-a" for mostly all 1.172 # variables and "-A" for really all variables. 1.173 -%l_value(sbcaA) %{expand:%(l=""; for x in `if [ ".%*" != . ]; then echo "%* "; else p=""; if [ ".%{-a:yes}" = .yes ]; then p="^%%l_(prefix|[smrn](usr|grp|uid|gid))"; elif [ ".%{-A:yes}" = .yes ]; then p="^%%l_"; fi; if [ ".$p" != . ]; then egrep "$p" %{l_prefix}/etc/openpkg/rpmmacros | sed -e '/^%%l_value/,$d' -e 's;^%%\\(l_[a-z1-9_]*\\).*;\\1;'; fi; fi`; do e=""; if [ ".%{-s:yes}" = .yes ]; then e="-e 's;@$x@;%%{$x};g'"; elif [ ".%{-b:yes}" = .yes ]; then e="$x='%%{$x}';"; elif [ ".%{-c:yes}" = .yes ]; then e="set $x = '%%{$x}';"; else e="%%{$x}"; fi; if [ ".$l" = . ]; then l="$e"; else l="$l $e"; fi; done; echo "$l")} 1.174 +%l_value(sbcaA) %{expand:%(\ 1.175 + l=""; \ 1.176 + for x in \\\ 1.177 + `if [ ".%*" != . ]; then \ 1.178 + echo "%* "; \ 1.179 + else \ 1.180 + p=""; \ 1.181 + if [ ".%{-a:yes}" = .yes ]; then \ 1.182 + p="^%%l_(prefix|[smrn](usr|grp|uid|gid))"; \ 1.183 + elif [ ".%{-A:yes}" = .yes ]; then \ 1.184 + p="^%%l_"; \ 1.185 + fi; \ 1.186 + if [ ".$p" != . ]; then \ 1.187 + egrep "$p" %{l_prefix}/etc/openpkg/rpmmacros |\\\ 1.188 + sed -e '/^%%l_value/,$d' \\\ 1.189 + -e 's;^%%\\(l_[a-z1-9_]*\\).*;\\1;'; \ 1.190 + fi; \ 1.191 + fi`; do \ 1.192 + e=""; \ 1.193 + if [ ".%{-s:yes}" = .yes ]; then \ 1.194 + e="-e 's;@$x@;%%{$x};g'"; \ 1.195 + elif [ ".%{-b:yes}" = .yes ]; then \ 1.196 + e="$x='%%{$x}';"; \ 1.197 + elif [ ".%{-c:yes}" = .yes ]; then \ 1.198 + e="set $x = '%%{$x}';"; \ 1.199 + else \ 1.200 + e="%%{$x}"; \ 1.201 + fi; \ 1.202 + if [ ".$l" = . ]; then \ 1.203 + l="$e"; \ 1.204 + else \ 1.205 + l="$l $e"; \ 1.206 + fi; \ 1.207 + done; \ 1.208 + echo "$l" \ 1.209 + )} 1.210 1.211 # local version of the empty macro 1.212 %l_nil %{nil} 1.213 1.214 +# local version of the tab character 1.215 +%l_tab %{lua: print "\t" } 1.216 + 1.217 # override the internal RPM hierarchy variables 1.218 %_usr %{nil} 1.219 %_var %{nil} 1.220 @@ -176,15 +271,23 @@ 1.221 %_specdir %{l_prefix}/RPM/SRC/%{name} 1.222 %_rpmdir %{l_prefix}/RPM/PKG 1.223 %_srcrpmdir %{l_prefix}/RPM/PKG 1.224 -%_repackage_dir %{l_prefix}/RPM/PKG 1.225 -%_cache_dbpath %{l_prefix}/RPM/PKG 1.226 -%_solve_dbpath %{l_prefix}/RPM/PKG 1.227 -%_solve_pkgsdir %{l_prefix}/RPM/PKG 1.228 +%_repackage_dir %{l_prefix}/RPM/TR 1.229 +%_cache_dbpath %{l_prefix}/RPM/CACHE 1.230 +%_solve_dbpath %{l_prefix}/RPM/CACHE 1.231 +%_solve_pkgsdir %{l_prefix}/RPM/CACHE 1.232 %_defaultdocdir %{l_docdir} 1.233 1.234 # complement the %{SOURCE<n>} and %{PATCH<n>} with %{SOURCE <file>} and %{PATCH <file>} 1.235 -%SOURCE() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) 1.236 -%PATCH() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) 1.237 +%_SOURCE_PATCH() %{lua: \ 1.238 + local source1 = rpm.expand("%{_specdir}/%1") \ 1.239 + local source2 = rpm.expand("%{_sourcedir}/%1") \ 1.240 + if posix.stat(source1) ~= nil then \ 1.241 + print(source1) \ 1.242 + else \ 1.243 + print(source2) \ 1.244 + end } 1.245 +%SOURCE() %{expand:%%{_SOURCE_PATCH %1}} 1.246 +%PATCH() %{expand:%%{_SOURCE_PATCH %1}} 1.247 1.248 # override RPM's absolute tool paths with relative ones 1.249 # (because if you upgrade RPM it would hard-code tools in own hierarchy, too) 1.250 @@ -195,7 +298,6 @@ 1.251 %__chmod chmod 1.252 %__chown chown 1.253 %__cp cp 1.254 -%__cpio cpio 1.255 %__grep grep 1.256 %__gzip %{_gzipbin} 1.257 %__id id 1.258 @@ -213,33 +315,37 @@ 1.259 %__sed sed 1.260 %__ssh ssh 1.261 %__tar %{_tarbin} 1.262 -%__unzip %{_unzipbin} 1.263 +%__xz %{_xzbin} 1.264 1.265 # override some more RPM macros where the default value is not acceptable 1.266 +%_dbapi %{l_once _dbapi %(if [ -f "%{_dbpath}/VERSION" ]; then \ 1.267 + . "%{_dbpath}/VERSION"; \ 1.268 + fi; \ 1.269 + echo "${DBAPI:-3}")} 1.270 +%__dbi_other %{?_tmppath:tmpdir=%{_tmppath}} %{?__dbi_cdb} %{?__dbi_private:private} 1.271 +%__file_context_path %{nil} 1.272 +%__check_files %{nil} 1.273 +%_patch_suffix -b --suffix .orig 1.274 +%_excludedocs 1 1.275 %_dependency_whiteout %{nil} 1.276 %__debug_install_post %{nil} 1.277 %_unpackaged_files_terminate_build 0 1.278 1.279 -# override automatic dependency generation 1.280 -%_use_internal_dependency_generator 0 1.281 -%__find_provides %{nil} 1.282 -%__find_requires %{nil} 1.283 -%__find_prereq %{nil} 1.284 -%__perl_provides %{nil} 1.285 -%__perl_requires %{nil} 1.286 - 1.287 # provide fixed paths to tools (standard) 1.288 %_gzipbin %{l_prefix}/lib/openpkg/gzip 1.289 %_bzip2bin %{l_prefix}/lib/openpkg/bzip2 1.290 +%_xzbin %{l_prefix}/lib/openpkg/xz 1.291 %_patchbin %{l_prefix}/lib/openpkg/patch 1.292 %_tarbin %{l_prefix}/lib/openpkg/tar 1.293 -%_unzipbin %{l_prefix}/lib/openpkg/unzip 1.294 +%__bsdtar %{l_prefix}/lib/openpkg/bsdtar 1.295 +%__cpio %{l_prefix}/lib/openpkg/bsdcpio 1.296 +%__unzip %{__bsdtar} 1.297 1.298 # provide path to platform identification file 1.299 %__platform %{l_prefix}/etc/openpkg/platform 1.300 1.301 # provide fixed paths to tools (additional) 1.302 -%l_rc %{l_prefix}/etc/rc 1.303 +%l_rc %{l_prefix}/bin/openpkg --keep-privileges rc 1.304 %l_rpm %{l_prefix}/libexec/openpkg/rpm 1.305 %l_rpm2cpio %{l_prefix}/libexec/openpkg/rpm2cpio 1.306 %l_rpm_config %{l_prefix}/libexec/openpkg/rpm-config 1.307 @@ -251,31 +357,41 @@ 1.308 %l_uuid %{l_prefix}/lib/openpkg/uuid 1.309 1.310 # provide smart paths to tools 1.311 -%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) 1.312 -%l_gzip %{l_tool_locate gzip gzip} 1.313 -%l_bzip2 %{l_tool_locate bzip2 bzip2} 1.314 -%l_tar %{l_tool_locate tar tar} 1.315 -%l_make %{l_tool_locate make make} 1.316 -%l_cc %{l_tool_locate cc cc} 1.317 -%l_ar %{l_tool_locate ar ar} 1.318 -%l_ld %{l_tool_locate ld ld} 1.319 -%l_as %{l_tool_locate as as} 1.320 -%l_strip %{l_tool_locate strip strip} 1.321 -%l_cxx %{l_tool_locate cxx c++} 1.322 -%l_patch %{l_tool_locate patch patch} 1.323 -%l_sed %{l_tool_locate sed sed} 1.324 -%l_grep %{l_tool_locate grep grep} 1.325 -%l_awk %{l_tool_locate awk awk} 1.326 -%l_autoconf %{l_tool_locate autoconf autoconf} 1.327 -%l_automake %{l_tool_locate automake automake} 1.328 -%l_libtool %{l_tool_locate libtool libtool} 1.329 -%l_flex %{l_tool_locate flex flex} 1.330 -%l_bison %{l_tool_locate bison bison} 1.331 -%l_perl %{l_tool_locate perl perl} 1.332 -%l_miniperl %{l_tool_locate miniperl miniperl} 1.333 -%l_openssl %{l_tool_locate openssl openssl} 1.334 -%l_xmkmf %{l_tool_locate xmkmf xmkmf} 1.335 -%l_vcheck %{l_tool_locate vcheck vcheck} 1.336 +%l_tool_locate() %{lua: \ 1.337 + if rpm.expand("%{expand:%%{?use_%1}}") ~= "" then \ 1.338 + print(rpm.expand("%{expand:%%{use_%1}}")) \ 1.339 + elseif posix.stat(rpm.expand("%{l_prefix}/bin/%2")) ~= nil then \ 1.340 + print(rpm.expand("%{l_prefix}/bin/%2")) \ 1.341 + elseif posix.stat(rpm.expand("%{l_prefix}/lib/openpkg/%2")) ~= nil then \ 1.342 + print(rpm.expand("%{l_prefix}/lib/openpkg/%2")) \ 1.343 + else \ 1.344 + print(rpm.expand("%2")) \ 1.345 + end } 1.346 +%l_gzip %{l_once l_gzip %{l_tool_locate gzip gzip}} 1.347 +%l_bzip2 %{l_once l_bzip2 %{l_tool_locate bzip2 bzip2}} 1.348 +%l_xz %{l_once l_xz %{l_tool_locate xz xz}} 1.349 +%l_tar %{l_once l_tar %{l_tool_locate tar tar}} 1.350 +%l_make %{l_once l_make %{l_tool_locate make make}} 1.351 +%l_cc %{l_once l_cc %{l_tool_locate cc cc}} 1.352 +%l_ar %{l_once l_ar %{l_tool_locate ar ar}} 1.353 +%l_ld %{l_once l_ld %{l_tool_locate ld ld}} 1.354 +%l_as %{l_once l_as %{l_tool_locate as as}} 1.355 +%l_strip %{l_once l_strip %{l_tool_locate strip strip}} 1.356 +%l_cxx %{l_once l_cxx %{l_tool_locate cxx c++}} 1.357 +%l_patch %{l_once l_patch %{l_tool_locate patch patch}} 1.358 +%l_sed %{l_once l_sed %{l_tool_locate sed sed}} 1.359 +%l_grep %{l_once l_grep %{l_tool_locate grep grep}} 1.360 +%l_awk %{l_once l_awk %{l_tool_locate awk awk}} 1.361 +%l_autoconf %{l_once l_autoconf %{l_tool_locate autoconf autoconf}} 1.362 +%l_automake %{l_once l_automake %{l_tool_locate automake automake}} 1.363 +%l_libtool %{l_once l_libtool %{l_tool_locate libtool libtool}} 1.364 +%l_flex %{l_once l_flex %{l_tool_locate flex flex}} 1.365 +%l_bison %{l_once l_bison %{l_tool_locate bison bison}} 1.366 +%l_perl %{l_once l_perl %{l_tool_locate perl perl}} 1.367 +%l_miniperl %{l_once l_miniperl %{l_tool_locate miniperl miniperl}} 1.368 +%l_openssl %{l_once l_openssl %{l_tool_locate openssl openssl}} 1.369 +%l_xmkmf %{l_once l_xmkmf %{l_tool_locate xmkmf xmkmf}} 1.370 +%l_vcheck %{l_once l_vcheck %{l_tool_locate vcheck vcheck}} 1.371 1.372 # tool options 1.373 %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") 1.374 @@ -285,11 +401,24 @@ 1.375 %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) 1.376 1.377 # OSSP fake syslog library 1.378 -%l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; else flags=''; fi; echo $flags) 1.379 -%l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --libs ) 2>/dev/null`; else flags=''; fi; echo $flags) 1.380 +%l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then \ 1.381 + flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; \ 1.382 + else \ 1.383 + flags=''; \ 1.384 + fi; \ 1.385 + echo $flags) 1.386 +%l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then \ 1.387 + flags=`(%{l_prefix}/bin/fsl-config --all --libs) 2>/dev/null`; \ 1.388 + else \ 1.389 + flags=''; \ 1.390 + fi; \ 1.391 + echo $flags) 1.392 1.393 # determine the current username 1.394 -%l_whoami %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME) 1.395 +%l_whoami %{l_once l_whoami %((id -un) 2>/dev/null || \\\ 1.396 + (whoami) 2>/dev/null || \\\ 1.397 + (who am i | cut "-d " -f1) 2>/dev/null || \\\ 1.398 + echo $LOGNAME)} 1.399 1.400 # macros for dynamically generating a %files list 1.401 %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' 1.402 @@ -297,8 +426,11 @@ 1.403 %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' 1.404 %l_files_std() %l_files_defattr %l_files_all %l_files_noshared 1.405 1.406 +# default %defattr when rolling SRPMS 1.407 +%_srcdefattr (-,openpkg,openpkg) 1.408 + 1.409 # path to local build root 1.410 -%l_buildroot %{_tmppath}/%{name}-%{version}-root 1.411 +%l_buildroot %{_tmppath}/%{name}-%{version}-%{release}-buildroot 1.412 %buildroot %{l_buildroot} 1.413 1.414 # path to local temporary location 1.415 @@ -316,7 +448,12 @@ 1.416 %_rpmfilename %{l_binrpmfilename} 1.417 %_build_name_fmt %{l_binrpmfilename} 1.418 %_repackage_name_fmt %{l_binrpmfilename} 1.419 -%_solve_name_fmt %{_solve_pkgsdir}/%{l_binrpmfilename} 1.420 +%_solve_name_fmt %{?_solve_pkgsdir}/%{l_binrpmfilename} 1.421 +%_query_all_fmt %%{NAME}-%%{VERSION}-%%{RELEASE} 1.422 +%___NVRA %%{NAME}-%%{VERSION}-%%{RELEASE} 1.423 + 1.424 +# do not repackage automatically 1.425 +%_repackage_all_erasures 0 1.426 1.427 # override the payload compression for the CPIO parts of an RPM 1.428 # (we use the equivalent of "bzip2 -9") 1.429 @@ -324,98 +461,177 @@ 1.430 %_binary_payload w9.bzdio 1.431 1.432 # package signature type is OpenPGP via GnuPG 1.433 -%__gpg %{l_prefix}/bin/gpg 1.434 +%__gpg %{l_tool_locate gpg gpg} 1.435 %_signature gpg 1.436 -%__vsflags 1 1.437 1.438 # two macro-processor add-ons (should be part of forthcoming RPM releases) 1.439 %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} 1.440 %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} 1.441 1.442 # macro for package option configuration 1.443 -%option() %{expand:%%{!?%{1}:%%global %*}} %{expand:%%global _options %{?_options:%{_options}:}%{1}=%%%{1}} \ 1.444 -Provides: %{name}::%{1} = %(echo '%{expand:%%{%{1}}}' | sed -e 's;%%;%%%%;g' -e 's; ;%%20;g' -e 's; ;%%09;g') 1.445 +%option() %{lua: \ 1.446 + local package_name = rpm.expand("%{name}") \ 1.447 + local option_name = rpm.expand("%1") \ 1.448 + if rpm.expand("%{?" .. option_name .. ":defined}") ~= "defined" then \ 1.449 + rpm.expand("%global " .. rpm.expand("%*")) \ 1.450 + end \ 1.451 + local option_value = rpm.expand("%{" .. option_name .. "}") \ 1.452 + option_value = util.rsubst(option_value, "(?s)%", "%%%%") \ 1.453 + option_value = util.rsubst(option_value, "(?s) ", "%%20") \ 1.454 + option_value = util.rsubst(option_value, "(?s)\\t", "%%09") \ 1.455 + rpm.expand("%global _options %{?_options:%{_options}:}" .. option_name .. "=" .. option_value) \ 1.456 + print(string.format("Provides: %s::%s = %s\\n", package_name, option_name, option_value)) \ 1.457 + } 1.458 1.459 # macros for NoSource/NoPatch (distribution restriction) integrity handling 1.460 -%NoSource() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoSource: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} 1.461 -%NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoPatch: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} 1.462 +%NoSource() %(if [ ".%{?restriction}" != ".no" ]; then \ 1.463 + echo "NoSource: %1"; \ 1.464 + fi) \ 1.465 + %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} 1.466 +%NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then \ 1.467 + echo "NoPatch: %1"; fi) \ 1.468 + %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} 1.469 %integrity() %{l_check_nosource} 1.470 1.471 # macros for checking build environment 1.472 -%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) 1.473 -%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") 1.474 +%l_check_nosource() %(%{l_sane_env}; checkok=1; \ 1.475 + checkinfo=`echo "Sorry, this OpenPKG package contains a DISTRIBUTION RESTRICTED source file."; \\\ 1.476 + echo "Before you can proceed building this package, fetch missing files MANUALLY:"`; \ 1.477 + for url in . %{?_restricted}; do \ 1.478 + [ ".$url" = .. ] && continue; \ 1.479 + eval `echo "$url" | \\\ 1.480 + sed -e 's!^\\(.*\\)::/\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ 1.481 + -e 's!^\\([^:;][^:]*://.*/\\)\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ 1.482 + -e 's:^\\([^;].*\\)$:;url="(unknown location) "; file="\\1":' \\\ 1.483 + -e 's:^;::'`; \ 1.484 + if [ ! -f "%{_specdir}/$file" ] && [ ! -f "%{_sourcedir}/$file" ]; then \\\ 1.485 + checkok=0; \ 1.486 + checkinfo=`echo "${checkinfo}"; \\\ 1.487 + echo ""; \\\ 1.488 + echo "from ${url}"; \\\ 1.489 + echo "file ${file}"; \\\ 1.490 + echo "here %{_sourcedir}/$file"`; \ 1.491 + fi; \ 1.492 + done; \ 1.493 + if [ $checkok -ne 1 ]; then \ 1.494 + echo "set +x"; \ 1.495 + echo "$checkinfo" | \\\ 1.496 + %{l_rpmtool} msg -b -t error | \\\ 1.497 + sed -e 's;^;echo ";' -e 's;$;";'; \ 1.498 + echo "exit 1"; \ 1.499 + fi) 1.500 +%l_check_class() %(%{l_sane_env}; \ 1.501 + class=`echo "@:%{?class}:%{?distribution}" | \\\ 1.502 + sed -e 's;^@:\\([^:][^:]*\\):.*$;\\1;' \\\ 1.503 + -e 's;^@:.*\\[\\(.*\\)\\].*$;\\1;' \\\ 1.504 + -e 's;^@:.*$;JUNK;'`; \ 1.505 + %{l_rpmtool} check-class "$class") 1.506 %prep %%prep\ 1.507 %{l_check_nosource} \ 1.508 %{l_check_class} \ 1.509 %{nil} 1.510 1.511 # macro-processor add-on for testing external conditions 1.512 -%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) 1.513 - 1.514 -# default list of vendor source fetching locations 1.515 -%l_fetch_mirror_0 - 1.516 -%l_fetch_mirror_1 - 1.517 -%l_fetch_mirror_2 - 1.518 -%l_fetch_mirror_3 - 1.519 -%l_fetch_mirror_4 - 1.520 -%l_fetch_mirror_5 - 1.521 -%l_fetch_mirror_6 - 1.522 -%l_fetch_mirror_7 - 1.523 -%l_fetch_mirror_8 - 1.524 -%l_fetch_mirror_9 - 1.525 -%l_fetch_backup_0 - 1.526 -%l_fetch_backup_1 - 1.527 -%l_fetch_backup_2 - 1.528 -%l_fetch_backup_3 - 1.529 -%l_fetch_backup_4 - 1.530 -%l_fetch_backup_5 - 1.531 -%l_fetch_backup_6 - 1.532 -%l_fetch_backup_7 - 1.533 -%l_fetch_backup_8 - 1.534 -%l_fetch_backup_9 ftp://ftp.openpkg.org/sources/DST/%{name}/ 1.535 +%l_test(pfd) %(if [ ".%{?-p:yes}" = .yes ]; then \ 1.536 + %{l_rpm} -q %1 >/dev/null 2>&1; rc=$?; \ 1.537 + elif [ ".%{?-f:yes}" = .yes ]; then \ 1.538 + test -f %1; rc=$?; \ 1.539 + elif [ ".%{?-d:yes}" = .yes ]; then \ 1.540 + test -d %1; rc=$?; \ 1.541 + fi; \ 1.542 + if [ ".$rc" = .0 ]; then \ 1.543 + echo "yes"; \ 1.544 + else \ 1.545 + echo "no"; \ 1.546 + fi) 1.547 1.548 # sane build environment setup 1.549 -%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) 1.550 +%l_build_path %{l_once l_build_path %(if [ -d %{l_prefix}/lib/openpkg/override ]; then \ 1.551 + echo "%{l_prefix}/lib/openpkg/override:"; \ 1.552 + fi)%{l_prefix}/bin:%{l_prefix}/sbin:@l_build_path@%(\ 1.553 + if [ -d %{l_prefix}/lib/openpkg/fallback ]; then \ 1.554 + echo ":%{l_prefix}/lib/openpkg/fallback"; \ 1.555 + fi)} 1.556 %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ 1.557 %l_build_ulim @l_build_ulim@ 1.558 %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash 1.559 %l_build_shell_opt --norc --noprofile --posix 1.560 1.561 # sane build environment for manual usage in macros (currently just $PATH) 1.562 -%l_sane_env PATH="%{l_build_path}"; export PATH; LD_LIBRARY_PATH="%{l_build_ldlp}"; export LD_LIBRARY_PATH 1.563 +%l_sane_env PATH="%{l_build_path}"; \ 1.564 + export PATH; \ 1.565 + LD_LIBRARY_PATH="%{l_build_ldlp}"; \ 1.566 + export LD_LIBRARY_PATH 1.567 1.568 # sane build environment for %prep/%build/%install 1.569 %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} 1.570 -%___build_pre \ 1.571 -HOME="%{l_prefix}"\ 1.572 -SHELL="%{l_build_shell_cmd}"\ 1.573 -TERM="%(echo $TERM)"\ 1.574 -TMPDIR="%{_tmppath}"\ 1.575 -USER="%(echo $USER)"\ 1.576 -LOGNAME="%(echo $LOGNAME)"\ 1.577 -PATH="%{l_build_path}"\ 1.578 -LD_LIBRARY_PATH="%{l_build_ldlp}"\ 1.579 -export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ 1.580 -RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ 1.581 -RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ 1.582 -RPM_OPT_FLAGS=\"%{optflags}\"\ 1.583 -RPM_ARCH=\"%{l_host_arch}\"\ 1.584 -RPM_OS=\"%{l_host_os}\"\ 1.585 -RPM_DOC_DIR=\"%{_docdir}\"\ 1.586 -RPM_PACKAGE_NAME=\"%{name}\"\ 1.587 -RPM_PACKAGE_VERSION=\"%{version}\"\ 1.588 -RPM_PACKAGE_RELEASE=\"%{release}\"\ 1.589 -export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ 1.590 -export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ 1.591 -%{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ 1.592 -export RPM_BUILD_ROOT}\ 1.593 -%{l_build_ulim}\ 1.594 -umask 022\ 1.595 -%{verbose:set -x}%{!verbose:exec >/dev/null}\ 1.596 -cd %{u2p:%{_builddir}} 1.597 +%___build_pre HOME="%{l_prefix}"\ 1.598 + SHELL="%{l_build_shell_cmd}"\ 1.599 + TERM="%{getenv:TERM}"\ 1.600 + TMPDIR="%{_tmppath}"\ 1.601 + USER="%{getenv:USER}"\ 1.602 + LOGNAME="%{getenv:LOGNAME}"\ 1.603 + PATH="%{l_build_path}"\ 1.604 + LD_LIBRARY_PATH="%{l_build_ldlp}"\ 1.605 + export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ 1.606 + RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ 1.607 + RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ 1.608 + RPM_OPT_FLAGS=\"%{optflags}\"\ 1.609 + RPM_ARCH=\"%{l_host_arch}\"\ 1.610 + RPM_OS=\"%{l_host_os}\"\ 1.611 + RPM_DOC_DIR=\"%{_docdir}\"\ 1.612 + RPM_PACKAGE_NAME=\"%{name}\"\ 1.613 + RPM_PACKAGE_VERSION=\"%{version}\"\ 1.614 + RPM_PACKAGE_RELEASE=\"%{release}\"\ 1.615 + export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ 1.616 + export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ 1.617 + %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ 1.618 + export RPM_BUILD_ROOT}\ 1.619 + %{l_build_ulim}\ 1.620 + umask 022\ 1.621 + %{verbose:set -x}%{!verbose:exec >/dev/null}\ 1.622 + cd %{u2p:%{_builddir}} 1.623 + 1.624 +# improved %patch macro 1.625 +%patch(b:p:P:REz:F:d:e:m:) %{lua: \ 1.626 + local subst = "" \ 1.627 + local options = rpm.expand("%**") \ 1.628 + local regex = "-e\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ 1.629 + local pcre = rex_pcre.new(regex) \ 1.630 + local n = 0 \ 1.631 + while true do \ 1.632 + local s, e, t = pcre:tfind(options, n) \ 1.633 + if s == nil then break end \ 1.634 + subst = subst .. " -e " .. t[1] \ 1.635 + n = e + 1 \ 1.636 + end \ 1.637 + local regex = "-m\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ 1.638 + local pcre = rex_pcre.new(regex) \ 1.639 + local n = 0 \ 1.640 + while true do \ 1.641 + local s, e, t = pcre:tfind(options, n) \ 1.642 + if s == nil then break end \ 1.643 + subst = subst .. " -e 's;@" .. t[1] .. "@;%{" .. t[1] .. "};g'" \ 1.644 + n = e + 1 \ 1.645 + end \ 1.646 + if subst ~= "" then \ 1.647 + subst = "| sed" .. subst \ 1.648 + rpm.define("__patch_subst " .. subst) \ 1.649 + else \ 1.650 + rpm.define("__patch_subst %{nil}") \ 1.651 + end \ 1.652 +}%{shrink: \ 1.653 +%define __patch_number %{-P:%{-P*}}%{!-P:0} \ 1.654 +%define __patch_file %{P:%{__patch_number}} \ 1.655 +%define __patch_suffix %{-b:-b --suffix %{-b*}}%{!-b:-b --suffix .orig} %{-z:--suffix %{-z*}} \ 1.656 +%define __patch_options -s %{-p:-p%{-p*}} %{-F:-F%{-F*}} %{-d:-d%{-d*}} %{-R} %{-E} %{__patch_suffix} \ 1.657 +echo "Patch #%{__patch_number} (%{basename:%{__patch_file}}):"; \ 1.658 +%{uncompress:%{__patch_file}} %{__patch_subst} | %{__patch} %{__patch_options}}\ 1.659 +%{nil} 1.660 1.661 # special %track section support 1.662 -%__spec_track_template VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.vc"\ 1.663 +%__spec_track_pre\ 1.664 +VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.track.vc"\ 1.665 rm -f $VCFILE\ 1.666 set -o noclobber\ 1.667 sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ 1.668 @@ -434,12 +650,81 @@ 1.669 ( echo "config = {"\ 1.670 echo "}"\ 1.671 ) >>$VCFILE\ 1.672 - %{l_vcheck} -v -f $VCFILE || true\ 1.673 + %{l_vcheck} %{verbose:--verbose}%{!verbose:--noverbose} -f $VCFILE || true\ 1.674 fi\ 1.675 rm -f $VCFILE\ 1.676 %{nil} 1.677 1.678 -# automatically include never changing RPM header text 1.679 +# support additional .spec tags 1.680 +%_arbitrary_tags Class:Track:TrackProg:BuildDependency:BuildEnvironment:My*:Local* 1.681 + 1.682 +# disable /bin/sh dependency (which doesn't fit into OpenPKG's environment) 1.683 +%_disable_shell_interpreter_deps 1 1.684 + 1.685 +# support downloading files via cURL (instead of internal RPMIO) 1.686 +# and optionally also from global and local mirror and backup location(s) 1.687 +%__urlgetfile_urls_mirror() \ 1.688 + %{nil} 1.689 +%__urlgetfile_urls_backup() %{lua: \ 1.690 + local url = rpm.expand("%1") \ 1.691 + local name = rpm.expand("%{name}") \ 1.692 + if name ~= "" and url ~= "" then \ 1.693 + local cache = "http://download.openpkg.org/components/cache/" .. name .. "/" \ 1.694 + url = util.rsubst(url, "^.+/([^/]+)$", cache .. "%1") \ 1.695 + print(url) \ 1.696 + end \ 1.697 +} 1.698 +%__urlgetfile_urls() \ 1.699 + %{?__urlgetfile_urls_mirror %1} %1 %{?__urlgetfile_urls_backup %1} 1.700 +%__urlgetfile() %{lua: \ 1.701 + local url_orig = rpm.expand("%1") \ 1.702 + local file = rpm.expand("%2") \ 1.703 + local urls = util.rsplit(rpm.expand("%{?__urlgetfile_urls " .. url_orig .. "}"), "\\\\s+") \ 1.704 + local result = "ERROR" \ 1.705 + local type = "mirror" \ 1.706 + for i, url in ipairs(urls) do \ 1.707 + if url ~= "" then 1.708 + if url == url_orig then \ 1.709 + type = "original" \ 1.710 + elseif type == "original" then \ 1.711 + type = "backup" \ 1.712 + end \ 1.713 + io.stdout:write(string.format("Fetching(%s): %s\\n", type, url)) \ 1.714 + local rc = rpm.expand( \ 1.715 + "%(%{l_prefix}/bin/openpkg curl '-#' -L -R -k " .. \ 1.716 + "-o '" .. file .. "'" .. " '" .. url .. "' 1>&2; echo $?)" \ 1.717 + ) \ 1.718 + if rc == "0" then \ 1.719 + result = "OK" \ 1.720 + break \ 1.721 + end \ 1.722 + end 1.723 + end \ 1.724 + print(result) \ 1.725 +} 1.726 + 1.727 +# increase size of line buffer for .spec file parsing 1.728 +# from 10KB to 4MB to support rather large BuildEnvironment tags 1.729 +%_spec_line_buffer_size 4000000 1.730 + 1.731 +# configure auto-generation of OpenPKG "BuildDependency" and "BuildEnvironment" tags 1.732 +%__autogen_builddependency 0 1.733 +%__autogen_buildenvironment 0 1.734 + 1.735 +# hook into %description 1.736 +%description\ 1.737 +%{?__hook_description_1}\ 1.738 +%{?__hook_description_2}\ 1.739 +%{?__hook_description_3}\ 1.740 +%{?__hook_description_4}\ 1.741 +%{?__hook_description_5}\ 1.742 +%{?__hook_description_6}\ 1.743 +%{?__hook_description_7}\ 1.744 +%{?__hook_description_8}\ 1.745 +%{?__hook_description_9}\ 1.746 +%%description 1.747 + 1.748 +# magically provide additional tags which are required but are always the same 1.749 %__hook_description_1 %{lua: \ 1.750 local prefix = rpm.expand("%{l_prefix_static}") \ 1.751 if rpm.expand("%{?prefix}") ~= prefix then \ 1.752 @@ -449,3 +734,254 @@ 1.753 print("AutoReqProv: no\\n") \ 1.754 } 1.755 1.756 +# auto-generate arbitrary tag "Marker" (via "rpm --marker <marker>") 1.757 +%__hook_description_2 %{?__marker:Marker: %{__marker}}\ 1.758 +%{nil} 1.759 + 1.760 +# auto-generate arbitrary tag "BuildDependency" from the standard tag(s) "BuildPreReq" 1.761 +# in order to forward-carry this build-time information to the binary RPM and to the RPMDB. 1.762 +%__hook_description_3 %{?__autogen_builddependency:%{?buildprereq:BuildDependency: %{@buildprereq:, }}}\ 1.763 +%{nil} 1.764 + 1.765 +# magically pickup all patched packaging source files (.orig/.rej) 1.766 +%__hook_description_4 %{lua: \ 1.767 + -- assemble RPM's information about SourceN and PatchN \ 1.768 + local sources = {} \ 1.769 + local macros = rpm.macros() \ 1.770 + for name, value in pairs(macros) do \ 1.771 + local s, _, m = util.rmatch(name, "^(?i)(SOURCE|PATCH)((?:URL)?)(\\\\d+)$") \ 1.772 + if s ~= nil and value["body"] ~= nil then \ 1.773 + local n = string.upper(string.sub(m[1], 1, 1)) .. string.lower(string.sub(m[1], 2)) .. m[3] \ 1.774 + if sources[n] == nil then \ 1.775 + sources[n] = { url = "", file = "" } \ 1.776 + end \ 1.777 + if m[2] ~= nil and m[2] ~= "" then \ 1.778 + sources[n].url = value["body"] \ 1.779 + else \ 1.780 + sources[n].file = value["body"] \ 1.781 + end \ 1.782 + end \ 1.783 + end \ 1.784 + \ 1.785 + -- add implicit .spec source file \ 1.786 + sources["Source999"] = { \ 1.787 + url = rpm.expand("%{name}.spec"), \ 1.788 + file = rpm.expand("%{_specdir}/%{name}.spec") \ 1.789 + } \ 1.790 + \ 1.791 + -- auto-generate tags for local SourceN and PatchN files \ 1.792 + -- where any corresponding .orig/.rej files exists \ 1.793 + for id, s in pairs(sources) do \ 1.794 + if util.rmatch(s.url, "^(?:ftp|https?)://.+") == nil then \ 1.795 + for i, ext in ipairs({ ".orig", ".rej" }) do \ 1.796 + if posix.access(s.file .. ext, "r") == 0 then \ 1.797 + local _, _, m = util.rmatch(id, "^(?i)(Source|Patch)(\\\\d+)$") \ 1.798 + local tag = string.format("%s%d: %s\\n", m[1], 10000 * i + m[2], s.url .. ext) \ 1.799 + print(tag) \ 1.800 + end \ 1.801 + end \ 1.802 + end \ 1.803 + end \ 1.804 +} 1.805 + 1.806 +# recursive package environment tracking configuration 1.807 +%__environment_delete_nve_regex ^gpg-pubkey-[^-]+-[^-]+$ 1.808 +%__environment_prune_nve_regex ^%{name}-[^-]+-[^-]+$ 1.809 +%__environment_prune_depth_number 3 1.810 +%__environment_debug 0 1.811 + 1.812 +# recursive package environment implementation 1.813 +%__hook_description_5 %{nil} 1.814 +%__hook_description_5_orig %{?__autogen_buildenvironment:%{lua: \ 1.815 + -- determine current debug status quo 1.816 + local debug = tonumber(rpm.expand("%{?__environment_debug}%{!?__environment_debug:0}")) \ 1.817 + \ 1.818 + -- determine current environment in serialized format \ 1.819 + -- (which actually is the Lua table constructor syntax) \ 1.820 + local result = {} \ 1.821 + for _, line in ipairs(rpm.query( \ 1.822 + "Q:\\\\[\\"%{name}-%{version}-%{release}\\"\\\\]=" .. \ 1.823 + "%|buildenvironment?{%{buildenvironment}}:{\\\\{\\\\}}|,", \ 1.824 + true, "*")) do \ 1.825 + local s, _, m = util.rmatch(line, "(?s)^Q:(.+)$") \ 1.826 + if s ~= nil then \ 1.827 + table.insert(result, m[1]) \ 1.828 + end \ 1.829 + end \ 1.830 + local constructor = "{" .. table.concat(result , "") .. "}" \ 1.831 + \ 1.832 + -- parse current environment \ 1.833 + -- (by evaluating the constructor as a Lua script) \ 1.834 + local environment = {} \ 1.835 + local f = loadstring("return " .. constructor) \ 1.836 + if f ~= nil then \ 1.837 + environment = f() \ 1.838 + else \ 1.839 + io.stderr:write("rpm: WARNING: failed to parse Lua table constructor: " .. constructor .. "\\n") \ 1.840 + end \ 1.841 + if debug > 0 then \ 1.842 + io.stdout:write("BuildEnvironment(original): " .. util.dump_object(environment, false) .. "\\n") \ 1.843 + end 1.844 + \ 1.845 + -- prune environment according to configuration \ 1.846 + function prune_environment (environment, depth) \ 1.847 + local delete_nve_regex = tostring(rpm.expand("%{?__environment_delete_nve_regex}")) \ 1.848 + local prune_nve_regex = tostring(rpm.expand("%{?__environment_prune_nve_regex}")) \ 1.849 + local prune_depth_number = tonumber(rpm.expand("%{?__environment_prune_depth_number}")) \ 1.850 + if type(environment) == "table" then \ 1.851 + for nve, _ in pairs(environment) do \ 1.852 + if (prune_depth_number ~= nil and prune_depth_number > 0 and depth > prune_depth_number) or \ 1.853 + (delete_nve_regex ~= "" and util.rmatch(nve, delete_nve_regex) ~= nil) then \ 1.854 + environment[nve] = nil \ 1.855 + elseif prune_nve_regex ~= nil and util.rmatch(nve, prune_nve_regex) ~= nil then \ 1.856 + environment[nve] = {} \ 1.857 + else \ 1.858 + prune_environment(environment[nve], depth + 1) \ 1.859 + end \ 1.860 + end \ 1.861 + end \ 1.862 + end \ 1.863 + prune_environment(environment, 1) \ 1.864 + if debug > 0 then \ 1.865 + io.stdout:write("BuildEnvironment(pruned): " .. util.dump_object(environment, false) .. "\\n") \ 1.866 + end \ 1.867 + \ 1.868 + -- export serialized environment as an RPM tag \ 1.869 + if type(environment) == "table" then \ 1.870 + local tag = "BuildEnvironment: " .. util.dump_object(environment, true) .. "\\n" \ 1.871 + print(tag) \ 1.872 + if debug > 0 then \ 1.873 + io.stdout:write(tag) \ 1.874 + end \ 1.875 + end \ 1.876 +}} 1.877 + 1.878 +# recursive package environment XML query support 1.879 +%__environment_to_xml %{lua: \ 1.880 + local lua = io.stdin:read("*all") \ 1.881 + local f = loadstring("return " .. lua) \ 1.882 + local xml = "" 1.883 + if f ~= nil then \ 1.884 + xml = xml .. "<?xml version=\\"1.0\\" encoding=\\"ISO-8859-1\\" standalone=\\"no\\"?>\\n" \ 1.885 + xml = xml .. "<!DOCTYPE environment\\n" \ 1.886 + xml = xml .. " PUBLIC \\"-//rpm5.org//DTD BuildEnvironment 1.0//EN\\"\\n" \ 1.887 + xml = xml .. " \\"http://rpm5.org/dtd/environment-1.0.dtd\\">\\n" \ 1.888 + function genxml (environment, prefix) \ 1.889 + local xml = prefix .. "<environment>\\n" \ 1.890 + for id, e in pairs(environment) do \ 1.891 + xml = xml .. prefix .. " <package>\\n" \ 1.892 + xml = xml .. prefix .. " <id>" .. id .. "</id>\\n" \ 1.893 + if e ~= nil and next(e) ~= nil then \ 1.894 + xml = xml .. genxml(e, prefix .. " ") \ 1.895 + end \ 1.896 + xml = xml .. prefix .. " </package>\\n" \ 1.897 + end \ 1.898 + xml = xml .. prefix .. "</environment>\\n" \ 1.899 + return xml 1.900 + end \ 1.901 + local environment = f() \ 1.902 + xml = xml .. genxml(environment, "") \ 1.903 + end \ 1.904 + print(xml) 1.905 +} 1.906 + 1.907 +# PGP public key information 1.908 +%l_pgpkey(n:F:) %{lua: \ 1.909 + local name = rpm.expand("%{?-n:%{-n*}}%{!?-n:openpkg.org}") \ 1.910 + local format = rpm.expand("%{?-F:%{-F*}}%{!?-F:%%f:%%i}") \ 1.911 + local fn = "?" \ 1.912 + local id = "?" \ 1.913 + if name == "openpkg.com" then \ 1.914 + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.com.pgp") \ 1.915 + id = "7D121A8FC05DC18A4329E9EF67042EC961B7AE34" \ 1.916 + elseif name == "openpkg.net" then \ 1.917 + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.net.pgp") \ 1.918 + id = "3BD10E1171B22598D7708C48AEBE764552197903" \ 1.919 + elseif name == "openpkg.org" then \ 1.920 + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.org.pgp") \ 1.921 + id = "6D96EFCFCF75328810DB40C2807593E063C4CB9F" \ 1.922 + end \ 1.923 + local result = util.rsubst(format, "%([nfi])", { ["n"] = name, ["f"] = fn, ["i"] = id }) \ 1.924 + print(result) \ 1.925 +} 1.926 + 1.927 +# integrity checking configuration 1.928 +%_integrity_spec_cfg_idx %{l_prefix}/etc/openpkg/license 1.929 +%_integrity_spec_cfg_dir %{l_prefix}/etc/openpkg/license.d 1.930 +%_integrity_spec_cfg %{lua: \ 1.931 + local idx = rpm.slurp(rpm.expand("%{_integrity_spec_cfg_idx}")) \ 1.932 + idx = util.rsubst(idx, "(?s)\\\\s*(.+?)\\\\s*$", "%1") \ 1.933 + local cfg = rpm.expand("%{_integrity_spec_cfg_dir}") .. "/" .. idx \ 1.934 + print(cfg) \ 1.935 +} 1.936 +%_integrity_proc_lua %{l_prefix}/lib/openpkg/license.lua 1.937 +%_integrity_pkey_pgp %{l_prefix}/etc/openpkg/openpkg.com.pgp 1.938 + 1.939 +## 1.940 +## Support for OpenPKG Flexible Filesystem Layout 1.941 +## 1.942 + 1.943 +# layout definition: RPM to OpenPKG variable mapping 1.944 +%_specdir %{expand:%%global _specdir %%{__openpkg_layout variable=specdir %{?openpkg_layout_specdir} %{!?openpkg_layout_specdir: %{openpkg_layout}}}}%{_specdir} 1.945 +%_sourcedir %{expand:%%global _sourcedir %%{__openpkg_layout variable=sourcedir %{?openpkg_layout_sourcedir}%{!?openpkg_layout_sourcedir:%{openpkg_layout}}}}%{_sourcedir} 1.946 +%_builddir %{expand:%%global _builddir %%{__openpkg_layout variable=builddir %{?openpkg_layout_builddir} %{!?openpkg_layout_builddir: %{openpkg_layout}}}}%{_builddir} 1.947 +%_tmppath %{expand:%%global _tmppath %%{__openpkg_layout variable=tmppath %{?openpkg_layout_tmppath} %{!?openpkg_layout_tmppath: %{openpkg_layout}}}}%{_tmppath} 1.948 +%_rpmdir %{expand:%%global _rpmdir %%{__openpkg_layout variable=rpmdir %{?openpkg_layout_rpmdir} %{!?openpkg_layout_rpmdir: %{openpkg_layout}}}}%{_rpmdir} 1.949 +%_srcrpmdir %{expand:%%global _srcrpmdir %%{__openpkg_layout variable=srcrpmdir %{?openpkg_layout_srcrpmdir}%{!?openpkg_layout_srcrpmdir:%{openpkg_layout}}}}%{_srcrpmdir} 1.950 + 1.951 +# default OpenPKG filesystem layout 1.952 +%openpkg_layout macrosfile=%{macrosfile} layout=global 1.953 + 1.954 +# layout determination: RPM macro to RPM Lua entry point 1.955 +%__openpkg_layout() %{lua: print(openpkg.layout(rpm.expand("%*"))) } 1.956 + 1.957 +# calculated base directory (placeholder definition only) 1.958 +%__openpkg_basedir %{l_prefix} 1.959 + 1.960 +# temporary path determination 1.961 +%__openpkg_tmpdir %{lua: print(openpkg.tmpdir()) } 1.962 + 1.963 +# shared environment (SE) support 1.964 +%__openpkg_SE_id %{l_hostname}-%{l_platform}-%{l_tag} 1.965 +%__openpkg_SE_subdir %{?__openpkg_shared:/%{__openpkg_SE_id}} 1.966 + 1.967 +# layout definition: GLOBAL filesystem layout 1.968 +%__openpkg_layout_global_specdir() %{l_prefix}/RPM/SRC/%{?name} 1.969 +%__openpkg_layout_global_sourcedir() %{l_prefix}/RPM/SRC/%{?name} 1.970 +%__openpkg_layout_global_builddir() %{l_prefix}/RPM/TMP 1.971 +%__openpkg_layout_global_tmppath() %{l_prefix}/RPM/TMP 1.972 +%__openpkg_layout_global_rpmdir() %{l_prefix}/RPM/PKG 1.973 +%__openpkg_layout_global_srcrpmdir() %{l_prefix}/RPM/PKG 1.974 + 1.975 +# layout definition: LOCAL filesystem layout 1.976 +%__openpkg_layout_local_specdir() %{__openpkg_basedir} 1.977 +%__openpkg_layout_local_sourcedir() %{__openpkg_basedir} 1.978 +%__openpkg_layout_local_builddir() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} 1.979 +%__openpkg_layout_local_tmppath() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} 1.980 +%__openpkg_layout_local_rpmdir() %{__openpkg_basedir} 1.981 +%__openpkg_layout_local_srcrpmdir() %{__openpkg_basedir} 1.982 + 1.983 +# layout definition: SIMPLE local filesystem layout 1.984 +%__openpkg_layout_simple_specdir() %{__openpkg_basedir} 1.985 +%__openpkg_layout_simple_sourcedir() %{__openpkg_basedir} 1.986 +%__openpkg_layout_simple_builddir() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.987 +%__openpkg_layout_simple_tmppath() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.988 +%__openpkg_layout_simple_rpmdir() %{realpath:%{__openpkg_basedir}/..} 1.989 +%__openpkg_layout_simple_srcrpmdir() %{realpath:%{__openpkg_basedir}/..} 1.990 + 1.991 +# layout definition: STRUCTURED local filesystem layout 1.992 +%__openpkg_layout_structured_specdir() %{__openpkg_basedir}/src 1.993 +%__openpkg_layout_structured_sourcedir() %{__openpkg_basedir}/dst %{__openpkg_basedir}/src 1.994 +%__openpkg_layout_structured_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.995 +%__openpkg_layout_structured_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.996 +%__openpkg_layout_structured_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} 1.997 +%__openpkg_layout_structured_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} 1.998 + 1.999 +# layout definition: DISTRIBUTED local filesystem layout 1.1000 +%__openpkg_layout_distributed_specdir() %{__openpkg_basedir}/src/%{?name} 1.1001 +%__openpkg_layout_distributed_sourcedir() %{__openpkg_basedir}/dst/%{?name} %{__openpkg_basedir}/src/%{?name} 1.1002 +%__openpkg_layout_distributed_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.1003 +%__openpkg_layout_distributed_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} 1.1004 +%__openpkg_layout_distributed_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} 1.1005 +%__openpkg_layout_distributed_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} 1.1006 +