Skip to content

Commit 7848e98

Browse files
committed
Remove bash parsing from AUR dep handling
1 parent bf1ece3 commit 7848e98

File tree

5 files changed

+38
-29
lines changed

5 files changed

+38
-29
lines changed

aura/src/Aura/Commands/A.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import Linux.Arch.Aur
4444
import Text.Printf (printf)
4545
import Text.Regex.PCRE ((=~))
4646

47-
import Aura.Bash (namespace, Namespace)
4847
import Aura.Colour.Text
4948
import Aura.Core
5049
import Aura.Install (InstallOptions(..))
@@ -118,11 +117,10 @@ aurPkgInfo (fmap T.pack -> pkgs) = aurInfo pkgs >>= traverse_ displayAurPkgInfo
118117
displayAurPkgInfo :: AurInfo -> Aura ()
119118
displayAurPkgInfo ai = ask >>= \ss -> do
120119
let name = T.unpack $ aurNameOf ai
121-
ns <- fromJust <$> pkgbuild (managerOf ss) name >>= namespace name . T.unpack
122-
liftIO $ putStrLn $ renderAurPkgInfo ss ai ns <> "\n"
120+
liftIO $ putStrLn $ renderAurPkgInfo ss ai <> "\n"
123121

124-
renderAurPkgInfo :: Settings -> AurInfo -> Namespace -> String
125-
renderAurPkgInfo ss ai ns = entrify ss fields entries
122+
renderAurPkgInfo :: Settings -> AurInfo -> String
123+
renderAurPkgInfo ss ai = entrify ss fields entries
126124
where fields = fmap bForeground . infoFields . langOf $ ss
127125
empty x = case x of [] -> "None"; _ -> x
128126
entries = [ magenta "aur"
@@ -133,8 +131,8 @@ renderAurPkgInfo ss ai ns = entrify ss fields entries
133131
, cyan $ maybe "(null)" T.unpack (urlOf ai)
134132
, pkgUrl $ T.unpack $ aurNameOf ai
135133
, T.unpack . T.unwords $ licenseOf ai
136-
, empty . unwords $ depends ns
137-
, empty . unwords $ makedepends ns
134+
, T.unpack . T.unwords $ dependsOf ai
135+
, T.unpack . T.unwords $ makeDepsOf ai
138136
, yellow . show $ aurVotesOf ai
139137
, yellow $ printf "%0.2f" (popularityOf ai)
140138
, maybe "(null)" T.unpack (aurDescriptionOf ai) ]

aura/src/Aura/Core.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ data InstallType = Pacman String | Build Buildable
7878
data Buildable = Buildable
7979
{ baseNameOf :: String
8080
, pkgbuildOf :: Pkgbuild
81+
, bldDepsOf :: [Dep]
82+
, bldVersionOf :: String
8183
-- | Did the user select this package, or is it being built as a dep?
8284
, isExplicit :: Bool
8385
-- | Fetch and extract the source code corresponding to the given package.

aura/src/Aura/Packages/ABS.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module Aura.Packages.ABS
4343
) where
4444

4545
import Control.Monad
46+
import Data.Monoid ((<>))
4647
import Data.List (find)
4748
import Data.Foldable (fold)
4849
import Data.Set (Set)
@@ -84,11 +85,30 @@ absDepsRepo :: Aura Repository
8485
absDepsRepo = asks (getRepo . buildABSDeps)
8586
where getRepo manual = if manual then absRepo else pacmanRepo
8687

