koji-tool 1.0 → 1.0.1
raw patch · 7 files changed
+53/−41 lines, 7 files
Files
- ChangeLog.md +4/−0
- README.md +3/−2
- koji-tool.cabal +2/−2
- src/Builds.hs +1/−1
- src/Find.hs +12/−6
- src/Install.hs +30/−29
- src/Main.hs +1/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Version history of koji-tool +## 1.0.1 (2023-05-08)+- 'install' now supports multiple arch options (#4)+- 'find': interpret small number as a limit (default still 10 results)+ ## 1.0 (2023-04-24) - 'builds': fix --install to use nvr instead of taskid - 'install': allow installing from an ongoing build; add kojiGetBuildTaskRPMs
README.md view
@@ -23,7 +23,7 @@ ## Commands ```shellsession $ koji-tool --version-1.0+1.0.1 $ koji-tool --help Query and track Koji tasks, and install rpms from Koji. @@ -47,7 +47,7 @@ find Simple quick common queries using words like: [my, last, fail, complete, current, build, detail, install, tail, notail, hwinfo, x86_64, PACKAGE,- USER\'s]+ USER\'s, LIMIT] ``` ## koji-tool builds@@ -342,6 +342,7 @@ x86_64 aarch64 ppc64le s390x i686 armv7hl PACKAGE USER\'s+LIMIT ```
koji-tool.cabal view
@@ -1,5 +1,5 @@ name: koji-tool-version: 1.0+version: 1.0.1 synopsis: Koji CLI tool for querying tasks and installing builds description: koji-tool is a CLI interface to Koji with commands to query@@ -24,7 +24,7 @@ || == 8.10.7 || == 9.0.2 || == 9.2.7- || == 9.4.4+ || == 9.4.5 source-repository head type: git
src/Builds.hs view
@@ -186,7 +186,7 @@ Tasks.tasksCmd (Just hub) (Tasks.QueryOpts Nothing 7 [] [] Nothing Nothing False Nothing) False False False Nothing (Tasks.Parent taskid) whenJust minstall $ \installopts -> do putStrLn ""- installCmd False debug No (Just hub) Nothing False False False Nothing Nothing Nothing Nothing installopts Nothing ReqNVR [showNVR (buildNVR build)]+ installCmd False debug No (Just hub) Nothing False False False Nothing [] Nothing Nothing installopts Nothing ReqNVR [showNVR (buildNVR build)] formatBuildResult :: String -> Bool -> TimeZone -> BuildResult -> [String] formatBuildResult hub ended tz (BuildResult nvr state buildid mtaskid start mendtime) =
src/Find.hs view
@@ -13,7 +13,7 @@ import Distribution.Koji ( BuildState(BuildBuilding, BuildFailed, BuildComplete), TaskState(TaskOpen, TaskFailed, TaskClosed) )-import SimpleCmd (error')+import SimpleCmd (error', (+-+)) import qualified Builds import qualified Tasks@@ -41,7 +41,7 @@ wordsList :: ([String] -> String) -> [String] wordsList f =- map (f . findWords) [minBound..] ++ ["PACKAGE","USER\\'s"]+ map (f . findWords) [minBound..] ++ ["PACKAGE","USER\\'s","LIMIT"] allWords :: [String] allWords = concatMap findWords [minBound..]@@ -63,7 +63,7 @@ unwords more archs = if hasWord Arch then filter (`elem` findWords Arch) args else []- limit = if hasWord Limit then 1 else 10+ defaultlimit = if hasWord Limit then 1 else 10 failure = hasWord Failure complete = hasWord Complete current = hasWord Current@@ -73,11 +73,17 @@ tail' = hasWord Tail notail = hasWord NoTail hwinfo = hasWord Hwinfo- mpkg =+ (limit,mpkg) = case removeUsers (args \\ allWords) of- [] -> Nothing+ [] -> (defaultlimit, Nothing)+ [num] | all isDigit num && not (hasWord Limit) ->+ let number = read num+ in if number < 1000+ then (number, Nothing)+ else error' $ "is" +-+ num +-++ "an id? Use 'tasks' for very large limits" -- FIXME allow pattern?- [pkg] | all isPkgNameChar pkg -> Just pkg+ [pkg] | all isPkgNameChar pkg -> (defaultlimit, Just pkg) other -> error' $ "you can only specify one package - too many unknown words: " ++
src/Install.hs view
@@ -103,10 +103,10 @@ -- FIXME offer to download subpackage deps -- FIXME is --check-remote-time really needed? installCmd :: Bool -> Bool -> Yes -> Maybe String -> Maybe String -> Bool- -> Bool -> Bool -> Maybe PkgMgr -> Maybe String+ -> Bool -> Bool -> Maybe PkgMgr -> [String] -> Maybe ExistingStrategy -> Maybe String -> Select -> Maybe String -> Request -> [String] -> IO ()-installCmd dryrun debug yes mhuburl mpkgsurl listmode latest checkremotetime mmgr march mstrategy mprefix select mdisttag request pkgbldtsks = do+installCmd dryrun debug yes mhuburl mpkgsurl listmode latest checkremotetime mmgr archs mstrategy mprefix select mdisttag request pkgbldtsks = do checkSelection select let huburl = maybe fedoraKojiHub hubURL mhuburl pkgsurl = fromMaybe (hubToPkgsURL huburl) mpkgsurl@@ -129,7 +129,7 @@ -> IO (FilePath, [(Existence,NVRA)]) kojiRPMs huburl pkgsurl printDlDir bldtask = case readMaybe bldtask of- Just taskid -> kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode march mstrategy mprefix select checkremotetime printDlDir taskid+ Just taskid -> kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode archs mstrategy mprefix select checkremotetime printDlDir taskid Nothing -> kojiBuildRPMs huburl pkgsurl printDlDir bldtask kojiBuildRPMs :: String -> String -> IO () -> String@@ -147,14 +147,15 @@ [nvr] -> do putStrLn $ showNVR nvr ++ "\n" bid <- kojiGetBuildID' huburl (showNVR nvr)- nvras <- sort . map readNVRA . filter notDebugPkg <$> kojiGetBuildRPMs huburl nvr march bid+ -- FIXME should we try kojiTaskRPMs first?+ nvras <- sort . map readNVRA . filter notDebugPkg <$> kojiGetBuildRPMs huburl nvr archs bid results <- if null nvras then do mtid <- kojiGetBuildTaskID huburl (showNVR nvr) case mtid of Just (TaskId tid) ->- kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode march mstrategy mprefix select checkremotetime printDlDir tid+ kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode archs mstrategy mprefix select checkremotetime printDlDir tid Nothing -> error' $ "task id not found for" +-+ showNVR nvr else do when debug $ mapM_ (putStrLn . showNVRA) nvras@@ -191,10 +192,10 @@ notDebugPkg p = not ("-debuginfo-" `isInfixOf` p || "-debugsource-" `isInfixOf` p) -kojiTaskRPMs :: Bool -> Bool -> Yes -> String -> String -> Bool -> Maybe String+kojiTaskRPMs :: Bool -> Bool -> Yes -> String -> String -> Bool -> [String] -> Maybe ExistingStrategy -> Maybe String -> Select -> Bool -> IO () -> Int -> IO (FilePath, [(Existence,NVRA)])-kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode march mstrategy mprefix select checkremotetime printDlDir taskid = do+kojiTaskRPMs dryrun debug yes huburl pkgsurl listmode archs mstrategy mprefix select checkremotetime printDlDir taskid = do mtaskinfo <- Koji.getTaskInfo huburl taskid True tasks <- case mtaskinfo of Nothing -> error' "failed to get taskinfo"@@ -208,13 +209,10 @@ Koji.getTaskChildren huburl taskid True "buildArch" -> return [taskinfo] _ -> error' $ "unsupport method: " ++ method- arch <-- case march of- Nothing -> cmd "rpm" ["--eval", "%{_arch}"]- Just ar -> return ar+ totalarchs <- getArchs archs let (archtid,archtask) =- case find (selectBuildArch arch) tasks of- Nothing -> error' $ "no " ++ arch ++ " task found"+ case find (selectBuildArch totalarchs) tasks of+ Nothing -> error' $ "no task found for" +-+ unwords totalarchs Just task' -> case lookupStruct "id" task' of Nothing -> error' "task id not found"@@ -245,12 +243,12 @@ printDlDir return (subdir,dlRpms) where- selectBuildArch :: String -> Struct -> Bool- selectBuildArch arch t =- let march' = lookupStruct "arch" t- mmethod = lookupStruct "method" t- in march' `elem` [Just arch,Just "noarch"] &&- mmethod == Just "buildArch"+ selectBuildArch :: [String] -> Struct -> Bool+ selectBuildArch archs' t =+ case lookupStruct "arch" t of+ Just arch -> arch `elem` "noarch" : archs' &&+ lookupStruct "method" t == Just "buildArch"+ Nothing -> False getTaskNVRAs :: Int -> IO [NVRA] getTaskNVRAs taskid' =@@ -265,6 +263,12 @@ if null few then "0" else few in dropSuffix "packages" pkgsurl +/+ "work/tasks/" ++ lastFew +/+ show taskid' +/+ rpm +getArchs :: [String] -> IO [String]+getArchs archs =+ case archs of+ [] -> cmdLines "rpm" ["--eval", "%{_arch}"]+ ars -> return ars+ data Existence = ExistingNVR | ChangedNVR | NotInstalled deriving (Eq, Ord, Show) @@ -460,19 +464,16 @@ NVR n _ -> (n, True) -- empty until build finishes-kojiGetBuildRPMs :: String -> NVR -> Maybe String -> BuildID -> IO [String]-kojiGetBuildRPMs huburl nvr march (BuildId bid) = do+kojiGetBuildRPMs :: String -> NVR -> [String] -> BuildID -> IO [String]+kojiGetBuildRPMs huburl nvr archs (BuildId bid) = do rpms <- Koji.listBuildRPMs huburl bid- arch <-- case march of- Nothing -> cmd "rpm" ["--eval", "%{_arch}"]- Just ar -> return ar- return $ map getNVRA $ filter (forArch arch) rpms+ totalarchs <- getArchs archs+ return $ map getNVRA $ filter (forArch totalarchs) rpms where- forArch :: String -> Struct -> Bool- forArch arch st =+ forArch :: [String] -> Struct -> Bool+ forArch archs' st = case lookupStruct "arch" st of- Just a -> a `elem` [arch, "noarch"]+ Just a -> a `elem` "noarch" : archs' Nothing -> error $ "No arch found for rpm for: " ++ showNVR nvr getNVRA :: Struct -> String
src/Main.hs view
@@ -79,7 +79,7 @@ <*> switchWith 'L' "latest" "Latest build" <*> switchWith 't' "check-remote-time" "Check remote rpm timestamps" <*> optional pkgMgrOpt- <*> optional archOpt+ <*> many archOpt <*> optional existingOpt <*> optional (strOptionWith 'b' "prefix" "SUBPKGPREFIX" "Prefix to use for subpackages [default: base package]") <*> selectOpt