]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- py_lint: fix files counting
[packages/rpm-build-macros.git] / rpm.macros
index c12ab2b41b4e4bc2ae5057f5242040e9c15b6fa6..5b816901c6a35700e64b8f41b4da0c131cb9fe0a 100644 (file)
@@ -16,8 +16,8 @@
 %kgcc_package  gcc
 
 # compiler version
-%cc_version    %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version
-%cxx_version   %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version
+%cc_version    %{expand:%%global cc_version %(%{__cc} -dumpversion 2>/dev/null || echo 0.0)}%cc_version
+%cxx_version   %{expand:%%global cxx_version %(%{__cxx} -dumpversion 2>/dev/null || echo 0.0)}%cxx_version
 
 %__rm          /bin/rm --interactive=never
 
 %{?__cc:CC="%{__cc}"} \\\
 %{?__cxx:CXX="%{__cxx}"} \\\
 CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \\\
-CFLAGS="${CFLAGS:-%{rpmcflags}}" \\\
-FFLAGS="${FFLAGS:-%{rpmcflags}}" \\\
-FCFLAGS="${FCFLAGS:-%{rpmcflags}}" \\\
-CXXFLAGS="${CXXFLAGS:-%{rpmcxxflags}}" \\\
-LDFLAGS="${LDFLAGS:-%{rpmldflags}}" \\\
 %{__cmake} \\\
        -DCMAKE_VERBOSE_MAKEFILE=ON \\\
-       -DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \\\
+       -DCMAKE_BUILD_TYPE=%{!?debug:PLD}%{?debug:Debug} \\\
        -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\
        -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
        -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
        -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
        -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\
        -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
+       -DCMAKE_CXX_FLAGS_PLD="${CXXFLAGS:-%{rpmcxxflags} -DNDEBUG}" \\\
+       -DCMAKE_C_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG}" \\\
+       -DCMAKE_Fortran_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG}" \\\
+       -DCMAKE_EXE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
+       -DCMAKE_SHARED_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
+       -DCMAKE_MODULE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\
 %if "%{_lib}" == "lib64" \
        -DLIB_SUFFIX=64 \\\
 %endif \