88+
-- | Yields the value of the `depends` field.
89+
depends :: Namespace -> [String]
90+
depends = flip value "depends"
91+
92+
makedepends :: Namespace -> [String]
93+
makedepends = flip value "makedepends"
94+
95+
checkdepends :: Namespace -> [String]
96+
checkdepends = flip value "checkdepends"
97+
98+
trueVersion :: Namespace -> String
99+
trueVersion ns = pkgver <> "-" <> pkgrel
100+
where pkgver = head $ value ns "pkgver"
101+
pkgrel = head $ value ns "pkgrel"
102+
87103
makeBuildable :: String -> String -> Aura Buildable
88104
makeBuildable repo name = do
89105
pb <- absPkgbuild repo name
106+
ns <- namespace name pb
90107
pure Buildable { baseNameOf = name
91108
, pkgbuildOf = pb
109+
, bldDepsOf = parseDep <$> foldMap ($ ns)
110+
[depends, makedepends, checkdepends]
111+
, bldVersionOf = trueVersion ns
92112
, isExplicit = False
93113
, buildScripts = \fp -> Just <$> copyTo repo name fp }
94114

aura/src/Aura/Packages/AUR.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,21 @@ import Utilities (decompress)
5454
---
5555

5656
aurLookup :: String -> Aura (Maybe Buildable)
57-
aurLookup name = asks managerOf >>= \m -> fmap (makeBuildable m name . T.unpack) <$> pkgbuild m name
57+
aurLookup name = asks managerOf >>= \m -> do
58+
junk <- fmap (makeBuildable m name . T.unpack)<$> pkgbuild m name
59+
sequence junk
5860

5961
aurRepo :: Repository
6062
aurRepo = Repository $ aurLookup >=> traverse packageBuildable
6163

62-
makeBuildable :: Manager -> String -> Pkgbuild -> Buildable
63-
makeBuildable m name pb = Buildable
64+
makeBuildable :: Manager -> String -> Pkgbuild -> Aura Buildable
65+
makeBuildable m name pb = do
66+
ai <- head <$> info m [T.pack name]
67+
return Buildable
6468
{ baseNameOf = name
6569
, pkgbuildOf = pb
70+
, bldDepsOf = parseDep . T.unpack <$> dependsOf ai ++ makeDepsOf ai
71+
, bldVersionOf = T.unpack $ aurVersionOf ai
6672
, isExplicit = False
6773
, buildScripts = f }
6874
where f fp = sourceTarball m fp (T.pack name) >>= traverse decompress

aura/src/Aura/Pkgbuild/Base.hs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ toFilename = (<> ".pb")
4040
pkgbuildPath :: String -> FilePath
4141
pkgbuildPath p = pkgbuildCache <> toFilename p
4242

43-
trueVersion :: Namespace -> String
44-
trueVersion ns = pkgver <> "-" <> pkgrel
45-
where pkgver = head $ value ns "pkgver"
46-
pkgrel = head $ value ns "pkgrel"
47-
48-
-- | Yields the value of the `depends` field.
49-
depends :: Namespace -> [String]
50-
depends = flip value "depends"
51-
52-
makedepends :: Namespace -> [String]
53-
makedepends = flip value "makedepends"
54-
55-
checkdepends :: Namespace -> [String]
56-
checkdepends = flip value "checkdepends"
57-
5843
-- One of my favourite functions in this code base.
5944
pbCustomization :: Buildable -> Aura Buildable
6045
pbCustomization = foldl (>=>) pure [customizepkg, hotEdit]
@@ -63,10 +48,8 @@ pbCustomization = foldl (>=>) pure [customizepkg, hotEdit]
6348
packageBuildable :: Buildable -> Aura Package
6449
packageBuildable b = do
6550
b' <- pbCustomization b
66-
ns <- namespace (baseNameOf b') (pkgbuildOf b')
6751
pure Package
6852
{ pkgNameOf = baseNameOf b'
69-
, pkgVersionOf = trueVersion ns
70-
, pkgDepsOf = parseDep <$> foldMap ($ ns)
71-
[depends, makedepends, checkdepends]
53+
, pkgDepsOf = bldDepsOf b'
54+
, pkgVersionOf = bldVersionOf b'
7255
, pkgInstallTypeOf = Build b' }

0 commit comments

Comments
 (0)