Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Reeto Chatterjee authored Apr 7, 2018
2 parents b103a34 + ec71a5b commit 992c27e
Show file tree
Hide file tree
Showing 15 changed files with 581 additions and 225 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ Yay was created with a few objectives in mind and based on the design of [yaourt

### Changelog

#### v5.608

* Updated Shell completions
* Added `-Qu` to extended pacman options
* Provides now supported in `-Si`
* Improved build method
* Improved conflict checking
* PKGBUILDs with unsupported arch can force build now
* PGP Key automatic importing
* GPG option passing
* `db/name` support readded

#### 4.505

* `yay` used to auto save permanent configuration options, now `--save` must be passed to save permanent configuration options
Expand Down
58 changes: 47 additions & 11 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Permanent configuration options:
--config <file> pacman.conf file to use
--requestsplitn <n> Max amount of packages to query per AUR request
--sortby <field> Sort AUR results by a specific field during search
--answerclean <a> Set a predetermined answer for the clean build menu
--answeredit <a> Set a predetermined answer for the edit pkgbuild menu
--answerupgrade <a> Set a predetermined answer for the upgrade menu
--noanswerclean Unset the answer for the clean build menu
--noansweredit Unset the answer for the edit pkgbuild menu
--noanswerupgrade Unset the answer for the upgrade menu
--topdown Shows repository's packages first and then AUR's
--bottomup Shows AUR's packages first and then repository's
Expand Down Expand Up @@ -126,6 +133,11 @@ func handleCmd() (err error) {
config.saveConfig()
}

if cmdArgs.existsArg("h", "help") {
err = handleHelp()
return
}

if config.SudoLoop && cmdArgs.needRoot() {
sudoLoopBackground()
}
Expand Down Expand Up @@ -174,6 +186,15 @@ func handleQuery() error {
return err
}

func handleHelp() error {
if cmdArgs.op == "Y" || cmdArgs.op == "yay" {
usage()
return nil
} else {
return passToPacman(cmdArgs)
}
}

//this function should only set config options
//but currently still uses the switch left over from old code
//eventually this should be refactored out futher
Expand All @@ -200,6 +221,8 @@ func handleConfig(option, value string) bool {
config.SortMode = TopDown
case "bottomup":
config.SortMode = BottomUp
case "sortby":
config.SortBy = value
case "noconfirm":
config.NoConfirm = true
case "redownload":
Expand All @@ -216,6 +239,18 @@ func handleConfig(option, value string) bool {
config.ReBuild = "tree"
case "norebuild":
config.ReBuild = "no"
case "answerclean":
config.AnswerClean = value
case "noanswerclean":
config.AnswerClean = ""
case "answeredit":
config.AnswerEdit = value
case "noansweredit":
config.AnswerEdit = ""
case "answerupgrade":
config.AnswerUpgrade = value
case "noanswerupgrade":
config.AnswerUpgrade = ""
case "gpgflags":
config.GpgFlags = value
case "mflags":
Expand Down Expand Up @@ -284,13 +319,8 @@ func handlePrint() (err error) {

func handleYay() (err error) {
//_, options, targets := cmdArgs.formatArgs()
if cmdArgs.existsArg("h", "help") {
usage()
} else if cmdArgs.existsArg("gendb") {
if cmdArgs.existsArg("gendb") {
err = createDevelDB()
if err != nil {
return
}
} else if cmdArgs.existsDouble("c") {
err = cleanDependencies(true)
} else if cmdArgs.existsArg("c", "clean") {
Expand Down Expand Up @@ -365,10 +395,7 @@ func handleRemove() (err error) {

// NumberMenu presents a CLI for selecting packages to install.
func numberMenu(pkgS []string, flags []string) (err error) {
aurQ, err := narrowSearch(pkgS, true)
if err != nil {
fmt.Println("Error during AUR search:", err)
}
aurQ, aurErr := narrowSearch(pkgS, true)
numaq := len(aurQ)
repoQ, numpq, err := queryRepo(pkgS)
if err != nil {
Expand All @@ -387,6 +414,11 @@ func numberMenu(pkgS []string, flags []string) (err error) {
aurQ.printSearch(numpq + 1)
}

if aurErr != nil {
fmt.Printf("Error during AUR search: %s\n", aurErr)
fmt.Println("Showing repo packages only")
}

fmt.Println(bold(green(arrow + " Packages to install (eg: 1 2 3, 1-3 or ^4)")))
fmt.Print(bold(green(arrow + " ")))

Expand Down Expand Up @@ -467,7 +499,11 @@ func passToPacman(args *arguments) error {

cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
err := cmd.Run()
return err

if err != nil {
return fmt.Errorf("")
}
return nil
}

//passToPacman but return the output instead of showing the user
Expand Down
2 changes: 1 addition & 1 deletion completions/bash
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ _yay() {
common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile
noconfirm noprogressbar noscriptlet quiet save mflags buildir editor
makepkg pacman tar git gpg gpgflags config requestsplitn sudoloop nosudoloop
redownload noredownload redownloadall root verbose' 'b d h q r v')
redownload noredownload redownloadall rebuild rebuildall rebuildtree norebuild root verbose' 'b d h q r v')
core=('database files help query remove sync upgrade version' 'D F Q R S U V h')

for o in 'D database' 'F files' 'Q query' 'R remove' 'S sync' 'U upgrade' 'Y yays' 'P print'; do
Expand Down
7 changes: 6 additions & 1 deletion completions/fish
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,24 @@ complete -c $progname -n "not $noopt" -l notimeupdate -d 'Check only package ver

complete -c $progname -n "not $noopt" -l save -d 'Save current arguments to yay permanent configuration' -f
complete -c $progname -n "not $noopt" -l mflags -d 'Pass the following options to makepkg' -f
complete -c $progname -n "not $noopt" -l gpgflags -d 'Pass the following options to gpg' -f
complete -c $progname -n "not $noopt" -l buildir -d 'Specify the build directory' -f
complete -c $progname -n "not $noopt" -l editor -d 'Editor to use' -f
complete -c $progname -n "not $noopt" -l makepkg -d 'Makepkg command to use' -f
complete -c $progname -n "not $noopt" -l pacman -d 'Pacman command to use' -f
complete -c $progname -n "not $noopt" -l tar -d 'Tar command to use' -f
complete -c $progname -n "not $noopt" -l git -d 'Git command to use' -f
complete -c $progname -n "not $noopt" -l config -d 'config command to use' -f
complete -c $progname -n "not $noopt" -l gpg -d 'Gpg command to use' -f
complete -c $progname -n "not $noopt" -l requestsplitn -d 'Max amount of packages to query per AUR request' -f
complete -c $progname -n "not $noopt" -l sudoloop -d 'Loop sudo calls in the backgroud to avoid timeout' -f
complete -c $progname -n "not $noopt" -l nosudoloop -d 'Do not loop sudo calls in the background' -f
complete -c $progname -n "not $noopt" -l redownload -d 'Redownload PKGBUILD of package even if up-to-date' -f
complete -c $progname -n "not $noopt" -l noredownload -d 'Do not redownload up-to-date PKGBUILDs' -f
complete -c $progname -n "not $noopt" -l redownloadall -d 'Redownload PKGBUILD of package and deps even if up-to-date' -f
complete -c $progname -n "not $noopt" -l rebuild -d 'Always build target packages' -f
complete -c $progname -n "not $noopt" -l rebuildall -d 'Always build all AUR packages' -f
complete -c $progname -n "not $noopt" -l rebuildtree -d 'Always build all AUR packages even if installed' -f
complete -c $progname -n "not $noopt" -l norebuild -d 'Skip package build if in cache and up to date' -f

# Yay options
complete -c $progname -n $yayspecific -s c -l clean -d 'Remove unneeded dependencies' -f
Expand Down
6 changes: 5 additions & 1 deletion completions/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ _pacman_opts_common=(
'--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[Pass arguments to makepkg]:mflags'
'--gpgflags[Pass arguments to gpg]:gpgflags'
'--sudoloop[Loop sudo calls in the backgroud to avoid timeout]'
Expand Down Expand Up @@ -376,8 +380,8 @@ _pacman_completions_installed_groups() {
# provides completions for installed packages
_pacman_completions_installed_packages() {
local -a cmd packages packages_long
packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
packages_long=(/var/lib/pacman/local/*(/))
packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
compadd "$@" -a packages
}

Expand Down
29 changes: 29 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"bytes"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -33,10 +34,14 @@ type Configuration struct {
TarBin string `json:"tarbin"`
ReDownload string `json:"redownload"`
ReBuild string `json:"rebuild"`
AnswerClean string `json:"answerclean"`
AnswerEdit string `json:"answeredit"`
AnswerUpgrade string `json:"answerupgrade"`
GitBin string `json:"gitbin"`
GpgBin string `json:"gpgbin"`
GpgFlags string `json:"gpgflags"`
MFlags string `json:"mflags"`
SortBy string `json:"sortby"`
RequestSplitN int `json:"requestsplitn"`
SearchMode int `json:"-"`
SortMode int `json:"sortmode"`
Expand Down Expand Up @@ -134,6 +139,7 @@ func defaultSettings(config *Configuration) {
config.GpgFlags = ""
config.MFlags = ""
config.SortMode = BottomUp
config.SortBy = "votes"
config.SudoLoop = false
config.TarBin = "bsdtar"
config.GitBin = "git"
Expand All @@ -142,6 +148,9 @@ func defaultSettings(config *Configuration) {
config.RequestSplitN = 150
config.ReDownload = "no"
config.ReBuild = "no"
config.AnswerClean = ""
config.AnswerEdit = ""
config.AnswerUpgrade = ""
}

// Editor returns the preferred system editor.
Expand Down Expand Up @@ -223,6 +232,26 @@ func continueTask(s string, def string) (cont bool) {
return true
}

func getInput(defaultValue string) (string, error) {
if defaultValue != "" || config.NoConfirm {
fmt.Println(defaultValue)
return defaultValue, nil
}

reader := bufio.NewReader(os.Stdin)

buf, overflow, err := reader.ReadLine()
if err != nil {
return "", err
}

if overflow {
return "", fmt.Errorf("Input too long")
}

return string(buf), nil
}

func (config Configuration) String() string {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
Expand Down
Loading

0 comments on commit 992c27e

Please sign in to comment.