Merge pull request #349 from Morganamilo/fix#331

Lots of formatting tweaks
This commit is contained in:
J Guerreiro 2018-04-12 15:40:22 +01:00 committed by GitHub
commit aa649d9b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 153 additions and 116 deletions

View File

@ -34,7 +34,7 @@ func questionCallback(question alpm.QuestionAny) {
if db != thisDb {
db = thisDb
str += bold(cyan("\n:: ")) + bold("Repository "+db+"\n\t")
str += bold(cyan("\n:: ")) + bold("Repository "+db+"\n ")
}
str += fmt.Sprintf("%d) %s ", size, pkg.Name())
size++

View File

@ -187,11 +187,11 @@ func editor() (string, []string) {
fallthrough
default:
fmt.Println()
fmt.Println(bold(red(arrow)+" Warning:"), cyan("$EDITOR"), "is not set")
fmt.Println(bold(arrow) + " Please add " + cyan("$EDITOR") + " or " + cyan("$VISUAL") + " to your environment variables.")
fmt.Println(bold(red(arrow)), bold(cyan("$EDITOR")), bold("is not set"))
fmt.Println(bold(red(arrow)) + bold(" Please add ") + bold(cyan("$EDITOR")) + bold(" or ") + bold(cyan("$VISUAL")) + bold(" to your environment variables."))
for {
fmt.Print(green(bold(arrow)) + green(" Edit PKGBUILD with: "))
fmt.Print(green(bold(arrow + " Edit PKGBUILD with: ")))
editorInput, err := getInput("")
if err != nil {
fmt.Println(err)
@ -225,7 +225,7 @@ func continueTask(s string, def string) (cont bool) {
}
var response string
fmt.Print(bold(green(arrow+" "+s+" ")), bold(postFix))
fmt.Print(bold(green(arrow)+" "+s), bold(postFix))
n, err := fmt.Scanln(&response)
if err != nil || n == 0 {

View File

@ -301,13 +301,13 @@ func checkForAllConflicts(dc *depCatagories) error {
var wg sync.WaitGroup
wg.Add(2)
fmt.Println(bold(cyan("::") + " Checking for conflicts..."))
fmt.Println(bold(cyan("::") + bold(" Checking for conflicts...")))
go func() {
conflicts, err = checkForConflicts(dc)
wg.Done()
}()
fmt.Println(bold(cyan("::") + " Checking for inner conflicts..."))
fmt.Println(bold(cyan("::") + bold(" Checking for inner conflicts...")))
go func() {
innerConflicts = checkForInnerConflicts(dc)
wg.Done()
@ -320,27 +320,28 @@ func checkForAllConflicts(dc *depCatagories) error {
}
if len(innerConflicts) != 0 {
fmt.Println(
red("\nInner conflicts found:"))
fmt.Println()
fmt.Println(bold(red(arrow)), bold("Inner conflicts found:"))
for name, pkgs := range innerConflicts {
str := "\t" + name + ":"
str := red(bold(smallArrow)) + " " + name + ":"
for pkg := range pkgs {
str += " " + magenta(pkg)
str += " " + cyan(pkg)
}
fmt.Println(str)
}
return fmt.Errorf("Aborting")
return fmt.Errorf("Unresolvable package conflicts, aborting")
}
if len(conflicts) != 0 {
fmt.Println(
red("\nPackage conflicts found:"))
fmt.Println()
fmt.Println(bold(red(arrow)), bold("Package conflicts found:"))
for name, pkgs := range conflicts {
str := "\tInstalling " + magenta(name) + " will remove:"
str := red(bold(smallArrow)) + " Installing " + cyan(name) + " will remove:"
for pkg := range pkgs {
str += " " + magenta(pkg)
str += " " + cyan(pkg)
}
fmt.Println(str)

View File

@ -16,6 +16,7 @@ type depTree struct {
Missing stringSet
Groups stringSet
Provides map[string]string
Warnings *aurWarnings
}
type depCatagories struct {
@ -33,6 +34,7 @@ func makeDepTree() *depTree {
make(stringSet),
make(stringSet),
make(map[string]string),
&aurWarnings{},
}
return &dt
@ -325,8 +327,9 @@ func depCatagoriesRecursive(_pkg *rpc.Pkg, dc *depCatagories, dt *depTree, isMak
// the same as the height of the tree.
// The example does not really do this justice, In the real world where packages
// have 10+ dependencies each this is a very nice optimization.
func getDepTree(pkgs []string) (*depTree, error) {
func getDepTree(pkgs []string, warnings *aurWarnings) (*depTree, error) {
dt := makeDepTree()
dt.Warnings = warnings
localDb, err := alpmHandle.LocalDb()
if err != nil {
@ -382,7 +385,7 @@ func getDepTree(pkgs []string) (*depTree, error) {
}
if len(dt.ToProcess) > 0 {
fmt.Println(bold(cyan("::") + " Querying AUR..."))
fmt.Println(bold(cyan("::") + bold(" Querying AUR...")))
}
err = depTreeRecursive(dt, localDb, syncDb, false)
@ -394,6 +397,8 @@ func getDepTree(pkgs []string) (*depTree, error) {
err = checkVersions(dt)
}
dt.Warnings.Print()
return dt, err
}
@ -456,7 +461,7 @@ func depTreeRecursive(dt *depTree, localDb *alpm.Db, syncDb alpm.DbList, isMake
}
// Assume toprocess only contains aur stuff we have not seen
info, err := aurInfo(currentProcess.toSlice())
info, err := aurInfo(currentProcess.toSlice(), dt.Warnings)
if err != nil {
return

View File

@ -107,10 +107,10 @@ nextPkg:
errD := downloadAndUnpack(url, path, true)
if errD != nil {
fmt.Println(bold(magenta(pkg.Name())), bold(green(errD.Error())))
fmt.Println(bold(red(arrow)) + " " + bold(cyan(pkg.Name())), bold(red(errD.Error())))
}
fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(magenta(pkg.Name())), bold(green("from ABS")))
fmt.Println(bold(yellow(arrow)), "Downloaded", cyan(pkg.Name()), "from ABS")
continue nextPkg
}
}
@ -123,14 +123,14 @@ nextPkg:
// GetPkgbuild downloads pkgbuild from the AUR.
func getPkgbuildsfromAUR(pkgs []string, dir string) (err error) {
aq, err := aurInfo(pkgs)
aq, err := aurInfoPrint(pkgs)
if err != nil {
return err
}
for _, pkg := range aq {
downloadAndUnpack(baseURL+aq[0].URLPath, dir, false)
fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(magenta(pkg.Name)), bold(green("from AUR")))
fmt.Println(bold(yellow(arrow)), "Downloaded", cyan(pkg.Name), "from AUR")
}
return

View File

@ -24,6 +24,8 @@ func install(parser *arguments) error {
var aurUp upSlice
var repoUp upSlice
warnings := &aurWarnings{}
removeMake := false
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
srcinfos := make(map[string]*gopkg.PKGBUILD)
@ -41,7 +43,7 @@ func install(parser *arguments) error {
//if we are doing -u also request all packages needing update
if parser.existsArg("u", "sysupgrade") {
aurUp, repoUp, err = upList()
aurUp, repoUp, err = upList(warnings)
if err != nil {
return err
}
@ -59,7 +61,7 @@ func install(parser *arguments) error {
//if len(aurTargets) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
// fmt.Println(bold(cyan("::") + " Querying AUR..."))
//}
dt, err := getDepTree(requestTargets)
dt, err := getDepTree(requestTargets, warnings)
if err != nil {
return err
}
@ -81,7 +83,7 @@ func install(parser *arguments) error {
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
for name := range dt.Missing {
str += "\n\t" + name
str += "\n " + name
}
return fmt.Errorf("%s", str)
@ -129,7 +131,7 @@ func install(parser *arguments) error {
}
if hasAur && 0 == os.Geteuid() {
return fmt.Errorf(red(arrow + " Refusing to install AUR Packages as root, Aborting."))
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
}
dc, err = getDepCatagories(requestTargets, dt)
@ -151,15 +153,16 @@ func install(parser *arguments) error {
}
if hasAur {
printDepCatagories(dc)
hasAur = len(dc.Aur) != 0
fmt.Println()
err = checkForAllConflicts(dc)
if err != nil {
return err
}
printDepCatagories(dc)
fmt.Println()
if len(dc.MakeOnly) > 0 {
if !continueTask("Remove make dependencies after install?", "yY") {
removeMake = true
@ -170,6 +173,7 @@ func install(parser *arguments) error {
if err != nil {
return err
}
cleanBuilds(toClean)
err = downloadPkgBuilds(dc.Aur, parser.targets, dc.Bases)
@ -182,6 +186,13 @@ func install(parser *arguments) error {
if err != nil {
return err
}
oldValue := config.NoConfirm
config.NoConfirm = false
if !continueTask(bold(green("Proceed with install?")), "nN") {
return fmt.Errorf("Aborting due to user")
}
config.NoConfirm = oldValue
}
//inital srcinfo parse before pkgver() bump
@ -222,13 +233,6 @@ func install(parser *arguments) error {
return fmt.Errorf("%s%s", stderr, err)
}
}
} else if hasAur {
oldValue := config.NoConfirm
config.NoConfirm = false
if len(toEdit) > 0 && !continueTask("Proceed with install?", "nN") {
return fmt.Errorf("Aborting due to user")
}
config.NoConfirm = oldValue
}
if hasAur {
@ -303,8 +307,8 @@ nextpkg:
}
if len(incompatible) > 0 {
fmt.Print(
bold(green(("\nThe following packages are not compatable with your architecture:"))))
fmt.Println()
fmt.Print(bold(yellow(arrow)) + " The following packages are not compatable with your architecture:")
for pkg := range incompatible {
fmt.Print(" " + cyan(pkg))
}
@ -329,7 +333,7 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
for n, pkg := range pkgs {
dir := config.BuildDir + pkg.PackageBase + "/"
toPrint += fmt.Sprintf("%s %-40s", magenta(strconv.Itoa(len(pkgs)-n)),
toPrint += fmt.Sprintf(magenta("%3d")+" %-40s", len(pkgs)-n,
bold(formatPkgbase(pkg, bases)))
if installed.get(pkg.Name) {
toPrint += bold(green(" (Installed)"))
@ -345,9 +349,10 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
fmt.Print(toPrint)
if askClean {
fmt.Println(bold(green(arrow + " Packages to cleanBuild?")))
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + green("[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)")))
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
fmt.Print(bold(green(arrow + " ")))
cleanInput, err := getInput(config.AnswerClean)
if err != nil {
@ -401,7 +406,7 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
}
fmt.Println(bold(green(arrow + " PKGBUILDs to edit?")))
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + green("[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)")))
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
fmt.Print(bold(green(arrow + " ")))
@ -454,7 +459,7 @@ func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
func cleanBuilds(pkgs []*rpc.Pkg) {
for i, pkg := range pkgs {
dir := config.BuildDir + pkg.PackageBase
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(pkgs), dir)
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(pkgs), cyan(dir))
os.RemoveAll(dir)
}
}
@ -483,7 +488,7 @@ func parseSRCINFOFiles(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bas
dir := config.BuildDir + pkg.PackageBase + "/"
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
pkgbuild, err := gopkg.ParseSRCINFO(dir + ".SRCINFO")
if err != nil {
@ -501,7 +506,7 @@ func tryParsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
dir := config.BuildDir + pkg.PackageBase + "/"
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
pkgbuild, err := gopkg.ParseSRCINFO(dir + ".SRCINFO")
if err != nil {
@ -551,7 +556,7 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r
if err == nil {
if !version.Newer(pkgbuild.Version()) {
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
continue
}
}
@ -560,7 +565,7 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r
str := bold(cyan("::") + " Downloading PKGBUILD (%d/%d): %s\n")
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
err := downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false)
if err != nil {
@ -582,7 +587,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, inco
err = passToMakepkg(dir, args...)
if err != nil {
return fmt.Errorf("Error downloading sources: %s", formatPkgbase(pkg, bases))
return fmt.Errorf("Error downloading sources: %s", cyan(formatPkgbase(pkg, bases)))
}
}
@ -625,8 +630,8 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
}
if built {
fmt.Println(bold(red(arrow+" Warning:")),
pkg.Name+"-"+pkg.Version+" Already made -- skipping build")
fmt.Println(bold(yellow(arrow)),
cyan(pkg.Name+"-"+pkg.Version) + bold(" Already made -- skipping build"))
} else {
args := []string{"-Ccf", "--noconfirm"}

18
keys.go
View File

@ -72,12 +72,16 @@ func checkPgpKeys(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, srcinfos map[str
return nil
}
fmt.Println()
question, err := formatKeysToImport(problematic, bases)
str, err := formatKeysToImport(problematic, bases)
if err != nil {
return err
}
if continueTask(question, "nN") {
fmt.Println()
fmt.Println(str)
if continueTask(bold(green("Import?")), "nN") {
return importKeys(problematic.toSlice())
}
@ -90,7 +94,7 @@ func importKeys(keys []string) error {
cmd := exec.Command(config.GpgBin, append(args, keys...)...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
fmt.Printf("%s Importing keys with gpg...\n", bold(cyan("::")))
fmt.Printf("%s %s...\n", bold(cyan("::")), bold("Importing keys with gpg..."))
err := cmd.Run()
if err != nil {
@ -107,15 +111,15 @@ func formatKeysToImport(keys pgpKeySet, bases map[string][]*rpc.Pkg) (string, er
}
var buffer bytes.Buffer
buffer.WriteString(bold(green(("GPG keys need importing:\n"))))
buffer.WriteString(bold(green(arrow)))
buffer.WriteString(bold(green(" PGP keys need importing:")))
for key, pkgs := range keys {
pkglist := ""
for _, pkg := range pkgs {
pkglist += formatPkgbase(pkg, bases) + " "
}
pkglist = strings.TrimRight(pkglist, " ")
buffer.WriteString(fmt.Sprintf("\t%s, required by: %s\n", green(key), cyan(pkglist)))
buffer.WriteString(fmt.Sprintf("\n%s %s, required by: %s", yellow(bold(smallArrow)), cyan(key), cyan(pkglist)))
}
buffer.WriteString(bold(green(fmt.Sprintf("%s Import?", arrow))))
return buffer.String(), nil
}

View File

@ -11,6 +11,34 @@ import (
)
const arrow = "==>"
const smallArrow = " ->"
func (warnings *aurWarnings) Print() {
if len(warnings.Missing) > 0 {
fmt.Print(bold(yellow(smallArrow)) + " Missing AUR Packages:")
for _, name := range warnings.Missing {
fmt.Print(" " + cyan(name))
}
fmt.Println()
}
if len(warnings.Orphans) > 0 {
fmt.Print(bold(yellow(smallArrow)) + " Orphaned AUR Packages:")
for _, name := range warnings.Orphans {
fmt.Print(" " + cyan(name))
}
fmt.Println()
}
if len(warnings.OutOfDate) > 0 {
fmt.Print(bold(yellow(smallArrow)) + " Out Of Date AUR Packages:")
for _, name := range warnings.OutOfDate {
fmt.Print(" " + cyan(name))
}
fmt.Println()
}
}
// human method returns results in human readable format.
func human(size int64) string {
@ -131,7 +159,7 @@ func (u upSlice) Print(start int) {
left, right := getVersionDiff(i.LocalVersion, i.RemoteVersion)
fmt.Print(magenta(fmt.Sprintf("%3d ", len(u)+start-k-1)))
fmt.Print(bold(colourHash(i.Repository)), "/", cyan(i.Name))
fmt.Print(bold(colourHash(i.Repository)), "/", bold(i.Name))
w := 70 - len(i.Repository) - len(i.Name)
padding := fmt.Sprintf("%%%ds", w)
@ -216,7 +244,7 @@ func printDownloads(repoName string, length int, packages string) {
repoInfo := bold(blue(
"[" + repoName + ": " + strconv.Itoa(length) + "]"))
fmt.Println(repoInfo + magenta(packages))
fmt.Println(repoInfo + cyan(packages))
}
// PrintInfo prints package info like pacman -Si.
@ -277,16 +305,16 @@ func localStatistics() error {
fmt.Printf(bold("Yay version v%s\n"), version)
fmt.Println(bold(cyan("===========================================")))
fmt.Println(bold(green("Total installed packages: ")) + magenta(strconv.Itoa(info.Totaln)))
fmt.Println(bold(green("Total foreign installed packages: ")) + magenta(strconv.Itoa(len(remoteNames))))
fmt.Println(bold(green("Explicitly installed packages: ")) + magenta(strconv.Itoa(info.Expln)))
fmt.Println(bold(green("Total Size occupied by packages: ")) + magenta(human(info.TotalSize)))
fmt.Println(bold(green("Total installed packages: ")) + cyan(strconv.Itoa(info.Totaln)))
fmt.Println(bold(green("Total foreign installed packages: ")) + cyan(strconv.Itoa(len(remoteNames))))
fmt.Println(bold(green("Explicitly installed packages: ")) + cyan(strconv.Itoa(info.Expln)))
fmt.Println(bold(green("Total Size occupied by packages: ")) + cyan(human(info.TotalSize)))
fmt.Println(bold(cyan("===========================================")))
fmt.Println(bold(green("Ten biggest packages:")))
biggestPackages()
fmt.Println(bold(cyan("===========================================")))
aurInfo(remoteNames)
aurInfoPrint(remoteNames)
return nil
}
@ -294,9 +322,10 @@ func localStatistics() error {
//TODO: Make it less hacky
func printNumberOfUpdates() error {
//todo
warnings := &aurWarnings{}
old := os.Stdout // keep backup of the real stdout
os.Stdout = nil
aurUp, repoUp, err := upList()
aurUp, repoUp, err := upList(warnings)
os.Stdout = old // restoring the real stdout
if err != nil {
return err
@ -308,10 +337,11 @@ func printNumberOfUpdates() error {
//TODO: Make it less hacky
func printUpdateList(parser *arguments) error {
warnings := &aurWarnings{}
old := os.Stdout // keep backup of the real stdout
os.Stdout = nil
_, _, localNames, remoteNames, err := filterPackages()
aurUp, repoUp, err := upList()
aurUp, repoUp, err := upList(warnings)
os.Stdout = old // restoring the real stdout
if err != nil {
return err

View File

@ -10,6 +10,12 @@ import (
rpc "github.com/mikkeloscar/aur"
)
type aurWarnings struct {
Orphans []string
OutOfDate []string
Missing []string
}
// Query is a collection of Results
type aurQuery []rpc.Pkg
@ -190,7 +196,7 @@ func syncInfo(pkgS []string) (err error) {
noDb = append(noDb, name)
}
info, err = aurInfo(noDb)
info, err = aurInfoPrint(noDb)
if err != nil {
fmt.Println(err)
}
@ -440,17 +446,13 @@ func statistics() (info struct {
// of packages exceeds the number set in config.RequestSplitN.
// If the number does exceed config.RequestSplitN multiple rpc requests will be
// performed concurrently.
func aurInfo(names []string) ([]*rpc.Pkg, error) {
func aurInfo(names []string, warnings *aurWarnings) ([]*rpc.Pkg, error) {
info := make([]*rpc.Pkg, 0, len(names))
seen := make(map[string]int)
var mux sync.Mutex
var wg sync.WaitGroup
var err error
missing := make([]string, 0, len(names))
orphans := make([]string, 0, len(names))
outOfDate := make([]string, 0, len(names))
makeRequest := func(n, max int) {
defer wg.Done()
tempInfo, requestErr := rpc.Info(names[n:max])
@ -488,43 +490,33 @@ func aurInfo(names []string) ([]*rpc.Pkg, error) {
for _, name := range names {
i, ok := seen[name]
if !ok {
missing = append(missing, name)
warnings.Missing = append(warnings.Missing, name)
continue
}
pkg := info[i]
if pkg.Maintainer == "" {
orphans = append(orphans, name)
warnings.Orphans = append(warnings.Orphans, name)
}
if pkg.OutOfDate != 0 {
outOfDate = append(outOfDate, name)
warnings.OutOfDate = append(warnings.OutOfDate, name)
}
}
if len(missing) > 0 {
fmt.Print(bold(red(arrow + " Missing AUR Packages:")))
for _, name := range missing {
fmt.Print(" " + bold(magenta(name)))
}
fmt.Println()
}
if len(orphans) > 0 {
fmt.Print(bold(red(arrow + " Orphaned AUR Packages:")))
for _, name := range orphans {
fmt.Print(" " + bold(magenta(name)))
}
fmt.Println()
}
if len(outOfDate) > 0 {
fmt.Print(bold(red(arrow + " Out Of Date AUR Packages:")))
for _, name := range outOfDate {
fmt.Print(" " + bold(magenta(name)))
}
fmt.Println()
}
return info, nil
}
func aurInfoPrint(names []string) ([]*rpc.Pkg, error) {
fmt.Println(bold(cyan("::") + bold(" Querying AUR...")))
warnings := &aurWarnings{}
info, err := aurInfo(names, warnings)
if err != nil {
return info, err
}
warnings.Print()
return info, nil
}

View File

@ -125,7 +125,7 @@ func getVersionDiff(oldVersion, newversion string) (left, right string) {
}
// upList returns lists of packages to upgrade from each source.
func upList() (aurUp upSlice, repoUp upSlice, err error) {
func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
local, remote, _, remoteNames, err := filterPackages()
if err != nil {
return nil, nil, err
@ -138,22 +138,22 @@ func upList() (aurUp upSlice, repoUp upSlice, err error) {
var aurErr error
var develErr error
fmt.Println(bold(cyan("::") + " Searching databases for updates..."))
fmt.Println(bold(cyan("::") + bold(" Searching databases for updates...")))
wg.Add(1)
go func() {
repoUp, repoErr = upRepo(local)
wg.Done()
}()
fmt.Println(bold(cyan("::") + " Searching AUR for updates..."))
fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates...")))
wg.Add(1)
go func() {
aurUp, aurErr = upAUR(remote, remoteNames)
aurUp, aurErr = upAUR(remote, remoteNames, warnings)
wg.Done()
}()
if config.Devel {
fmt.Println(bold(cyan("::") + " Checking development packages..."))
fmt.Println(bold(cyan("::") + bold(" Checking development packages...")))
wg.Add(1)
go func() {
develUp, develErr = upDevel(remote)
@ -229,8 +229,8 @@ func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) {
for _, pkg := range toUpdate {
if pkg.ShouldIgnore() {
left, right := getVersionDiff(pkg.Version(), "latest-commit")
fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", cyan(pkg.Name()), left, right)
fmt.Print(yellow(bold(smallArrow)))
fmt.Printf(" Ignoring package upgrade %s (%s => %s)\n", cyan(pkg.Name()), left, right)
} else {
toUpgrade = append(toUpgrade, upgrade{pkg.Name(), "devel", pkg.Version(), "latest-commit"})
}
@ -242,9 +242,9 @@ func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) {
// upAUR gathers foreign packages and checks if they have new versions.
// Output: Upgrade type package list.
func upAUR(remote []alpm.Package, remoteNames []string) (upSlice, error) {
func upAUR(remote []alpm.Package, remoteNames []string, warnings *aurWarnings) (upSlice, error) {
toUpgrade := make(upSlice, 0)
_pkgdata, err := aurInfo(remoteNames)
_pkgdata, err := aurInfo(remoteNames, warnings)
if err != nil {
return nil, err
}
@ -264,8 +264,8 @@ func upAUR(remote []alpm.Package, remoteNames []string) (upSlice, error) {
(alpm.VerCmp(pkg.Version(), aurPkg.Version) < 0) {
if pkg.ShouldIgnore() {
left, right := getVersionDiff(pkg.Version(), aurPkg.Version)
fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", cyan(pkg.Name()), left, right)
fmt.Print(yellow(bold(smallArrow)))
fmt.Printf(" Ignoring package upgrade: %s (%s => %s)\n", cyan(pkg.Name()), left, right)
} else {
toUpgrade = append(toUpgrade, upgrade{aurPkg.Name, "aur", pkg.Version(), aurPkg.Version})
}
@ -290,8 +290,8 @@ func upRepo(local []alpm.Package) (upSlice, error) {
if newPkg != nil {
if pkg.ShouldIgnore() {
left, right := getVersionDiff(pkg.Version(), newPkg.Version())
fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", cyan(pkg.Name()), left, right)
fmt.Print(yellow(bold(smallArrow)))
fmt.Printf(" Ignoring package upgrade: %s (%s => %s)\n", cyan(pkg.Name()), left, right)
} else {
slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()})
}
@ -311,11 +311,11 @@ func upgradePkgs(aurUp, repoUp upSlice) (stringSet, stringSet, error) {
sort.Sort(repoUp)
sort.Sort(aurUp)
fmt.Println(bold(blue("::")), len(aurUp)+len(repoUp), bold("Packages to upgrade."))
fmt.Printf("%s"+bold(" %d ")+"%s\n", bold(cyan("::")), len(aurUp)+len(repoUp), bold("Packages to upgrade."))
repoUp.Print(len(aurUp) + 1)
aurUp.Print(1)
fmt.Println(bold(green(arrow + " Packages to not upgrade (eg: 1 2 3, 1-3, ^4 or repo name)")))
fmt.Println(bold(green(arrow + " Packages to not upgrade: (eg: 1 2 3, 1-3, ^4 or repo name)")))
fmt.Print(bold(green(arrow + " ")))
numbers, err := getInput(config.AnswerUpgrade)

6
vcs.go
View File

@ -32,7 +32,7 @@ func createDevelDB() error {
return err
}
info, err := aurInfo(remoteNames)
info, err := aurInfoPrint(remoteNames)
if err != nil {
return err
}
@ -57,7 +57,7 @@ func createDevelDB() error {
}
}
fmt.Println(bold(green(arrow + " GenDB finished. No packages were installed")))
fmt.Println(bold(yellow(arrow) + bold(" GenDB finished. No packages were installed")))
return err
}
@ -125,7 +125,7 @@ func updateVCSData(pkgName string, sources []string) {
savedInfo[pkgName] = info
fmt.Println(bold(green(arrow+" Found git repo: ")) + cyan(url))
fmt.Println(bold(yellow(arrow)) + " Found git repo: " + cyan(url))
saveVCSInfo()
}
}