Skip to content

Commit

Permalink
local,install: new --jobs option for rpmbuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
juhp committed Dec 17, 2024
1 parent 5e3fe81 commit 4815363
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.6.1 (2024-12-17)
- 'build','parallel': waitrepo now just uses "koji wait-repo --request"
- 'build': now respects --waitrepo
- 'local','install': new --jobs option for _smp_ncpus_max
- waitrepo is timed
- Koji targetMaybeSidetag: print sidetags if more than one

Expand Down
14 changes: 7 additions & 7 deletions src/Cmd/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import RpmBuild
-- FIXME add --debug or respect --verbose for dnf commands
-- FIXME handle subpackage renames (eg ghc-rpm-macros-no-prof to ghc-rpm-macros-quick)
-- FIXME allow building an srpm
-- FIXME ExistingStrategy option
installCmd :: Bool -> Bool -> Maybe Branch -> Maybe ForceShort -> [BCond]
-> Bool -> Bool -> Bool -> Select -> Maybe ExistingStrategy
-> (Maybe Branch,[String]) -> IO ()
installCmd quiet recurse mfrom mforceshort bconds reinstall nobuild nobuilddeps select mexisting (mbr, pkgs) = do
installCmd :: Bool -> Bool -> Maybe Branch -> Maybe Natural
-> Maybe ForceShort -> [BCond] -> Bool -> Bool -> Bool -> Select
-> Maybe ExistingStrategy -> (Maybe Branch,[String])
-> IO ()
installCmd quiet recurse mfrom mjobs mforceshort bconds reinstall nobuild nobuilddeps select mexisting (mbr, pkgs) = do
when (recurse && isShortCircuit mforceshort) $
error' "cannot use --recurse and --shortcircuit"
withPackagesMaybeBranch (boolHeader (recurse || length pkgs > 1)) True Nothing installPkg (mbr, pkgs)
Expand Down Expand Up @@ -76,15 +76,15 @@ installCmd quiet recurse mfrom mforceshort bconds reinstall nobuild nobuilddeps
mpkgdir <- lookForPkgDir rbr ".." dep
case mpkgdir of
Nothing -> putStrLn $ dep +-+ "not known"
Just pkgdir -> installCmd quiet recurse mfrom mforceshort bconds reinstall nobuild nobuilddeps select mexisting (mbr, [pkgdir]) >> putNewLn
Just pkgdir -> installCmd quiet recurse mfrom mjobs mforceshort bconds reinstall nobuild nobuilddeps select mexisting (mbr, [pkgdir]) >> putNewLn
-- FIXME option to enable/disable installing missing deps
-- FIXME --skip-missing-deps or prompt
else installDeps True spec
-- FIXME unused
_wasbuilt <-
if nobuild
then return True
else buildRPMs quiet False False mforceshort' bconds rpms br spec
else buildRPMs quiet False False mjobs mforceshort' bconds rpms br spec
unless (isShortCircuit mforceshort') $ do
let nvras = rpmsToNVRAs rpms
-- FIXME: prefix = fromMaybe (nvrName nvr) mprefix
Expand Down
6 changes: 3 additions & 3 deletions src/Cmd/Local.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import Git
import Package
import RpmBuild

localCmd :: Bool -> Bool -> Maybe ForceShort -> [BCond]
localCmd :: Bool -> Bool -> Maybe Natural -> Maybe ForceShort -> [BCond]
-> (BranchesReq, [String]) -> IO ()
localCmd quiet debug mforceshort bconds =
localCmd quiet debug mjobs mforceshort bconds =
withPackagesByBranches HeaderNone False Nothing ZeroOrOne localBuildPkg
where
localBuildPkg :: Package -> AnyBranch -> IO ()
Expand All @@ -38,7 +38,7 @@ localCmd quiet debug mforceshort bconds =
then return []
else builtRpms br spec
-- FIXME backup BUILD tree to .prev
void $ buildRPMs quiet debug True mforceshort bconds rpms br spec
void $ buildRPMs quiet debug True mjobs mforceshort bconds rpms br spec
-- FIXME mark BUILD dir complete

installDepsCmd :: (Maybe Branch,[String]) -> IO ()
Expand Down
1 change: 0 additions & 1 deletion src/Cmd/Merge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Cmd.Merge (
getNewerBranch)
where

import Numeric.Natural (Natural)
import Safe (tailSafe)

import Common
Expand Down
4 changes: 2 additions & 2 deletions src/Cmd/ReviewPackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ doInteractiveReview importsrpm mspec srpm = do
-- FIXME or download rpms
build <- yesNoDefault importsrpm "Build package locally"
when build $
localCmd False False Nothing [] (Branches [],[])
localCmd False False Nothing Nothing [] (Branches [],[])
putNewLn
putStrLn "# RpmLint"
void $ cmdBool "rpmlint" ["."] -- FIXME $ spec:srpm:rpms
spec <- maybe findSpecfile return mspec
whenM (yesNoDefault importsrpm "Install packages locally") $ do
installCmd False False Nothing Nothing [] False True True selectDefault Nothing (Nothing,[])
installCmd False False Nothing Nothing Nothing [] False True True selectDefault Nothing (Nothing,[])
rpms <- cmdLines "rpmspec" ["-q", "--rpms", "--qf", "%{name}\n", spec]
whenM (yesNoDefault importsrpm "Rpmlint installed packages") $ do
(_ok, out, err) <- cmdFull "rpmlint" ("-i" : rpms) ""
Expand Down
2 changes: 2 additions & 0 deletions src/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Common (
module Control.Monad.Extra,
module Data.List.Extra,
module Data.Maybe,
Natural,
#if !MIN_VERSION_base(4,11,0)
(<>),
#endif
Expand Down Expand Up @@ -34,6 +35,7 @@ import Data.Semigroup ((<>))
#endif

import Network.HTTP.Query ((+/+))
import Numeric.Natural (Natural)
import SimpleCmd ((+-+))

pluralOnly :: [a] -> String -> String
Expand Down
4 changes: 4 additions & 0 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ main = do
localCmd
<$> quietOpt "Hide the build.log until it errors"
<*> debugOpt "show the rpmbuild command"
<*> jobsOpt
<*> optional forceshortOpt
<*> many bcondOpt
<*> branchesPackages
Expand Down Expand Up @@ -261,6 +262,7 @@ main = do
<$> quietOpt "Quiet rpmbuild output"
<*> switchWith 'R' "recurse" "build and install missing deps packages"
<*> optional (optionLongWith branchM "from" "BRANCH" "Merge branch first")
<*> jobsOpt
<*> optional forceshortOpt
<*> many bcondOpt
<*> switchWith 'r' "reinstall" "reinstall rpms"
Expand Down Expand Up @@ -707,3 +709,5 @@ main = do
allowHeadOpt = switchLongWith "allow-head" "allow detached HEAD"

forceOpt = switchWith 'f' "force"

jobsOpt = optional (optionWith auto 'j' "jobs" "NUM" "Max processes in rpmbuild")
12 changes: 8 additions & 4 deletions src/RpmBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ isShortCircuit ms =
-- Note does not check if bcond changed
-- FIXME check tarball timestamp
-- FIXME handle prep (-bp) too?
buildRPMs :: Bool -> Bool -> Bool -> Maybe ForceShort -> [BCond] -> [FilePath]
-> AnyBranch -> FilePath -> IO Bool
buildRPMs quiet debug noclean mforceshort bconds rpms br spec = do
buildRPMs :: Bool -> Bool -> Bool -> Maybe Natural -> Maybe ForceShort
-> [BCond] -> [FilePath] -> AnyBranch -> FilePath -> IO Bool
buildRPMs quiet debug noclean mjobs mforceshort bconds rpms br spec = do
needBuild <-
if isJust mforceshort
then return True
Expand All @@ -306,8 +306,12 @@ buildRPMs quiet debug noclean mforceshort bconds rpms br spec = do
Just ShortCompile -> ["-bc", "--short-circuit"]
Just ShortInstall -> ["-bi", "--short-circuit"]
_ -> "-bb" : ["--noclean" | noclean]
jobs =
case mjobs of
Nothing -> []
Just n -> ["--define", "_smp_ncpus_max" +-+ show n]
args = sourcediropt ++ distopt ++
buildopt ++ map show bconds ++ autoreleaseOpt ++ [spec]
buildopt ++ jobs ++ map show bconds ++ autoreleaseOpt ++ [spec]
date <- cmd "date" ["+%T"]
rbr <- anyBranchToRelease br
nvr <- do
Expand Down

0 comments on commit 4815363

Please sign in to comment.