Skip to content

Commit

Permalink
Prepared support for makepkg's --ignorearch flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Jan 6, 2014
1 parent 6b5be0e commit aa0e5ff
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Aura/Core.hs
Expand Up @@ -75,7 +75,7 @@ data InstallType = Pacman String | Build Buildable

-- | A package to be built manually before installing.
data Buildable = Buildable
{ baseNameOf :: String -- What is this?
{ baseNameOf :: String
, pkgbuildOf :: Pkgbuild
-- | Did the user select this package, or is it being built as a dep?
, isExplicit :: Bool
Expand Down
22 changes: 14 additions & 8 deletions Aura/Flags.hs
Expand Up @@ -36,6 +36,7 @@ module Aura.Flags
, customizepkgStatus
, notSettingsFlag
, ignoredAuraPkgs
, makepkgFlags
, buildPath
, buildUser
, auraOperMsg
Expand Down Expand Up @@ -96,6 +97,7 @@ data Flag = ABSInstall
| ViewConf
| RestoreState
| NoPowerPill
| IgnoreArch
| Languages
| Version
| Help
Expand All @@ -119,8 +121,8 @@ allFlags lang = concat [ auraOperations lang
, pacmanOptions
, dualOptions ]

simpleMakeOption :: ([Char],[String],Flag) -> OptDescr Flag
simpleMakeOption (c,s,f) = Option c s (NoArg f) ""
simpleOption :: ([Char],[String],Flag) -> OptDescr Flag
simpleOption (c,s,f) = Option c s (NoArg f) ""

auraOperations :: Language -> [OptDescr Flag]
auraOperations lang =
Expand All @@ -135,7 +137,7 @@ auraOptions :: [OptDescr Flag]
auraOptions = Option [] ["aurignore"] (ReqArg Ignore "" ) "" :
Option [] ["build"] (ReqArg BuildPath "" ) "" :
Option [] ["builduser"] (ReqArg BuildUser "" ) "" :
map simpleMakeOption
map simpleOption
[ ( ['a'], ["delmakedeps"], DelMDeps )
, ( ['b'], ["backup"], CacheBackup )
, ( ['c'], ["clean"], Clean )
Expand All @@ -159,25 +161,26 @@ auraOptions = Option [] ["aurignore"] (ReqArg Ignore "" ) "" :
, ( [], ["devel"], Devel )
, ( [], ["head"], TruncHead )
, ( [], ["hotedit"], HotEdit )
, ( [], ["ignorearch"], IgnoreArch )
, ( [], ["languages"], Languages )
, ( [], ["no-pp"], NoPowerPill )
, ( [], ["tail"], TruncTail )
, ( [], ["viewconf"], ViewConf ) ]

-- These are intercepted Pacman flags. Their functionality is different.
pacmanOptions :: [OptDescr Flag]
pacmanOptions = map simpleMakeOption
pacmanOptions = map simpleOption
[ ( ['y'], ["refresh"], Refresh )
, ( ['V'], ["version"], Version )
, ( ['h'], ["help"], Help ) ]

-- Options that have functionality stretching across both Aura and Pacman.
dualOptions :: [OptDescr Flag]
dualOptions = map simpleMakeOption
dualOptions = map simpleOption
[ ( [], ["noconfirm"], NoConfirm ) ]

languageOptions :: [OptDescr Flag]
languageOptions = map simpleMakeOption
languageOptions = map simpleOption
[ ( [], ["japanese","日本語"], JapOut )
, ( [], ["polish","polski"], PolishOut )
, ( [], ["croatian","hrvatski"], CroatianOut )
Expand Down Expand Up @@ -222,7 +225,7 @@ reconvertFlag flagMap f = fromMaybe "" $ f `lookup` flagMap
settingsFlags :: [Flag]
settingsFlags = [ Unsuppress,NoConfirm,HotEdit,DiffPkgbuilds,Debug,Devel
, DelMDeps,Customizepkg,Quiet,NoPowerPill,KeepSource,BuildABSDeps
, ABCSort, TruncHead, TruncTail ]
, ABCSort, TruncHead, TruncTail, IgnoreArch ]

-- Flags like `Ignore` and `BuildPath` have args, and thus can't be included
-- in the `settingsFlags` list.
Expand All @@ -236,7 +239,7 @@ auraOperMsg :: Language -> String
auraOperMsg lang = usageInfo (yellow $ auraOperTitle lang) $ auraOperations lang

-- Extracts desirable results from given Flags.
-- Callers must supply an alternate value for when there are no matches.
-- Callers must supply an [alt]ernate value for when there are no matches.
fishOutFlag :: [(Flag,a)] -> a -> [Flag] -> a
fishOutFlag [] alt _ = alt
fishOutFlag ((f,r):fs) alt flags | f `elem` flags = r
Expand Down Expand Up @@ -279,6 +282,9 @@ noPowerPillStatus = fishOutFlag [(NoPowerPill,True)] False
keepSourceStatus = fishOutFlag [(KeepSource,True)] False
buildABSDepsStatus = fishOutFlag [(BuildABSDeps,True)] False

makepkgFlags :: [Flag] -> [String]
makepkgFlags = fishOutFlag [(IgnoreArch,["--ignorearch"])] []

parseLanguageFlag :: [String] -> (Maybe Language,[String])
parseLanguageFlag args =
case getOpt' Permute languageOptions args of
Expand Down
2 changes: 1 addition & 1 deletion Aura/MakePkg.hs
Expand Up @@ -29,7 +29,7 @@ module Aura.MakePkg
import Text.Regex.PCRE ((=~))

import Aura.Monad.Aura
import Aura.Settings.Base (suppressMakepkg)
import Aura.Settings.Base (suppressMakepkg,makepkgFlagsOf)
import Aura.Shell (shellCmd, quietShellCmd, quietShellCmd', checkExitCode')

import Shell (pwd, ls)
Expand Down
1 change: 1 addition & 0 deletions Aura/Settings/Base.hs
Expand Up @@ -44,6 +44,7 @@ data Settings = Settings { inputOf :: [String]
, editorOf :: String
, carchOf :: String
, ignoredPkgsOf :: [String]
, makepkgFlagsOf :: [String]
, buildPathOf :: FilePath
, cachePathOf :: FilePath
, logFilePathOf :: FilePath
Expand Down
3 changes: 2 additions & 1 deletion Aura/Settings/Enable.hs
Expand Up @@ -59,6 +59,7 @@ getSettings lang (auraFlags,input,pacOpts) = do
"COULDN'T READ $CARCH"
, ignoredPkgsOf = getIgnoredPkgs confFile ++
ignoredAuraPkgs auraFlags
, makepkgFlagsOf = makepkgFlags auraFlags
, buildPathOf = buildPath'
, cachePathOf = getCachePath confFile
, logFilePathOf = getLogFilePath confFile
Expand Down Expand Up @@ -86,7 +87,7 @@ debugOutput ss = do
, "Using Sudo? => " ++ yn (varExists "SUDO_USER" env)
, "Pacman Flags => " ++ unwords (pacOptsOf ss)
, "Other Flags => " ++ unwords (otherOptsOf ss)
, "Other input => " ++ unwords (inputOf ss)
, "Other Input => " ++ unwords (inputOf ss)
, "Language => " ++ show (langOf ss)
, "Pacman Command => " ++ pacmanCmdOf ss
, "Editor => " ++ editorOf ss
Expand Down
1 change: 0 additions & 1 deletion Bash/Parser.hs
Expand Up @@ -173,7 +173,6 @@ andStatement = do
body <- field
return $ If cond [body] Nothing

-- Only tries to parse equality checks at the moment.
comparison :: Parser Comparison
comparison = do
spaces >> leftBs >> spaces
Expand Down

0 comments on commit aa0e5ff

Please sign in to comment.