@@ -69,22 +69,34 @@ cmdBuild
69
69
getSourceMeta <- addOracle $ \ (GetSourceMeta PackageId {pkgName, pkgVersion}) ->
70
70
readSourceMeta' $ inputDir </> pkgName </> pkgVersion </> " meta.toml"
71
71
72
- getSourceDir <- addOracle $ \ (GetSourceDir pkgId) -> do
72
+ getSourceDir <- addOracle $ \ (GetSourceDir pkgId@ PackageId {pkgName, pkgVersion} ) -> do
73
73
SourceMeta {sourceUrl, sourceSubdir} <- getSourceMeta (GetSourceMeta pkgId)
74
- let srcDir = " _cache" </> urlToFileName sourceUrl
74
+ let urlDir = " _cache" </> urlToFileName sourceUrl
75
75
76
- need [srcDir </> " .downloaded" ]
76
+ need [urlDir </> " .downloaded" ]
77
77
-- FIXME Without this, sometimes the download doesn't trigger
78
78
putInfo $ " 👀 " <> sourceUrl
79
79
80
- projectFiles <- liftIO $ filter (" cabal.project" `isPrefixOf` ) <$> IO. getDirectoryContents srcDir
80
+ projectFiles <- liftIO $ filter (" cabal.project" `isPrefixOf` ) <$> IO. getDirectoryContents urlDir
81
81
unless (null projectFiles) $ do
82
- putWarn $ " ⚠️ Deleting cabal project files from " ++ srcDir
83
- liftIO $ for_ projectFiles $ IO. removeFile . (srcDir </> )
82
+ putWarn $ " ⚠️ Deleting cabal project files from " ++ urlDir
83
+ liftIO $ for_ projectFiles $ IO. removeFile . (urlDir </> )
84
84
85
- return $ case sourceSubdir of
86
- Just s -> srcDir </> s
87
- Nothing -> srcDir
85
+ let srcDir = case sourceSubdir of
86
+ Just s -> urlDir </> s
87
+ Nothing -> urlDir
88
+
89
+ let patchesDir = inputDir </> pkgName </> pkgVersion </> " patches"
90
+ hasPatches <- doesDirectoryExist patchesDir
91
+
92
+ when hasPatches $ do
93
+ patches <- getDirectoryFiles (inputDir </> pkgName </> pkgVersion </> " patches" ) [" *.patch" ]
94
+ for_ patches $ \ patch -> do
95
+ let patchfile = inputDir </> pkgName </> pkgVersion </> " patches" </> patch
96
+ putInfo $ " Applying patch: " <> patch
97
+ cmd_ Shell (Cwd srcDir) (FileStdin patchfile) " patch --backup -p1"
98
+
99
+ return srcDir
88
100
89
101
getPackages <- addOracle $ \ GetPackages -> do
90
102
metaFiles <- getDirectoryFiles inputDir [" */*/meta.toml" ]
@@ -341,23 +353,12 @@ cmdBuild
341
353
342
354
outputDir </> " package/*.tar.gz" %> \ path -> do
343
355
let [_, _, filename] = splitDirectories path
344
- let Just pkgId@ PackageId {pkgName, pkgVersion} = parsePkgId <$> stripExtension " tar.gz" filename
356
+ let Just pkgId = parsePkgId <$> stripExtension " tar.gz" filename
345
357
346
358
srcDir <- getSourceDir (GetSourceDir pkgId)
347
359
348
360
withTempDir $ \ tmpDir -> do
349
361
putInfo $ " Creating source distribution for " <> pkgIdToString pkgId
350
-
351
- let patchesDir = inputDir </> pkgName </> pkgVersion </> " patches"
352
- hasPatches <- doesDirectoryExist patchesDir
353
-
354
- when hasPatches $ do
355
- patches <- getDirectoryFiles (inputDir </> pkgName </> pkgVersion </> " patches" ) [" *.patch" ]
356
- for_ patches $ \ patch -> do
357
- let patchfile = inputDir </> pkgName </> pkgVersion </> " patches" </> patch
358
- putInfo $ " Applying patch: " <> patch
359
- cmd_ Shell (Cwd srcDir) (FileStdin patchfile) " patch --backup -p1"
360
-
361
362
cmd_ Shell (Cwd srcDir) (FileStdout path) (" cabal sdist --ignore-project --output-directory " <> tmpDir)
362
363
363
364
-- check cabal sdist has produced a single tarball with the
0 commit comments