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

This commit is contained in:
Jens Petersen 2020-06-18 10:56:14 +08:00
parent 0bb1bc2091
commit 31a55c3bc9
5 changed files with 38 additions and 29 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
#%%global without_hscolour 1
Name: ghc-rpm-macros
Version: 2.0.9
Version: 2.0.10
Release: 1%{?dist}
Summary: RPM macros for building Haskell packages for GHC
@ -212,6 +212,9 @@ EOF
%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
- doc subpackages should own /usr/share/doc/ghc/, /usr/share/doc/ghc/html/,
and /usr/share/doc/ghc/html/libraries/ (#1795526)