Add --rebuild flag

Similar to the --redownload flag, when specifed targets will be rebuilt
even if an up to date version is cached. --rebuildall can be used to
ensure uninstalled dependencies are rebuilt as well.

Additionally, unlike --redownload there is also --rebuildtree. This
causes a rebuild and reinstall of a package and all of it's dependencies
recursivley. This is designed for when a libary updae, breaks an
installed AUR package due to a partial upgrade. polybar is a common
example

--rebuild allows you to easily skip the cache and rebuild against a newer
libary version. --rebuildtree is a more nuclear option where you can
rebuild the whole dependency tree.
This commit is contained in:
morganamilo 2018-03-14 01:48:33 +00:00
parent 62e244db0f
commit 18af700053
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
4 changed files with 26 additions and 8 deletions

8
cmd.go
View file

@ -397,6 +397,14 @@ func handleConfig(option, value string) bool {
config.ReDownload = "all"
case "noredownload":
config.ReDownload = "no"
case "rebuild":
config.ReBuild = "yes"
case "rebuildall":
config.ReBuild = "all"
case "rebuildtree":
config.ReBuild = "tree"
case "norebuild":
config.ReBuild = "no"
case "mflags":
config.MFlags = value
case "builddir":

View file

@ -32,6 +32,7 @@ type Configuration struct {
PacmanConf string `json:"pacmanconf"`
TarBin string `json:"tarbin"`
ReDownload string `json:"redownload"`
ReBuild string `json:"rebuild"`
GitBin string `json:"gitbin"`
GpgBin string `json:"gpgbin"`
MFlags string `json:"mflags"`
@ -135,6 +136,7 @@ func defaultSettings(config *Configuration) {
config.TimeUpdate = false
config.RequestSplitN = 150
config.ReDownload = "no"
config.ReBuild = "no"
}
// Editor returns the preferred system editor.

View file

@ -412,13 +412,17 @@ func depTreeRecursive(dt *depTree, localDb *alpm.Db, syncDb alpm.DbList, isMake
// Check if already installed.
_, isInstalled := localDb.PkgCache().FindSatisfier(versionedDep)
if isInstalled == nil {
if isInstalled == nil && config.ReBuild != "tree" {
continue
}
// Check the repos for a matching dep.
repoPkg, inRepos := syncDb.FindSatisfier(versionedDep)
if inRepos == nil {
if isInstalled == nil && config.ReBuild == "tree" {
continue
}
repoTreeRecursive(repoPkg, dt, localDb, syncDb)
continue
}

View file

@ -622,15 +622,19 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
srcinfo := srcinfos[pkg.PackageBase]
version := srcinfo.CompleteVersion()
for _, split := range bases[pkg.PackageBase] {
file, err := completeFileName(dir, split.Name+"-"+version.String())
if err != nil {
return err
}
if config.ReBuild == "no" || (config.ReBuild == "yes" && !targets.get(pkg.Name)) {
for _, split := range bases[pkg.PackageBase] {
file, err := completeFileName(dir, split.Name+"-"+version.String())
if err != nil {
return err
}
if file == "" {
built = false
if file == "" {
built = false
}
}
} else {
built = false
}
if built {