Skip to content

Commit ca9c38d

Browse files
committed
(aura) Pull package sources via git
1 parent 19ccb24 commit ca9c38d

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

aura/lib/Aura/Build.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Aura.Build
3232
import Aura.Core
3333
import Aura.Languages
3434
import Aura.MakePkg
35+
import Aura.Packages.AUR (clone)
3536
import Aura.Pacman (pacman)
3637
import Aura.Settings
3738
import Aura.Types
@@ -100,7 +101,7 @@ build' ss p = do
100101
getBuildScripts :: Buildable -> User -> Sh (Either Failure FilePath)
101102
getBuildScripts pkg user = do
102103
currDir <- toTextIgnore <$> pwd
103-
scriptsDir <- chown user currDir [] *> liftIO (buildScripts pkg (T.unpack currDir))
104+
scriptsDir <- chown user currDir [] *> clone pkg
104105
case scriptsDir of
105106
Nothing -> pure . Left . Failure . buildFail_7 $ bldNameOf pkg
106107
Just sd -> do

aura/lib/Aura/Packages/AUR.hs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module Aura.Packages.AUR
2929
( aurLookup
3030
, aurRepo
3131
, isAurPackage
32+
, clone
3233
, sourceTarball
3334
, aurInfo
3435
, aurSearch
@@ -49,8 +50,9 @@ import Data.Versions (versioning)
4950
import Internet
5051
import Linux.Arch.Aur
5152
import Network.HTTP.Client (Manager)
53+
import Shelly (Sh, run_)
5254
import System.FilePath ((</>))
53-
import Utilities (decompress, list)
55+
import Utilities (list, quietSh)
5456

5557
---
5658

@@ -81,9 +83,7 @@ buildable m ai = do
8183
, bldProvidesOf = list (Provides $ aurNameOf ai) (Provides . head) $ providesOf ai
8284
, bldDepsOf = mapMaybe parseDep $ dependsOf ai ++ makeDepsOf ai -- TODO bad mapMaybe?
8385
, bldVersionOf = either (const Nothing) Just . versioning $ aurVersionOf ai
84-
, isExplicit = False
85-
, buildScripts = f }
86-
where f fp = sourceTarball m fp (pkgBaseOf ai) >>= traverse (fmap T.unpack . decompress (T.pack fp) . T.pack)
86+
, isExplicit = False }
8787

8888
isAurPackage :: (Member (Reader Settings) r, Member IO r) => T.Text -> Eff r Bool
8989
isAurPackage name = asks managerOf >>= \m -> isJust <$> send (pkgbuild' @IO m name)
@@ -97,6 +97,16 @@ aurLink = "https://aur.archlinux.org"
9797
pkgUrl :: T.Text -> T.Text
9898
pkgUrl pkg = T.pack $ T.unpack aurLink </> "packages" </> T.unpack pkg
9999

100+
-------------------
101+
-- SOURCES FROM GIT
102+
-------------------
103+
clone :: Buildable -> Sh (Maybe FilePath)
104+
clone b = do
105+
(ec, _) <- quietSh $ run_ "git" ["clone", "--depth", "1", aurLink <> "/" <> bldBaseNameOf b <> ".git"]
106+
case ec of
107+
(ExitFailure _) -> pure Nothing
108+
ExitSuccess -> pure . Just . T.unpack $ bldBaseNameOf b
109+
100110
------------------
101111
-- SOURCE TARBALLS
102112
------------------

aura/lib/Aura/Types.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ data Buildable = Buildable
173173
, bldDepsOf :: [Dep]
174174
, bldVersionOf :: Maybe Versioning
175175
-- | Did the user select this package, or is it being built as a dep?
176-
, isExplicit :: Bool
177-
-- | Fetch and extract the source code corresponding to the given package.
178-
-- Expects a directory in which to place the scripts, and yields the path
179-
-- they were successfully extracted to.
180-
, buildScripts :: FilePath -> IO (Maybe FilePath) }
176+
, isExplicit :: Bool }
181177

182178
data Language = English
183179
| Japanese

0 commit comments

Comments
 (0)