#
# Package with cabal, and attempt build in test dir ../TestPack.
# 1) We need to change the path to build the binary executable,
# from /media/ramdisk to . (dot).
ed -s ./z >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^ /#/
.+1s/^#/ /
wq
'EOF'
ed -s ./freesect.sh >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^ /#/
.+1s/^#/ /
wq
'EOF'
ed -s ./ile >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^ /#/
.+1s/^#/ /
wq
'EOF'
ed -s ./Makefile >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/..*/.\/.\/dist\/build\/freesect\/freesect: \\/
wq
'EOF'
ed -s ./cln >&! /dev/null <<'EOF'
/CLNSCRIPT/
.+1s/^#/ /
.+1s/^#/ /
wq
'EOF'
# 2) Attempt to run cabal sdist.
echo cabal sdist
cabal sdist
if ( $? ) then
echo "cabal sdist failed"
exit 1
endif
# 3) Change back the binpathnames:
ed -s ./z >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^#/ /
.+1s/^ /#/
wq
'EOF'
ed -s ./freesect.sh >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^#/ /
.+1s/^ /#/
wq
'EOF'
ed -s ./ile >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/^#/ /
.+1s/^ /#/
wq
'EOF'
ed -s ./Makefile >&! /dev/null <<'EOF'
/BINPATHNAME/
.+1s/..*/\/media\/ramdisk\/freesect: \\/
wq
'EOF'
ed -s ./cln >&! /dev/null <<'EOF'
/CLNSCRIPT/
.+1s/^ /#/
.+1s/^ /#/
wq
'EOF'
# 4) Set up the TestBuild dir.
set srcdir=$cwd
/bin/rm -rf ../TestBuild >&! /dev/null
mkdir ../TestBuild
cp -p dist/freesect-*.tar.gz ../TestBuild
cd ../TestBuild
tar zxf freesect-*.tar.gz
cd freesect-*[0-9]
# 5) Attempt to cabal configure and build.
echo cabal configure
cabal configure
if ( $? ) then
echo "cabal configure failed"
exit 1
endif
echo cabal build
cabal build
if ( $? ) then
echo "cabal build failed"
exit 1
endif
# 6) Attempt to run freesect test in new build.
./z
# 7) Finish up.
echo
echo "cwd = "$srcdir
echo