[ghc-rpm-macros/f20] backport ghc-deps.sh support for ghc-7.8 and cabal-tweak-flag manual field

Jens Petersen petersen at fedoraproject.org
Tue Feb 4 03:55:23 UTC 2014


commit 0be5b40270f2015a9f8d7d6acf86563b7131c08c
Author: Jens Petersen <petersen at redhat.com>
Date:   Tue Feb 4 12:55:27 2014 +0900

    backport ghc-deps.sh support for ghc-7.8 and cabal-tweak-flag manual field
    
    - ghc_fix_dynamic_rpath: abort for non-existent executable name with error msg
    - cabal-tweak-flag: add manual field to enforce flag changes
    - ghc-deps.sh fixes for bootstrapping new ghc version
      - use objdump -p instead of ldd to read executable dependencies
      - update for ghc-7.8 rts

 cabal-tweak-flag    |    2 +-
 ghc-deps.sh         |   17 +++++++++--------
 ghc-rpm-macros.ghc  |   19 ++++++++++++-------
 ghc-rpm-macros.spec |   10 +++++++++-
 4 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/cabal-tweak-flag b/cabal-tweak-flag
index 2db3a72..a357bd3 100755
--- a/cabal-tweak-flag
+++ b/cabal-tweak-flag
@@ -47,4 +47,4 @@ if [ ! -f $CABALFILE.orig ]; then
     BACKUP=.orig
 fi
 
-sed -i$BACKUP -e "/[Ff]lag *$FLAG/,/[Dd]efault: *$OLD/ s/\([Dd]efault: *\)$OLD/\1$NEW/" $CABALFILE
+sed -i$BACKUP -e "/[Ff]lag *$FLAG/,/[Dd]efault: *$OLD/ s/\( \+\)\([Dd]efault:[ \t]*\)$OLD/\1\2$NEW\n\1manual: True/" $CABALFILE
diff --git a/ghc-deps.sh b/ghc-deps.sh
index 2725cf7..324926c 100755
--- a/ghc-deps.sh
+++ b/ghc-deps.sh
@@ -8,15 +8,20 @@
 
 [ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
 
+set +x
+
 MODE=$1
 PKGBASEDIR=$2
 PKGCONFDIR=$PKGBASEDIR/package.conf.d
 GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//)
 
-if [ ! -x "/usr/bin/ghc-pkg-${GHC_VER}" -a -x "$PKGBASEDIR/ghc-pkg" ]; then
+if [ -x "$PKGBASEDIR/bin/ghc-pkg" ]; then
+    # ghc-7.8
+    GHC_PKG="$PKGBASEDIR/bin/ghc-pkg --global-package-db=$PKGCONFDIR"
+elif [ -x "$PKGBASEDIR/ghc-pkg" ]; then
     GHC_PKG="$PKGBASEDIR/ghc-pkg --global-package-db=$PKGCONFDIR"
 else
-    GHC_PKG="/usr/bin/ghc-pkg"
+    GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER}"
 fi
 
 case $MODE in
@@ -29,14 +34,10 @@ if [ -d "$PKGBASEDIR" ]; then
   SHARED=$(find $PKGBASEDIR -type f -name '*.so')
 fi
 
-GHCVERSION=$(ghc --numeric-version)
-
 files=$(cat)
 
-#set -x
-
 for i in $files; do
-    LIB_FILE=$(echo $i | grep /libHS | egrep -v "$PKGBASEDIR/libHS")
+    LIB_FILE=$(echo $i | grep /libHS | egrep -v "/libHSrts")
     if [ "$LIB_FILE" ]; then
 	if [ -d "$PKGCONFDIR" ]; then
 	    META=""
@@ -68,7 +69,7 @@ for i in $files; do
 	fi
     elif [ "$MODE" = "--requires" ]; then
 	if file $i | grep -q 'executable, .* dynamically linked'; then
-	    BIN_DEPS=$(ldd $i | grep libHS | grep -v libHSrts | sed -e "s%^\\tlibHS\(.*\)-ghc${GHCVERSION}.so =.*%\1%")
+	    BIN_DEPS=$(objdump -p $i | grep NEEDED | grep libHS | grep -v libHSrts | sed -e "s%^ *NEEDED *libHS\(.*\)-ghc${GHC_VER}.so%\1%")
 	    if [ -d "$PKGCONFDIR" ]; then
 		PACKAGE_CONF_OPT="--package-conf=$PKGCONFDIR"
 	    fi
diff --git a/ghc-rpm-macros.ghc b/ghc-rpm-macros.ghc
index 0a2b565..045a1b4 100644
--- a/ghc-rpm-macros.ghc
+++ b/ghc-rpm-macros.ghc
@@ -138,13 +138,18 @@ fi
 PDIR=$(cd ..; pwd)\
 for i in %*; do\
   PROG=%{buildroot}%{_bindir}/$i\
-  RPATH=$(chrpath $PROG| sed -e "s@^$PROG: RPATH=@@")\
-  case $RPATH in\
-    *$PDIR*)\
-      NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR@%{ghclibdir}@g" -e "s@/dist/build@@g")\
-      chrpath -r $NEWRPATH $PROG\
-      ;;\
-  esac\
+  if [ -x "$PROG" ]; then\
+    RPATH=$(chrpath $PROG| sed -e "s@^$PROG: RPATH=@@")\
+    case $RPATH in\
+         *$PDIR*)\
+         NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR@%{ghclibdir}@g" -e "s@/dist/build@@g")\
+         chrpath -r $NEWRPATH $PROG\
+         ;;\
+    esac\
+  else\
+    echo "%%ghc_fix_dynamic_rpath: no such file $PROG"\
+    exit 1\
+  fi\
 done\
 %endif\
 %{nil}
diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec
index b3c0654..d28063b 100644
--- a/ghc-rpm-macros.spec
+++ b/ghc-rpm-macros.spec
@@ -6,7 +6,7 @@
 #%%global without_hscolour 1
 
 Name:           ghc-rpm-macros
-Version:        1.0.7.2
+Version:        1.0.7.3
 Release:        1%{?dist}
 Summary:        RPM macros for building packages for GHC
 
@@ -90,6 +90,14 @@ EOF
 
 
 %changelog
+* Tue Feb  4 2014 Jens Petersen <petersen at redhat.com> - 1.0.7.3-1
+- ghc_fix_dynamic_rpath: abort for non-existent executable name with error msg
+- cabal-tweak-flag: add manual field to enforce flag changes
+- ghc-deps.sh: fix ghc-pkg path when bootstrapping new ghc version
+- fix ghc-deps.sh when bootstrapping a new ghc version
+- use objdump -p instead of ldd to read executable dependencies
+- update ghc-deps.sh to handling ghc-7.8 rts
+
 * Fri Oct 25 2013 Jens Petersen <petersen at redhat.com> - 1.0.7.2-1
 - ghcpkgdocdir should be versioned (for F20 and earlier)
 


More information about the scm-commits mailing list