koji-tool 0.6 → 0.6.1
raw patch · 5 files changed
+46/−26 lines, 5 files
Files
- ChangeLog.md +6/−0
- README.md +2/−1
- koji-tool.cabal +2/−2
- src/Install.hs +34/−22
- src/Main.hs +2/−1
ChangeLog.md view
@@ -1,5 +1,11 @@ # Version history of koji-tool +# 0.6.1 (2022-01-14)+- install --list: now lists the rpms of a unique nvr+- install --list: new --latest option which only finds the latest build+- install --nv: now actually looks for N-V nor N-V-R+- install --exclude: don't exclude subpackage when a rpm package matches+ ## 0.6 (2022-01-13) - renamed from koji-install to koji-tool, which combines koji-query and koji-progress - subcommands are 'install', 'query', 'progress', and 'buildlog-sizes'
README.md view
@@ -114,7 +114,7 @@ ```shellsession $ koji-tool install --help Usage: koji-tool install [-n|--dry-run] [-D|--debug] [-H|--hub HUB]- [-P|--packages-url URL] [-l|--list]+ [-P|--packages-url URL] [-l|--list] [-L|--latest] [(-a|--all) | (-A|--ask) | [-p|--package SUBPKG] [-x|--exclude SUBPKG]] [-d|--disttag DISTTAG] [(-R|--nvr) | (-V|--nv)] PKG|NVR|TASKID...@@ -127,6 +127,7 @@ rpmfusion, or URL) [default: fedora] -P,--packages-url URL KojiFiles packages url [default: Fedora] -l,--list List builds+ -L,--latest Latest build -a,--all all subpackages -A,--ask ask for each subpackge [default if not installed] -p,--package SUBPKG Subpackage (glob) to install
koji-tool.cabal view
@@ -1,9 +1,9 @@ name: koji-tool-version: 0.6+version: 0.6.1 synopsis: Koji CLI tool for querying tasks and installing builds description: koji-tool is a CLI interface to Koji with commands to query tasks,- install rpms, and check buildlog sizes.+ install rpms, and track buildlog sizes. . Koji is the RPM-based buildsystem of Fedora Linux and CentOS. license: BSD3
src/Install.hs view
@@ -70,9 +70,9 @@ -- FIXME --arch (including src) -- FIXME --debuginfo -- FIXME --delete after installing-installCmd :: Bool -> Bool -> Maybe String -> Maybe String -> Bool -> Mode- -> String -> Request -> [String] -> IO ()-installCmd dryrun debug mhuburl mpkgsurl listmode mode disttag request pkgbldtsks = do+installCmd :: Bool -> Bool -> Maybe String -> Maybe String -> Bool -> Bool+ -> Mode -> String -> Request -> [String] -> IO ()+installCmd dryrun debug mhuburl mpkgsurl listmode latest mode disttag request pkgbldtsks = do let huburl = maybe fedoraKojiHub hubURL mhuburl pkgsurl = fromMaybe (defaultPkgsURL huburl) mpkgsurl when debug $ do@@ -95,11 +95,14 @@ kojiBuildRPMs :: String -> String -> String -> String -> IO [String] kojiBuildRPMs huburl pkgsurl dlDir pkgbld = do- nvrs <- kojiBuildOSBuilds debug huburl listmode disttag request pkgbld+ nvrs <- kojiBuildOSBuilds debug huburl listmode latest disttag request pkgbld if listmode then if mode /= PkgsReq [] []+ -- FIXME: then error' "modes not supported for listing build"- else return nvrs+ else case nvrs of+ [nvr] -> ([nvr,""] ++) . map (<.> "rpm") . sort . filter (not . debugPkg) <$> kojiGetBuildRPMs huburl nvr+ _ -> return nvrs else case nvrs of [] -> error' $ pkgbld ++ " not found for " ++ disttag@@ -214,6 +217,8 @@ -- FIXME somehow determine unused excludes foldl' (exclude subpkgs) [] rpms where+ rpmnames = map nvraName rpms+ exclude :: [String] -> [String] -> String -> [String] exclude [] acc rpm = acc ++ [rpm] exclude (pat:pats) acc rpm =@@ -226,6 +231,7 @@ let comppat = compile pat in if isLiteral comppat then pat == rpmname ||+ pat `notElem` rpmnames && maybe False (\b -> (b ++ '-' : pat) == rpmname) mbase else match comppat rpmname selectRPMs mbase (subpkgs,exclpkgs) rpms =@@ -246,16 +252,22 @@ 'n' -> return Nothing _ -> rpmPrompt rpm -kojiBuildOSBuilds :: Bool -> String -> Bool -> String -> Request -> String- -> IO [String]-kojiBuildOSBuilds debug hub listmode disttag request pkgpat = do- let (pkg,full) = packageOfPattern pkgpat+kojiBuildOSBuilds :: Bool -> String -> Bool -> Bool -> String -> Request+ -> String -> IO [String]+kojiBuildOSBuilds debug hub listmode latest disttag request pkgpat = do+ when debug $ putStrLn pkgpat+ let (pkg,full) = packageOfPattern request pkgpat oldkoji = "rpmfusion" `isInfixOf` hub+ when debug $ putStrLn pkg+ when (latest && request == ReqNVR) $+ error' "cannot use --latest with --nvr"+ when (latest && not listmode) $+ putStrLn "--latest is implied when not using --list" when (oldkoji && ("*" `isInfixOf` pkgpat || request /= ReqName)) $ error' "cannot use pattern with this kojihub" mpkgid <- Koji.getPackageID hub pkg case mpkgid of- Nothing -> error $ "package not found: " ++ pkg+ Nothing -> error' $ "package not found: " ++ pkg Just pkgid -> do -- strictly should getAPIVersion let opts = (if oldkoji@@ -264,7 +276,7 @@ [("packageID", ValueInt pkgid), ("state", ValueInt (fromEnum BuildComplete)), ("queryOpts",ValueStruct- [("limit",ValueInt $ if listmode || oldkoji then 10 else 1),+ [("limit",ValueInt $ if listmode && not latest || oldkoji then 10 else 1), ("order",ValueString "-build_id")])] when debug $ print opts nvrs <- mapMaybe (lookupStruct "nvr") <$> Koji.listBuilds hub opts@@ -279,17 +291,17 @@ rs@(r:_) -> if listmode then rs else [r] else nvrs- where- packageOfPattern :: String -> (String, Bool)- packageOfPattern pat =- case request of- ReqName -> (dropSuffix "-" $ takeWhile (/= '*') pat, False)- ReqNV ->- case readNV pat of- NV n _ -> (n, False)- ReqNVR ->- case readNVR pat of- NVR n _ -> (n, True)++packageOfPattern :: Request -> String -> (String, Bool)+packageOfPattern request pat =+ case request of+ ReqName -> (dropSuffix "-" $ takeWhile (/= '*') pat, False)+ ReqNV ->+ case readNV pat of+ NV n _ -> (n, False)+ ReqNVR ->+ case readNVR pat of+ NVR n _ -> (n, True) kojiGetBuildRPMs :: String -> String -> IO [String] kojiGetBuildRPMs huburl nvr = do
src/Main.hs view
@@ -35,10 +35,11 @@ <*> optional (strOptionWith 'P' "packages-url" "URL" "KojiFiles packages url [default: Fedora]") <*> switchWith 'l' "list" "List builds"+ <*> switchWith 'L' "latest" "Latest build" <*> modeOpt <*> disttagOpt sysdisttag <*> (flagWith' ReqNVR 'R' "nvr" "Give an N-V-R instead of package name"- <|> flagWith ReqName ReqNVR 'V' "nv" "Give an N-V instead of package name")+ <|> flagWith ReqName ReqNV 'V' "nv" "Give an N-V instead of package name") <*> some (strArg "PKG|NVR|TASKID...") , Subcommand "query"