@@ -659,14 +660,14 @@ fi; }; __spec_install_post_chrpath } } }
 #      %define skip_post_check_so libwithoutfoo.so.* libwithoutbar.so.*
 #
 %__spec_install_post_check_so { \
- __spec_install_post_check_so() { \
-    fail=0; \
-    printf "Searching for shared objects with unresolved symbols..."; \
-    for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
-        LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; symbols = "" } /^[0-9a-z]+ +D +\*UND\*/ { if ($NF in skip) { next; }; found = 1; symbols = symbols "\n\t" $NF } END { if (found) { print "\nUnresolved symbols found in: " file symbols; %{?skip_post_check_so:split("%{skip_post_check_so}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "Library marked with skip_post_check_so, ignoring errors.\n"; exit(0); } } } exit(1); } } ' || fail=1 ; \
-    done ; \
-    echo " DONE"; \
-    %{!?no_install_post_check_so:return $fail;} \
+__spec_install_post_check_so() { \
+       fail=0; \
+       printf "Searching for shared objects with unresolved symbols..."; \
+       for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
+               LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; symbols = "" } /^[0-9a-z]+ +D +\*UND\*/ { if ($NF in skip) { next; }; found = 1; symbols = symbols "\n\t" $NF } END { if (found) { print "\nUnresolved symbols found in: " file symbols; %{?skip_post_check_so:split("%{skip_post_check_so}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "Library marked with skip_post_check_so, ignoring errors.\n"; exit(0); } } } exit(1); } } ' || fail=1 ; \
+       done ; \
+       echo " DONE"; \
+       %{!?no_install_post_check_so:return $fail;} \
 }; __spec_install_post_check_so }}
 
 #-----------------------------------------------------------------
@@ -744,11 +745,16 @@ fi; \
 
 #-----------------------------------------------------------------
 # Update icon cache
-# requires: gtk+
+# BuildRequires:  rpmbuild(macros) >= 1.596
+# Requires:  hicolor-icon-theme
 #
 %update_icon_cache() {{ \
-       umask 022; \
-       /usr/bin/gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
+       %{!?1:%{error:%{0}: Required theme name missing}} \
+       if [ -x /usr/bin/gtk-update-icon-cache ]; then \
+               umask 022; \
+               touch --no-create %{_iconsdir}/%1; \
+               /usr/bin/gtk-update-icon-cache -qf %{_iconsdir}/%1; \
+       fi; \
 };} \
 %{nil}
 
@@ -766,6 +772,16 @@ if [ "$1" = "0" ]; then \
 fi; \
 %{nil}
 
+#-----------------------------------------------------------------
+# Compile GSettings schemas
+# requires: glib2 >= 1:2.26.0
+#
+%glib_compile_schemas() {{ \
+       umask 022; \
+       /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas; \
+};} \
+%{nil}
+
 #-----------------------------------------------------------------
 # post %install sequence:
 # - autodeps exceptions
@@ -1063,7 +1079,7 @@ fi; \
 # banner support (useful in {pre,post}{,un} and triggers)
 #
 # Usage:
-#      %banner name [-a] [-e] [-n] [-tn] <<EOF
+#      %banner name [-a] [-e] [-n] [-tn] [-o] <<EOF
 # the banner text, the banner text
 # the banner text, and following line
 #EOF
@@ -1074,12 +1090,16 @@ fi; \
 # -e   - send to stderr instead of stdout
 # -n   - no show banner (overrides -t)
 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
+# -o   - show only once, i.e when package is installed for the first time
 #
 # Tests:
 # (rpm -E '%banner -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
+# (rpm -E '%banner -o -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m
+# (rpm -E '%banner -o -e banner <<EOF'; echo -e 'hi\nEOF') > m; sh -x m 1
 # rpm -E 'date | %banner -e banner' > m; sh -x m
+# rpm -E 'date | %banner -o -e banner' > m; sh -x m
 #
-%banner(aent:) ( \
+%banner(aenot:) %{-o:([ "$1" != 1 ] ||} ( \
 RPM_SCRIPTVERBOSITY=5 \
 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
 if [ -x /usr/bin/banner.sh ]; then \
@@ -1087,7 +1107,7 @@ if [ -x /usr/bin/banner.sh ]; then \
 else \
        CMD="cat%{-e: >&2}" \
 fi \
-eval $CMD %{?2:%2}%{?3: %3}) \
+eval $CMD %{?2:%2}%{?3: %3})%{-o:)} \
 %{nil}
 
 # useradd/groupadd macros
@@ -1456,10 +1476,13 @@ cat %{-z:$_N/}.install.log | %__pear_install_log \
 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
 %{nil}
 
-# Copies exctracted PEAR package structure and PEAR registry to buildroot.
+# Copies extracted PEAR package structure and PEAR registry to buildroot.
 # Author: Elan Ruusamäe <glen@pld-linux.org>
 %pear_package_install() \
 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
+# tests should not be packaged \
+%{__rm} -rf $RPM_BUILD_ROOT%{php_pear_dir}/tests \
+# cleanup backups \
 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
 # help the developer out a little: \
 if [ -f _noautoreq ]; then \
@@ -1834,7 +1857,7 @@ io.open("/etc/shells", "w"):write(s)\
 #
 # Requirements:
 # BuildRequires:       python
-# BuildRequires:       rpmbuild(macros) >= 1.469
+# BuildRequires:       rpmbuild(macros) >= 1.602
 
 %py_lint() \
 __py_lint() { \
@@ -1842,22 +1865,26 @@ find "$@" -type f -name '*.py' | python -c ' \
 import sys \
 import compiler \
 \
-err = 0\
+found = err = 0\
 for f in sys.stdin: \
-       fd = open(f.strip()) \
+       fd = open(f.rstrip()) \
        c = fd.read() \
        fd.close() \
+       found = found + 1 \
        try: \
                compiler.parse(c) \
        except SyntaxError, e: \
-               print "py_lint: %s: %s" % (f.strip(), e) \
+               print "py_lint: %s: %s" % (f.rstrip(), e) \
                err = err + 1\
 \
-if err: \
+if not found:\
+       print >> sys.stderr, "\\npy_lint: ERROR: No files processed.\\n" \
+       sys.exit(1) \
+elif err: \
        print >> sys.stderr, "\\npy_lint: ERROR: Syntax errors in %d files.\\n" % err \
        sys.exit(1) \
 else: \
-       print >> sys.stderr,  "py_lint: Found no syntax errors." \
+       print >> sys.stderr,  "py_lint: %d files scanned, found no syntax errors." % found \
 ' \
 }; __py_lint %* \
 %{nil}
This page took 0.037499 seconds and 4 git commands to generate.