packages feed

koji-tool 1.0.1 → 1.1

raw patch · 8 files changed

+47/−29 lines, 8 filesdep +simple-prompt

Dependencies added: simple-prompt

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Version history of koji-tool +## 1.1 (2023-07-22)+- tasks: now shows children of 'build' task+- install: correctly handle arch for installed packages (#4)+- install: support dnf5 and dnf-3 (default dnf)+- use simple-prompt+ ## 1.0.1 (2023-05-08) - 'install' now supports multiple arch options (#4) - 'find': interpret small number as a limit (default still 10 results)
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2021, Jens Petersen+Copyright (c) 2021-2023, Jens Petersen  All rights reserved. 
README.md view
@@ -5,7 +5,7 @@ and check buildlog sizes.  [Koji](https://pagure.io/koji/) is the RPM package buildsystem used by-Fedora Linux, CentOS, and some other projects.+Fedora Linux, CentOS Stream, RHEL, and some other projects.  By default Fedora Koji is used. @@ -23,7 +23,7 @@ ## Commands ```shellsession $ koji-tool --version-1.0.1+1.1 $ koji-tool --help Query and track Koji tasks, and install rpms from Koji. @@ -272,7 +272,8 @@ $ koji-tool install --help Usage: koji-tool install [-n|--dry-run] [-D|--debug] [-y|--yes] [-H|--hub HUB]                          [-P|--packages-url URL] [-l|--list] [-L|--latest]-                         [-t|--check-remote-time] [--rpm | --rpm-ostree | --dnf]+                         [-t|--check-remote-time]+                         [--rpm | --rpm-ostree | --dnf5 | --dnf3]                          [-a|--arch ARCH]                          [(-N|--no-reinstall) | (-S|--skip-existing)]                          [-b|--prefix SUBPKGPREFIX]@@ -295,7 +296,8 @@   -t,--check-remote-time   Check remote rpm timestamps   --rpm                    Use rpm instead of dnf   --rpm-ostree             Use rpm-ostree instead of dnf-  --dnf                    Use dnf to install [default unless ostree]+  --dnf5                   Use dnf5 to install+  --dnf3                   Use dnf-3 to install [default dnf unless ostree]   -a,--arch ARCH           Task arch   -N,--no-reinstall        Do not reinstall existing NVRs   -S,--skip-existing       Ignore already installed subpackages (implies@@ -387,5 +389,5 @@ koji-tool is distributed under a BSD license.  Bug reports and contributions are welcomed:-please propose suggestions and changes at:+please report issues and suggestions at: https://github.com/juhp/koji-tool/
TODO view
@@ -35,6 +35,7 @@ - different hubs put builds in different locations - html output - --rootlog+- maybe smaller number as buildid and larger as taskid  ## builds - --show-tags
koji-tool.cabal view
@@ -1,5 +1,5 @@ name:                koji-tool-version:             1.0.1+version:             1.1 synopsis:            Koji CLI tool for querying tasks and installing builds description:         koji-tool is a CLI interface to Koji with commands to query@@ -25,6 +25,7 @@                      || == 9.0.2                      || == 9.2.7                      || == 9.4.5+                     || == 9.6.2  source-repository head   type:                git@@ -58,6 +59,7 @@                        rpm-nvr >= 0.1.2,                        simple-cmd >= 0.2.2,                        simple-cmd-args >= 0.1.8,+                       simple-prompt >=0.2,                        text,                        time >= 1.9.1,                        utf8-string,
src/Install.hs view
@@ -26,6 +26,7 @@ import qualified Distribution.Koji.API as Koji import Network.HTTP.Directory (httpFileSize', httpLastModified', (+/+)) import SimpleCmd+import SimplePrompt (yesNoDefault) import System.Directory import System.FilePath import System.FilePath.Glob@@ -88,11 +89,12 @@ data Request = ReqName | ReqNV | ReqNVR   deriving Eq -data PkgMgr = DNF | RPM | OSTREE+data PkgMgr = DNF3 | DNF5 | RPM | OSTREE   deriving Eq  data ExistingStrategy = ExistingNoReinstall | ExistingSkip +-- FIXME autodetect NVR, NV, etc -- FIXME support buildid -- FIXME specify tag or task -- FIXME support --latest@@ -295,12 +297,14 @@   where     installExists :: NVRA -> IO (Maybe (Existence, NVRA))     installExists nvra = do-      minstalled <- cmdMaybe "rpm" ["-q", rpmName nvra]+      -- FIXME this will fail for noarch changes+      -- FIXME check kernel+      minstalled <- cmdMaybe "rpm" ["-q", rpmName nvra <.> rpmArch nvra]       let existence =             case minstalled of               Nothing -> NotInstalled               Just installed ->-                if installed == showNVRA nvra+                if showNVRA nvra `elem` lines installed                 then ExistingNVR                 else ChangedNVR       return $@@ -393,16 +397,7 @@ prompt yes str = do   if yes == Yes     then return True-    else do-    putStr $ str ++ " [Y/n]: "-    inp <- trim <$> getLine-    case lower inp of-      "" -> return True-      "y" -> return True-      "yes" -> return True-      "n" -> return False-      "no" -> return False-      _ -> prompt yes str+    else yesNoDefault True str  rpmPrompt :: Yes -> (Existence,NVRA) -> IO (Maybe (Existence,NVRA)) rpmPrompt yes (exist,nvra) = do@@ -508,13 +503,18 @@       unless (null dirpkgs) $ do       mgr <-         case mmgr of+          Just m -> return m           Nothing -> do             mostree <- findExecutable "rpm-ostree"-            return $ if isJust mostree then OSTREE else DNF-          Just m -> return m+            case mostree of+              Just _ -> return OSTREE+              Nothing -> do+                mdnf5 <- findExecutable "dnf5"+                return $ maybe DNF3 (const DNF5) mdnf5       let pkgmgr =             case mgr of-              DNF -> "dnf"+              DNF3 -> "dnf-3"+              DNF5 -> "dnf5"               RPM -> "rpm"               OSTREE -> "rpm-ostree"           com =@@ -529,7 +529,7 @@           (case mgr of             OSTREE -> cmd_             _ -> sudo_) pkgmgr $-            com ++ map showRpmFile dirpkgs ++ ["--assumeyes" | yes == Yes && mgr == DNF]+            com ++ map showRpmFile dirpkgs ++ ["--assumeyes" | yes == Yes && mgr `elem` [DNF3,DNF5]]      installTypes :: [(FilePath,[(Existence,NVRA)])]                  -> ([(FilePath,NVRA)],[(FilePath,NVRA)])@@ -545,14 +545,16 @@     reinstallCommand :: PkgMgr -> [String]     reinstallCommand mgr =       case mgr of-        DNF -> ["reinstall"]+        DNF3 -> ["reinstall"]+        DNF5 -> ["reinstall"]         RPM -> ["-Uvh","--replacepkgs"]         OSTREE -> ["install"]      installCommand :: PkgMgr -> [String]     installCommand mgr =       case mgr of-        DNF -> ["localinstall"]+        DNF3 -> ["localinstall"]+        DNF5 -> ["install"]         RPM -> ["-ivh"]         OSTREE -> ["install"] 
src/Main.hs view
@@ -157,7 +157,8 @@     pkgMgrOpt =       flagLongWith' RPM "rpm" "Use rpm instead of dnf" <|>       flagLongWith' OSTREE "rpm-ostree" "Use rpm-ostree instead of dnf" <|>-      flagLongWith' DNF "dnf" "Use dnf to install [default unless ostree]"+      flagLongWith' DNF5 "dnf5" "Use dnf5 to install" <|>+      flagLongWith' DNF3 "dnf3" "Use dnf-3 to install [default dnf unless ostree]"      existingOpt :: Parser ExistingStrategy     existingOpt =
src/Tasks.hs view
@@ -61,7 +61,7 @@ data TaskResult =   TaskResult {taskPackage :: Either String NVR,               taskArch :: String,-              _taskMethod :: String,+              taskMethod :: String,               _taskState :: TaskState,               _mtaskParent :: Maybe Int,               taskId :: Int,@@ -126,7 +126,11 @@         putStrLn ""         -- FIX for parent/build method show children (like we do with taskid)         (mapM_ putStrLn . formatTaskResult hub mtime tz) task-        buildlogSize qDebug tail' hwinfo mgrep hub task+        if taskMethod task == "build"+          then do+          getTasks tz hub queryopts (Parent $ taskId task) >>=+            mapM_ (printTask detailed tz) . mapMaybe maybeTaskResult+          else buildlogSize qDebug tail' hwinfo mgrep hub task         else do         (putStrLn . compactTaskResult hub tz) task         when (tail' || hwinfo || isJust mgrep) $