浏览代码

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.
morganamilo 7 年之前
父节点
当前提交
18af700053
共有 4 个文件被更改,包括 26 次插入8 次删除
  1. 8 0
      cmd.go
  2. 2 0
      config.go
  3. 5 1
      dependencies.go
  4. 11 7
      install.go

+ 8 - 0
cmd.go

@@ -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":

+ 2 - 0
config.go

@@ -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.

+ 5 - 1
dependencies.go

@@ -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
 				}

+ 11 - 7
install.go

@@ -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 {