[Git][ghc/ghc][master] Handle trailing path separator in package DB names (#16360)

Marge Bot gitlab at gitlab.haskell.org
Sun Jun 9 22:43:03 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
9d238791 by Kevin Buhr at 2019-06-09T22:42:57Z
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.

- - - - -


6 changed files:

- compiler/main/Packages.hs
- + testsuite/tests/driver/T16360/Hello.hs
- + testsuite/tests/driver/T16360/Makefile
- + testsuite/tests/driver/T16360/all.T
- + testsuite/tests/driver/T16360/test/Test.hs
- + testsuite/tests/driver/T16360/test/test.pkg


Changes:

=====================================
compiler/main/Packages.hs
=====================================
@@ -559,13 +559,15 @@ readPackageConfig dflags conf_file = do
                       "can't find a package database at " ++ conf_file
 
   let
+      -- Fix #16360: remove trailing slash from conf_file before calculting pkgroot
+      conf_file' = dropTrailingPathSeparator conf_file
       top_dir = topDir dflags
-      pkgroot = takeDirectory conf_file
+      pkgroot = takeDirectory conf_file'
       pkg_configs1 = map (mungePackageConfig top_dir pkgroot)
                          proto_pkg_configs
       pkg_configs2 = setBatchPackageFlags dflags pkg_configs1
   --
-  return (conf_file, pkg_configs2)
+  return (conf_file', pkg_configs2)
   where
     readDirStylePackageConfig conf_dir = do
       let filename = conf_dir </> "package.cache"


=====================================
testsuite/tests/driver/T16360/Hello.hs
=====================================
@@ -0,0 +1,3 @@
+import Test
+
+main = print test


=====================================
testsuite/tests/driver/T16360/Makefile
=====================================
@@ -0,0 +1,17 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+LOCAL_PKGCONF=package.conf.d
+
+clean:
+	rm -f test/*.o test/*.hi *.o *.hi
+	rm -rf $(LOCAL_PKGCONF)
+
+.PHONY: T16360
+T16360:
+	@rm -rf $(LOCAL_PKGCONF)
+	"$(TEST_HC)" $(TEST_HC_OPTS) -this-unit-id test-1.0 -c test/Test.hs
+	"$(GHC_PKG)" init $(LOCAL_PKGCONF)
+	"$(GHC_PKG)" --no-user-package-db -f $(LOCAL_PKGCONF) register test/test.pkg -v0
+	"$(TEST_HC)" $(TEST_HC_OPTS) -package-db $(LOCAL_PKGCONF)/ -c Hello.hs


=====================================
testsuite/tests/driver/T16360/all.T
=====================================
@@ -0,0 +1 @@
+test('T16360', [extra_files(['Hello.hs', 'test/'])], makefile_test, [])


=====================================
testsuite/tests/driver/T16360/test/Test.hs
=====================================
@@ -0,0 +1,4 @@
+module Test where
+
+test :: Int
+test = 42


=====================================
testsuite/tests/driver/T16360/test/test.pkg
=====================================
@@ -0,0 +1,8 @@
+name: test
+version: 1.0
+id: test-1.0
+key: test-1.0
+exposed-modules: Test
+import-dirs: ${pkgroot}/test
+library-dirs: ${pkgroot}/test
+exposed: True



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/9d238791862e8b128d397a1c0317986ea82ed000

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/9d238791862e8b128d397a1c0317986ea82ed000
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190609/13e75146/attachment-0001.html>


More information about the ghc-commits mailing list