diff -r 71503088f51b -r f880f219c566 openpkg/rpmmacros --- a/openpkg/rpmmacros Tue Jul 31 12:12:54 2012 +0200 +++ b/openpkg/rpmmacros Tue Jul 31 12:23:42 2012 +0200 @@ -1,14 +1,13 @@ ## ## rpmmacros -- OpenPKG RPM Macros -## Copyright (c) 2000-2007 OpenPKG Foundation e.V. -## Copyright (c) 2000-2007 Ralf S. Engelschall +## Copyright (c) 2000-2012 OpenPKG GmbH ## -## Permission to use, copy, modify, and distribute this software for -## any purpose with or without fee is hereby granted, provided that -## the above copyright notice and this permission notice appear in all -## copies. +## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. +## All rights reserved. Licenses which grant limited permission to use, +## copy, modify and distribute this software are available from the +## OpenPKG GmbH. ## -## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR @@ -21,12 +20,20 @@ ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## + +## ## The purpose of this macro set is to override the default ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. ## +# utility macro for "delayed one-time expansion" of macro bodies +# (works by redefining a macro in-place to its expanded body on its first usage) +%l_once() %{expand:%%global %{*}}%{expand:%%{%{1}}} + # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) -%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"}) +%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"}) # the OpenPKG OIDs (root is officially registered at IANA) %l_openpkg_oid 1.3.6.1.4.1.18749 @@ -37,15 +44,31 @@ # the OpenPKG package tagging %l_tag_fmt @TAG@ -%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) -%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;') -%l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; %{l_uuid} -v3 $uuid_ns '%{?_options}') +%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) +%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;' \\\ + ) +%l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; \ + %{l_uuid} -v3 $uuid_ns '%{?_options}') %l_tag_fmt_uuid %(%{l_uuid} -v1) %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') -%l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} -%l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g') +%l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | \\\ + sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} +%l_tag %{l_once l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g')} # the OpenPKG instance location (backward compatibility only) %l_location %{l_tag} @@ -92,35 +115,65 @@ %l_host_os %{_host_os} %l_host %{_host_cpu}-%{_host_os} +# host name or FQDN identification +%l_hostname(f) %(%{l_shtool} echo -n -e '%%h%{?-f:%%d}') + # new OpenPKG platform identification -%l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then fmt="%{-F*}"; else T="%{?-c:c}%{?-p:p}%{?-t:t}"; [ ".$T" = . ] && T="p"; fmt="%%-%%"; fi; %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") +%l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then \ + fmt="%{-F*}"; \ + else \ + T="%{?-c:c}%{?-p:p}%{?-t:t}"; \ + [ ".$T" = . ] && T="p"; \ + fmt="%%-%%"; \ + fi; \ + %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") # old OpenPKG platform identification %l_target %{l_platform -t} +# UID/GID lookup +%l_xuid_lookup() %(( getent passwd '%1'; \ + grep '^%1:' /etc/passwd; \ + ypmatch '%1' passwd; \ + nismatch '%1' passwd; \ + nidump passwd . | grep '^%1:' \ + ) 2>/dev/null | \ + sed -e 'q' | \\\ + awk -F: '{ print $3; }' \ + ) +%l_xgid_lookup() %(( getent group '%2'; \ + grep '^%2:' /etc/group; \ + ypmatch '%2' group; \ + nismatch '%2' group; \ + nidump group . | grep '^%1:' \ + ) 2>/dev/null | \ + sed -e 'q' | \\\ + awk -F: '{ print $3; }' \ + ) + # the *S*uper-user user/group name/id pair %l_susr @SUSR@ %l_sgrp @SGRP@ -%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; }') -%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; }') +%l_suid %{expand:%%{l_xuid_lookup %{l_susr} %{l_sgrp}}} +%l_sgid %{expand:%%{l_xgid_lookup %{l_susr} %{l_sgrp}}} # the *M*anagement user/group name/id pair %l_musr @MUSR@ %l_mgrp @MGRP@ -%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; }') -%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; }') +%l_muid %{expand:%%{l_xuid_lookup %{l_musr} %{l_mgrp}}} +%l_mgid %{expand:%%{l_xgid_lookup %{l_musr} %{l_mgrp}}} # the *R*restricted user/group name/id pair %l_rusr @RUSR@ %l_rgrp @RGRP@ -%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; }') -%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; }') +%l_ruid %{expand:%%{l_xuid_lookup %{l_rusr} %{l_rgrp}}} +%l_rgid %{expand:%%{l_xgid_lookup %{l_rusr} %{l_rgrp}}} # the *N*on-privileged user/group name/id pair %l_nusr @NUSR@ %l_ngrp @NGRP@ -%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; }') -%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; }') +%l_nuid %{expand:%%{l_xuid_lookup %{l_nusr} %{l_ngrp}}} +%l_ngid %{expand:%%{l_xgid_lookup %{l_nusr} %{l_ngrp}}} # backward compatibility (openpkg < 20020204) %l_fsusr %{l_musr} @@ -128,6 +181,10 @@ %l_npuid %{l_nuid} %l_npgid %{l_ngid} +# whether we are intended to operate in an environment where +# only a single unprivileged user account can be used +%l_unprivileged @l_unprivileged@ + # define the installation hierarchy (used parts) %l_prefix @l_prefix@ %l_prefix_static @l_prefix_static@ @@ -159,11 +216,49 @@ # ";" for "-s" and ";" for "-b" and "-c". You can either specify one # or more names of variables to expand or use "-a" for mostly all # variables and "-A" for really all variables. -%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")} +%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" \ + )} # local version of the empty macro %l_nil %{nil} +# local version of the tab character +%l_tab %{lua: print "\t" } + # override the internal RPM hierarchy variables %_usr %{nil} %_var %{nil} @@ -176,15 +271,23 @@ %_specdir %{l_prefix}/RPM/SRC/%{name} %_rpmdir %{l_prefix}/RPM/PKG %_srcrpmdir %{l_prefix}/RPM/PKG -%_repackage_dir %{l_prefix}/RPM/PKG -%_cache_dbpath %{l_prefix}/RPM/PKG -%_solve_dbpath %{l_prefix}/RPM/PKG -%_solve_pkgsdir %{l_prefix}/RPM/PKG +%_repackage_dir %{l_prefix}/RPM/TR +%_cache_dbpath %{l_prefix}/RPM/CACHE +%_solve_dbpath %{l_prefix}/RPM/CACHE +%_solve_pkgsdir %{l_prefix}/RPM/CACHE %_defaultdocdir %{l_docdir} # complement the %{SOURCE} and %{PATCH} with %{SOURCE } and %{PATCH } -%SOURCE() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) -%PATCH() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) +%_SOURCE_PATCH() %{lua: \ + local source1 = rpm.expand("%{_specdir}/%1") \ + local source2 = rpm.expand("%{_sourcedir}/%1") \ + if posix.stat(source1) ~= nil then \ + print(source1) \ + else \ + print(source2) \ + end } +%SOURCE() %{expand:%%{_SOURCE_PATCH %1}} +%PATCH() %{expand:%%{_SOURCE_PATCH %1}} # override RPM's absolute tool paths with relative ones # (because if you upgrade RPM it would hard-code tools in own hierarchy, too) @@ -195,7 +298,6 @@ %__chmod chmod %__chown chown %__cp cp -%__cpio cpio %__grep grep %__gzip %{_gzipbin} %__id id @@ -213,33 +315,37 @@ %__sed sed %__ssh ssh %__tar %{_tarbin} -%__unzip %{_unzipbin} +%__xz %{_xzbin} # override some more RPM macros where the default value is not acceptable +%_dbapi %{l_once _dbapi %(if [ -f "%{_dbpath}/VERSION" ]; then \ + . "%{_dbpath}/VERSION"; \ + fi; \ + echo "${DBAPI:-3}")} +%__dbi_other %{?_tmppath:tmpdir=%{_tmppath}} %{?__dbi_cdb} %{?__dbi_private:private} +%__file_context_path %{nil} +%__check_files %{nil} +%_patch_suffix -b --suffix .orig +%_excludedocs 1 %_dependency_whiteout %{nil} %__debug_install_post %{nil} %_unpackaged_files_terminate_build 0 -# override automatic dependency generation -%_use_internal_dependency_generator 0 -%__find_provides %{nil} -%__find_requires %{nil} -%__find_prereq %{nil} -%__perl_provides %{nil} -%__perl_requires %{nil} - # provide fixed paths to tools (standard) %_gzipbin %{l_prefix}/lib/openpkg/gzip %_bzip2bin %{l_prefix}/lib/openpkg/bzip2 +%_xzbin %{l_prefix}/lib/openpkg/xz %_patchbin %{l_prefix}/lib/openpkg/patch %_tarbin %{l_prefix}/lib/openpkg/tar -%_unzipbin %{l_prefix}/lib/openpkg/unzip +%__bsdtar %{l_prefix}/lib/openpkg/bsdtar +%__cpio %{l_prefix}/lib/openpkg/bsdcpio +%__unzip %{__bsdtar} # provide path to platform identification file %__platform %{l_prefix}/etc/openpkg/platform # provide fixed paths to tools (additional) -%l_rc %{l_prefix}/etc/rc +%l_rc %{l_prefix}/bin/openpkg --keep-privileges rc %l_rpm %{l_prefix}/libexec/openpkg/rpm %l_rpm2cpio %{l_prefix}/libexec/openpkg/rpm2cpio %l_rpm_config %{l_prefix}/libexec/openpkg/rpm-config @@ -251,31 +357,41 @@ %l_uuid %{l_prefix}/lib/openpkg/uuid # provide smart paths to tools -%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) -%l_gzip %{l_tool_locate gzip gzip} -%l_bzip2 %{l_tool_locate bzip2 bzip2} -%l_tar %{l_tool_locate tar tar} -%l_make %{l_tool_locate make make} -%l_cc %{l_tool_locate cc cc} -%l_ar %{l_tool_locate ar ar} -%l_ld %{l_tool_locate ld ld} -%l_as %{l_tool_locate as as} -%l_strip %{l_tool_locate strip strip} -%l_cxx %{l_tool_locate cxx c++} -%l_patch %{l_tool_locate patch patch} -%l_sed %{l_tool_locate sed sed} -%l_grep %{l_tool_locate grep grep} -%l_awk %{l_tool_locate awk awk} -%l_autoconf %{l_tool_locate autoconf autoconf} -%l_automake %{l_tool_locate automake automake} -%l_libtool %{l_tool_locate libtool libtool} -%l_flex %{l_tool_locate flex flex} -%l_bison %{l_tool_locate bison bison} -%l_perl %{l_tool_locate perl perl} -%l_miniperl %{l_tool_locate miniperl miniperl} -%l_openssl %{l_tool_locate openssl openssl} -%l_xmkmf %{l_tool_locate xmkmf xmkmf} -%l_vcheck %{l_tool_locate vcheck vcheck} +%l_tool_locate() %{lua: \ + if rpm.expand("%{expand:%%{?use_%1}}") ~= "" then \ + print(rpm.expand("%{expand:%%{use_%1}}")) \ + elseif posix.stat(rpm.expand("%{l_prefix}/bin/%2")) ~= nil then \ + print(rpm.expand("%{l_prefix}/bin/%2")) \ + elseif posix.stat(rpm.expand("%{l_prefix}/lib/openpkg/%2")) ~= nil then \ + print(rpm.expand("%{l_prefix}/lib/openpkg/%2")) \ + else \ + print(rpm.expand("%2")) \ + end } +%l_gzip %{l_once l_gzip %{l_tool_locate gzip gzip}} +%l_bzip2 %{l_once l_bzip2 %{l_tool_locate bzip2 bzip2}} +%l_xz %{l_once l_xz %{l_tool_locate xz xz}} +%l_tar %{l_once l_tar %{l_tool_locate tar tar}} +%l_make %{l_once l_make %{l_tool_locate make make}} +%l_cc %{l_once l_cc %{l_tool_locate cc cc}} +%l_ar %{l_once l_ar %{l_tool_locate ar ar}} +%l_ld %{l_once l_ld %{l_tool_locate ld ld}} +%l_as %{l_once l_as %{l_tool_locate as as}} +%l_strip %{l_once l_strip %{l_tool_locate strip strip}} +%l_cxx %{l_once l_cxx %{l_tool_locate cxx c++}} +%l_patch %{l_once l_patch %{l_tool_locate patch patch}} +%l_sed %{l_once l_sed %{l_tool_locate sed sed}} +%l_grep %{l_once l_grep %{l_tool_locate grep grep}} +%l_awk %{l_once l_awk %{l_tool_locate awk awk}} +%l_autoconf %{l_once l_autoconf %{l_tool_locate autoconf autoconf}} +%l_automake %{l_once l_automake %{l_tool_locate automake automake}} +%l_libtool %{l_once l_libtool %{l_tool_locate libtool libtool}} +%l_flex %{l_once l_flex %{l_tool_locate flex flex}} +%l_bison %{l_once l_bison %{l_tool_locate bison bison}} +%l_perl %{l_once l_perl %{l_tool_locate perl perl}} +%l_miniperl %{l_once l_miniperl %{l_tool_locate miniperl miniperl}} +%l_openssl %{l_once l_openssl %{l_tool_locate openssl openssl}} +%l_xmkmf %{l_once l_xmkmf %{l_tool_locate xmkmf xmkmf}} +%l_vcheck %{l_once l_vcheck %{l_tool_locate vcheck vcheck}} # tool options %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") @@ -285,11 +401,24 @@ %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) # OSSP fake syslog library -%l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; else flags=''; fi; echo $flags) -%l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --libs ) 2>/dev/null`; else flags=''; fi; echo $flags) +%l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then \ + flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; \ + else \ + flags=''; \ + fi; \ + echo $flags) +%l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then \ + flags=`(%{l_prefix}/bin/fsl-config --all --libs) 2>/dev/null`; \ + else \ + flags=''; \ + fi; \ + echo $flags) # determine the current username -%l_whoami %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME) +%l_whoami %{l_once l_whoami %((id -un) 2>/dev/null || \\\ + (whoami) 2>/dev/null || \\\ + (who am i | cut "-d " -f1) 2>/dev/null || \\\ + echo $LOGNAME)} # macros for dynamically generating a %files list %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' @@ -297,8 +426,11 @@ %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' %l_files_std() %l_files_defattr %l_files_all %l_files_noshared +# default %defattr when rolling SRPMS +%_srcdefattr (-,openpkg,openpkg) + # path to local build root -%l_buildroot %{_tmppath}/%{name}-%{version}-root +%l_buildroot %{_tmppath}/%{name}-%{version}-%{release}-buildroot %buildroot %{l_buildroot} # path to local temporary location @@ -316,7 +448,12 @@ %_rpmfilename %{l_binrpmfilename} %_build_name_fmt %{l_binrpmfilename} %_repackage_name_fmt %{l_binrpmfilename} -%_solve_name_fmt %{_solve_pkgsdir}/%{l_binrpmfilename} +%_solve_name_fmt %{?_solve_pkgsdir}/%{l_binrpmfilename} +%_query_all_fmt %%{NAME}-%%{VERSION}-%%{RELEASE} +%___NVRA %%{NAME}-%%{VERSION}-%%{RELEASE} + +# do not repackage automatically +%_repackage_all_erasures 0 # override the payload compression for the CPIO parts of an RPM # (we use the equivalent of "bzip2 -9") @@ -324,98 +461,177 @@ %_binary_payload w9.bzdio # package signature type is OpenPGP via GnuPG -%__gpg %{l_prefix}/bin/gpg +%__gpg %{l_tool_locate gpg gpg} %_signature gpg -%__vsflags 1 # two macro-processor add-ons (should be part of forthcoming RPM releases) %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} # macro for package option configuration -%option() %{expand:%%{!?%{1}:%%global %*}} %{expand:%%global _options %{?_options:%{_options}:}%{1}=%%%{1}} \ -Provides: %{name}::%{1} = %(echo '%{expand:%%{%{1}}}' | sed -e 's;%%;%%%%;g' -e 's; ;%%20;g' -e 's; ;%%09;g') +%option() %{lua: \ + local package_name = rpm.expand("%{name}") \ + local option_name = rpm.expand("%1") \ + if rpm.expand("%{?" .. option_name .. ":defined}") ~= "defined" then \ + rpm.expand("%global " .. rpm.expand("%*")) \ + end \ + local option_value = rpm.expand("%{" .. option_name .. "}") \ + option_value = util.rsubst(option_value, "(?s)%", "%%%%") \ + option_value = util.rsubst(option_value, "(?s) ", "%%20") \ + option_value = util.rsubst(option_value, "(?s)\\t", "%%09") \ + rpm.expand("%global _options %{?_options:%{_options}:}" .. option_name .. "=" .. option_value) \ + print(string.format("Provides: %s::%s = %s\\n", package_name, option_name, option_value)) \ + } # macros for NoSource/NoPatch (distribution restriction) integrity handling -%NoSource() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoSource: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} -%NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoPatch: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} +%NoSource() %(if [ ".%{?restriction}" != ".no" ]; then \ + echo "NoSource: %1"; \ + fi) \ + %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} +%NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then \ + echo "NoPatch: %1"; fi) \ + %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} %integrity() %{l_check_nosource} # macros for checking build environment -%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) -%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") +%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) +%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") %prep %%prep\ %{l_check_nosource} \ %{l_check_class} \ %{nil} # macro-processor add-on for testing external conditions -%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) - -# default list of vendor source fetching locations -%l_fetch_mirror_0 - -%l_fetch_mirror_1 - -%l_fetch_mirror_2 - -%l_fetch_mirror_3 - -%l_fetch_mirror_4 - -%l_fetch_mirror_5 - -%l_fetch_mirror_6 - -%l_fetch_mirror_7 - -%l_fetch_mirror_8 - -%l_fetch_mirror_9 - -%l_fetch_backup_0 - -%l_fetch_backup_1 - -%l_fetch_backup_2 - -%l_fetch_backup_3 - -%l_fetch_backup_4 - -%l_fetch_backup_5 - -%l_fetch_backup_6 - -%l_fetch_backup_7 - -%l_fetch_backup_8 - -%l_fetch_backup_9 ftp://ftp.openpkg.org/sources/DST/%{name}/ +%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) # sane build environment setup -%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) +%l_build_path %{l_once 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)} %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ %l_build_ulim @l_build_ulim@ %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash %l_build_shell_opt --norc --noprofile --posix # sane build environment for manual usage in macros (currently just $PATH) -%l_sane_env PATH="%{l_build_path}"; export PATH; LD_LIBRARY_PATH="%{l_build_ldlp}"; export LD_LIBRARY_PATH +%l_sane_env PATH="%{l_build_path}"; \ + export PATH; \ + LD_LIBRARY_PATH="%{l_build_ldlp}"; \ + export LD_LIBRARY_PATH # sane build environment for %prep/%build/%install %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} -%___build_pre \ -HOME="%{l_prefix}"\ -SHELL="%{l_build_shell_cmd}"\ -TERM="%(echo $TERM)"\ -TMPDIR="%{_tmppath}"\ -USER="%(echo $USER)"\ -LOGNAME="%(echo $LOGNAME)"\ -PATH="%{l_build_path}"\ -LD_LIBRARY_PATH="%{l_build_ldlp}"\ -export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ -RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ -RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ -RPM_OPT_FLAGS=\"%{optflags}\"\ -RPM_ARCH=\"%{l_host_arch}\"\ -RPM_OS=\"%{l_host_os}\"\ -RPM_DOC_DIR=\"%{_docdir}\"\ -RPM_PACKAGE_NAME=\"%{name}\"\ -RPM_PACKAGE_VERSION=\"%{version}\"\ -RPM_PACKAGE_RELEASE=\"%{release}\"\ -export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ -export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ -%{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ -export RPM_BUILD_ROOT}\ -%{l_build_ulim}\ -umask 022\ -%{verbose:set -x}%{!verbose:exec >/dev/null}\ -cd %{u2p:%{_builddir}} +%___build_pre HOME="%{l_prefix}"\ + SHELL="%{l_build_shell_cmd}"\ + TERM="%{getenv:TERM}"\ + TMPDIR="%{_tmppath}"\ + USER="%{getenv:USER}"\ + LOGNAME="%{getenv:LOGNAME}"\ + PATH="%{l_build_path}"\ + LD_LIBRARY_PATH="%{l_build_ldlp}"\ + export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ + RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ + RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ + RPM_OPT_FLAGS=\"%{optflags}\"\ + RPM_ARCH=\"%{l_host_arch}\"\ + RPM_OS=\"%{l_host_os}\"\ + RPM_DOC_DIR=\"%{_docdir}\"\ + RPM_PACKAGE_NAME=\"%{name}\"\ + RPM_PACKAGE_VERSION=\"%{version}\"\ + RPM_PACKAGE_RELEASE=\"%{release}\"\ + export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ + export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ + %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ + export RPM_BUILD_ROOT}\ + %{l_build_ulim}\ + umask 022\ + %{verbose:set -x}%{!verbose:exec >/dev/null}\ + cd %{u2p:%{_builddir}} + +# improved %patch macro +%patch(b:p:P:REz:F:d:e:m:) %{lua: \ + local subst = "" \ + local options = rpm.expand("%**") \ + local regex = "-e\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ + local pcre = rex_pcre.new(regex) \ + local n = 0 \ + while true do \ + local s, e, t = pcre:tfind(options, n) \ + if s == nil then break end \ + subst = subst .. " -e " .. t[1] \ + n = e + 1 \ + end \ + local regex = "-m\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ + local pcre = rex_pcre.new(regex) \ + local n = 0 \ + while true do \ + local s, e, t = pcre:tfind(options, n) \ + if s == nil then break end \ + subst = subst .. " -e 's;@" .. t[1] .. "@;%{" .. t[1] .. "};g'" \ + n = e + 1 \ + end \ + if subst ~= "" then \ + subst = "| sed" .. subst \ + rpm.define("__patch_subst " .. subst) \ + else \ + rpm.define("__patch_subst %{nil}") \ + end \ +}%{shrink: \ +%define __patch_number %{-P:%{-P*}}%{!-P:0} \ +%define __patch_file %{P:%{__patch_number}} \ +%define __patch_suffix %{-b:-b --suffix %{-b*}}%{!-b:-b --suffix .orig} %{-z:--suffix %{-z*}} \ +%define __patch_options -s %{-p:-p%{-p*}} %{-F:-F%{-F*}} %{-d:-d%{-d*}} %{-R} %{-E} %{__patch_suffix} \ +echo "Patch #%{__patch_number} (%{basename:%{__patch_file}}):"; \ +%{uncompress:%{__patch_file}} %{__patch_subst} | %{__patch} %{__patch_options}}\ +%{nil} # special %track section support -%__spec_track_template VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.vc"\ +%__spec_track_pre\ +VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.track.vc"\ rm -f $VCFILE\ set -o noclobber\ sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ @@ -434,12 +650,81 @@ ( echo "config = {"\ echo "}"\ ) >>$VCFILE\ - %{l_vcheck} -v -f $VCFILE || true\ + %{l_vcheck} %{verbose:--verbose}%{!verbose:--noverbose} -f $VCFILE || true\ fi\ rm -f $VCFILE\ %{nil} -# automatically include never changing RPM header text +# support additional .spec tags +%_arbitrary_tags Class:Track:TrackProg:BuildDependency:BuildEnvironment:My*:Local* + +# disable /bin/sh dependency (which doesn't fit into OpenPKG's environment) +%_disable_shell_interpreter_deps 1 + +# support downloading files via cURL (instead of internal RPMIO) +# and optionally also from global and local mirror and backup location(s) +%__urlgetfile_urls_mirror() \ + %{nil} +%__urlgetfile_urls_backup() %{lua: \ + local url = rpm.expand("%1") \ + local name = rpm.expand("%{name}") \ + if name ~= "" and url ~= "" then \ + local cache = "http://download.openpkg.org/components/cache/" .. name .. "/" \ + url = util.rsubst(url, "^.+/([^/]+)$", cache .. "%1") \ + print(url) \ + end \ +} +%__urlgetfile_urls() \ + %{?__urlgetfile_urls_mirror %1} %1 %{?__urlgetfile_urls_backup %1} +%__urlgetfile() %{lua: \ + local url_orig = rpm.expand("%1") \ + local file = rpm.expand("%2") \ + local urls = util.rsplit(rpm.expand("%{?__urlgetfile_urls " .. url_orig .. "}"), "\\\\s+") \ + local result = "ERROR" \ + local type = "mirror" \ + for i, url in ipairs(urls) do \ + if url ~= "" then + if url == url_orig then \ + type = "original" \ + elseif type == "original" then \ + type = "backup" \ + end \ + io.stdout:write(string.format("Fetching(%s): %s\\n", type, url)) \ + local rc = rpm.expand( \ + "%(%{l_prefix}/bin/openpkg curl '-#' -L -R -k " .. \ + "-o '" .. file .. "'" .. " '" .. url .. "' 1>&2; echo $?)" \ + ) \ + if rc == "0" then \ + result = "OK" \ + break \ + end \ + end + end \ + print(result) \ +} + +# increase size of line buffer for .spec file parsing +# from 10KB to 4MB to support rather large BuildEnvironment tags +%_spec_line_buffer_size 4000000 + +# configure auto-generation of OpenPKG "BuildDependency" and "BuildEnvironment" tags +%__autogen_builddependency 0 +%__autogen_buildenvironment 0 + +# hook into %description +%description\ +%{?__hook_description_1}\ +%{?__hook_description_2}\ +%{?__hook_description_3}\ +%{?__hook_description_4}\ +%{?__hook_description_5}\ +%{?__hook_description_6}\ +%{?__hook_description_7}\ +%{?__hook_description_8}\ +%{?__hook_description_9}\ +%%description + +# magically provide additional tags which are required but are always the same %__hook_description_1 %{lua: \ local prefix = rpm.expand("%{l_prefix_static}") \ if rpm.expand("%{?prefix}") ~= prefix then \ @@ -449,3 +734,254 @@ print("AutoReqProv: no\\n") \ } +# auto-generate arbitrary tag "Marker" (via "rpm --marker ") +%__hook_description_2 %{?__marker:Marker: %{__marker}}\ +%{nil} + +# auto-generate arbitrary tag "BuildDependency" from the standard tag(s) "BuildPreReq" +# in order to forward-carry this build-time information to the binary RPM and to the RPMDB. +%__hook_description_3 %{?__autogen_builddependency:%{?buildprereq:BuildDependency: %{@buildprereq:, }}}\ +%{nil} + +# magically pickup all patched packaging source files (.orig/.rej) +%__hook_description_4 %{lua: \ + -- assemble RPM's information about SourceN and PatchN \ + local sources = {} \ + local macros = rpm.macros() \ + for name, value in pairs(macros) do \ + local s, _, m = util.rmatch(name, "^(?i)(SOURCE|PATCH)((?:URL)?)(\\\\d+)$") \ + if s ~= nil and value["body"] ~= nil then \ + local n = string.upper(string.sub(m[1], 1, 1)) .. string.lower(string.sub(m[1], 2)) .. m[3] \ + if sources[n] == nil then \ + sources[n] = { url = "", file = "" } \ + end \ + if m[2] ~= nil and m[2] ~= "" then \ + sources[n].url = value["body"] \ + else \ + sources[n].file = value["body"] \ + end \ + end \ + end \ + \ + -- add implicit .spec source file \ + sources["Source999"] = { \ + url = rpm.expand("%{name}.spec"), \ + file = rpm.expand("%{_specdir}/%{name}.spec") \ + } \ + \ + -- auto-generate tags for local SourceN and PatchN files \ + -- where any corresponding .orig/.rej files exists \ + for id, s in pairs(sources) do \ + if util.rmatch(s.url, "^(?:ftp|https?)://.+") == nil then \ + for i, ext in ipairs({ ".orig", ".rej" }) do \ + if posix.access(s.file .. ext, "r") == 0 then \ + local _, _, m = util.rmatch(id, "^(?i)(Source|Patch)(\\\\d+)$") \ + local tag = string.format("%s%d: %s\\n", m[1], 10000 * i + m[2], s.url .. ext) \ + print(tag) \ + end \ + end \ + end \ + end \ +} + +# recursive package environment tracking configuration +%__environment_delete_nve_regex ^gpg-pubkey-[^-]+-[^-]+$ +%__environment_prune_nve_regex ^%{name}-[^-]+-[^-]+$ +%__environment_prune_depth_number 3 +%__environment_debug 0 + +# recursive package environment implementation +%__hook_description_5 %{nil} +%__hook_description_5_orig %{?__autogen_buildenvironment:%{lua: \ + -- determine current debug status quo + local debug = tonumber(rpm.expand("%{?__environment_debug}%{!?__environment_debug:0}")) \ + \ + -- determine current environment in serialized format \ + -- (which actually is the Lua table constructor syntax) \ + local result = {} \ + for _, line in ipairs(rpm.query( \ + "Q:\\\\[\\"%{name}-%{version}-%{release}\\"\\\\]=" .. \ + "%|buildenvironment?{%{buildenvironment}}:{\\\\{\\\\}}|,", \ + true, "*")) do \ + local s, _, m = util.rmatch(line, "(?s)^Q:(.+)$") \ + if s ~= nil then \ + table.insert(result, m[1]) \ + end \ + end \ + local constructor = "{" .. table.concat(result , "") .. "}" \ + \ + -- parse current environment \ + -- (by evaluating the constructor as a Lua script) \ + local environment = {} \ + local f = loadstring("return " .. constructor) \ + if f ~= nil then \ + environment = f() \ + else \ + io.stderr:write("rpm: WARNING: failed to parse Lua table constructor: " .. constructor .. "\\n") \ + end \ + if debug > 0 then \ + io.stdout:write("BuildEnvironment(original): " .. util.dump_object(environment, false) .. "\\n") \ + end + \ + -- prune environment according to configuration \ + function prune_environment (environment, depth) \ + local delete_nve_regex = tostring(rpm.expand("%{?__environment_delete_nve_regex}")) \ + local prune_nve_regex = tostring(rpm.expand("%{?__environment_prune_nve_regex}")) \ + local prune_depth_number = tonumber(rpm.expand("%{?__environment_prune_depth_number}")) \ + if type(environment) == "table" then \ + for nve, _ in pairs(environment) do \ + if (prune_depth_number ~= nil and prune_depth_number > 0 and depth > prune_depth_number) or \ + (delete_nve_regex ~= "" and util.rmatch(nve, delete_nve_regex) ~= nil) then \ + environment[nve] = nil \ + elseif prune_nve_regex ~= nil and util.rmatch(nve, prune_nve_regex) ~= nil then \ + environment[nve] = {} \ + else \ + prune_environment(environment[nve], depth + 1) \ + end \ + end \ + end \ + end \ + prune_environment(environment, 1) \ + if debug > 0 then \ + io.stdout:write("BuildEnvironment(pruned): " .. util.dump_object(environment, false) .. "\\n") \ + end \ + \ + -- export serialized environment as an RPM tag \ + if type(environment) == "table" then \ + local tag = "BuildEnvironment: " .. util.dump_object(environment, true) .. "\\n" \ + print(tag) \ + if debug > 0 then \ + io.stdout:write(tag) \ + end \ + end \ +}} + +# recursive package environment XML query support +%__environment_to_xml %{lua: \ + local lua = io.stdin:read("*all") \ + local f = loadstring("return " .. lua) \ + local xml = "" + if f ~= nil then \ + xml = xml .. "\\n" \ + xml = xml .. "\\n" \ + function genxml (environment, prefix) \ + local xml = prefix .. "\\n" \ + for id, e in pairs(environment) do \ + xml = xml .. prefix .. " \\n" \ + xml = xml .. prefix .. " " .. id .. "\\n" \ + if e ~= nil and next(e) ~= nil then \ + xml = xml .. genxml(e, prefix .. " ") \ + end \ + xml = xml .. prefix .. " \\n" \ + end \ + xml = xml .. prefix .. "\\n" \ + return xml + end \ + local environment = f() \ + xml = xml .. genxml(environment, "") \ + end \ + print(xml) +} + +# PGP public key information +%l_pgpkey(n:F:) %{lua: \ + local name = rpm.expand("%{?-n:%{-n*}}%{!?-n:openpkg.org}") \ + local format = rpm.expand("%{?-F:%{-F*}}%{!?-F:%%f:%%i}") \ + local fn = "?" \ + local id = "?" \ + if name == "openpkg.com" then \ + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.com.pgp") \ + id = "7D121A8FC05DC18A4329E9EF67042EC961B7AE34" \ + elseif name == "openpkg.net" then \ + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.net.pgp") \ + id = "3BD10E1171B22598D7708C48AEBE764552197903" \ + elseif name == "openpkg.org" then \ + fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.org.pgp") \ + id = "6D96EFCFCF75328810DB40C2807593E063C4CB9F" \ + end \ + local result = util.rsubst(format, "%([nfi])", { ["n"] = name, ["f"] = fn, ["i"] = id }) \ + print(result) \ +} + +# integrity checking configuration +%_integrity_spec_cfg_idx %{l_prefix}/etc/openpkg/license +%_integrity_spec_cfg_dir %{l_prefix}/etc/openpkg/license.d +%_integrity_spec_cfg %{lua: \ + local idx = rpm.slurp(rpm.expand("%{_integrity_spec_cfg_idx}")) \ + idx = util.rsubst(idx, "(?s)\\\\s*(.+?)\\\\s*$", "%1") \ + local cfg = rpm.expand("%{_integrity_spec_cfg_dir}") .. "/" .. idx \ + print(cfg) \ +} +%_integrity_proc_lua %{l_prefix}/lib/openpkg/license.lua +%_integrity_pkey_pgp %{l_prefix}/etc/openpkg/openpkg.com.pgp + +## +## Support for OpenPKG Flexible Filesystem Layout +## + +# layout definition: RPM to OpenPKG variable mapping +%_specdir %{expand:%%global _specdir %%{__openpkg_layout variable=specdir %{?openpkg_layout_specdir} %{!?openpkg_layout_specdir: %{openpkg_layout}}}}%{_specdir} +%_sourcedir %{expand:%%global _sourcedir %%{__openpkg_layout variable=sourcedir %{?openpkg_layout_sourcedir}%{!?openpkg_layout_sourcedir:%{openpkg_layout}}}}%{_sourcedir} +%_builddir %{expand:%%global _builddir %%{__openpkg_layout variable=builddir %{?openpkg_layout_builddir} %{!?openpkg_layout_builddir: %{openpkg_layout}}}}%{_builddir} +%_tmppath %{expand:%%global _tmppath %%{__openpkg_layout variable=tmppath %{?openpkg_layout_tmppath} %{!?openpkg_layout_tmppath: %{openpkg_layout}}}}%{_tmppath} +%_rpmdir %{expand:%%global _rpmdir %%{__openpkg_layout variable=rpmdir %{?openpkg_layout_rpmdir} %{!?openpkg_layout_rpmdir: %{openpkg_layout}}}}%{_rpmdir} +%_srcrpmdir %{expand:%%global _srcrpmdir %%{__openpkg_layout variable=srcrpmdir %{?openpkg_layout_srcrpmdir}%{!?openpkg_layout_srcrpmdir:%{openpkg_layout}}}}%{_srcrpmdir} + +# default OpenPKG filesystem layout +%openpkg_layout macrosfile=%{macrosfile} layout=global + +# layout determination: RPM macro to RPM Lua entry point +%__openpkg_layout() %{lua: print(openpkg.layout(rpm.expand("%*"))) } + +# calculated base directory (placeholder definition only) +%__openpkg_basedir %{l_prefix} + +# temporary path determination +%__openpkg_tmpdir %{lua: print(openpkg.tmpdir()) } + +# shared environment (SE) support +%__openpkg_SE_id %{l_hostname}-%{l_platform}-%{l_tag} +%__openpkg_SE_subdir %{?__openpkg_shared:/%{__openpkg_SE_id}} + +# layout definition: GLOBAL filesystem layout +%__openpkg_layout_global_specdir() %{l_prefix}/RPM/SRC/%{?name} +%__openpkg_layout_global_sourcedir() %{l_prefix}/RPM/SRC/%{?name} +%__openpkg_layout_global_builddir() %{l_prefix}/RPM/TMP +%__openpkg_layout_global_tmppath() %{l_prefix}/RPM/TMP +%__openpkg_layout_global_rpmdir() %{l_prefix}/RPM/PKG +%__openpkg_layout_global_srcrpmdir() %{l_prefix}/RPM/PKG + +# layout definition: LOCAL filesystem layout +%__openpkg_layout_local_specdir() %{__openpkg_basedir} +%__openpkg_layout_local_sourcedir() %{__openpkg_basedir} +%__openpkg_layout_local_builddir() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} +%__openpkg_layout_local_tmppath() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} +%__openpkg_layout_local_rpmdir() %{__openpkg_basedir} +%__openpkg_layout_local_srcrpmdir() %{__openpkg_basedir} + +# layout definition: SIMPLE local filesystem layout +%__openpkg_layout_simple_specdir() %{__openpkg_basedir} +%__openpkg_layout_simple_sourcedir() %{__openpkg_basedir} +%__openpkg_layout_simple_builddir() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_simple_tmppath() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_simple_rpmdir() %{realpath:%{__openpkg_basedir}/..} +%__openpkg_layout_simple_srcrpmdir() %{realpath:%{__openpkg_basedir}/..} + +# layout definition: STRUCTURED local filesystem layout +%__openpkg_layout_structured_specdir() %{__openpkg_basedir}/src +%__openpkg_layout_structured_sourcedir() %{__openpkg_basedir}/dst %{__openpkg_basedir}/src +%__openpkg_layout_structured_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_structured_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_structured_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} +%__openpkg_layout_structured_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} + +# layout definition: DISTRIBUTED local filesystem layout +%__openpkg_layout_distributed_specdir() %{__openpkg_basedir}/src/%{?name} +%__openpkg_layout_distributed_sourcedir() %{__openpkg_basedir}/dst/%{?name} %{__openpkg_basedir}/src/%{?name} +%__openpkg_layout_distributed_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_distributed_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} +%__openpkg_layout_distributed_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} +%__openpkg_layout_distributed_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} +