diff --git a/clean.go b/clean.go index 015196e30..2992d56eb 100644 --- a/clean.go +++ b/clean.go @@ -192,10 +192,8 @@ func cleanUntracked() error { } dir := filepath.Join(config.BuildDir, file.Name()) - if shouldUseGit(dir) { - if err := show(passToGit(dir, "clean", "-fx")); err != nil { - return err - } + if err := show(passToGit(dir, "clean", "-fx")); err != nil { + return err } } @@ -208,21 +206,14 @@ func cleanAfter(bases []Base) { for i, base := range bases { dir := filepath.Join(config.BuildDir, base.Pkgbase()) - if shouldUseGit(dir) { - fmt.Printf(bold(cyan("::")+" Cleaning (%d/%d): %s\n"), i+1, len(bases), cyan(dir)) - _, stderr, err := capture(passToGit(dir, "reset", "--hard", "HEAD")) - if err != nil { - fmt.Fprintf(os.Stderr, "error resetting %s: %s", base.String(), stderr) - } + fmt.Printf(bold(cyan("::")+" Cleaning (%d/%d): %s\n"), i+1, len(bases), cyan(dir)) + _, stderr, err := capture(passToGit(dir, "reset", "--hard", "HEAD")) + if err != nil { + fmt.Fprintf(os.Stderr, "error resetting %s: %s", base.String(), stderr) + } - if err := show(passToGit(dir, "clean", "-fx")); err != nil { - fmt.Fprintln(os.Stderr, err) - } - } else { - fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir)) - if err := os.RemoveAll(dir); err != nil { - fmt.Fprintln(os.Stderr, err) - } + if err := show(passToGit(dir, "clean", "-fx")); err != nil { + fmt.Fprintln(os.Stderr, err) } } } diff --git a/cmd.go b/cmd.go index 52a7f3603..dd8275f3d 100644 --- a/cmd.go +++ b/cmd.go @@ -51,7 +51,6 @@ Permanent configuration options: --makepkg makepkg command to use --mflags Pass arguments to makepkg --pacman pacman command to use - --tar bsdtar command to use --git git command to use --gitflags Pass arguments to git --gpg gpg command to use @@ -91,8 +90,6 @@ Permanent configuration options: --devel Check development packages during sysupgrade --nodevel Do not check development packages - --gitclone Use git clone for PKGBUILD retrieval - --nogitclone Never use git clone for PKGBUILD retrieval --rebuild Always build target packages --rebuildall Always build all AUR packages --norebuild Skip package build if in cache and up to date @@ -131,7 +128,7 @@ yay specific options: --gendb Generates development package DB used for updating getpkgbuild specific options: - -f --force Force download for existing tar packages + -f --force Force download for existing ABS packages If no arguments are provided 'yay -Syu' will be performed If no operation is provided -Y will be assumed`) diff --git a/completions/fish b/completions/fish index c7b54d159..61e3bf5eb 100644 --- a/completions/fish +++ b/completions/fish @@ -172,7 +172,7 @@ complete -c $progname -n "$show" -s w -l news -d 'Print arch news' -f complete -c $progname -n "$show" -s q -l quiet -d 'Do not print news description' -f # Getpkgbuild options -complete -c $progname -n "$getpkgbuild" -s f -l force -d 'Force download for existing tar packages' -f +complete -c $progname -n "$getpkgbuild" -s f -l force -d 'Force download for existing ABS packages' -f complete -c $progname -n "$getpkgbuild" -xa "$listall" # Premenent configuration settings @@ -217,8 +217,6 @@ complete -c $progname -n "not $noopt" -l topdown -d 'Shows repository packages f complete -c $progname -n "not $noopt" -l bottomup -d 'Shows aur packages first and then repository' -f complete -c $progname -n "not $noopt" -l devel -d 'Check -git/-svn/-hg development version' -f complete -c $progname -n "not $noopt" -l nodevel -d 'Disable development version checking' -f -complete -c $progname -n "not $noopt" -l gitclone -d 'Use git to download and update PKGBUILDs' -f -complete -c $progname -n "not $noopt" -l nogitclone -d 'Download and update PKGBUILDs using tarballs' -f complete -c $progname -n "not $noopt" -l cleanafter -d 'Clean package sources after successful build' -f complete -c $progname -n "not $noopt" -l nocleanafter -d 'Disable package sources cleaning' -f complete -c $progname -n "not $noopt" -l timeupdate -d 'Check package modification date and version' -f diff --git a/config.go b/config.go index 8ff49fc4c..684460af4 100644 --- a/config.go +++ b/config.go @@ -72,7 +72,6 @@ type Configuration struct { NoConfirm bool `json:"-"` Devel bool `json:"devel"` CleanAfter bool `json:"cleanAfter"` - GitClone bool `json:"gitclone"` Provides bool `json:"provides"` PGPFetch bool `json:"pgpfetch"` UpgradeMenu bool `json:"upgrademenu"` @@ -180,7 +179,6 @@ func defaultSettings() *Configuration { AnswerEdit: "", AnswerUpgrade: "", RemoveMake: "ask", - GitClone: true, Provides: true, UpgradeMenu: true, CleanMenu: true, diff --git a/doc/yay.8 b/doc/yay.8 index 76c6de5d9..f3d18d652 100644 --- a/doc/yay.8 +++ b/doc/yay.8 @@ -31,8 +31,8 @@ Perform yay specific print operations. .TP .B \-G, \-\-getpkgbuild -Downloads PKGBUILD from ABS or AUR. ABS pkgbuilds are always downloaded using -tarballs and taken from trunk. The ABS can only be used for Arch Linux repositories +Downloads PKGBUILD from ABS or AUR. The ABS can only be used for Arch Linux +repositories .RE If no arguments are provided 'yay \-Syu' will be performed. @@ -47,9 +47,8 @@ These operations are extended to support both AUR and repo packages. .TP .B \-Sc Yay will also clean cached AUR package and any untracked Files in the -cache. Untracked files cleaning only works for packages downloaded -using gitclone. Cleaning untracked files will wipe any downloaded -sources or built packages but will keep already downloaded vcs sources. +cache. Cleaning untracked files will wipe any downloaded sources or +built packages but will keep already downloaded vcs sources. .TP .B \-R @@ -132,9 +131,8 @@ Only show titles when printing news. .SH GETPKGBUILD OPTIONS (APPLY TO \-G AND \-\-GETPKGBUILD) .TP .B \-f, \-\-force -Force download for packages that already exist in the current directory. This -ensures directories are not accidentally overwritten. This option is not needed -for git based downloads as \fBgit pull\fR already has safety mechanisms. +Force download for ABS packages that already exist in the current directory. This +ensures directories are not accidentally overwritten. .SH PERMANENT CONFIGURATION SETTINGS .TP @@ -355,28 +353,14 @@ a list of packages into yay (see \fBexamples\fR). .B \-\-nodevel Do not check for development packages updates during sysupgrade. -.TP -.B \-\-gitclone -Use git to download and update PKGBUILDs. PKGBUILDs previously downloaded -using tarball will continue to use tarballs until the package is clean -built. Similarly, PKGBUILDs managed with git will continue to use git until -the package is clean built.. - -.TP -.B \-\-nogitclone -Download and update PKGBUILDs using tarballs. The above conditions about -previously installed packages still apply. - .TP .B \-\-cleanafter -Remove package sources after successful Install. +Remove untracked files after installation. -For packages downloaded through git, untracked files are removed with the -exception of directories. This allows VCS packages to easily pull an update +Untracked files are removed with the exception of directories. +This allows VCS packages to easily pull an update instead of having to re clone the entire repo. -For packages downloaded via tarball, the entire directory is deleted. - .TP .B \-\-nocleanafter Do not remove package sources after successful Install. diff --git a/download.go b/download.go index ffef549cf..ef3e1fd1d 100644 --- a/download.go +++ b/download.go @@ -2,8 +2,6 @@ package main import ( "fmt" - "io" - "net/http" "os" "os/exec" "path/filepath" @@ -16,40 +14,6 @@ import ( const gitDiffRefName = "AUR_SEEN" -// Decide what download method to use: -// Use the config option when the destination does not already exits -// If .git exists in the destination use git -// Otherwise use a tarrball -func shouldUseGit(path string) bool { - _, err := os.Stat(path) - if os.IsNotExist(err) { - return config.GitClone - } - - _, err = os.Stat(filepath.Join(path, ".git")) - return err == nil || os.IsExist(err) -} - -func downloadFile(path string, url string) (err error) { - // Create the file - out, err := os.Create(path) - if err != nil { - return err - } - defer out.Close() - - // Get the data - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - // Writer the body to file - _, err = io.Copy(out, resp.Body) - return err -} - // Update the YAY_DIFF_REVIEW ref to HEAD. We use this ref to determine which diff were // reviewed by the user func gitUpdateSeenRef(path string, name string) error { @@ -172,31 +136,6 @@ func gitMerge(path string, name string) error { return nil } -// DownloadAndUnpack downloads url tgz and extracts to path. -func downloadAndUnpack(url string, path string) error { - err := os.MkdirAll(path, 0755) - if err != nil { - return err - } - - fileName := filepath.Base(url) - - tarLocation := filepath.Join(path, fileName) - defer os.Remove(tarLocation) - - err = downloadFile(tarLocation, url) - if err != nil { - return err - } - - _, stderr, err := capture(exec.Command(config.TarBin, "-xf", tarLocation, "-C", path)) - if err != nil { - return fmt.Errorf("%s", stderr) - } - - return nil -} - func getPkgbuilds(pkgs []string) error { missing := false wd, err := os.Getwd() @@ -239,14 +178,11 @@ func getPkgbuilds(pkgs []string) error { case err != nil && !os.IsNotExist(err): fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err) continue - case os.IsNotExist(err), cmdArgs.existsArg("f", "force"), shouldUseGit(filepath.Join(wd, name)): + default: if err = os.RemoveAll(filepath.Join(wd, name)); err != nil { fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err) continue } - default: - fmt.Printf("%s %s %s\n", yellow(smallArrow), cyan(name), "already downloaded -- use -f to overwrite") - continue } bases = append(bases, base) diff --git a/install.go b/install.go index 75dd8e4a7..cb54f857a 100644 --- a/install.go +++ b/install.go @@ -720,12 +720,9 @@ func updatePkgbuildSeenRef(bases []Base, cloned stringset.StringSet) error { var errMulti multierror.MultiError for _, base := range bases { pkg := base.Pkgbase() - dir := filepath.Join(config.BuildDir, pkg) - if shouldUseGit(dir) { - err := gitUpdateSeenRef(config.BuildDir, pkg) - if err != nil { - errMulti.Add(err) - } + err := gitUpdateSeenRef(config.BuildDir, pkg) + if err != nil { + errMulti.Add(err) } } return errMulti.Return() @@ -736,46 +733,34 @@ func showPkgbuildDiffs(bases []Base, cloned stringset.StringSet) error { for _, base := range bases { pkg := base.Pkgbase() dir := filepath.Join(config.BuildDir, pkg) - if shouldUseGit(dir) { - start, err := getLastSeenHash(config.BuildDir, pkg) + start, err := getLastSeenHash(config.BuildDir, pkg) + if err != nil { + errMulti.Add(err) + continue + } + + if cloned.Get(pkg) { + start = gitEmptyTree + } else { + hasDiff, err := gitHasDiff(config.BuildDir, pkg) if err != nil { errMulti.Add(err) continue } - if cloned.Get(pkg) { - start = gitEmptyTree - } else { - hasDiff, err := gitHasDiff(config.BuildDir, pkg) - if err != nil { - errMulti.Add(err) - continue - } - - if !hasDiff { - fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(base.String()), bold("No changes -- skipping")) - continue - } + if !hasDiff { + fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(base.String()), bold("No changes -- skipping")) + continue } + } - args := []string{"diff", start + "..HEAD@{upstream}", "--src-prefix", dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO"} - if useColor { - args = append(args, "--color=always") - } else { - args = append(args, "--color=never") - } - _ = show(passToGit(dir, args...)) + args := []string{"diff", start + "..HEAD@{upstream}", "--src-prefix", dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO"} + if useColor { + args = append(args, "--color=always") } else { - args := []string{"diff"} - if useColor { - args = append(args, "--color=always") - } else { - args = append(args, "--color=never") - } - args = append(args, "--no-index", "/var/empty", dir) - // git always returns 1. why? I have no idea - _ = show(passToGit(dir, args...)) + args = append(args, "--color=never") } + _ = show(passToGit(dir, args...)) } return errMulti.Return() @@ -861,11 +846,9 @@ func pkgbuildsToSkip(bases []Base, targets stringset.StringSet) stringset.String func mergePkgbuilds(bases []Base) error { for _, base := range bases { - if shouldUseGit(filepath.Join(config.BuildDir, base.Pkgbase())) { - err := gitMerge(config.BuildDir, base.Pkgbase()) - if err != nil { - return err - } + err := gitMerge(config.BuildDir, base.Pkgbase()) + if err != nil { + return err } } @@ -892,23 +875,15 @@ func downloadPkgbuilds(bases []Base, toSkip stringset.StringSet, buildDir string return } - if shouldUseGit(filepath.Join(config.BuildDir, pkg)) { - clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg) - if err != nil { - errs.Add(err) - return - } - if clone { - mux.Lock() - cloned.Set(pkg) - mux.Unlock() - } - } else { - err := downloadAndUnpack(config.AURURL+base.URLPath(), buildDir) - if err != nil { - errs.Add(err) - return - } + clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg) + if err != nil { + errs.Add(err) + return + } + if clone { + mux.Lock() + cloned.Set(pkg) + mux.Unlock() } mux.Lock() diff --git a/parser.go b/parser.go index 2631c89c9..4d25c3779 100644 --- a/parser.go +++ b/parser.go @@ -406,8 +406,6 @@ func isArg(arg string) bool { case "noansweredit": case "answerupgrade": case "noanswerupgrade": - case "gitclone": - case "nogitclone": case "gpgflags": case "mflags": case "gitflags": @@ -528,10 +526,6 @@ func handleConfig(option, value string) bool { config.AnswerUpgrade = value case "noanswerupgrade": config.AnswerUpgrade = "" - case "gitclone": - config.GitClone = true - case "nogitclone": - config.GitClone = false case "gpgflags": config.GpgFlags = value case "mflags":