cabal-tweak-*: output errors to stderr with scriptname

epel9
Jens Petersen 5 years ago
parent 0bb1bc2091
commit 31a55c3bc9

@ -2,11 +2,15 @@
set -e +x set -e +x
function fail {
echo "$0: $1" >&2
exit 1
}
USAGE="Usage: $0 dep old new" USAGE="Usage: $0 dep old new"
if [ $# -ne 3 ]; then if [ $# -ne 3 ]; then
echo "$USAGE" fail "$USAGE"
exit 1
fi fi
DEP=$1 DEP=$1
@ -16,15 +20,13 @@ NEW=$3
CABALFILE=$(ls *.cabal) CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
echo "There needs to be one .cabal file in the current dir!" fail "There needs to be one .cabal file in the current dir!"
exit 1
fi fi
BREAK=[^[:alnum:]-] BREAK=[^[:alnum:]-]
if ! grep -q "$BREAK$DEP$BREAK[^,]*$OLD" $CABALFILE; then if ! grep -q "$BREAK$DEP$BREAK[^,]*$OLD" $CABALFILE; then
echo "$CABALFILE does not match: $DEP $OLD" fail "$CABALFILE does not match: $DEP $OLD"
exit 1
fi fi
if [ ! -f $CABALFILE.orig ]; then if [ ! -f $CABALFILE.orig ]; then

@ -2,11 +2,15 @@
set -e +x set -e +x
function fail {
echo "$0: $1" >&2
exit 1
}
USAGE="Usage: $0 dep" USAGE="Usage: $0 dep"
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "$USAGE" fail "$USAGE"
exit 1
fi fi
DEP=$1 DEP=$1
@ -14,8 +18,7 @@ DEP=$1
CABALFILE=$(ls *.cabal) CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
echo "There needs to be one .cabal file in the current dir!" fail "There needs to be one .cabal file in the current dir!"
exit 1
fi fi
if [ ! -f $CABALFILE.orig ]; then if [ ! -f $CABALFILE.orig ]; then
@ -23,8 +26,7 @@ if [ ! -f $CABALFILE.orig ]; then
fi fi
if grep "$DEP" $CABALFILE | sed -e "s/$DEP//" | grep -q -e "[A-Za-z]"; then if grep "$DEP" $CABALFILE | sed -e "s/$DEP//" | grep -q -e "[A-Za-z]"; then
echo "$0: deleting whole $DEP lines not safe - try more precise pattern" fail "$0: deleting whole $DEP lines not safe - try more precise pattern"
exit 1
fi fi
sed -i$BACKUP -e "/$DEP/d" $CABALFILE sed -i$BACKUP -e "/$DEP/d" $CABALFILE

@ -5,11 +5,15 @@
set -e +x set -e +x
function fail {
echo "$0: $1" >&2
exit 1
}
USAGE="Usage: $0 FLAG [True|False]" USAGE="Usage: $0 FLAG [True|False]"
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "$USAGE" fail "$USAGE"
exit 1
fi fi
FLAG=$1 FLAG=$1
@ -24,23 +28,19 @@ esac
CABALFILE=$(ls *.cabal) CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
echo "There needs to be one .cabal file in the current dir!" fail "There needs to be one .cabal file in the current dir!"
exit 1
fi fi
if ! grep -q -i "^flag *$FLAG" $CABALFILE; then if ! grep -q -i "^flag *$FLAG" $CABALFILE; then
echo "$CABALFILE does not have flag $FLAG" fail "$CABALFILE does not have flag $FLAG"
exit 1
fi fi
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default:"; then if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default:"; then
echo "$CABALFILE: $FLAG flag might not have a default" fail "$CABALFILE: $FLAG flag might not have a default"
exit 1
fi fi
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default: *$OLD"; then if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default: *$OLD"; then
echo "$CABALFILE: $FLAG flag already defaults to $NEW" fail "$CABALFILE: $FLAG flag already defaults to $NEW"
exit 1
fi fi
if [ ! -f $CABALFILE.orig ]; then if [ ! -f $CABALFILE.orig ]; then

@ -2,26 +2,28 @@
set -e +x set -e +x
function fail {
echo "$0: $1" >&2
exit 1
}
USAGE="Usage: $0 dep" USAGE="Usage: $0 dep"
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "$USAGE" fail "$USAGE"
exit 1
fi fi
DEP=$1 DEP=$1
CABALFILE=$(ls *.cabal) CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
echo "There needs to be one .cabal file in the current dir!" fail "There needs to be one .cabal file in the current dir!"
exit 1
fi fi
BREAK=[^[:alnum:]-] BREAK=[^[:alnum:]-]
if ! grep -q "$BREAK$DEP$BREAK[^,]*" $CABALFILE; then if ! grep -q "$BREAK$DEP$BREAK[^,]*" $CABALFILE; then
echo "$CABALFILE does not match: $DEP" fail "$CABALFILE does not match: $DEP"
exit 1
fi fi
if [ ! -f $CABALFILE.orig ]; then if [ ! -f $CABALFILE.orig ]; then

@ -10,7 +10,7 @@
#%%global without_hscolour 1 #%%global without_hscolour 1
Name: ghc-rpm-macros Name: ghc-rpm-macros
Version: 2.0.9 Version: 2.0.10
Release: 1%{?dist} Release: 1%{?dist}
Summary: RPM macros for building Haskell packages for GHC Summary: RPM macros for building Haskell packages for GHC
@ -212,6 +212,9 @@ EOF
%changelog %changelog
* Thu Jun 18 2020 Jens Petersen <petersen@redhat.com> - 2.0.10-1
- cabal-tweak script now output errors to stderr
* Thu Jun 4 2020 Jens Petersen <petersen@redhat.com> - 2.0.9-1 * Thu Jun 4 2020 Jens Petersen <petersen@redhat.com> - 2.0.9-1
- doc subpackages should own /usr/share/doc/ghc/, /usr/share/doc/ghc/html/, - doc subpackages should own /usr/share/doc/ghc/, /usr/share/doc/ghc/html/,
and /usr/share/doc/ghc/html/libraries/ (#1795526) and /usr/share/doc/ghc/html/libraries/ (#1795526)

Loading…
Cancel
Save