dnf-repo 0.6.3 → 0.6.4
raw patch · 5 files changed
+91/−86 lines, 5 files
Files
- ChangeLog.md +4/−0
- README.md +11/−9
- dnf-repo.cabal +2/−1
- src/Main.hs +57/−55
- src/State.hs +17/−21
ChangeLog.md view
@@ -1,5 +1,9 @@ # dnf-repo releases +## 0.6.4 (2026-06-22)+- fix handling of --only for enabled repos+- don't run dnf from /etc/yum.repos.d/ to unbreak relative rpm paths+ ## 0.6.3 (2026-05-27) - fix 0.6.2 regression in dnf detection logic that defaulted to /usr/bin/dnf5 - with dnf5 `--save` no longer uses config-manager since
README.md view
@@ -22,7 +22,7 @@ `$ dnf-repo --version` ```-0.6.3+0.6.4 ``` `$ dnf-repo --help` @@ -33,14 +33,14 @@ [-s|--save] [-4|--dnf4] [(-w|--weak-deps) | (-W|--no-weak-deps)] [--exact] [(-d|--disable REPOPAT) | (-e|--enable REPOPAT) | - (-o|--only REPOPAT) | (-x|--expire REPOPAT) | - (-X|--clear-expires) | (-E|--delete-repofile REPOPAT) | - (-z|--timestamp REPOPAT) | (-t|--enable-testing) | - (-T|--disable-testing) | (-m|--enable-modular) | - (-M|--disable-modular) | --enable-debuginfo | - --disable-debuginfo | --enable-source | --disable-source | - (-c|--add-copr [SERVER/]COPR/PROJECT|URL) [--osname OSNAME] - [--copr-releasever RELEASEVER] |+ (-o|--only REPOPAT) | --base-mirror URL | + (-x|--expire REPOPAT) | (-X|--clear-expires) | + (-E|--delete-repofile REPOPAT) | (-z|--timestamp REPOPAT) | + (-t|--enable-testing) | (-T|--disable-testing) | + (-m|--enable-modular) | (-M|--disable-modular) | + --enable-debuginfo | --disable-debuginfo | --enable-source | + --disable-source | (-c|--add-copr [SERVER/]COPR/PROJECT|URL) + [--osname OSNAME] [--copr-releasever RELEASEVER] | (-k|--add-koji REPO) | (-r|--add-repofile REPOFILEURL) [--repo-releasever RELEASEVER] | (-u|--repourl URL)] [DNFARGS]@@ -62,6 +62,8 @@ -d,--disable REPOPAT Disable repos -e,--enable REPOPAT Enable repos -o,--only REPOPAT Only use matching repos+ --base-mirror URL Override fedora metalink with a mirror baseurl (eg+ 'cloudfront', or reset with 'metalink') -x,--expire REPOPAT Expire repo cache (dnf4) -X,--clear-expires Undo cache expirations (dnf4) -E,--delete-repofile REPOPAT
dnf-repo.cabal view
@@ -1,5 +1,5 @@ name: dnf-repo-version: 0.6.3+version: 0.6.4 synopsis: A dnf wrapper with fine control of enabled repos description: A command-line wrapper of the dnf package manager to@@ -23,6 +23,7 @@ || == 9.6.7 || == 9.8.4 || == 9.10.3+ || == 9.12.4 data-dir: data data-files: koji-REPO.repo
src/Main.hs view
@@ -120,7 +120,8 @@ hSetBuffering stdout NoBuffering unlessM (doesDirectoryExist yumReposD) $ error' $ yumReposD +-+ "not found!"- withCurrentDirectory yumReposD $ do+ (nameStates,actions) <-+ withCurrentDirectory yumReposD $ do forM_ modes $ \case AddCopr copr mosname mrelease ->@@ -162,61 +163,62 @@ _ -> return False when (or outputs && (save || moreoutput) && not quiet) $ warning ""- mpkgmgr <-- if dnf4- then do- mdnf3 <- checkSystemPathFile "dnf-3"- case mdnf3 of- Just _ -> return $ Just Dnf4- Nothing -> error' "dnf-3 not found"- else do- mdnf5 <- checkSystemPathFile "dnf5"- case mdnf5 of- Just _ -> return $ Just Dnf5- Nothing -> do- mdnf3 <- checkSystemPathFile "dnf-3"- case mdnf3 of- Just _ -> return $ Just Dnf4- Nothing -> return Nothing- when save $- if null actions- then putStrLn "no changes to save"- else do- let changes = concatMap (saveRepo (mpkgmgr == Just Dnf4)) actions- unless (null changes) $ do- ok <- yesNo $ "Save changed repo" +-+ "enabled state" ++ ['s' | length changes > 1]- when ok $- if mpkgmgr == Just Dnf4- then doSudo dryrun debug (pkgMgrCmd Dnf4) $ "config-manager" : changes- else doSudo dryrun debug "sh" ["-c", unwords $ "sed" : "-i" : map show changes ++ ["/etc/yum.repos.d/*.repo"]]- if null args- then- when (null actions || listrepos) $ do- when save $ putStrLn ""- listRepos $ map (updateState actions) nameStates+ return (nameStates,actions)+ mpkgmgr <-+ if dnf4+ then do+ mdnf3 <- checkSystemPathFile "dnf-3"+ case mdnf3 of+ Just _ -> return $ Just Dnf4+ Nothing -> error' "dnf-3 not found"+ else do+ mdnf5 <- checkSystemPathFile "dnf5"+ case mdnf5 of+ Just _ -> return $ Just Dnf5+ Nothing -> do+ mdnf3 <- checkSystemPathFile "dnf-3"+ case mdnf3 of+ Just _ -> return $ Just Dnf4+ Nothing -> return Nothing+ when save $+ if null actions+ then putStrLn "no changes to save" else do- when save $ putStrLn ""- case mpkgmgr of- Just dnf ->- let repoargs = mapMaybe 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)]- extraargs =- -- special case for "dnf-repo [-c owner/project|-e repo] install"- case actions of- [action] ->- case action of- Enable repo True | args == ["install"] ->- [takeWhileEnd (/= ':') repo]- _ -> []- _ -> []- -- FIXME default to "install" of no command?- in doSudo dryrun debug (pkgMgrCmd dnf) $- quietopt repoargs ++ cachedir ++ weakdeps ++ map mungeArg args ++- extraargs- -- FIXME rpm-ostree install supports --enablerepo- Nothing -> error' "missing dnf (rpm-ostree is not supported)"+ let changes = concatMap (saveRepo (mpkgmgr == Just Dnf4)) actions+ unless (null changes) $ do+ ok <- yesNo $ "Save changed repo" +-+ "enabled state" ++ ['s' | length changes > 1]+ when ok $+ if mpkgmgr == Just Dnf4+ then doSudo dryrun debug (pkgMgrCmd Dnf4) $ "config-manager" : changes+ else doSudo dryrun debug "sh" ["-c", unwords $ "sed" : "-i" : map show changes ++ ["/etc/yum.repos.d/*.repo"]]+ if null args+ then+ when (null actions || listrepos) $ do+ when save $ putStrLn ""+ listRepos $ map (updateState actions) nameStates+ else do+ when save $ putStrLn ""+ case mpkgmgr of+ Just dnf ->+ let repoargs = mapMaybe 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)]+ extraargs =+ -- special case for "dnf-repo [-c owner/project|-e repo] install"+ case actions of+ [action] ->+ case action of+ Enable repo True | args == ["install"] ->+ [takeWhileEnd (/= ':') repo]+ _ -> []+ _ -> []+ -- FIXME default to "install" of no command?+ in doSudo dryrun debug (pkgMgrCmd dnf) $+ quietopt repoargs ++ cachedir ++ weakdeps ++ map mungeArg args +++ extraargs+ -- FIXME rpm-ostree install supports --enablerepo+ Nothing -> error' "missing dnf (rpm-ostree is not supported)" where mungeArg :: String -> String mungeArg "distrosync" = "distro-sync"
src/State.hs view
@@ -218,28 +218,27 @@ selectRepoMode mode acc (name,(enabled,file,murl)) = case mode of AddCopr repo _ _ ->- maybeChange repo isSuffixOf (not enabled) False (Enable name)+ maybeChange repo isSuffixOf (not enabled) (Enable name) AddKoji repo ->- maybeChange repo isSuffixOf (not enabled) False (Enable name)+ maybeChange repo isSuffixOf (not enabled) (Enable name) AddRepo repo _ ->- maybeChange (takeBaseName repo) isSuffixOf (not enabled) False (Enable name)+ maybeChange (takeBaseName repo) isSuffixOf (not enabled) (Enable name) RepoURL url -> Just $ BaseURL url EnableRepo pat ->- maybeChange pat matchesRepo (not enabled) False (Enable name)+ maybeChange pat matchesRepo (not enabled) (Enable name) DisableRepo pat ->- maybeChange pat matchesRepo enabled False (Disable name)+ maybeChange pat matchesRepo enabled (Disable name) OnlyRepo pat ->- maybeChange pat matchesRepo (not enabled) True (Only name)+ maybeChange pat matchesRepo True (Only name) ExpireRepo pat ->- maybeChange pat matchesRepo True False (Expire name)+ maybeChange pat matchesRepo True (Expire name) ClearExpires -> Just UnExpire DeleteRepo pat -> maybeChange pat matchesRepo (not enabled || error ("disable repo before deleting:" +-+ name))- False (Delete file) TimeStampRepo pat ->- maybeChange pat matchesRepo (not enabled) False (TimeStamp name murl)+ maybeChange pat matchesRepo (not enabled) (TimeStamp name murl) Specific change -> let substr = repoSubstr change in if change `elem`@@ -248,24 +247,21 @@ maybeChange substr (\p n -> p `isInfixOf` n && repoStatus acc (removeInfix substr name))- (not enabled) False (Enable name)+ (not enabled) (Enable name) else- maybeChange substr isInfixOf enabled False (Disable name)+ maybeChange substr isInfixOf enabled (Disable name) where- maybeChange :: String -> (String -> String -> Bool) -> Bool -> Bool+ maybeChange :: String -> (String -> String -> Bool) -> Bool -> (Bool -> ChangeEnable) -> Maybe ChangeEnable- maybeChange pat matcher state always change =+ maybeChange pat matcher state change = if pat `matcher` name then- if always- then Just $ change state+ if state+ then Just $ change True else- if state- then Just $ change True- else- if isGlob pat- then Nothing- else Just $ change False+ if isGlob pat+ then Nothing+ else Just $ change False else Nothing repoStatus :: [ChangeEnable] -> String -> Bool