You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghc-rpm-macros/cabal-tweak-dep-ver

29 lines
484 B

#!/bin/sh
set -e +x
USAGE="Usage: $0 dep old new"
if [ $# -ne 3 ]; then
echo "$USAGE"
exit 1
fi
DEP=$1
OLD=$(echo $2 | sed -e "s/*/\\\\*/g" -e "s/\./\\\\./g")
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
fi
if ! grep -q "$DEP.*$OLD" $CABALFILE; then
echo "$CABALFILE does not match: $DEP $OLD"
exit 1
fi
sed -i.$1 -e "s/\($DEP.*\)$OLD/\1$NEW/g" $CABALFILE