Skip to content

Commit

Permalink
(aura) Pull package sources via git
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Jul 7, 2018
1 parent 19ccb24 commit ca9c38d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion aura/lib/Aura/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module Aura.Build
import Aura.Core
import Aura.Languages
import Aura.MakePkg
import Aura.Packages.AUR (clone)
import Aura.Pacman (pacman)
import Aura.Settings
import Aura.Types
Expand Down Expand Up @@ -100,7 +101,7 @@ build' ss p = do
getBuildScripts :: Buildable -> User -> Sh (Either Failure FilePath)
getBuildScripts pkg user = do
currDir <- toTextIgnore <$> pwd
scriptsDir <- chown user currDir [] *> liftIO (buildScripts pkg (T.unpack currDir))
scriptsDir <- chown user currDir [] *> clone pkg
case scriptsDir of
Nothing -> pure . Left . Failure . buildFail_7 $ bldNameOf pkg
Just sd -> do
Expand Down
18 changes: 14 additions & 4 deletions aura/lib/Aura/Packages/AUR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Aura.Packages.AUR
( aurLookup
, aurRepo
, isAurPackage
, clone
, sourceTarball
, aurInfo
, aurSearch
Expand All @@ -49,8 +50,9 @@ import Data.Versions (versioning)
import Internet
import Linux.Arch.Aur
import Network.HTTP.Client (Manager)
import Shelly (Sh, run_)
import System.FilePath ((</>))
import Utilities (decompress, list)
import Utilities (list, quietSh)

---

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

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

-------------------
-- SOURCES FROM GIT
-------------------
clone :: Buildable -> Sh (Maybe FilePath)
clone b = do
(ec, _) <- quietSh $ run_ "git" ["clone", "--depth", "1", aurLink <> "/" <> bldBaseNameOf b <> ".git"]
case ec of
(ExitFailure _) -> pure Nothing
ExitSuccess -> pure . Just . T.unpack $ bldBaseNameOf b

------------------
-- SOURCE TARBALLS
------------------
Expand Down
6 changes: 1 addition & 5 deletions aura/lib/Aura/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ data Buildable = Buildable
, bldDepsOf :: [Dep]
, bldVersionOf :: Maybe Versioning
-- | Did the user select this package, or is it being built as a dep?
, isExplicit :: Bool
-- | Fetch and extract the source code corresponding to the given package.
-- Expects a directory in which to place the scripts, and yields the path
-- they were successfully extracted to.
, buildScripts :: FilePath -> IO (Maybe FilePath) }
, isExplicit :: Bool }

data Language = English
| Japanese
Expand Down

0 comments on commit ca9c38d

Please sign in to comment.