Wed, 21 Sep 2011 13:51:49 +0200
Update version and integrate setuid logic from upstream package vendor.
michael@13 | 1 | ## |
michael@13 | 2 | ## rpmmacros -- OpenPKG RPM Macros |
michael@13 | 3 | ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/> |
michael@13 | 4 | ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/> |
michael@13 | 5 | ## |
michael@13 | 6 | ## Permission to use, copy, modify, and distribute this software for |
michael@13 | 7 | ## any purpose with or without fee is hereby granted, provided that |
michael@13 | 8 | ## the above copyright notice and this permission notice appear in all |
michael@13 | 9 | ## copies. |
michael@13 | 10 | ## |
michael@13 | 11 | ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
michael@13 | 12 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@13 | 13 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@13 | 14 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@13 | 15 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@13 | 16 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@13 | 17 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@13 | 18 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@13 | 19 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@13 | 20 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@13 | 21 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@13 | 22 | ## SUCH DAMAGE. |
michael@13 | 23 | ## |
michael@13 | 24 | ## The purpose of this macro set is to override the default |
michael@13 | 25 | ## macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy. |
michael@13 | 26 | ## |
michael@13 | 27 | |
michael@13 | 28 | # the OpenPKG release identification (for the current package or as a fallback for the bootstrap package) |
michael@13 | 29 | %l_openpkg_release(F:) %(%{l_prefix}/libexec/openpkg/release --release="%{?release}%{!?release:%(%{l_rpm} -q --qf '%{release}' openpkg)}" %{?-F:-F "%{-F*}"}%{!?-F:-F "OpenPKG-%%t"}) |
michael@13 | 30 | |
michael@13 | 31 | # the OpenPKG OIDs (root is officially registered at IANA) |
michael@13 | 32 | %l_openpkg_oid 1.3.6.1.4.1.18749 |
michael@13 | 33 | %l_openpkg_oid_bootstrap %{l_openpkg_oid}.4.1 |
michael@13 | 34 | %l_openpkg_oid_instance %{l_openpkg_oid_bootstrap}.1 |
michael@13 | 35 | %l_openpkg_oid_platform %{l_openpkg_oid_bootstrap}.2 |
michael@13 | 36 | %l_openpkg_oid_tagfmtopt %{l_openpkg_oid_bootstrap}.3 |
michael@13 | 37 | |
michael@13 | 38 | # the OpenPKG package tagging |
michael@13 | 39 | %l_tag_fmt @TAG@ |
michael@13 | 40 | %l_tag_fmt_compat %(prefix="%{l_prefix_static}"; if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then loc=`echo $prefix | cut -c2-4`; else loc=`echo $prefix | sed -e 's;/\\(.\\)[^/]*;\\1;g' | cut -c1-3`; fi; echo $loc) |
michael@13 | 41 | %l_tag_fmt_loc %(echo "%{l_prefix_static}" | sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/][^/]\\).*;\\1;' -e 's;^/\\([^/][^/]\\).*;\\1;' -e 's;^/\\([^/]\\).*;\\1;') |
michael@13 | 42 | %l_tag_fmt_opt %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; %{l_uuid} -v3 $uuid_ns '%{?_options}') |
michael@13 | 43 | %l_tag_fmt_uuid %(%{l_uuid} -v1) |
michael@13 | 44 | %l_tag_fmt_time %(date '+%%Y%%m%%d%%H%%M%%S') |
michael@13 | 45 | %l_tag_fmt_user %(%{l_shtool} echo -e '%%u') |
michael@13 | 46 | %l_tag_fmt_host %(%{l_shtool} echo -e '%%h%%d') |
michael@13 | 47 | %l_tag_gen %{expand:%(echo '%{l_tag_fmt}' | sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')} |
michael@13 | 48 | %l_tag %(echo "%{l_tag_gen}" | sed -e 's;-;;g') |
michael@13 | 49 | |
michael@13 | 50 | # the OpenPKG instance location (backward compatibility only) |
michael@13 | 51 | %l_location %{l_tag} |
michael@13 | 52 | |
michael@13 | 53 | # standard RPM host platform identification |
michael@13 | 54 | # (defaults via "shtool platform" and uname(3); used internally) |
michael@13 | 55 | #%_host_cpu ...USE INTERNAL DEFAULT... |
michael@13 | 56 | #%_host_vendor ...USE INTERNAL DEFAULT... |
michael@13 | 57 | #%_host_os ...USE INTERNAL DEFAULT... |
michael@13 | 58 | %_host_alias %{nil} |
michael@13 | 59 | %_host %{_host_cpu}-%{_host_os} |
michael@13 | 60 | |
michael@13 | 61 | # standard RPM build platform identification |
michael@13 | 62 | # (defaults via %{_host*} macros; not used internally AFAIK) |
michael@13 | 63 | %_build_cpu %{_host_cpu} |
michael@13 | 64 | %_build_vendor %{_host_vendor} |
michael@13 | 65 | %_build_os %{_host_os} |
michael@13 | 66 | %_build_alias %{_host_alias} |
michael@13 | 67 | %_build %{_host} |
michael@13 | 68 | |
michael@13 | 69 | # standard RPM target platform identification |
michael@13 | 70 | # (defaults via %{_host*} macros; used internally for %ifarch/%ifnarch) |
michael@13 | 71 | %_target_cpu %{_host_cpu} |
michael@13 | 72 | %_target_vendor %{_host_vendor} |
michael@13 | 73 | %_target_os %{_host_os} |
michael@13 | 74 | %_target_alias %{_host_alias} |
michael@13 | 75 | %_target %{_host} |
michael@13 | 76 | |
michael@13 | 77 | # legacy RPM platform macros |
michael@13 | 78 | # (defaults via config.guess/config.sub under RPM build-time) |
michael@13 | 79 | %_arch %{_host_cpu} |
michael@13 | 80 | %_vendor %{_host_vendor} |
michael@13 | 81 | %_os %{_host_os} |
michael@13 | 82 | |
michael@13 | 83 | # legacy RPM platform macros |
michael@13 | 84 | # (defaults via various other macros; partly used internally) |
michael@13 | 85 | %_build_arch %{_arch} |
michael@13 | 86 | %_target_platform %{_target_cpu}-%{_target_vendor}-%{_target_os} |
michael@13 | 87 | %_gnu %{nil} |
michael@13 | 88 | |
michael@13 | 89 | # official OpenPKG host platform identification |
michael@13 | 90 | %l_host_arch %{_host_cpu} |
michael@13 | 91 | %l_host_vendor %{_host_vendor} |
michael@13 | 92 | %l_host_os %{_host_os} |
michael@13 | 93 | %l_host %{_host_cpu}-%{_host_os} |
michael@13 | 94 | |
michael@13 | 95 | # new OpenPKG platform identification |
michael@13 | 96 | %l_platform(cptF:) %(if [ ".%{?-F}" != . ]; then fmt="%{-F*}"; else T="%{?-c:c}%{?-p:p}%{?-t:t}"; [ ".$T" = . ] && T="p"; fmt="%%<a$T>-%%<s$T>"; fi; %{l_shtool} platform -n -L -S "" -C "+" -F "$fmt") |
michael@13 | 97 | |
michael@13 | 98 | # old OpenPKG platform identification |
michael@13 | 99 | %l_target %{l_platform -t} |
michael@13 | 100 | |
michael@13 | 101 | # the *S*uper-user user/group name/id pair |
michael@13 | 102 | %l_susr @SUSR@ |
michael@13 | 103 | %l_sgrp @SGRP@ |
michael@13 | 104 | %l_suid %((getent passwd "%{l_susr}"; grep "^%{l_susr}:" /etc/passwd; ypmatch "%{l_susr}" passwd; nismatch "%{l_susr}" passwd; nidump passwd . | grep "^%{l_susr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 105 | %l_sgid %((getent group "%{l_sgrp}"; grep "^%{l_sgrp}:" /etc/group; ypmatch "%{l_sgrp}" group; nismatch "%{l_sgrp}" group; nidump group . | grep "^%{l_susr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 106 | |
michael@13 | 107 | # the *M*anagement user/group name/id pair |
michael@13 | 108 | %l_musr @MUSR@ |
michael@13 | 109 | %l_mgrp @MGRP@ |
michael@13 | 110 | %l_muid %((getent passwd "%{l_musr}"; grep "^%{l_musr}:" /etc/passwd; ypmatch "%{l_musr}" passwd; nismatch "%{l_musr}" passwd; nidump passwd . | grep "^%{l_musr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 111 | %l_mgid %((getent group "%{l_mgrp}"; grep "^%{l_mgrp}:" /etc/group; ypmatch "%{l_mgrp}" group; nismatch "%{l_mgrp}" group; nidump group . | grep "^%{l_musr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 112 | |
michael@13 | 113 | # the *R*restricted user/group name/id pair |
michael@13 | 114 | %l_rusr @RUSR@ |
michael@13 | 115 | %l_rgrp @RGRP@ |
michael@13 | 116 | %l_ruid %((getent passwd "%{l_rusr}"; grep "^%{l_rusr}:" /etc/passwd; ypmatch "%{l_rusr}" passwd; nismatch "%{l_rusr}" passwd; nidump passwd . | grep "^%{l_rusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 117 | %l_rgid %((getent group "%{l_rgrp}"; grep "^%{l_rgrp}:" /etc/group; ypmatch "%{l_rgrp}" group; nismatch "%{l_rgrp}" group; nidump group . | grep "^%{l_rusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 118 | |
michael@13 | 119 | # the *N*on-privileged user/group name/id pair |
michael@13 | 120 | %l_nusr @NUSR@ |
michael@13 | 121 | %l_ngrp @NGRP@ |
michael@13 | 122 | %l_nuid %((getent passwd "%{l_nusr}"; grep "^%{l_nusr}:" /etc/passwd; ypmatch "%{l_nusr}" passwd; nismatch "%{l_nusr}" passwd; nidump passwd . | grep "^%{l_nusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 123 | %l_ngid %((getent group "%{l_ngrp}"; grep "^%{l_ngrp}:" /etc/group; ypmatch "%{l_ngrp}" group; nismatch "%{l_ngrp}" group; nidump group . | grep "^%{l_nusr}:") 2>/dev/null | sed -e 'q' | awk -F: '{ print $3; }') |
michael@13 | 124 | |
michael@13 | 125 | # backward compatibility (openpkg < 20020204) |
michael@13 | 126 | %l_fsusr %{l_musr} |
michael@13 | 127 | %l_fsgrp %{l_mgrp} |
michael@13 | 128 | %l_npuid %{l_nuid} |
michael@13 | 129 | %l_npgid %{l_ngid} |
michael@13 | 130 | |
michael@13 | 131 | # define the installation hierarchy (used parts) |
michael@13 | 132 | %l_prefix @l_prefix@ |
michael@13 | 133 | %l_prefix_static @l_prefix_static@ |
michael@13 | 134 | |
michael@13 | 135 | # define the installation hierarchy (unused parts) |
michael@13 | 136 | %l_exec_prefix %{l_prefix} |
michael@13 | 137 | %l_bindir %{l_prefix}/bin |
michael@13 | 138 | %l_sbindir %{l_prefix}/sbin |
michael@13 | 139 | %l_libexecdir %{l_prefix}/libexec |
michael@13 | 140 | %l_datadir %{l_prefix}/share |
michael@13 | 141 | %l_sysconfdir %{l_prefix}/etc |
michael@13 | 142 | %l_sharedstatedir %{l_prefix}/com |
michael@13 | 143 | %l_localstatedir %{l_prefix}/var |
michael@13 | 144 | %l_libdir %{l_prefix}/lib |
michael@13 | 145 | %l_includedir %{l_prefix}/include |
michael@13 | 146 | %l_infodir %{l_prefix}/info |
michael@13 | 147 | %l_mandir %{l_prefix}/man |
michael@13 | 148 | %l_docdir %{l_prefix}/doc |
michael@13 | 149 | |
michael@13 | 150 | # provide killer macro "%{l_value -s|-b|-c (l_xxx ...|-a|-A)}" which |
michael@13 | 151 | # expands to the values of previous l_xxx variables in this file. With |
michael@13 | 152 | # option "-s" it expands into a chain of "-e 's;<name>;<value>;g'" |
michael@13 | 153 | # constructs for used with Stream Editor sed(1), with option "-b" it |
michael@13 | 154 | # expands into a chain of "<name>='<value>';" constructs for use with |
michael@13 | 155 | # Bourne-Shell sh(1), with option "-c" it expands into a chain of "set |
michael@13 | 156 | # <name> = '<value>';" constructs for use with C-Shell csh(1). But |
michael@13 | 157 | # be careful, <value> currently (for expansion speed reasons) is not |
michael@13 | 158 | # escaped, so make sure the values of the above macros do not contain |
michael@13 | 159 | # ";" for "-s" and ";" for "-b" and "-c". You can either specify one |
michael@13 | 160 | # or more names of variables to expand or use "-a" for mostly all |
michael@13 | 161 | # variables and "-A" for really all variables. |
michael@13 | 162 | %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")} |
michael@13 | 163 | |
michael@13 | 164 | # local version of the empty macro |
michael@13 | 165 | %l_nil %{nil} |
michael@13 | 166 | |
michael@13 | 167 | # override the internal RPM hierarchy variables |
michael@13 | 168 | %_usr %{nil} |
michael@13 | 169 | %_var %{nil} |
michael@13 | 170 | %_usrsrc %{nil} |
michael@13 | 171 | %_topdir %{nil} |
michael@13 | 172 | %_dbpath %{l_prefix}/RPM/DB |
michael@13 | 173 | %_builddir %{l_prefix}/RPM/TMP |
michael@13 | 174 | %_tmppath %{l_prefix}/RPM/TMP |
michael@13 | 175 | %_sourcedir %{l_prefix}/RPM/SRC/%{name} |
michael@13 | 176 | %_specdir %{l_prefix}/RPM/SRC/%{name} |
michael@13 | 177 | %_rpmdir %{l_prefix}/RPM/PKG |
michael@13 | 178 | %_srcrpmdir %{l_prefix}/RPM/PKG |
michael@13 | 179 | %_repackage_dir %{l_prefix}/RPM/PKG |
michael@13 | 180 | %_cache_dbpath %{l_prefix}/RPM/PKG |
michael@13 | 181 | %_solve_dbpath %{l_prefix}/RPM/PKG |
michael@13 | 182 | %_solve_pkgsdir %{l_prefix}/RPM/PKG |
michael@13 | 183 | %_defaultdocdir %{l_docdir} |
michael@13 | 184 | |
michael@13 | 185 | # complement the %{SOURCE<n>} and %{PATCH<n>} with %{SOURCE <file>} and %{PATCH <file>} |
michael@13 | 186 | %SOURCE() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) |
michael@13 | 187 | %PATCH() %(f="%1"; if [ -f "%{_specdir}/$f" ]; then echo "%{_specdir}/$f"; else echo "%{_sourcedir}/$f"; fi) |
michael@13 | 188 | |
michael@13 | 189 | # override RPM's absolute tool paths with relative ones |
michael@13 | 190 | # (because if you upgrade RPM it would hard-code tools in own hierarchy, too) |
michael@13 | 191 | %__awk awk |
michael@13 | 192 | %__bzip2 %{_bzip2bin} |
michael@13 | 193 | %__cat cat |
michael@13 | 194 | %__chgrp chgrp |
michael@13 | 195 | %__chmod chmod |
michael@13 | 196 | %__chown chown |
michael@13 | 197 | %__cp cp |
michael@13 | 198 | %__cpio cpio |
michael@13 | 199 | %__grep grep |
michael@13 | 200 | %__gzip %{_gzipbin} |
michael@13 | 201 | %__id id |
michael@13 | 202 | %__install install |
michael@13 | 203 | %__ln_s ln -s |
michael@13 | 204 | %__make make |
michael@13 | 205 | %__mkdir mkdir |
michael@13 | 206 | %__mkdir_p %{l_shtool} mkdir -p |
michael@13 | 207 | %__mv mv |
michael@13 | 208 | %__patch %{_patchbin} |
michael@13 | 209 | %__perl perl |
michael@13 | 210 | %__pgp %{_pgpbin} |
michael@13 | 211 | %__rm rm |
michael@13 | 212 | %__rsh rsh |
michael@13 | 213 | %__sed sed |
michael@13 | 214 | %__ssh ssh |
michael@13 | 215 | %__tar %{_tarbin} |
michael@13 | 216 | %__unzip %{_unzipbin} |
michael@13 | 217 | |
michael@13 | 218 | # override some more RPM macros where the default value is not acceptable |
michael@13 | 219 | %_dependency_whiteout %{nil} |
michael@13 | 220 | %__debug_install_post %{nil} |
michael@13 | 221 | %_unpackaged_files_terminate_build 0 |
michael@13 | 222 | |
michael@303 | 223 | # override automatic dependency generation |
michael@303 | 224 | %_use_internal_dependency_generator 0 |
michael@303 | 225 | %__find_provides %{nil} |
michael@303 | 226 | %__find_requires %{nil} |
michael@303 | 227 | %__find_prereq %{nil} |
michael@303 | 228 | %__perl_provides %{nil} |
michael@303 | 229 | %__perl_requires %{nil} |
michael@303 | 230 | |
michael@13 | 231 | # provide fixed paths to tools (standard) |
michael@13 | 232 | %_gzipbin %{l_prefix}/lib/openpkg/gzip |
michael@13 | 233 | %_bzip2bin %{l_prefix}/lib/openpkg/bzip2 |
michael@13 | 234 | %_patchbin %{l_prefix}/lib/openpkg/patch |
michael@13 | 235 | %_tarbin %{l_prefix}/lib/openpkg/tar |
michael@13 | 236 | %_unzipbin %{l_prefix}/lib/openpkg/unzip |
michael@13 | 237 | |
michael@13 | 238 | # provide path to platform identification file |
michael@13 | 239 | %__platform %{l_prefix}/etc/openpkg/platform |
michael@13 | 240 | |
michael@13 | 241 | # provide fixed paths to tools (additional) |
michael@13 | 242 | %l_rc %{l_prefix}/etc/rc |
michael@13 | 243 | %l_rpm %{l_prefix}/libexec/openpkg/rpm |
michael@13 | 244 | %l_rpm2cpio %{l_prefix}/libexec/openpkg/rpm2cpio |
michael@13 | 245 | %l_rpm_config %{l_prefix}/libexec/openpkg/rpm-config |
michael@13 | 246 | %l_lsync %{l_prefix}/libexec/openpkg/lsync |
michael@13 | 247 | %l_rpmtool %{l_prefix}/lib/openpkg/rpmtool |
michael@13 | 248 | %l_shtool %{l_prefix}/lib/openpkg/shtool |
michael@13 | 249 | %l_curl %{l_prefix}/lib/openpkg/curl |
michael@13 | 250 | %l_bash %{l_prefix}/lib/openpkg/bash |
michael@13 | 251 | %l_uuid %{l_prefix}/lib/openpkg/uuid |
michael@13 | 252 | |
michael@13 | 253 | # provide smart paths to tools |
michael@13 | 254 | %l_tool_locate() %(if [ ".%{expand:%%{?use_%1}}" != . ]; then tool="%{expand:%%{use_%1}}"; elif [ -f "%{l_prefix}/bin/%2" ]; then tool="%{l_prefix}/bin/%2"; elif [ -f "%{l_prefix}/lib/openpkg/%2" ]; then tool="%{l_prefix}/lib/openpkg/%2"; else tool="%2"; fi; echo $tool) |
michael@13 | 255 | %l_gzip %{l_tool_locate gzip gzip} |
michael@13 | 256 | %l_bzip2 %{l_tool_locate bzip2 bzip2} |
michael@13 | 257 | %l_tar %{l_tool_locate tar tar} |
michael@13 | 258 | %l_make %{l_tool_locate make make} |
michael@13 | 259 | %l_cc %{l_tool_locate cc cc} |
michael@13 | 260 | %l_ar %{l_tool_locate ar ar} |
michael@13 | 261 | %l_ld %{l_tool_locate ld ld} |
michael@13 | 262 | %l_as %{l_tool_locate as as} |
michael@13 | 263 | %l_strip %{l_tool_locate strip strip} |
michael@13 | 264 | %l_cxx %{l_tool_locate cxx c++} |
michael@13 | 265 | %l_patch %{l_tool_locate patch patch} |
michael@13 | 266 | %l_sed %{l_tool_locate sed sed} |
michael@13 | 267 | %l_grep %{l_tool_locate grep grep} |
michael@13 | 268 | %l_awk %{l_tool_locate awk awk} |
michael@13 | 269 | %l_autoconf %{l_tool_locate autoconf autoconf} |
michael@13 | 270 | %l_automake %{l_tool_locate automake automake} |
michael@13 | 271 | %l_libtool %{l_tool_locate libtool libtool} |
michael@13 | 272 | %l_flex %{l_tool_locate flex flex} |
michael@13 | 273 | %l_bison %{l_tool_locate bison bison} |
michael@13 | 274 | %l_perl %{l_tool_locate perl perl} |
michael@13 | 275 | %l_miniperl %{l_tool_locate miniperl miniperl} |
michael@13 | 276 | %l_openssl %{l_tool_locate openssl openssl} |
michael@13 | 277 | %l_xmkmf %{l_tool_locate xmkmf xmkmf} |
michael@13 | 278 | %l_vcheck %{l_tool_locate vcheck vcheck} |
michael@13 | 279 | |
michael@13 | 280 | # tool options |
michael@13 | 281 | %l_mflags(O) %(%{l_sane_env}; %{l_rpmtool} mflags %{-O:-O} "%{l_make}") |
michael@13 | 282 | %l_cflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cc}") |
michael@13 | 283 | %l_cxxflags(O) %(%{l_sane_env}; %{l_rpmtool} cflags %{-O:-O} "%{l_cxx}") |
michael@13 | 284 | %l_cppflags(i) %(%{l_sane_env}; %{l_rpmtool} cppflags -p%{l_prefix} %{-i:-i} -- %*) |
michael@13 | 285 | %l_ldflags() %(%{l_sane_env}; %{l_rpmtool} ldflags -p%{l_prefix} -- %*) |
michael@13 | 286 | |
michael@13 | 287 | # OSSP fake syslog library |
michael@13 | 288 | %l_fsl_ldflags() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --ldflags) 2>/dev/null`; else flags=''; fi; echo $flags) |
michael@13 | 289 | %l_fsl_libs() %(if [ ".%{with_fsl}" = ".yes" ]; then flags=`(%{l_prefix}/bin/fsl-config --all --libs ) 2>/dev/null`; else flags=''; fi; echo $flags) |
michael@13 | 290 | |
michael@13 | 291 | # determine the current username |
michael@13 | 292 | %l_whoami %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME) |
michael@13 | 293 | |
michael@13 | 294 | # macros for dynamically generating a %files list |
michael@13 | 295 | %l_files_defattr '%%defattr(-,%{l_musr},%{l_mgrp})' |
michael@13 | 296 | %l_files_all '%{l_prefix}' |
michael@13 | 297 | %l_files_noshared '%%not %%dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}' |
michael@13 | 298 | %l_files_std() %l_files_defattr %l_files_all %l_files_noshared |
michael@13 | 299 | |
michael@13 | 300 | # path to local build root |
michael@13 | 301 | %l_buildroot %{_tmppath}/%{name}-%{version}-root |
michael@13 | 302 | |
michael@13 | 303 | # path to local temporary location |
michael@13 | 304 | %l_tmpdir() %{_tmppath} |
michael@13 | 305 | %l_tmpfile() %{l_tmpdir}/%{name}-%{version}-%{release}-tmp%{?1:-%1} |
michael@13 | 306 | |
michael@13 | 307 | # executable path for %post/%pre |
michael@13 | 308 | %_install_script_path %{l_prefix}/bin:%{l_prefix}/sbin:/bin:/sbin:/usr/bin:/usr/sbin |
michael@13 | 309 | |
michael@13 | 310 | # names of RPM files |
michael@13 | 311 | %l_srcrpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.src.rpm |
michael@13 | 312 | %l_binrpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm |
michael@13 | 313 | |
michael@13 | 314 | # override the name scheme for RPM files |
michael@13 | 315 | %_rpmfilename %{l_binrpmfilename} |
michael@13 | 316 | %_build_name_fmt %{l_binrpmfilename} |
michael@13 | 317 | %_repackage_name_fmt %{l_binrpmfilename} |
michael@13 | 318 | %_solve_name_fmt %{_solve_pkgsdir}/%{l_binrpmfilename} |
michael@13 | 319 | |
michael@13 | 320 | # override the payload compression for the CPIO parts of an RPM |
michael@13 | 321 | # (we use the equivalent of "bzip2 -9") |
michael@13 | 322 | %_source_payload w9.bzdio |
michael@13 | 323 | %_binary_payload w9.bzdio |
michael@13 | 324 | |
michael@13 | 325 | # package signature type is OpenPGP via GnuPG |
michael@13 | 326 | %__gpg %{l_prefix}/bin/gpg |
michael@13 | 327 | %_signature gpg |
michael@13 | 328 | %__vsflags 1 |
michael@13 | 329 | |
michael@13 | 330 | # two macro-processor add-ons (should be part of forthcoming RPM releases) |
michael@13 | 331 | %ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} |
michael@13 | 332 | %ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} |
michael@13 | 333 | |
michael@13 | 334 | # macro for package option configuration |
michael@13 | 335 | %option() %{expand:%%{!?%{1}:%%global %*}} %{expand:%%global _options %{?_options:%{_options}:}%{1}=%%%{1}} \ |
michael@13 | 336 | Provides: %{name}::%{1} = %(echo '%{expand:%%{%{1}}}' | sed -e 's;%%;%%%%;g' -e 's; ;%%20;g' -e 's; ;%%09;g') |
michael@13 | 337 | |
michael@13 | 338 | # macros for NoSource/NoPatch (distribution restriction) integrity handling |
michael@13 | 339 | %NoSource() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoSource: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{SOURCEURL%1}} |
michael@13 | 340 | %NoPatch() %(if [ ".%{?restriction}" != ".no" ]; then echo "NoPatch: %1"; fi)%{expand:%%global _restricted %{?_restricted:%{_restricted}} %%{PATCHURL%1}} |
michael@13 | 341 | %integrity() %{l_check_nosource} |
michael@13 | 342 | |
michael@13 | 343 | # macros for checking build environment |
michael@13 | 344 | %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) |
michael@13 | 345 | %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") |
michael@13 | 346 | %prep %%prep\ |
michael@13 | 347 | %{l_check_nosource} \ |
michael@13 | 348 | %{l_check_class} \ |
michael@13 | 349 | %{nil} |
michael@13 | 350 | |
michael@13 | 351 | # macro-processor add-on for testing external conditions |
michael@13 | 352 | %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) |
michael@13 | 353 | |
michael@13 | 354 | # default list of vendor source fetching locations |
michael@13 | 355 | %l_fetch_mirror_0 - |
michael@13 | 356 | %l_fetch_mirror_1 - |
michael@13 | 357 | %l_fetch_mirror_2 - |
michael@13 | 358 | %l_fetch_mirror_3 - |
michael@13 | 359 | %l_fetch_mirror_4 - |
michael@13 | 360 | %l_fetch_mirror_5 - |
michael@13 | 361 | %l_fetch_mirror_6 - |
michael@13 | 362 | %l_fetch_mirror_7 - |
michael@13 | 363 | %l_fetch_mirror_8 - |
michael@13 | 364 | %l_fetch_mirror_9 - |
michael@13 | 365 | %l_fetch_backup_0 - |
michael@13 | 366 | %l_fetch_backup_1 - |
michael@13 | 367 | %l_fetch_backup_2 - |
michael@13 | 368 | %l_fetch_backup_3 - |
michael@13 | 369 | %l_fetch_backup_4 - |
michael@13 | 370 | %l_fetch_backup_5 - |
michael@13 | 371 | %l_fetch_backup_6 - |
michael@13 | 372 | %l_fetch_backup_7 - |
michael@13 | 373 | %l_fetch_backup_8 - |
michael@13 | 374 | %l_fetch_backup_9 ftp://ftp.openpkg.org/sources/DST/%{name}/ |
michael@13 | 375 | |
michael@13 | 376 | # sane build environment setup |
michael@13 | 377 | %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) |
michael@13 | 378 | %l_build_ldlp %{l_prefix}/lib:@l_build_ldlp@ |
michael@13 | 379 | %l_build_ulim @l_build_ulim@ |
michael@13 | 380 | %l_build_shell_cmd %{l_prefix}/lib/openpkg/bash |
michael@13 | 381 | %l_build_shell_opt --norc --noprofile --posix |
michael@13 | 382 | |
michael@13 | 383 | # sane build environment for manual usage in macros (currently just $PATH) |
michael@13 | 384 | %l_sane_env PATH="%{l_build_path}"; export PATH; LD_LIBRARY_PATH="%{l_build_ldlp}"; export LD_LIBRARY_PATH |
michael@13 | 385 | |
michael@13 | 386 | # sane build environment for %prep/%build/%install |
michael@13 | 387 | %_buildshell env -i %{l_build_shell_cmd} %{l_build_shell_opt} |
michael@13 | 388 | %___build_pre \ |
michael@13 | 389 | HOME="%{l_prefix}"\ |
michael@13 | 390 | SHELL="%{l_build_shell_cmd}"\ |
michael@13 | 391 | TERM="%(echo $TERM)"\ |
michael@13 | 392 | TMPDIR="%{_tmppath}"\ |
michael@13 | 393 | USER="%(echo $USER)"\ |
michael@13 | 394 | LOGNAME="%(echo $LOGNAME)"\ |
michael@13 | 395 | PATH="%{l_build_path}"\ |
michael@13 | 396 | LD_LIBRARY_PATH="%{l_build_ldlp}"\ |
michael@13 | 397 | export HOME SHELL TMPDIR USER LOGNAME PATH LD_LIBRARY_PATH\ |
michael@13 | 398 | RPM_SOURCE_DIR=\"%{u2p:%{_sourcedir}}\"\ |
michael@13 | 399 | RPM_BUILD_DIR=\"%{u2p:%{_builddir}}\"\ |
michael@13 | 400 | RPM_OPT_FLAGS=\"%{optflags}\"\ |
michael@13 | 401 | RPM_ARCH=\"%{l_host_arch}\"\ |
michael@13 | 402 | RPM_OS=\"%{l_host_os}\"\ |
michael@13 | 403 | RPM_DOC_DIR=\"%{_docdir}\"\ |
michael@13 | 404 | RPM_PACKAGE_NAME=\"%{name}\"\ |
michael@13 | 405 | RPM_PACKAGE_VERSION=\"%{version}\"\ |
michael@13 | 406 | RPM_PACKAGE_RELEASE=\"%{release}\"\ |
michael@13 | 407 | export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR\ |
michael@13 | 408 | export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\ |
michael@13 | 409 | %{?buildroot:RPM_BUILD_ROOT=\"%{u2p:%{buildroot}}\"\ |
michael@13 | 410 | export RPM_BUILD_ROOT}\ |
michael@13 | 411 | %{l_build_ulim}\ |
michael@13 | 412 | umask 022\ |
michael@13 | 413 | %{verbose:set -x}%{!verbose:exec >/dev/null}\ |
michael@13 | 414 | cd %{u2p:%{_builddir}} |
michael@13 | 415 | |
michael@13 | 416 | # special %track section support |
michael@13 | 417 | %__spec_track_template VCFILE="%{_tmppath}/%{name}-%{version}-%{release}.vc"\ |
michael@13 | 418 | rm -f $VCFILE\ |
michael@13 | 419 | set -o noclobber\ |
michael@13 | 420 | sed -e 's;^ *#.*$;;' -e 's;^ ;;' >$VCFILE <<'EOF'\ |
michael@13 | 421 | %{nil} |
michael@13 | 422 | %__spec_track_post EOF\ |
michael@13 | 423 | if [ ".%{?___track_dump}" = .yes ]; then\ |
michael@13 | 424 | cat $VCFILE\ |
michael@13 | 425 | else\ |
michael@13 | 426 | if [ ! -f "%{l_vcheck}" ]; then\ |
michael@13 | 427 | echo "rpm:ERROR: Vendor source tracking functionality currently not available because"\ |
michael@13 | 428 | echo "rpm:ERROR: URL tracking tool vcheck(1) not found under \\"%{l_vcheck}\\"."\ |
michael@13 | 429 | echo "rpm:ERROR: You have to install the OpenPKG \\"vcheck\\" package first or set"\ |
michael@13 | 430 | echo "rpm:ERROR: the RPM macro \\"%%{l_vcheck}\\" to the path of your vcheck(1) tool."\ |
michael@13 | 431 | exit 0\ |
michael@13 | 432 | fi\ |
michael@13 | 433 | ( echo "config = {"\ |
michael@13 | 434 | echo "}"\ |
michael@13 | 435 | ) >>$VCFILE\ |
michael@13 | 436 | %{l_vcheck} -v -f $VCFILE || true\ |
michael@13 | 437 | fi\ |
michael@13 | 438 | rm -f $VCFILE\ |
michael@13 | 439 | %{nil} |
michael@13 | 440 |