[ghc-rpm-macros/f18] backport cabal-tweak-flag and pkgdir ownership fix from f19 rawhide

Jens Petersen petersen at fedoraproject.org
Sat Jan 19 07:43:53 UTC 2013


commit be71f209c4d15f0e03b7b007f3721eb4dd00ccea
Author: Jens Petersen <petersen at redhat.com>
Date:   Fri Jan 18 19:08:45 2013 +0900

    backport cabal-tweak-flag and pkgdir ownership fix from f19 rawhide

 cabal-tweak-flag    |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ghc-rpm-macros.ghc  |    4 ++--
 ghc-rpm-macros.spec |   11 +++++++++--
 3 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/cabal-tweak-flag b/cabal-tweak-flag
new file mode 100755
index 0000000..0d54d53
--- /dev/null
+++ b/cabal-tweak-flag
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# TODO:
+# support "$0 FLAG NEW" when no upstream default
+
+set -e +x
+
+USAGE="Usage: $0 FLAG OLD NEW"
+
+if [ $# -ne 3 ]; then
+    echo "$USAGE"
+    exit 1
+fi
+
+FLAG=$1
+OLD=$2
+NEW=$3
+
+if [ "$OLD" = "$NEW" ]; then
+  echo "Old and new value can't be the same!"
+  exit 1
+fi
+
+CABALFILE=$(ls *.cabal)
+
+if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
+   echo "There needs to be one .cabal file in the current dir!"
+   exit 1
+fi
+
+if ! grep -q -i "^flag *$FLAG" $CABALFILE; then
+   echo "$CABALFILE does have flag $FLAG"
+   exit 1
+fi
+
+if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default:"; then
+   echo "$CABALFILE: $FLAG flag might not have a default"
+   exit 1
+fi
+
+if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default: *$OLD"; then
+   echo "$CABALFILE: $FLAG flag already defaults to $NEW"
+   exit 1
+fi
+
+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
diff --git a/ghc-rpm-macros.ghc b/ghc-rpm-macros.ghc
index 387531b..60ca199 100644
--- a/ghc-rpm-macros.ghc
+++ b/ghc-rpm-macros.ghc
@@ -42,9 +42,9 @@ fi
 %define pkgdir %{ghclibdir}/%{pkgnamever}\
 %define docdir %{ghclibdocdir}/%{pkgnamever}\
 rm -f %{basepkg}.files %{basepkg}-devel.files\
+echo "%dir %{pkgdir}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
 %if %{undefined ghc_without_shared}\
 if [ -d "%{buildroot}%{pkgdir}" ]; then\
-echo "%dir %{pkgdir}" >> %{basepkg}.files\
 echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
 fi\
 %endif\
@@ -67,7 +67,7 @@ fi\
 %endif\
 echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
 if [ -d "%{buildroot}%{pkgdir}" ]; then\
-find %{buildroot}%{pkgdir} -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
+find %{buildroot}%{pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
 find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
 fi\
 if [ -d "%{buildroot}%{docdir}" ]; then\
diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec
index 7e822f5..798940e 100644
--- a/ghc-rpm-macros.spec
+++ b/ghc-rpm-macros.spec
@@ -6,8 +6,8 @@
 #%%global without_hscolour 1
 
 Name:           ghc-rpm-macros
-Version:        0.95.8
-Release:        2%{?dist}
+Version:        0.95.9
+Release:        1%{?dist}
 Summary:        Macros for building packages for GHC
 
 Group:          Development/Libraries
@@ -23,6 +23,7 @@ Source1:        COPYING
 Source2:        AUTHORS
 Source3:        ghc-deps.sh
 Source4:        cabal-tweak-dep-ver
+Source5:        cabal-tweak-flag
 Requires:       redhat-rpm-config
 %if %{undefined without_hscolour}
 BuildRequires:  redhat-rpm-config
@@ -51,6 +52,7 @@ 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
+install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag
 
 # this is why this package is now arch-dependent:
 # turn off shared libs and dynamic linking on secondary archs
@@ -69,9 +71,14 @@ EOF
 %config(noreplace) %{macros_file}
 %{_prefix}/lib/rpm/ghc-deps.sh
 %{_bindir}/cabal-tweak-dep-ver
+%{_bindir}/cabal-tweak-flag
 
 
 %changelog
+* Fri Jan 18 2013 Jens Petersen <petersen at redhat.com> - 0.95.9-1
+- be more careful about library pkgdir ownership (#893777)
+- add cabal-tweak-flag script for toggling flag default
+
 * Thu Oct 25 2012 Jens Petersen <petersen at redhat.com> - 0.95.8-2
 - BR redhat-rpm-config instead of ghc-rpm-macros
 - no longer set without_hscolour in macros.ghc for bootstrapping


More information about the scm-commits mailing list