Skip to content

Commit

Permalink
[build] patches folder doesn't have to exist
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini committed Mar 30, 2022
1 parent 0df2f10 commit ea498db
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/Foliage/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Foliage.CmdBuild (cmdBuild) where
import Codec.Archive.Tar qualified as Tar
import Codec.Archive.Tar.Entry qualified as Tar
import Codec.Compression.GZip qualified as GZip
import Control.Monad (unless)
import Control.Monad (unless, when)
import Data.ByteString.Lazy qualified as BSL
import Data.Foldable (for_)
import Data.List (isPrefixOf, sortOn)
Expand Down Expand Up @@ -348,12 +348,15 @@ cmdBuild
withTempDir $ \tmpDir -> do
putInfo $ " Creating source distribution for " <> pkgIdToString pkgId

patches <- getDirectoryFiles (inputDir </> pkgName </> pkgVersion </> "patches") ["*.patch"]
let patchesDir = inputDir </> pkgName </> pkgVersion </> "patches"
hasPatches <- doesDirectoryExist patchesDir

for_ patches $ \patch -> do
let patchfile = inputDir </> pkgName </> pkgVersion </> "patches" </> patch
putInfo $ "Applying patch: " <> patch
cmd_ Shell (Cwd srcDir) (FileStdin patchfile) "patch --backup -p1"
when hasPatches $ do
patches <- getDirectoryFiles (inputDir </> pkgName </> pkgVersion </> "patches") ["*.patch"]
for_ patches $ \patch -> do
let patchfile = inputDir </> pkgName </> pkgVersion </> "patches" </> patch
putInfo $ "Applying patch: " <> patch
cmd_ Shell (Cwd srcDir) (FileStdin patchfile) "patch --backup -p1"

cmd_ Shell (Cwd srcDir) (FileStdout path) ("cabal sdist --ignore-project --output-directory " <> tmpDir)

Expand Down

0 comments on commit ea498db

Please sign in to comment.