Custom bundle names come from cabal file name #45

This commit is contained in:
Michael Snoyman 2014-12-02 16:28:14 +02:00
parent b0e2fbf782
commit cd53f7d0e5

View File

@ -176,17 +176,14 @@ putUploadStackageR = do
Nothing -> return () Nothing -> return ()
fp | (base1, Just "gz") <- splitExtension fp fp | (base1, Just "gz") <- splitExtension fp
, (base, Just "tar") <- splitExtension base1 , (fpToText -> base, Just "tar") <- splitExtension base1 -> do
, Just (name, version) <- parseName (fpToText base) -> do
ident <- lsIdent <$> get ident <- lsIdent <$> get
sourceLazy lbs $$ storeWrite (CustomSdist ident name version)
_ <- update $ concat _ <- update $ concat
[ "Extracting cabal file for custom tarball: " [ "Extracting cabal file for custom tarball: "
, toPathPiece name , base
, "-"
, toPathPiece version
] ]
cabalLBS <- extractCabal lbs name version (name, version, cabalLBS) <- extractCabal lbs base
sourceLazy lbs $$ storeWrite (CustomSdist ident name version)
addFile True name version $ sourceLazy cabalLBS addFile True name version $ sourceLazy cabalLBS
_ -> return () _ -> return ()
_ -> return () _ -> return ()
@ -235,28 +232,27 @@ type IsOverride = Bool
extractCabal :: (MonadLogger m, MonadThrow m) extractCabal :: (MonadLogger m, MonadThrow m)
=> LByteString => LByteString
-> PackageName -- ^ name -> Text -- ^ basename
-> Version -- ^ version -> m (PackageName, Version, LByteString)
-> m LByteString extractCabal lbs basename' =
extractCabal lbs name version =
loop $ Tar.read $ GZip.decompress lbs loop $ Tar.read $ GZip.decompress lbs
where where
loop Tar.Done = error $ "extractCabal: cabal file missing for " ++ show (name, version) loop Tar.Done = error $ "extractCabal: cabal file missing for " ++ unpack basename'
loop (Tar.Fail e) = throwM e loop (Tar.Fail e) = throwM e
loop (Tar.Next e es) = do loop (Tar.Next e es) = do
$logDebug $ tshow (Tar.entryPath e, fp) $logDebug $ pack $ Tar.entryPath e
case Tar.entryContent e of case Tar.entryContent e of
Tar.NormalFile lbs' _ | Tar.entryPath e == fp -> return lbs' Tar.NormalFile lbs' _
| Just (name, version) <- parseNameVersion (pack $ Tar.entryPath e)
-> return (name, version, lbs')
_ -> loop es _ -> loop es
fp = unpack $ concat parseNameVersion t = do
[ toPathPiece name [dir, filename'] <- Just $ T.splitOn "/" t
, "-" let (name', version) = T.breakOnEnd "-" dir
, toPathPiece version name <- stripSuffix "-" name'
, "/" guard $ name ++ ".cabal" == filename'
, toPathPiece name return (PackageName name, Version version)
, ".cabal"
]
-- | Get a unique version of the given slug by appending random numbers to the -- | Get a unique version of the given slug by appending random numbers to the
-- end. -- end.