fixup-hs-plist 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. #
  3. # $OpenBSD: fixup-hs-plist,v 1.1 2015/09/01 09:58:00 kili Exp $
  4. #
  5. # usage: fixup-hs-plist [plist ...]
  6. #
  7. # Fixes the given plists (default if no file given: pkg/PLIST) for
  8. # hs-ports by
  9. #
  10. # - replacing all occurences of ${FULLPKGNAME[^}*]} by hs-${DISTNAME},
  11. # i.e. repair the broken backward substution made by update-plist,
  12. # - ensures that the @exec .../register.sh, @unexec .../unregister.sh
  13. # and the lib/ghc/${DISTNAME}/unregister.sh come at the end of
  14. # the plist file, to stop the warnings about non-existing .haddock
  15. # files.
  16. if [ $# -eq 0 ]; then
  17. set pkg/PLIST
  18. fi
  19. for plist; do
  20. cp -p "$plist" "$plist~"
  21. ed -s "$plist" <<- 'EOF'
  22. g/\${FULLPKGNAME[^}]*}/s/\${FULLPKGNAME[^}]*}/hs-${DISTNAME}/g
  23. g/^@exec .*%D\/lib\/ghc\/\${DISTNAME}\/register\.sh/d
  24. g/^@unexec .*%D\/lib\/ghc\/\${DISTNAME}\/unregister\.sh/d
  25. g/^lib\/ghc\/\${DISTNAME}\/unregister\.sh$/d
  26. $a
  27. @exec /usr/bin/env HOME=/nonexistent %D/lib/ghc/${DISTNAME}/register.sh -v0
  28. @unexec /usr/bin/env HOME=/nonexistent %D/lib/ghc/${DISTNAME}/unregister.sh -v0 --force
  29. lib/ghc/${DISTNAME}/unregister.sh
  30. .
  31. wq
  32. EOF
  33. [ $? -eq 0 ] || cat "$plist~" > "$plist"
  34. rm -f "$plist~"
  35. done