Преглед изворни кода

Merge pull request #243 from Morganamilo/rebuild2

 Add --rebuild flag
J Guerreiro пре 7 година
родитељ
комит
e0b8c92433
5 измењених фајлова са 55 додато и 8 уклоњено
  1. 12 0
      cmd.go
  2. 2 0
      config.go
  3. 5 1
      dependencies.go
  4. 11 7
      install.go
  5. 25 0
      yay.8

+ 12 - 0
cmd.go

@@ -61,6 +61,10 @@ Permanent configuration options:
     --redownload         Always download pkgbuilds of targets
     --redownloadall      Always download pkgbuilds of all AUR packages
     --noredownload       Skip pkgbuild download if in cache and up to date
+    --rebuild            Always build target packages
+    --rebuildall         Always build all AUR packages
+    --rebuildtree       Always build all AUR packages even if installed
+    --norebuild          Skip package build if in cache and up to date
     --mflags <flags>     Pass arguments to makepkg
     --sudoloop           Loop sudo calls in the background to avoid timeout
     --nosudoloop         Do not loop sudo calls in the background
@@ -397,6 +401,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

@@ -625,15 +625,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 {

+ 25 - 0
yay.8

@@ -224,6 +224,31 @@ When downloading pkgbuilds if the pkgbuild is found in cache and is equal or
 newer than the AUR's version use that instead of downloading a new one\&.
 .RE
 .PP
+\fB\-\-rebuild\fR
+.RS 4
+Always build target packages even when a copy is available in cache\&.
+.RE
+.PP
+\fB\-\-rebuildall\fR
+.RS 4
+Always build all AUR packages even when a copy is available
+in cache\&.
+.RE
+.PP
+\fB\-\-rebuildtree\fR
+.RS 4
+When installing an AUR package rebuild and reinstall all of its AUR
+dependencies recursivley, even the ones already installed. This flag allows
+you to easily rebuild packages against your current system's libraries if they
+have become incompatible.
+.RE
+.PP
+\fB\-\-norebuild\fR
+.RS 4
+When building packages if the package is found in cache and is an equal version
+to the one wanted skip the package build and use the existing package\&.
+.RE
+.PP
 \fB\-\-mflags <flags>\fR
 .RS 4
 Passes arguments to makepkg\&. These flags get passed to every instance where