forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix --program-{prefix,suffix} resulting in invalid installation
Currently the options `--program-{prefix,suffix}` for cabal install affects the name of the file in the install directory *and* the executable name in the store. The installation fails: - If using `--install-method=symlink`, the *target* of the symlink is not affected by the affix options and it results in an invalid symlink. - If using `--install-method=copy`, the copy fails because the source is not found. Another issue is that it affects the computation of the hash of the build directory in the store, resulting in needless rebuild when using successively different affix options. Fixed by making the name of the executable in the store canonical, i.e. always ignoring the program affix options. Added a test for all the combinations of `--install-method` and program affixes options.
- Loading branch information
Showing
6 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main = pure () |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/Install/ProgramAffixes/cabal.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: . |
27 changes: 27 additions & 0 deletions
27
cabal-testsuite/PackageTests/Install/ProgramAffixes/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Test.Cabal.Prelude | ||
import Data.Foldable (traverse_) | ||
|
||
-- Test that program affixes options result in successful installation: | ||
-- • Valid symlinks (--install-method=symlink) | ||
-- • Valid copy of executables (--install-method=copy) | ||
main = cabalTest $ do | ||
env <- getTestEnv | ||
recordMode DoNotRecord $ do | ||
let installdir = testPrefixDir env </> "bin" | ||
commonOpts = ["p", "--installdir", installdir, "--overwrite-policy=always"] | ||
testAllAffixes installMethod = do | ||
let testAffixes' = testAffixes | ||
(commonOpts ++ ["--install-method", installMethod]) | ||
testAffixes' Nothing Nothing | ||
testAffixes' (Just "a-") Nothing | ||
testAffixes' Nothing (Just "-z") | ||
testAffixes' (Just "a-") (Just "-z") | ||
traverse_ testAllAffixes ["symlink", "copy"] | ||
where | ||
mkAffixOption option = maybe [] (\a -> ["--program-" ++ option, a]) | ||
mkProgramName p s = maybe [] id p ++ "p" ++ maybe [] id s | ||
testAffixes commonOpts prefix suffix = do | ||
cabal "install" ( commonOpts | ||
++ mkAffixOption "prefix" prefix | ||
++ mkAffixOption "suffix" suffix) | ||
runInstalledExe (mkProgramName prefix suffix) [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: p | ||
version: 1.0 | ||
build-type: Simple | ||
cabal-version: >= 1.2 | ||
|
||
executable p | ||
main-is: Main.hs | ||
build-depends: base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
synopsis: Fix --program-suffix resulting in invalid installation | ||
packages: cabal-install | ||
issues: #8823 #9919 | ||
prs: #10056 |