dnf-repo 0.5.4 → 0.5.5
raw patch · 7 files changed
+59/−36 lines, 7 filesdep ~simple-prompt
Dependency ranges changed: simple-prompt
Files
- ChangeLog.md +6/−0
- README.md +10/−10
- dnf-repo.cabal +2/−2
- src/ExpireRepos.hs +3/−3
- src/Main.hs +27/−12
- src/Sudo.hs +3/−4
- src/YumRepoFile.hs +8/−5
ChangeLog.md view
@@ -1,5 +1,11 @@ # dnf-repo releases +## 0.5.5 (2023-07-02)+- for dnf5 test for dnf-3 (for config-manager) and also dnf+- YumRepoFile: fix parsing of "enable = 1" (for UBI)+- sudo debug: print cmd+- update simple-prompt to 0.2+ ## 0.5.4 (2023-05-06) - Revert "don't printAction's if no args" - use simple-prompt
README.md view
@@ -3,16 +3,16 @@ A wrapper of the dnf package manager for fine control of enabled/disabled yum repos (eg Copr repos). -dnf is the package manager used by Fedora Linux and also from RHEL 8 on.+dnf is the package manager used by Fedora Linux, Centos Stream, and RHEL. -DNF is a bit slow at handling multiple repos because it attempts-to refresh the cached repodata frequently. So it can be advantageous-to disable smaller repos by default and only enable them as needed-periodically.+DNF can get slower with many repos enabled because it attempts+to refresh its cached repodata frequently. So it can be advantageous+to disable some small repos by default and only enable them periodically+as needed. This tool can temporarily enable/disable repo(s) selected by substring(s). Changes to repos' enabled states can be saved too.-It is also possible to expire repos' caches individually.+It is also possible to expire repo caches individually. There are also smart options to enable/disable testing/modular repos (and even source/debuginfo repos),@@ -22,7 +22,7 @@ ```shellsession $ dnf-repo --version-0.5.4+0.5.5 $ dnf-repo --help DNF wrapper repo tool @@ -65,7 +65,7 @@ --enable-source Enable source repos --disable-source Disable source repos -c,--add-copr COPR Create repo file for copr repo- -k,--add-koji REPO Create repo file for koji repo (f37-build, rawhide,+ -k,--add-koji REPO Create repo file for koji repo (f38-build, rawhide, epel9-build, etc) -u,--repourl URL Use temporary repo from a baseurl ```@@ -122,9 +122,9 @@ ``` ### Switch system from rawhide-Switch a system from Rawhide to F37:+Switch a system from Rawhide to F38: ```shellsession-$ dnf-repo -d rawhide -e fedora distrosync --releasever 37 fedora-\*+$ dnf-repo -d rawhide -e fedora distrosync --releasever 38 fedora-\* with disabled 'rawhide' with enabled 'fedora'
dnf-repo.cabal view
@@ -1,5 +1,5 @@ name: dnf-repo-version: 0.5.4+version: 0.5.5 synopsis: DNF wrapper tool to control repos description: A command-line wrapper of the dnf package manager to@@ -46,7 +46,7 @@ http-directory >= 0.1.9, simple-cmd, simple-cmd-args >= 0.1.8,- simple-prompt+ simple-prompt >= 0.2 default-language: Haskell2010 ghc-options: -Wall if impl(ghc >= 8.0)
src/ExpireRepos.hs view
@@ -6,7 +6,7 @@ import Control.Monad import Data.List (nub) import SimpleCmd (error')-import SimplePrompt (yesno)+import SimplePrompt (yesNo) import Sudo @@ -17,7 +17,7 @@ expireRepo dryrun debug repo = do old <- read <$> readFile expiredFile :: IO [String] let expired = nub $ old ++ [repo]- ok <- yesno Nothing $ "Mark '" ++ repo ++ "' cache expired"+ ok <- yesNo $ "Mark '" ++ repo ++ "' cache expired" when ok $ do doSudo dryrun debug "sed" ["-i", "-e", "s/" ++ renderShow old ++ "/" ++ renderShow expired ++ "/",@@ -42,7 +42,7 @@ else do mapM_ putStrLn old putStrLn ""- ok <- yesno Nothing "Unset cache expirations"+ ok <- yesNo "Unset cache expirations" when ok $ do doSudo dryrun debug "sed" ["-i", "-e", "s/" ++ renderShow old ++ "/" ++ renderShow [] ++ "/",
src/Main.hs view
@@ -12,8 +12,12 @@ import Network.HTTP.Directory (httpExists', (+/+)) import SimpleCmd import SimpleCmdArgs-import SimplePrompt (yesno)-import System.Directory+import SimplePrompt (yesNo)+import System.Directory (doesFileExist, findExecutable, withCurrentDirectory,+#if !MIN_VERSION_simple_cmd(0,2,4)+ listDirectory+#endif+ ) import System.Environment (lookupEnv) import System.FilePath import System.IO (hSetBuffering, stdout, BufferMode(NoBuffering))@@ -64,7 +68,7 @@ flagLongWith' (Specific EnableSource) "enable-source" "Enable source repos" <|> flagLongWith' (Specific DisableSource) "disable-source" "Disable source repos" <|> AddCopr <$> repoOptionWith 'c' "add-copr" "COPR" "Create repo file for copr repo" <|>- AddKoji <$> repoOptionWith 'k' "add-koji" "REPO" "Create repo file for koji repo (f37-build, rawhide, epel9-build, etc)" <|>+ AddKoji <$> repoOptionWith 'k' "add-koji" "REPO" "Create repo file for koji repo (f38-build, rawhide, epel9-build, etc)" <|> RepoURL <$> strOptionWith 'u' "repourl" "URL" "Use temporary repo from a baseurl" coprRepoTemplate :: FilePath@@ -117,9 +121,14 @@ else do let changes = concatMap saveRepo actions unless (null changes) $ do- ok <- yesno Nothing $ "Save changed repo" ++ " enabled state" ++ ['s' | length changes > 1]- when ok $- doSudo dryrun debug "dnf" $ "config-manager" : changes+ ok <- yesNo $ "Save changed repo" ++ " enabled state" ++ ['s' | length changes > 1]+ when ok $ do+ mdnf3 <- findExecutable "dnf-3"+ case mdnf3 of+ -- FIXME cannot combine --disable and --enable+ Just dnf3 -> doSudo dryrun debug dnf3 $ "config-manager" : changes+ -- FIXME need to have repo files in changes+ Nothing -> doSudo dryrun debug "sed" $ "config-manager" : changes if null args then when (null actions || listrepos) $ do@@ -128,11 +137,17 @@ else do sleep 1 when save $ putStrLn ""- let repoargs = concatMap changeRepo actions- weakdeps = maybe [] (\w -> ["--setopt=install_weak_deps=" ++ show w]) mweakdeps- quietopt = if quiet then ("-q" :) else id- cachedir = ["--setopt=cachedir=/var/cache/dnf" </> relver | relver <- maybeToList (maybeReleaseVer args)]- in doSudo dryrun debug "dnf" $ quietopt repoargs ++ cachedir ++ weakdeps ++ args+ mdnf <- findExecutable "dnf"+ case mdnf of+ Just dnf -> do+ when debug $ putStrLn dnf+ let repoargs = concatMap changeRepo actions+ weakdeps = maybe [] (\w -> ["--setopt=install_weak_deps=" ++ show w]) mweakdeps+ quietopt = if quiet then ("-q" :) else id+ cachedir = ["--setopt=cachedir=/var/cache/dnf" </> relver | relver <- maybeToList (maybeReleaseVer args)]+ in doSudo dryrun debug dnf $ quietopt repoargs ++ cachedir ++ weakdeps ++ args+ -- FIXME rpm-ostree install supports --enablerepo+ Nothing -> error' "rpm-ostree not supported" -- FIXME pull non-fedora copr repo file addCoprRepo :: Bool -> Bool -> String -> IO ()@@ -195,7 +210,7 @@ case mowned of Just owner -> warning $ repofile +-+ "owned by" +-+ owner Nothing -> do- ok <- yesno Nothing $ "Remove " ++ takeFileName repofile+ ok <- yesNo $ "Remove " ++ takeFileName repofile when ok $ do doSudo dryrun debug "rm" [repofile]
src/Sudo.hs view
@@ -8,8 +8,7 @@ -- FIXME make this silent (simple-cmd-0.2.7) unless debug doSudo :: Bool -> Bool -> String -> [String] -> IO () doSudo dryrun debug c args = do- if dryrun- then cmdN c args- else do- when debug $ cmdN c args+ when (dryrun || debug) $ do+ cmdN c args+ unless dryrun $ sudo_ c args
src/YumRepoFile.hs view
@@ -18,7 +18,7 @@ import Data.Either (partitionEithers) import Data.List.Extra (dropPrefix, dropSuffix, isPrefixOf, isInfixOf, isSuffixOf, nub,- replace, sortOn, stripInfix, trim)+ replace, sortOn, splitOn, stripInfix, trim) import Data.Maybe (mapMaybe) import SimpleCmd (error') import System.FilePath.Glob (compile, match)@@ -260,12 +260,15 @@ Nothing -> [] Just (section,rest) -> let (enabled,more) =- case dropWhile (not . ("enabled=" `isPrefixOf`)) rest of+ case dropWhile (not . ("enabled" `isPrefixOf`)) rest of [] -> error' $ "no enabled field for " ++ section (e:more') ->- case trim e of- "enabled=1" -> (True,more')- "enabled=0" -> (False,more')+ case splitOn "=" e of+ [_,v] ->+ case trim v of+ "1" -> (True,more')+ "0" -> (False,more')+ _ -> error' $ "strange enabled state " ++ e ++ " for " ++ section _ -> error' $ "unknown enabled state " ++ e ++ " for " ++ section in (section,(enabled,file)) : parseRepos file more where