@@ -127,6 +127,8 @@ import Distribution.Version
127
127
( Version )
128
128
import qualified Distribution.Deprecated.ParseUtils as OldParser
129
129
( ParseResult (.. ), locatedErrorMsg , showPWarning )
130
+ import Distribution.Client.SrcDist
131
+ ( packageDirToSdist )
130
132
131
133
import qualified Codec.Archive.Tar as Tar
132
134
import qualified Codec.Archive.Tar.Entry as Tar
@@ -1170,6 +1172,7 @@ syncAndReadSourcePackagesRemoteRepos verbosity
1170
1172
syncSourceRepos verbosity vcs
1171
1173
[ (repo, repoPath)
1172
1174
| (repo, _, repoPath) <- repoGroupWithPaths ]
1175
+ -- TODO phadej 2020-06-18 add post-sync script
1173
1176
1174
1177
-- But for reading we go through each 'SourceRepo' including its subdir
1175
1178
-- value and have to know which path each one ended up in.
@@ -1199,24 +1202,30 @@ syncAndReadSourcePackagesRemoteRepos verbosity
1199
1202
: [ pathStem ++ " -" ++ show (i :: Int ) | i <- [2 .. ] ]
1200
1203
1201
1204
readPackageFromSourceRepo
1202
- :: SourceRepositoryPackage Maybe -> FilePath
1205
+ :: SourceRepositoryPackage Maybe
1206
+ -> FilePath
1203
1207
-> Rebuild (PackageSpecifier (SourcePackage UnresolvedPkgLoc ))
1204
1208
readPackageFromSourceRepo repo repoPath = do
1205
- let packageDir = maybe repoPath (repoPath </> ) (srpSubdir repo)
1209
+ let packageDir :: FilePath
1210
+ packageDir = maybe repoPath (repoPath </> ) (srpSubdir repo)
1211
+
1206
1212
entries <- liftIO $ getDirectoryContents packageDir
1207
- -- TODO: wrap exceptions
1213
+ -- TODO: dcoutts 2018-06-23: wrap exceptions
1208
1214
case filter (\ e -> takeExtension e == " .cabal" ) entries of
1209
1215
[] -> liftIO $ throwIO $ NoCabalFileFound packageDir
1210
1216
(_: _: _) -> liftIO $ throwIO $ MultipleCabalFilesFound packageDir
1211
1217
[cabalFileName] -> do
1218
+ let cabalFilePath = packageDir </> cabalFileName
1212
1219
monitorFiles [monitorFileHashed cabalFilePath]
1213
- liftIO $ fmap (mkSpecificSourcePackage location)
1214
- . readSourcePackageCabalFile verbosity cabalFilePath
1215
- =<< BS. readFile cabalFilePath
1216
- where
1217
- cabalFilePath = packageDir </> cabalFileName
1218
- location = RemoteSourceRepoPackage repo packageDir
1220
+ gpd <- liftIO $ readSourcePackageCabalFile verbosity cabalFilePath =<< BS. readFile cabalFilePath
1221
+
1222
+ -- write sdist tarball, to repoPath-pgkid
1223
+ tarball <- liftIO $ packageDirToSdist verbosity gpd packageDir
1224
+ let tarballPath = repoPath ++ " - " ++ prettyShow (packageId gpd) ++ " .tar.gz "
1225
+ liftIO $ LBS. writeFile tarballPath tarball
1219
1226
1227
+ let location = RemoteSourceRepoPackage repo tarballPath
1228
+ return $ mkSpecificSourcePackage location gpd
1220
1229
1221
1230
reportSourceRepoProblems :: [(SourceRepoList , SourceRepoProblem )] -> Rebuild a
1222
1231
reportSourceRepoProblems = liftIO . die' verbosity . renderSourceRepoProblems
@@ -1231,13 +1240,11 @@ syncAndReadSourcePackagesRemoteRepos verbosity
1231
1240
--
1232
1241
mkSpecificSourcePackage :: PackageLocation FilePath
1233
1242
-> GenericPackageDescription
1234
- -> PackageSpecifier
1235
- (SourcePackage (PackageLocation (Maybe FilePath )))
1243
+ -> PackageSpecifier (SourcePackage UnresolvedPkgLoc )
1236
1244
mkSpecificSourcePackage location pkg =
1237
1245
SpecificSourcePackage SourcePackage
1238
1246
{ srcpkgPackageId = packageId pkg
1239
1247
, srcpkgDescription = pkg
1240
- -- TODO: it is silly that we still have to use a Maybe FilePath here
1241
1248
, srcpkgSource = fmap Just location
1242
1249
, srcpkgDescrOverride = Nothing
1243
1250
}
0 commit comments