[ghc-rpm-macros] replace %cabal_tweak_dep_ver with cabal-tweak-dep-ver script

Jens Petersen petersen at fedoraproject.org
Fri Jun 22 04:47:08 UTC 2012


commit 7cdea6ff7e7f816c2f3f149e71a3e73365287fe3
Author: Jens Petersen <petersen at redhat.com>
Date:   Fri Jun 22 13:46:59 2012 +0900

    replace %cabal_tweak_dep_ver with cabal-tweak-dep-ver script
    
    rpmbuild doesn't handle spaces in quoted args

 cabal-tweak-dep-ver |   22 ++++++++++++++++++++++
 ghc-rpm-macros.ghc  |    8 --------
 ghc-rpm-macros.spec |    6 +++++-
 3 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/cabal-tweak-dep-ver b/cabal-tweak-dep-ver
new file mode 100755
index 0000000..b637eed
--- /dev/null
+++ b/cabal-tweak-dep-ver
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+USAGE="Usage: $0 dep old new"
+
+if [ $# -ne 3 ]; then
+    echo "$USAGE"
+    exit 1
+fi
+
+CABALFILE=*.cabal
+
+if [ $(ls $CABALFILE | wc -l) -ne 1 ]; then
+   echo "There needs to be one .cabal file in the current dir!"
+   exit 1
+fi
+
+if ! grep -q "$1.*$2" $CABALFILE; then
+   echo "$CABALFILE does not match: $1 $2" 
+   exit 1
+fi
+
+sed -i.$1 -e "s/\($1.*\)$2/\1$3/g" $CABALFILE
diff --git a/ghc-rpm-macros.ghc b/ghc-rpm-macros.ghc
index 0e94ec6..13879bf 100644
--- a/ghc-rpm-macros.ghc
+++ b/ghc-rpm-macros.ghc
@@ -18,14 +18,6 @@ proceeding, to avoid dependency ABI breakage from a future ghc rebuild."\
 %endif\
 fi
 
-# tweak depends versions
-# cabal_tweak_dep_ver dep old new [backup]
-%cabal_tweak_dep_ver()\
-if ! grep -q "%1[ >=].*%2"; then\
-   exit 1\
-fi\
-sed -i.%{?3}%1 -e "s/\(%1[ >=].*\)%2/\1%3/g" %{pkg_name}-%{version}/%{pkg_name}.cabal
-
 # configure
 %cabal_configure\
 %ghc_check_bootstrap\
diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec
index 82a7a62..c5ac739 100644
--- a/ghc-rpm-macros.spec
+++ b/ghc-rpm-macros.spec
@@ -19,6 +19,7 @@ Source0:        ghc-rpm-macros.ghc
 Source1:        COPYING
 Source2:        AUTHORS
 Source3:        ghc-deps.sh
+Source4:        cabal-tweak-dep-ver
 Requires:       redhat-rpm-config
 
 %description
@@ -41,6 +42,8 @@ install -p -D -m 0644 %{SOURCE0} ${RPM_BUILD_ROOT}/%{macros_file}
 
 install -p -D -m 0755 %{SOURCE3} %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh
 
+install -p -D -m 0755 %{SOURCE4} %{buildroot}/%{_bindir}/cabal-tweak-dep-ver
+
 # this is why this package is now arch-dependent:
 # turn off shared libs and dynamic linking on secondary archs
 %ifnarch %{ix86} x86_64
@@ -57,11 +60,12 @@ EOF
 %doc COPYING AUTHORS
 %config(noreplace) %{macros_file}
 %{_prefix}/lib/rpm/ghc-deps.sh
+%{_bindir}/cabal-tweak-dep-ver
 
 
 %changelog
 * Fri Jun 22 2012 Jens Petersen <petersen at redhat.com> - 0.95.4-1
-- add cabal_tweak_dep_ver macro to tweak a depend's version bound in .cabal
+- new cabal-tweak-dep-ver script to tweak depends version bounds in .cabal
 
 * Sat Jun  9 2012 Jens Petersen <petersen at redhat.com> - 0.95.3-1
 - ghc-dep.sh: only use buildroot package.conf.d if it exists


More information about the scm-commits mailing list