michael@13: ## michael@13: ## rpmmacros -- OpenPKG RPM Macros michael@428: ## Copyright (c) 2000-2012 OpenPKG GmbH michael@13: ## michael@428: ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. michael@428: ## All rights reserved. Licenses which grant limited permission to use, michael@428: ## copy, modify and distribute this software are available from the michael@428: ## OpenPKG GmbH. michael@13: ## michael@428: ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED michael@13: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@13: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@13: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@13: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@13: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@13: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@13: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@13: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@13: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@13: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@13: ## SUCH DAMAGE. michael@13: ## michael@428: michael@428: ## michael@13: ## The purpose of this macro set is to override the default michael@13: ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. michael@13: ## michael@13: michael@428: # utility macro for "delayed one-time expansion" of macro bodies michael@428: # (works by redefining a macro in-place to its expanded body on its first usage) michael@428: %l_once() %{expand:%%global %{*}}%{expand:%%{%{1}}} michael@428: michael@13: # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) michael@428: %l_openpkg_release(F:) %(%{l_prefix}/libexec/openpkg/release \\\ michael@428: --release="%{?release}%{!?release:%(%{l_rpm} -q --qf '%{release}' openpkg)}" \\\ michael@428: %{?-F:-F "%{-F*}"}%{!?-F:-F "OpenPKG-%%t"}) michael@13: michael@13: # the OpenPKG OIDs (root is officially registered at IANA) michael@13: %l_openpkg_oid 1.3.6.1.4.1.18749 michael@13: %l_openpkg_oid_bootstrap %{l_openpkg_oid}.4.1 michael@13: %l_openpkg_oid_instance %{l_openpkg_oid_bootstrap}.1 michael@13: %l_openpkg_oid_platform %{l_openpkg_oid_bootstrap}.2 michael@13: %l_openpkg_oid_tagfmtopt %{l_openpkg_oid_bootstrap}.3 michael@13: michael@13: # the OpenPKG package tagging michael@13: %l_tag_fmt @TAG@ michael@428: %l_tag_fmt_compat %(prefix="%{l_prefix_static}"; \ michael@428: if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then \ michael@428: loc=`echo $prefix | cut -c2-4`; \ michael@428: else \ michael@428: loc=`echo $prefix | sed -e 's;/\\(.\\)[^/]*;\\1;g' | cut -c1-3`; \ michael@428: fi; \ michael@428: echo $loc) michael@428: %l_tag_fmt_loc %(echo "%{l_prefix_static}" | \\\ michael@428: sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' \\\ michael@428: -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' \\\ michael@428: -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ michael@428: -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' \\\ michael@428: -e 's;^/\\([^/][^/][^/]\\).*;\\1;' \\\ michael@428: -e 's;^/\\([^/][^/]\\).*;\\1;' \\\ michael@428: -e 's;^/\\([^/]\\).*;\\1;' \\\ michael@428: ) michael@428: %l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; \ michael@428: %{l_uuid} -v3 $uuid_ns '%{?_options}') michael@13: %l_tag_fmt_uuid %(%{l_uuid} -v1) michael@13: %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') michael@13: %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') michael@13: %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') michael@428: %l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | \\\ michael@428: sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} michael@428: %l_tag %{l_once l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g')} michael@13: michael@13: # the OpenPKG instance location (backward compatibility only) michael@13: %l_location %{l_tag} michael@13: michael@13: # standard RPM host platform identification michael@13: # (defaults via "shtool platform" and uname(3); used internally) michael@13: #%_host_cpu ...USE INTERNAL DEFAULT... michael@13: #%_host_vendor ...USE INTERNAL DEFAULT... michael@13: #%_host_os ...USE INTERNAL DEFAULT... michael@13: %_host_alias %{nil} michael@13: %_host %{_host_cpu}-%{_host_os} michael@13: michael@13: # standard RPM build platform identification michael@13: # (defaults via %{_host*} macros; not used internally AFAIK) michael@13: %_build_cpu %{_host_cpu} michael@13: %_build_vendor %{_host_vendor} michael@13: %_build_os %{_host_os} michael@13: %_build_alias %{_host_alias} michael@13: %_build %{_host} michael@13: michael@13: # standard RPM target platform identification michael@13: # (defaults via %{_host*} macros; used internally for %ifarch/%ifnarch) michael@13: %_target_cpu %{_host_cpu} michael@13: %_target_vendor %{_host_vendor} michael@13: %_target_os %{_host_os} michael@13: %_target_alias %{_host_alias} michael@13: %_target %{_host} michael@13: michael@13: # legacy RPM platform macros michael@13: # (defaults via config.guess/config.sub under RPM build-time) michael@13: %_arch %{_host_cpu} michael@13: %_vendor %{_host_vendor} michael@13: %_os %{_host_os} michael@13: michael@13: # legacy RPM platform macros michael@13: # (defaults via various other macros; partly used internally) michael@13: %_build_arch %{_arch} michael@13: %_target_platform %{_target_cpu}-%{_target_vendor}-%{_target_os} michael@13: %_gnu %{nil} michael@13: michael@13: # official OpenPKG host platform identification michael@13: %l_host_arch %{_host_cpu} michael@13: %l_host_vendor %{_host_vendor} michael@13: %l_host_os %{_host_os} michael@13: %l_host %{_host_cpu}-%{_host_os} michael@13: michael@428: # host name or FQDN identification michael@428: %l_hostname(f) %(%{l_shtool} echo -n -e '%%h%{?-f:%%d}') michael@428: michael@13: # new OpenPKG platform identification michael@428: %l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then \ michael@428: fmt="%{-F*}"; \ michael@428: else \ michael@428: T="%{?-c:c}%{?-p:p}%{?-t:t}"; \ michael@428: [ ".$T" = . ] && T="p"; \ michael@428: fmt="%%-%%"; \ michael@428: fi; \ michael@428: %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") michael@13: michael@13: # old OpenPKG platform identification michael@13: %l_target %{l_platform -t} michael@13: michael@428: # UID/GID lookup michael@428: %l_xuid_lookup() %(( getent passwd '%1'; \ michael@428: grep '^%1:' /etc/passwd; \ michael@428: ypmatch '%1' passwd; \ michael@428: nismatch '%1' passwd; \ michael@428: nidump passwd . | grep '^%1:' \ michael@428: ) 2>/dev/null | \ michael@428: sed -e 'q' | \\\ michael@428: awk -F: '{ print $3; }' \ michael@428: ) michael@428: %l_xgid_lookup() %(( getent group '%2'; \ michael@428: grep '^%2:' /etc/group; \ michael@428: ypmatch '%2' group; \ michael@428: nismatch '%2' group; \ michael@428: nidump group . | grep '^%1:' \ michael@428: ) 2>/dev/null | \ michael@428: sed -e 'q' | \\\ michael@428: awk -F: '{ print $3; }' \ michael@428: ) michael@428: michael@13: # the *S*uper-user user/group name/id pair michael@13: %l_susr @SUSR@ michael@13: %l_sgrp @SGRP@ michael@428: %l_suid %{expand:%%{l_xuid_lookup %{l_susr} %{l_sgrp}}} michael@428: %l_sgid %{expand:%%{l_xgid_lookup %{l_susr} %{l_sgrp}}} michael@13: michael@13: # the *M*anagement user/group name/id pair michael@13: %l_musr @MUSR@ michael@13: %l_mgrp @MGRP@ michael@428: %l_muid %{expand:%%{l_xuid_lookup %{l_musr} %{l_mgrp}}} michael@428: %l_mgid %{expand:%%{l_xgid_lookup %{l_musr} %{l_mgrp}}} michael@13: michael@13: # the *R*restricted user/group name/id pair michael@13: %l_rusr @RUSR@ michael@13: %l_rgrp @RGRP@ michael@428: %l_ruid %{expand:%%{l_xuid_lookup %{l_rusr} %{l_rgrp}}} michael@428: %l_rgid %{expand:%%{l_xgid_lookup %{l_rusr} %{l_rgrp}}} michael@13: michael@13: # the *N*on-privileged user/group name/id pair michael@13: %l_nusr @NUSR@ michael@13: %l_ngrp @NGRP@ michael@428: %l_nuid %{expand:%%{l_xuid_lookup %{l_nusr} %{l_ngrp}}} michael@428: %l_ngid %{expand:%%{l_xgid_lookup %{l_nusr} %{l_ngrp}}} michael@13: michael@13: # backward compatibility (openpkg < 20020204) michael@13: %l_fsusr %{l_musr} michael@13: %l_fsgrp %{l_mgrp} michael@13: %l_npuid %{l_nuid} michael@13: %l_npgid %{l_ngid} michael@13: michael@428: # whether we are intended to operate in an environment where michael@428: # only a single unprivileged user account can be used michael@428: %l_unprivileged @l_unprivileged@ michael@428: michael@13: # define the installation hierarchy (used parts) michael@13: %l_prefix @l_prefix@ michael@13: %l_prefix_static @l_prefix_static@ michael@13: michael@13: # define the installation hierarchy (unused parts) michael@13: %l_exec_prefix %{l_prefix} michael@13: %l_bindir %{l_prefix}/bin michael@13: %l_sbindir %{l_prefix}/sbin michael@13: %l_libexecdir %{l_prefix}/libexec michael@13: %l_datadir %{l_prefix}/share michael@13: %l_sysconfdir %{l_prefix}/etc michael@13: %l_sharedstatedir %{l_prefix}/com michael@13: %l_localstatedir %{l_prefix}/var michael@13: %l_libdir %{l_prefix}/lib michael@13: %l_includedir %{l_prefix}/include michael@13: %l_infodir %{l_prefix}/info michael@13: %l_mandir %{l_prefix}/man michael@13: %l_docdir %{l_prefix}/doc michael@13: michael@13: # provide killer macro "%{l_value -s|-b|-c (l_xxx ...|-a|-A)}" which michael@13: # expands to the values of previous l_xxx variables in this file. With michael@13: # option "-s" it expands into a chain of "-e 's;;;g'" michael@13: # constructs for used with Stream Editor sed(1), with option "-b" it michael@13: # expands into a chain of "='';" constructs for use with michael@13: # Bourne-Shell sh(1), with option "-c" it expands into a chain of "set michael@13: # = '';" constructs for use with C-Shell csh(1). But michael@13: # be careful, currently (for expansion speed reasons) is not michael@13: # escaped, so make sure the values of the above macros do not contain michael@13: # ";" for "-s" and ";" for "-b" and "-c". You can either specify one michael@13: # or more names of variables to expand or use "-a" for mostly all michael@13: # variables and "-A" for really all variables. michael@428: %l_value(sbcaA) %{expand:%(\ michael@428: l=""; \ michael@428: for x in \\\ michael@428: `if [ ".%*" != . ]; then \ michael@428: echo "%* "; \ michael@428: else \ michael@428: p=""; \ michael@428: if [ ".%{-a:yes}" = .yes ]; then \ michael@428: p="^%%l_(prefix|[smrn](usr|grp|uid|gid))"; \ michael@428: elif [ ".%{-A:yes}" = .yes ]; then \ michael@428: p="^%%l_"; \ michael@428: fi; \ michael@428: if [ ".$p" != . ]; then \ michael@428: egrep "$p" %{l_prefix}/etc/openpkg/rpmmacros |\\\ michael@428: sed -e '/^%%l_value/,$d' \\\ michael@428: -e 's;^%%\\(l_[a-z1-9_]*\\).*;\\1;'; \ michael@428: fi; \ michael@428: fi`; do \ michael@428: e=""; \ michael@428: if [ ".%{-s:yes}" = .yes ]; then \ michael@428: e="-e 's;@$x@;%%{$x};g'"; \ michael@428: elif [ ".%{-b:yes}" = .yes ]; then \ michael@428: e="$x='%%{$x}';"; \ michael@428: elif [ ".%{-c:yes}" = .yes ]; then \ michael@428: e="set $x = '%%{$x}';"; \ michael@428: else \ michael@428: e="%%{$x}"; \ michael@428: fi; \ michael@428: if [ ".$l" = . ]; then \ michael@428: l="$e"; \ michael@428: else \ michael@428: l="$l $e"; \ michael@428: fi; \ michael@428: done; \ michael@428: echo "$l" \ michael@428: )} michael@13: michael@13: # local version of the empty macro michael@13: %l_nil %{nil} michael@13: michael@428: # local version of the tab character michael@428: %l_tab %{lua: print "\t" } michael@428: michael@13: # override the internal RPM hierarchy variables michael@13: %_usr %{nil} michael@13: %_var %{nil} michael@13: %_usrsrc %{nil} michael@13: %_topdir %{nil} michael@13: %_dbpath %{l_prefix}/RPM/DB michael@13: %_builddir %{l_prefix}/RPM/TMP michael@13: %_tmppath %{l_prefix}/RPM/TMP michael@13: %_sourcedir %{l_prefix}/RPM/SRC/%{name} michael@13: %_specdir %{l_prefix}/RPM/SRC/%{name} michael@13: %_rpmdir %{l_prefix}/RPM/PKG michael@13: %_srcrpmdir %{l_prefix}/RPM/PKG michael@428: %_repackage_dir %{l_prefix}/RPM/TR michael@428: %_cache_dbpath %{l_prefix}/RPM/CACHE michael@428: %_solve_dbpath %{l_prefix}/RPM/CACHE michael@428: %_solve_pkgsdir %{l_prefix}/RPM/CACHE michael@13: %_defaultdocdir %{l_docdir} michael@13: michael@13: # complement the %{SOURCE} and %{PATCH} with %{SOURCE } and %{PATCH } michael@428: %_SOURCE_PATCH() %{lua: \ michael@428: local source1 = rpm.expand("%{_specdir}/%1") \ michael@428: local source2 = rpm.expand("%{_sourcedir}/%1") \ michael@428: if posix.stat(source1) ~= nil then \ michael@428: print(source1) \ michael@428: else \ michael@428: print(source2) \ michael@428: end } michael@428: %SOURCE() %{expand:%%{_SOURCE_PATCH %1}} michael@428: %PATCH() %{expand:%%{_SOURCE_PATCH %1}} michael@13: michael@13: # override RPM's absolute tool paths with relative ones michael@13: # (because if you upgrade RPM it would hard-code tools in own hierarchy, too) michael@13: %__awk awk michael@13: %__bzip2 %{_bzip2bin} michael@13: %__cat cat michael@13: %__chgrp chgrp michael@13: %__chmod chmod michael@13: %__chown chown michael@13: %__cp cp michael@13: %__grep grep michael@13: %__gzip %{_gzipbin} michael@13: %__id id michael@13: %__install install michael@13: %__ln_s ln -s michael@13: %__make make michael@13: %__mkdir mkdir michael@13: %__mkdir_p %{l_shtool} mkdir -p michael@13: %__mv mv michael@13: %__patch %{_patchbin} michael@13: %__perl perl michael@13: %__pgp %{_pgpbin} michael@13: %__rm rm michael@13: %__rsh rsh michael@13: %__sed sed michael@13: %__ssh ssh michael@13: %__tar %{_tarbin} michael@428: %__xz %{_xzbin} michael@13: michael@13: # override some more RPM macros where the default value is not acceptable michael@428: %_dbapi %{l_once _dbapi %(if [ -f "%{_dbpath}/VERSION" ]; then \ michael@428: . "%{_dbpath}/VERSION"; \ michael@428: fi; \ michael@428: echo "${DBAPI:-3}")} michael@428: %__dbi_other %{?_tmppath:tmpdir=%{_tmppath}} %{?__dbi_cdb} %{?__dbi_private:private} michael@428: %__file_context_path %{nil} michael@428: %__check_files %{nil} michael@428: %_patch_suffix -b --suffix .orig michael@428: %_excludedocs 1 michael@13: %_dependency_whiteout %{nil} michael@13: %__debug_install_post %{nil} michael@13: %_unpackaged_files_terminate_build 0 michael@13: michael@13: # provide fixed paths to tools (standard) michael@13: %_gzipbin %{l_prefix}/lib/openpkg/gzip michael@13: %_bzip2bin %{l_prefix}/lib/openpkg/bzip2 michael@428: %_xzbin %{l_prefix}/lib/openpkg/xz michael@13: %_patchbin %{l_prefix}/lib/openpkg/patch michael@13: %_tarbin %{l_prefix}/lib/openpkg/tar michael@428: %__bsdtar %{l_prefix}/lib/openpkg/bsdtar michael@428: %__cpio %{l_prefix}/lib/openpkg/bsdcpio michael@428: %__unzip %{__bsdtar} michael@13: michael@13: # provide path to platform identification file michael@13: %__platform %{l_prefix}/etc/openpkg/platform michael@13: michael@13: # provide fixed paths to tools (additional) michael@428: %l_rc %{l_prefix}/bin/openpkg --keep-privileges rc michael@13: %l_rpm %{l_prefix}/libexec/openpkg/rpm michael@13: %l_rpm2cpio %{l_prefix}/libexec/openpkg/rpm2cpio michael@13: %l_rpm_config %{l_prefix}/libexec/openpkg/rpm-config michael@13: %l_lsync %{l_prefix}/libexec/openpkg/lsync michael@13: %l_rpmtool %{l_prefix}/lib/openpkg/rpmtool michael@13: %l_shtool %{l_prefix}/lib/openpkg/shtool michael@13: %l_curl %{l_prefix}/lib/openpkg/curl michael@13: %l_bash %{l_prefix}/lib/openpkg/bash michael@13: %l_uuid %{l_prefix}/lib/openpkg/uuid michael@13: michael@13: # provide smart paths to tools michael@428: %l_tool_locate() %{lua: \ michael@428: if rpm.expand("%{expand:%%{?use_%1}}") ~= "" then \ michael@428: print(rpm.expand("%{expand:%%{use_%1}}")) \ michael@428: elseif posix.stat(rpm.expand("%{l_prefix}/bin/%2")) ~= nil then \ michael@428: print(rpm.expand("%{l_prefix}/bin/%2")) \ michael@428: elseif posix.stat(rpm.expand("%{l_prefix}/lib/openpkg/%2")) ~= nil then \ michael@428: print(rpm.expand("%{l_prefix}/lib/openpkg/%2")) \ michael@428: else \ michael@428: print(rpm.expand("%2")) \ michael@428: end } michael@428: %l_gzip %{l_once l_gzip %{l_tool_locate gzip gzip}} michael@428: %l_bzip2 %{l_once l_bzip2 %{l_tool_locate bzip2 bzip2}} michael@428: %l_xz %{l_once l_xz %{l_tool_locate xz xz}} michael@428: %l_tar %{l_once l_tar %{l_tool_locate tar tar}} michael@428: %l_make %{l_once l_make %{l_tool_locate make make}} michael@428: %l_cc %{l_once l_cc %{l_tool_locate cc cc}} michael@428: %l_ar %{l_once l_ar %{l_tool_locate ar ar}} michael@428: %l_ld %{l_once l_ld %{l_tool_locate ld ld}} michael@428: %l_as %{l_once l_as %{l_tool_locate as as}} michael@428: %l_strip %{l_once l_strip %{l_tool_locate strip strip}} michael@428: %l_cxx %{l_once l_cxx %{l_tool_locate cxx c++}} michael@428: %l_patch %{l_once l_patch %{l_tool_locate patch patch}} michael@428: %l_sed %{l_once l_sed %{l_tool_locate sed sed}} michael@428: %l_grep %{l_once l_grep %{l_tool_locate grep grep}} michael@428: %l_awk %{l_once l_awk %{l_tool_locate awk awk}} michael@428: %l_autoconf %{l_once l_autoconf %{l_tool_locate autoconf autoconf}} michael@428: %l_automake %{l_once l_automake %{l_tool_locate automake automake}} michael@428: %l_libtool %{l_once l_libtool %{l_tool_locate libtool libtool}} michael@428: %l_flex %{l_once l_flex %{l_tool_locate flex flex}} michael@428: %l_bison %{l_once l_bison %{l_tool_locate bison bison}} michael@428: %l_perl %{l_once l_perl %{l_tool_locate perl perl}} michael@428: %l_miniperl %{l_once l_miniperl %{l_tool_locate miniperl miniperl}} michael@428: %l_openssl %{l_once l_openssl %{l_tool_locate openssl openssl}} michael@428: %l_xmkmf %{l_once l_xmkmf %{l_tool_locate xmkmf xmkmf}} michael@428: %l_vcheck %{l_once l_vcheck %{l_tool_locate vcheck vcheck}} michael@13: michael@13: # tool options michael@13: %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") michael@13: %l_cflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cc}") michael@13: %l_cxxflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cxx}") michael@13: %l_cppflags(i) %(%{l_sane_env}; %{l_rpmtool} cppflags -p%{l_prefix} %{-i:-i} -- %*) michael@13: %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) michael@13: michael@13: # OSSP fake syslog library michael@428: %l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then \ michael@428: flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; \ michael@428: else \ michael@428: flags=''; \ michael@428: fi; \ michael@428: echo $flags) michael@428: %l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then \ michael@428: flags=`(%{l_prefix}/bin/fsl-config --all --libs) 2>/dev/null`; \ michael@428: else \ michael@428: flags=''; \ michael@428: fi; \ michael@428: echo $flags) michael@13: michael@13: # determine the current username michael@428: %l_whoami %{l_once l_whoami %((id -un) 2>/dev/null || \\\ michael@428: (whoami) 2>/dev/null || \\\ michael@428: (who am i | cut "-d " -f1) 2>/dev/null || \\\ michael@428: echo $LOGNAME)} michael@13: michael@13: # macros for dynamically generating a %files list michael@13: %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' michael@13: %l_files_all '%{l_prefix}' michael@13: %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' michael@13: %l_files_std() %l_files_defattr %l_files_all %l_files_noshared michael@13: michael@428: # default %defattr when rolling SRPMS michael@428: %_srcdefattr (-,openpkg,openpkg) michael@428: michael@13: # path to local build root michael@428: %l_buildroot %{_tmppath}/%{name}-%{version}-%{release}-buildroot michael@427: %buildroot %{l_buildroot} michael@13: michael@13: # path to local temporary location michael@13: %l_tmpdir() %{_tmppath} michael@13: %l_tmpfile() %{l_tmpdir}/%{name}-%{version}-%{release}-tmp%{?1:-%1} michael@13: michael@13: # executable path for %post/%pre michael@13: %_install_script_path %{l_prefix}/bin:%{l_prefix}/sbin:/bin:/sbin:/usr/bin:/usr/sbin michael@13: michael@13: # names of RPM files michael@13: %l_srcrpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.src.rpm michael@13: %l_binrpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm michael@13: michael@13: # override the name scheme for RPM files michael@13: %_rpmfilename %{l_binrpmfilename} michael@13: %_build_name_fmt %{l_binrpmfilename} michael@13: %_repackage_name_fmt %{l_binrpmfilename} michael@428: %_solve_name_fmt %{?_solve_pkgsdir}/%{l_binrpmfilename} michael@428: %_query_all_fmt %%{NAME}-%%{VERSION}-%%{RELEASE} michael@428: %___NVRA %%{NAME}-%%{VERSION}-%%{RELEASE} michael@428: michael@428: # do not repackage automatically michael@428: %_repackage_all_erasures 0 michael@13: michael@13: # override the payload compression for the CPIO parts of an RPM michael@13: # (we use the equivalent of "bzip2 -9") michael@13: %_source_payload w9.bzdio michael@13: %_binary_payload w9.bzdio michael@13: michael@13: # package signature type is OpenPGP via GnuPG michael@428: %__gpg %{l_tool_locate gpg gpg} michael@13: %_signature gpg michael@13: michael@13: # two macro-processor add-ons (should be part of forthcoming RPM releases) michael@13: %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} michael@13: %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} michael@13: michael@13: # macro for package option configuration michael@428: %option() %{lua: \ michael@428: local package_name = rpm.expand("%{name}") \ michael@428: local option_name = rpm.expand("%1") \ michael@428: if rpm.expand("%{?" .. option_name .. ":defined}") ~= "defined" then \ michael@428: rpm.expand("%global " .. rpm.expand("%*")) \ michael@428: end \ michael@428: local option_value = rpm.expand("%{" .. option_name .. "}") \ michael@428: option_value = util.rsubst(option_value, "(?s)%", "%%%%") \ michael@428: option_value = util.rsubst(option_value, "(?s) ", "%%20") \ michael@428: option_value = util.rsubst(option_value, "(?s)\\t", "%%09") \ michael@428: rpm.expand("%global _options %{?_options:%{_options}:}" .. option_name .. "=" .. option_value) \ michael@428: print(string.format("Provides: %s::%s = %s\\n", package_name, option_name, option_value)) \ michael@428: } michael@13: michael@13: # macros for NoSource/NoPatch (distribution restriction) integrity handling michael@428: %NoSource() %(if [ ".%{?restriction}" != ".no" ]; then \ michael@428: echo "NoSource: %1"; \ michael@428: fi) \ michael@428: %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} michael@428: %NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then \ michael@428: echo "NoPatch: %1"; fi) \ michael@428: %{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} michael@13: %integrity() %{l_check_nosource} michael@13: michael@13: # macros for checking build environment michael@428: %l_check_nosource() %(%{l_sane_env}; checkok=1; \ michael@428: checkinfo=`echo "Sorry, this OpenPKG package contains a DISTRIBUTION RESTRICTED source file."; \\\ michael@428: echo "Before you can proceed building this package, fetch missing files MANUALLY:"`; \ michael@428: for url in . %{?_restricted}; do \ michael@428: [ ".$url" = .. ] && continue; \ michael@428: eval `echo "$url" | \\\ michael@428: sed -e 's!^\\(.*\\)::/\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ michael@428: -e 's!^\\([^:;][^:]*://.*/\\)\\([^/][^/]*\\)$!;url=\\"\\1\\"; file=\\"\\2\\"!' \\\ michael@428: -e 's:^\\([^;].*\\)$:;url="(unknown location) "; file="\\1":' \\\ michael@428: -e 's:^;::'`; \ michael@428: if [ ! -f "%{_specdir}/$file" ] && [ ! -f "%{_sourcedir}/$file" ]; then \\\ michael@428: checkok=0; \ michael@428: checkinfo=`echo "${checkinfo}"; \\\ michael@428: echo ""; \\\ michael@428: echo "from ${url}"; \\\ michael@428: echo "file ${file}"; \\\ michael@428: echo "here %{_sourcedir}/$file"`; \ michael@428: fi; \ michael@428: done; \ michael@428: if [ $checkok -ne 1 ]; then \ michael@428: echo "set +x"; \ michael@428: echo "$checkinfo" | \\\ michael@428: %{l_rpmtool} msg -b -t error | \\\ michael@428: sed -e 's;^;echo ";' -e 's;$;";'; \ michael@428: echo "exit 1"; \ michael@428: fi) michael@428: %l_check_class() %(%{l_sane_env}; \ michael@428: class=`echo "@:%{?class}:%{?distribution}" | \\\ michael@428: sed -e 's;^@:\\([^:][^:]*\\):.*$;\\1;' \\\ michael@428: -e 's;^@:.*\\[\\(.*\\)\\].*$;\\1;' \\\ michael@428: -e 's;^@:.*$;JUNK;'`; \ michael@428: %{l_rpmtool} check-class "$class") michael@13: %prep %%prep\ michael@13: %{l_check_nosource} \ michael@13: %{l_check_class} \ michael@13: %{nil} michael@13: michael@13: # macro-processor add-on for testing external conditions michael@428: %l_test(pfd) %(if [ ".%{?-p:yes}" = .yes ]; then \ michael@428: %{l_rpm} -q %1 >/dev/null 2>&1; rc=$?; \ michael@428: elif [ ".%{?-f:yes}" = .yes ]; then \ michael@428: test -f %1; rc=$?; \ michael@428: elif [ ".%{?-d:yes}" = .yes ]; then \ michael@428: test -d %1; rc=$?; \ michael@428: fi; \ michael@428: if [ ".$rc" = .0 ]; then \ michael@428: echo "yes"; \ michael@428: else \ michael@428: echo "no"; \ michael@428: fi) michael@13: michael@13: # sane build environment setup michael@428: %l_build_path %{l_once l_build_path %(if [ -d %{l_prefix}/lib/openpkg/override ]; then \ michael@428: echo "%{l_prefix}/lib/openpkg/override:"; \ michael@428: fi)%{l_prefix}/bin:%{l_prefix}/sbin:@l_build_path@%(\ michael@428: if [ -d %{l_prefix}/lib/openpkg/fallback ]; then \ michael@428: echo ":%{l_prefix}/lib/openpkg/fallback"; \ michael@428: fi)} michael@13: %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ michael@13: %l_build_ulim @l_build_ulim@ michael@13: %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash michael@13: %l_build_shell_opt --norc --noprofile --posix michael@13: michael@13: # sane build environment for manual usage in macros (currently just $PATH) michael@428: %l_sane_env PATH="%{l_build_path}"; \ michael@428: export PATH; \ michael@428: LD_LIBRARY_PATH="%{l_build_ldlp}"; \ michael@428: export LD_LIBRARY_PATH michael@13: michael@13: # sane build environment for %prep/%build/%install michael@13: %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} michael@428: %___build_pre HOME="%{l_prefix}"\ michael@428: SHELL="%{l_build_shell_cmd}"\ michael@428: TERM="%{getenv:TERM}"\ michael@428: TMPDIR="%{_tmppath}"\ michael@428: USER="%{getenv:USER}"\ michael@428: LOGNAME="%{getenv:LOGNAME}"\ michael@428: PATH="%{l_build_path}"\ michael@428: LD_LIBRARY_PATH="%{l_build_ldlp}"\ michael@428: export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ michael@428: RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ michael@428: RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ michael@428: RPM_OPT_FLAGS=\"%{optflags}\"\ michael@428: RPM_ARCH=\"%{l_host_arch}\"\ michael@428: RPM_OS=\"%{l_host_os}\"\ michael@428: RPM_DOC_DIR=\"%{_docdir}\"\ michael@428: RPM_PACKAGE_NAME=\"%{name}\"\ michael@428: RPM_PACKAGE_VERSION=\"%{version}\"\ michael@428: RPM_PACKAGE_RELEASE=\"%{release}\"\ michael@428: export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ michael@428: export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ michael@428: %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ michael@428: export RPM_BUILD_ROOT}\ michael@428: %{l_build_ulim}\ michael@428: umask 022\ michael@428: %{verbose:set -x}%{!verbose:exec >/dev/null}\ michael@428: cd %{u2p:%{_builddir}} michael@428: michael@428: # improved %patch macro michael@428: %patch(b:p:P:REz:F:d:e:m:) %{lua: \ michael@428: local subst = "" \ michael@428: local options = rpm.expand("%**") \ michael@428: local regex = "-e\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ michael@428: local pcre = rex_pcre.new(regex) \ michael@428: local n = 0 \ michael@428: while true do \ michael@428: local s, e, t = pcre:tfind(options, n) \ michael@428: if s == nil then break end \ michael@428: subst = subst .. " -e " .. t[1] \ michael@428: n = e + 1 \ michael@428: end \ michael@428: local regex = "-m\\\\s*('[^']*'|\\"[^\\"]*\\"|\\\\S+)" \ michael@428: local pcre = rex_pcre.new(regex) \ michael@428: local n = 0 \ michael@428: while true do \ michael@428: local s, e, t = pcre:tfind(options, n) \ michael@428: if s == nil then break end \ michael@428: subst = subst .. " -e 's;@" .. t[1] .. "@;%{" .. t[1] .. "};g'" \ michael@428: n = e + 1 \ michael@428: end \ michael@428: if subst ~= "" then \ michael@428: subst = "| sed" .. subst \ michael@428: rpm.define("__patch_subst " .. subst) \ michael@428: else \ michael@428: rpm.define("__patch_subst %{nil}") \ michael@428: end \ michael@428: }%{shrink: \ michael@428: %define __patch_number %{-P:%{-P*}}%{!-P:0} \ michael@428: %define __patch_file %{P:%{__patch_number}} \ michael@428: %define __patch_suffix %{-b:-b --suffix %{-b*}}%{!-b:-b --suffix .orig} %{-z:--suffix %{-z*}} \ michael@428: %define __patch_options -s %{-p:-p%{-p*}} %{-F:-F%{-F*}} %{-d:-d%{-d*}} %{-R} %{-E} %{__patch_suffix} \ michael@428: echo "Patch #%{__patch_number} (%{basename:%{__patch_file}}):"; \ michael@428: %{uncompress:%{__patch_file}} %{__patch_subst} | %{__patch} %{__patch_options}}\ michael@428: %{nil} michael@13: michael@13: # special %track section support michael@428: %__spec_track_pre\ michael@428: VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.track.vc"\ michael@13: rm -f $VCFILE\ michael@13: set -o noclobber\ michael@13: sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ michael@13: %{nil} michael@13: %__spec_track_post EOF\ michael@13: if [ ".%{?___track_dump}" = .yes ]; then\ michael@13: cat $VCFILE\ michael@13: else\ michael@13: if [ ! -f "%{l_vcheck}" ]; then\ michael@13: echo "rpm:ERROR: Vendor source tracking functionality currently not available because"\ michael@13: echo "rpm:ERROR: URL tracking tool vcheck(1) not found under \\"%{l_vcheck}\\"."\ michael@13: echo "rpm:ERROR: You have to install the OpenPKG \\"vcheck\\" package first or set"\ michael@13: echo "rpm:ERROR: the RPM macro \\"%%{l_vcheck}\\" to the path of your vcheck(1) tool."\ michael@13: exit 0\ michael@13: fi\ michael@13: ( echo "config = {"\ michael@13: echo "}"\ michael@13: ) >>$VCFILE\ michael@428: %{l_vcheck} %{verbose:--verbose}%{!verbose:--noverbose} -f $VCFILE || true\ michael@13: fi\ michael@13: rm -f $VCFILE\ michael@13: %{nil} michael@13: michael@428: # support additional .spec tags michael@428: %_arbitrary_tags Class:Track:TrackProg:BuildDependency:BuildEnvironment:My*:Local* michael@428: michael@428: # disable /bin/sh dependency (which doesn't fit into OpenPKG's environment) michael@428: %_disable_shell_interpreter_deps 1 michael@428: michael@428: # support downloading files via cURL (instead of internal RPMIO) michael@428: # and optionally also from global and local mirror and backup location(s) michael@428: %__urlgetfile_urls_mirror() \ michael@428: %{nil} michael@428: %__urlgetfile_urls_backup() %{lua: \ michael@428: local url = rpm.expand("%1") \ michael@428: local name = rpm.expand("%{name}") \ michael@428: if name ~= "" and url ~= "" then \ michael@428: local cache = "http://download.openpkg.org/components/cache/" .. name .. "/" \ michael@428: url = util.rsubst(url, "^.+/([^/]+)$", cache .. "%1") \ michael@428: print(url) \ michael@428: end \ michael@428: } michael@428: %__urlgetfile_urls() \ michael@428: %{?__urlgetfile_urls_mirror %1} %1 %{?__urlgetfile_urls_backup %1} michael@428: %__urlgetfile() %{lua: \ michael@428: local url_orig = rpm.expand("%1") \ michael@428: local file = rpm.expand("%2") \ michael@428: local urls = util.rsplit(rpm.expand("%{?__urlgetfile_urls " .. url_orig .. "}"), "\\\\s+") \ michael@428: local result = "ERROR" \ michael@428: local type = "mirror" \ michael@428: for i, url in ipairs(urls) do \ michael@428: if url ~= "" then michael@428: if url == url_orig then \ michael@428: type = "original" \ michael@428: elseif type == "original" then \ michael@428: type = "backup" \ michael@428: end \ michael@428: io.stdout:write(string.format("Fetching(%s): %s\\n", type, url)) \ michael@428: local rc = rpm.expand( \ michael@428: "%(%{l_prefix}/bin/openpkg curl '-#' -L -R -k " .. \ michael@428: "-o '" .. file .. "'" .. " '" .. url .. "' 1>&2; echo $?)" \ michael@428: ) \ michael@428: if rc == "0" then \ michael@428: result = "OK" \ michael@428: break \ michael@428: end \ michael@428: end michael@428: end \ michael@428: print(result) \ michael@428: } michael@428: michael@428: # increase size of line buffer for .spec file parsing michael@428: # from 10KB to 4MB to support rather large BuildEnvironment tags michael@428: %_spec_line_buffer_size 4000000 michael@428: michael@428: # configure auto-generation of OpenPKG "BuildDependency" and "BuildEnvironment" tags michael@428: %__autogen_builddependency 0 michael@428: %__autogen_buildenvironment 0 michael@428: michael@428: # hook into %description michael@428: %description\ michael@428: %{?__hook_description_1}\ michael@428: %{?__hook_description_2}\ michael@428: %{?__hook_description_3}\ michael@428: %{?__hook_description_4}\ michael@428: %{?__hook_description_5}\ michael@428: %{?__hook_description_6}\ michael@428: %{?__hook_description_7}\ michael@428: %{?__hook_description_8}\ michael@428: %{?__hook_description_9}\ michael@428: %%description michael@428: michael@428: # magically provide additional tags which are required but are always the same michael@427: %__hook_description_1 %{lua: \ michael@427: local prefix = rpm.expand("%{l_prefix_static}") \ michael@427: if rpm.expand("%{?prefix}") ~= prefix then \ michael@427: print(string.format("Prefix: %s\\n", prefix)) \ michael@427: end \ michael@427: print("AutoReq: no\\n") \ michael@427: print("AutoReqProv: no\\n") \ michael@427: } michael@427: michael@428: # auto-generate arbitrary tag "Marker" (via "rpm --marker ") michael@428: %__hook_description_2 %{?__marker:Marker: %{__marker}}\ michael@428: %{nil} michael@428: michael@428: # auto-generate arbitrary tag "BuildDependency" from the standard tag(s) "BuildPreReq" michael@428: # in order to forward-carry this build-time information to the binary RPM and to the RPMDB. michael@428: %__hook_description_3 %{?__autogen_builddependency:%{?buildprereq:BuildDependency: %{@buildprereq:, }}}\ michael@428: %{nil} michael@428: michael@428: # magically pickup all patched packaging source files (.orig/.rej) michael@428: %__hook_description_4 %{lua: \ michael@428: -- assemble RPM's information about SourceN and PatchN \ michael@428: local sources = {} \ michael@428: local macros = rpm.macros() \ michael@428: for name, value in pairs(macros) do \ michael@428: local s, _, m = util.rmatch(name, "^(?i)(SOURCE|PATCH)((?:URL)?)(\\\\d+)$") \ michael@428: if s ~= nil and value["body"] ~= nil then \ michael@428: local n = string.upper(string.sub(m[1], 1, 1)) .. string.lower(string.sub(m[1], 2)) .. m[3] \ michael@428: if sources[n] == nil then \ michael@428: sources[n] = { url = "", file = "" } \ michael@428: end \ michael@428: if m[2] ~= nil and m[2] ~= "" then \ michael@428: sources[n].url = value["body"] \ michael@428: else \ michael@428: sources[n].file = value["body"] \ michael@428: end \ michael@428: end \ michael@428: end \ michael@428: \ michael@428: -- add implicit .spec source file \ michael@428: sources["Source999"] = { \ michael@428: url = rpm.expand("%{name}.spec"), \ michael@428: file = rpm.expand("%{_specdir}/%{name}.spec") \ michael@428: } \ michael@428: \ michael@428: -- auto-generate tags for local SourceN and PatchN files \ michael@428: -- where any corresponding .orig/.rej files exists \ michael@428: for id, s in pairs(sources) do \ michael@428: if util.rmatch(s.url, "^(?:ftp|https?)://.+") == nil then \ michael@428: for i, ext in ipairs({ ".orig", ".rej" }) do \ michael@428: if posix.access(s.file .. ext, "r") == 0 then \ michael@428: local _, _, m = util.rmatch(id, "^(?i)(Source|Patch)(\\\\d+)$") \ michael@428: local tag = string.format("%s%d: %s\\n", m[1], 10000 * i + m[2], s.url .. ext) \ michael@428: print(tag) \ michael@428: end \ michael@428: end \ michael@428: end \ michael@428: end \ michael@428: } michael@428: michael@428: # recursive package environment tracking configuration michael@428: %__environment_delete_nve_regex ^gpg-pubkey-[^-]+-[^-]+$ michael@428: %__environment_prune_nve_regex ^%{name}-[^-]+-[^-]+$ michael@428: %__environment_prune_depth_number 3 michael@428: %__environment_debug 0 michael@428: michael@428: # recursive package environment implementation michael@428: %__hook_description_5 %{nil} michael@428: %__hook_description_5_orig %{?__autogen_buildenvironment:%{lua: \ michael@428: -- determine current debug status quo michael@428: local debug = tonumber(rpm.expand("%{?__environment_debug}%{!?__environment_debug:0}")) \ michael@428: \ michael@428: -- determine current environment in serialized format \ michael@428: -- (which actually is the Lua table constructor syntax) \ michael@428: local result = {} \ michael@428: for _, line in ipairs(rpm.query( \ michael@428: "Q:\\\\[\\"%{name}-%{version}-%{release}\\"\\\\]=" .. \ michael@428: "%|buildenvironment?{%{buildenvironment}}:{\\\\{\\\\}}|,", \ michael@428: true, "*")) do \ michael@428: local s, _, m = util.rmatch(line, "(?s)^Q:(.+)$") \ michael@428: if s ~= nil then \ michael@428: table.insert(result, m[1]) \ michael@428: end \ michael@428: end \ michael@428: local constructor = "{" .. table.concat(result , "") .. "}" \ michael@428: \ michael@428: -- parse current environment \ michael@428: -- (by evaluating the constructor as a Lua script) \ michael@428: local environment = {} \ michael@428: local f = loadstring("return " .. constructor) \ michael@428: if f ~= nil then \ michael@428: environment = f() \ michael@428: else \ michael@428: io.stderr:write("rpm: WARNING: failed to parse Lua table constructor: " .. constructor .. "\\n") \ michael@428: end \ michael@428: if debug > 0 then \ michael@428: io.stdout:write("BuildEnvironment(original): " .. util.dump_object(environment, false) .. "\\n") \ michael@428: end michael@428: \ michael@428: -- prune environment according to configuration \ michael@428: function prune_environment (environment, depth) \ michael@428: local delete_nve_regex = tostring(rpm.expand("%{?__environment_delete_nve_regex}")) \ michael@428: local prune_nve_regex = tostring(rpm.expand("%{?__environment_prune_nve_regex}")) \ michael@428: local prune_depth_number = tonumber(rpm.expand("%{?__environment_prune_depth_number}")) \ michael@428: if type(environment) == "table" then \ michael@428: for nve, _ in pairs(environment) do \ michael@428: if (prune_depth_number ~= nil and prune_depth_number > 0 and depth > prune_depth_number) or \ michael@428: (delete_nve_regex ~= "" and util.rmatch(nve, delete_nve_regex) ~= nil) then \ michael@428: environment[nve] = nil \ michael@428: elseif prune_nve_regex ~= nil and util.rmatch(nve, prune_nve_regex) ~= nil then \ michael@428: environment[nve] = {} \ michael@428: else \ michael@428: prune_environment(environment[nve], depth + 1) \ michael@428: end \ michael@428: end \ michael@428: end \ michael@428: end \ michael@428: prune_environment(environment, 1) \ michael@428: if debug > 0 then \ michael@428: io.stdout:write("BuildEnvironment(pruned): " .. util.dump_object(environment, false) .. "\\n") \ michael@428: end \ michael@428: \ michael@428: -- export serialized environment as an RPM tag \ michael@428: if type(environment) == "table" then \ michael@428: local tag = "BuildEnvironment: " .. util.dump_object(environment, true) .. "\\n" \ michael@428: print(tag) \ michael@428: if debug > 0 then \ michael@428: io.stdout:write(tag) \ michael@428: end \ michael@428: end \ michael@428: }} michael@428: michael@428: # recursive package environment XML query support michael@428: %__environment_to_xml %{lua: \ michael@428: local lua = io.stdin:read("*all") \ michael@428: local f = loadstring("return " .. lua) \ michael@428: local xml = "" michael@428: if f ~= nil then \ michael@428: xml = xml .. "\\n" \ michael@428: xml = xml .. "\\n" \ michael@428: function genxml (environment, prefix) \ michael@428: local xml = prefix .. "\\n" \ michael@428: for id, e in pairs(environment) do \ michael@428: xml = xml .. prefix .. " \\n" \ michael@428: xml = xml .. prefix .. " " .. id .. "\\n" \ michael@428: if e ~= nil and next(e) ~= nil then \ michael@428: xml = xml .. genxml(e, prefix .. " ") \ michael@428: end \ michael@428: xml = xml .. prefix .. " \\n" \ michael@428: end \ michael@428: xml = xml .. prefix .. "\\n" \ michael@428: return xml michael@428: end \ michael@428: local environment = f() \ michael@428: xml = xml .. genxml(environment, "") \ michael@428: end \ michael@428: print(xml) michael@428: } michael@428: michael@428: # PGP public key information michael@428: %l_pgpkey(n:F:) %{lua: \ michael@428: local name = rpm.expand("%{?-n:%{-n*}}%{!?-n:openpkg.org}") \ michael@428: local format = rpm.expand("%{?-F:%{-F*}}%{!?-F:%%f:%%i}") \ michael@428: local fn = "?" \ michael@428: local id = "?" \ michael@428: if name == "openpkg.com" then \ michael@428: fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.com.pgp") \ michael@428: id = "7D121A8FC05DC18A4329E9EF67042EC961B7AE34" \ michael@428: elseif name == "openpkg.net" then \ michael@428: fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.net.pgp") \ michael@428: id = "3BD10E1171B22598D7708C48AEBE764552197903" \ michael@428: elseif name == "openpkg.org" then \ michael@428: fn = rpm.expand("%{l_prefix}/etc/openpkg/openpkg.org.pgp") \ michael@428: id = "6D96EFCFCF75328810DB40C2807593E063C4CB9F" \ michael@428: end \ michael@428: local result = util.rsubst(format, "%([nfi])", { ["n"] = name, ["f"] = fn, ["i"] = id }) \ michael@428: print(result) \ michael@428: } michael@428: michael@428: # integrity checking configuration michael@428: %_integrity_spec_cfg_idx %{l_prefix}/etc/openpkg/license michael@428: %_integrity_spec_cfg_dir %{l_prefix}/etc/openpkg/license.d michael@428: %_integrity_spec_cfg %{lua: \ michael@428: local idx = rpm.slurp(rpm.expand("%{_integrity_spec_cfg_idx}")) \ michael@428: idx = util.rsubst(idx, "(?s)\\\\s*(.+?)\\\\s*$", "%1") \ michael@428: local cfg = rpm.expand("%{_integrity_spec_cfg_dir}") .. "/" .. idx \ michael@428: print(cfg) \ michael@428: } michael@428: %_integrity_proc_lua %{l_prefix}/lib/openpkg/license.lua michael@428: %_integrity_pkey_pgp %{l_prefix}/etc/openpkg/openpkg.com.pgp michael@428: michael@428: ## michael@428: ## Support for OpenPKG Flexible Filesystem Layout michael@428: ## michael@428: michael@428: # layout definition: RPM to OpenPKG variable mapping michael@428: %_specdir %{expand:%%global _specdir %%{__openpkg_layout variable=specdir %{?openpkg_layout_specdir} %{!?openpkg_layout_specdir: %{openpkg_layout}}}}%{_specdir} michael@428: %_sourcedir %{expand:%%global _sourcedir %%{__openpkg_layout variable=sourcedir %{?openpkg_layout_sourcedir}%{!?openpkg_layout_sourcedir:%{openpkg_layout}}}}%{_sourcedir} michael@428: %_builddir %{expand:%%global _builddir %%{__openpkg_layout variable=builddir %{?openpkg_layout_builddir} %{!?openpkg_layout_builddir: %{openpkg_layout}}}}%{_builddir} michael@428: %_tmppath %{expand:%%global _tmppath %%{__openpkg_layout variable=tmppath %{?openpkg_layout_tmppath} %{!?openpkg_layout_tmppath: %{openpkg_layout}}}}%{_tmppath} michael@428: %_rpmdir %{expand:%%global _rpmdir %%{__openpkg_layout variable=rpmdir %{?openpkg_layout_rpmdir} %{!?openpkg_layout_rpmdir: %{openpkg_layout}}}}%{_rpmdir} michael@428: %_srcrpmdir %{expand:%%global _srcrpmdir %%{__openpkg_layout variable=srcrpmdir %{?openpkg_layout_srcrpmdir}%{!?openpkg_layout_srcrpmdir:%{openpkg_layout}}}}%{_srcrpmdir} michael@428: michael@428: # default OpenPKG filesystem layout michael@428: %openpkg_layout macrosfile=%{macrosfile} layout=global michael@428: michael@428: # layout determination: RPM macro to RPM Lua entry point michael@428: %__openpkg_layout() %{lua: print(openpkg.layout(rpm.expand("%*"))) } michael@428: michael@428: # calculated base directory (placeholder definition only) michael@428: %__openpkg_basedir %{l_prefix} michael@428: michael@428: # temporary path determination michael@428: %__openpkg_tmpdir %{lua: print(openpkg.tmpdir()) } michael@428: michael@428: # shared environment (SE) support michael@428: %__openpkg_SE_id %{l_hostname}-%{l_platform}-%{l_tag} michael@428: %__openpkg_SE_subdir %{?__openpkg_shared:/%{__openpkg_SE_id}} michael@428: michael@428: # layout definition: GLOBAL filesystem layout michael@428: %__openpkg_layout_global_specdir() %{l_prefix}/RPM/SRC/%{?name} michael@428: %__openpkg_layout_global_sourcedir() %{l_prefix}/RPM/SRC/%{?name} michael@428: %__openpkg_layout_global_builddir() %{l_prefix}/RPM/TMP michael@428: %__openpkg_layout_global_tmppath() %{l_prefix}/RPM/TMP michael@428: %__openpkg_layout_global_rpmdir() %{l_prefix}/RPM/PKG michael@428: %__openpkg_layout_global_srcrpmdir() %{l_prefix}/RPM/PKG michael@428: michael@428: # layout definition: LOCAL filesystem layout michael@428: %__openpkg_layout_local_specdir() %{__openpkg_basedir} michael@428: %__openpkg_layout_local_sourcedir() %{__openpkg_basedir} michael@428: %__openpkg_layout_local_builddir() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_local_tmppath() %{__openpkg_basedir}/.openpkg-tmp:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_local_rpmdir() %{__openpkg_basedir} michael@428: %__openpkg_layout_local_srcrpmdir() %{__openpkg_basedir} michael@428: michael@428: # layout definition: SIMPLE local filesystem layout michael@428: %__openpkg_layout_simple_specdir() %{__openpkg_basedir} michael@428: %__openpkg_layout_simple_sourcedir() %{__openpkg_basedir} michael@428: %__openpkg_layout_simple_builddir() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_simple_tmppath() %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_simple_rpmdir() %{realpath:%{__openpkg_basedir}/..} michael@428: %__openpkg_layout_simple_srcrpmdir() %{realpath:%{__openpkg_basedir}/..} michael@428: michael@428: # layout definition: STRUCTURED local filesystem layout michael@428: %__openpkg_layout_structured_specdir() %{__openpkg_basedir}/src michael@428: %__openpkg_layout_structured_sourcedir() %{__openpkg_basedir}/dst %{__openpkg_basedir}/src michael@428: %__openpkg_layout_structured_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_structured_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_structured_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} michael@428: %__openpkg_layout_structured_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} michael@428: michael@428: # layout definition: DISTRIBUTED local filesystem layout michael@428: %__openpkg_layout_distributed_specdir() %{__openpkg_basedir}/src/%{?name} michael@428: %__openpkg_layout_distributed_sourcedir() %{__openpkg_basedir}/dst/%{?name} %{__openpkg_basedir}/src/%{?name} michael@428: %__openpkg_layout_distributed_builddir() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_distributed_tmppath() %{__openpkg_basedir}/tmp:+%{__openpkg_SE_subdir} %{__openpkg_tmpdir}:+%{__openpkg_SE_subdir} michael@428: %__openpkg_layout_distributed_rpmdir() %{__openpkg_basedir}/pkg/bin %{__openpkg_basedir}/pkg %{__openpkg_basedir} michael@428: %__openpkg_layout_distributed_srcrpmdir() %{__openpkg_basedir}/pkg/src %{__openpkg_basedir}/pkg %{__openpkg_basedir} michael@428: