Handle trailing path separator in package DB names (#16360)

Package DB directories with trailing separator (provided via
GHC_PACKAGE_PATH or via -package-db) resulted in incorrect calculation of
${pkgroot} substitution variable.  Keep the trailing separator while
resolving as directory or file, but remove it before dropping the last
path component with takeDirectory.

Closes #16360.
19 jobs for master in 118 minutes and 49 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Lint
passed #96720
lint
lint-submods-branch

00:00:13

 
  Build
failed #96722
x86_64-linux
hadrian-ghc-in-ghci

00:19:14

failed #96724
x86_64-linux allowed to fail
release-x86_64-linux-deb9-dwarf

01:30:50

passed #96723
x86_64-linux
validate-x86_64-linux-deb9-debug

01:06:15

failed #96721
x86_64-linux allowed to fail
validate-x86_64-linux-deb9-hadrian

01:58:28

 
  Full Build
skipped #96726
aarch64-linux allowed to fail
validate-aarch64-linux-deb9
skipped #96727
x86_64-linux
validate-i386-linux-deb9
skipped #96725
x86_64-darwin
validate-x86_64-darwin
skipped #96728
x86_64-linux
validate-x86_64-linux-deb9
skipped #96730
x86_64-linux
validate-x86_64-linux-deb9-integer-simple
skipped #96729
x86_64-linux
validate-x86_64-linux-deb9-llvm
skipped #96731
x86_64-linux
validate-x86_64-linux-deb9-unreg
skipped #96732
x86_64-linux
validate-x86_64-linux-fedora27
skipped #96734
x86_64-windows allowed to fail
validate-x86_64-windows
skipped #96733
x86_64-windows allowed to fail
validate-x86_64-windows-hadrian
 
  Cleanup
passed #96735
x86_64-darwin
cleanup-darwin

00:00:07

 
  Packaging
skipped #96736
x86_64-linux allowed to fail
doc-tarball
 
  Hackage
skipped #96737
x86_64-linux allowed to fail manual
hackage
 
  Deploy
skipped #96738
x86_64-linux allowed to fail
pages
 
Name Stage Failure
failed
hadrian-ghc-in-ghci Build There has been a runner system failure, please try again
Running with gitlab-runner 11.9.2 (v11.9.2)
on serokell-jupiter-1 BcnYxdgF
Using Docker executor with image registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:ac65f31dcffb09cd7ca7aaa70f447fcbb19f427f ...
Pulling docker image registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:ac65f31dcffb09cd7ca7aaa70f447fcbb19f427f ...
Using docker image sha256:419e951ea7a37d4840a68653dc35c6af268fcd6a46344c75b4a47aa5c0bc9ac3 for registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:ac65f31dcffb09cd7ca7aaa70f447fcbb19f427f ...
ERROR: Job failed (system failure): Error response from daemon: No such container: 7261828ea528efdea950f11b16f85f8560afde9c08e04c72f0663e2e59753e33 (executor_docker.go:932:6s)
failed
release-x86_64-linux-deb9-dwarf Build
$ cp -Rf $HOME/.cabal cabal-cache
Uploading artifacts...
ghc-*.tar.xz: found 1 matching files
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=96724 responseStatus=201 Created token=RH5vRoz9
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=96724 responseStatus=201 Created token=RH5vRoz9
ERROR: Job failed: exit code 1
failed
validate-x86_64-linux-deb9-hadrian Build
Exit code: 1
Stderr:
)


Uploading artifacts...
junit.xml: found 1 matching files
Uploading artifacts to coordinator... ok
id=96721 responseStatus=201 Created token=cxYTsiQ1
ERROR: Job failed: exit code 1