mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Support --aur and --repo flags
These flags limit operations to only check the repos or only check the AUR. These flags apply to -S, -Si and -Su. -a may also be used as a short option for --aur. --repo has no short option as -r is taken.
This commit is contained in:
parent
b5715de4fd
commit
0ae8fc2a06
4
cmd.go
4
cmd.go
@ -300,6 +300,10 @@ func handleConfig(option, value string) bool {
|
|||||||
config.Provides = true
|
config.Provides = true
|
||||||
case "noprovides":
|
case "noprovides":
|
||||||
config.Provides = false
|
config.Provides = false
|
||||||
|
case "a", "aur":
|
||||||
|
mode = ModeAUR
|
||||||
|
case "repo":
|
||||||
|
mode = ModeRepo
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
11
config.go
11
config.go
@ -25,6 +25,14 @@ const (
|
|||||||
TopDown
|
TopDown
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type targetMode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ModeAUR targetMode = iota
|
||||||
|
ModeRepo
|
||||||
|
ModeAny
|
||||||
|
)
|
||||||
|
|
||||||
// Configuration stores yay's config.
|
// Configuration stores yay's config.
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
BuildDir string `json:"buildDir"`
|
BuildDir string `json:"buildDir"`
|
||||||
@ -98,6 +106,9 @@ var alpmConf alpm.PacmanConfig
|
|||||||
// AlpmHandle is the alpm handle used by yay.
|
// AlpmHandle is the alpm handle used by yay.
|
||||||
var alpmHandle *alpm.Handle
|
var alpmHandle *alpm.Handle
|
||||||
|
|
||||||
|
// Mode is used to restrict yay to AUR or repo only modes
|
||||||
|
var mode targetMode = ModeAny
|
||||||
|
|
||||||
func readAlpmConfig(pacmanconf string) (conf alpm.PacmanConfig, err error) {
|
func readAlpmConfig(pacmanconf string) (conf alpm.PacmanConfig, err error) {
|
||||||
file, err := os.Open(pacmanconf)
|
file, err := os.Open(pacmanconf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -101,12 +101,17 @@ func (dp *depPool) ResolveTargets(pkgs []string) error {
|
|||||||
var singleDb *alpm.Db
|
var singleDb *alpm.Db
|
||||||
|
|
||||||
// aur/ prefix means we only check the aur
|
// aur/ prefix means we only check the aur
|
||||||
if target.Db == "aur" {
|
if target.Db == "aur" || (target.Db == "" && mode == ModeAUR) {
|
||||||
dp.Targets = append(dp.Targets, target)
|
dp.Targets = append(dp.Targets, target)
|
||||||
aurTargets.set(target.DepString())
|
aurTargets.set(target.DepString())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mode == ModeAUR {
|
||||||
|
dp.Targets = append(dp.Targets, target)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// if theres a different priefix only look in that repo
|
// if theres a different priefix only look in that repo
|
||||||
if target.Db != "" {
|
if target.Db != "" {
|
||||||
singleDb, err = alpmHandle.SyncDbByName(target.Db)
|
singleDb, err = alpmHandle.SyncDbByName(target.Db)
|
||||||
@ -151,7 +156,7 @@ func (dp *depPool) ResolveTargets(pkgs []string) error {
|
|||||||
dp.Targets = append(dp.Targets, target)
|
dp.Targets = append(dp.Targets, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(aurTargets) > 0 {
|
if len(aurTargets) > 0 && (mode == ModeAny || mode == ModeAUR) {
|
||||||
return dp.resolveAURPackages(aurTargets, true)
|
return dp.resolveAURPackages(aurTargets, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@ func install(parser *arguments) error {
|
|||||||
arguments.op = "S"
|
arguments.op = "S"
|
||||||
arguments.targets = make(stringSet)
|
arguments.targets = make(stringSet)
|
||||||
|
|
||||||
|
if mode == ModeAUR {
|
||||||
|
arguments.delArg("u", "sysupgrade")
|
||||||
|
}
|
||||||
|
|
||||||
//if we are doing -u also request all packages needing update
|
//if we are doing -u also request all packages needing update
|
||||||
if parser.existsArg("u", "sysupgrade") {
|
if parser.existsArg("u", "sysupgrade") {
|
||||||
aurUp, repoUp, err = upList(warnings)
|
aurUp, repoUp, err = upList(warnings)
|
||||||
@ -125,7 +129,7 @@ func install(parser *arguments) error {
|
|||||||
arguments.addTarget(pkg)
|
arguments.addTarget(pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(do.Aur) == 0 && len(arguments.targets) == 0 && !parser.existsArg("u", "sysupgrade") {
|
if len(do.Aur) == 0 && len(arguments.targets) == 0 && (!parser.existsArg("u", "sysupgrade") || mode == ModeAUR) {
|
||||||
fmt.Println("There is nothing to do")
|
fmt.Println("There is nothing to do")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
12
query.go
12
query.go
@ -220,8 +220,8 @@ func syncInfo(pkgS []string) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(aurS) != len(info) {
|
if len(repoS)+len(aurS) != len(pkgS) {
|
||||||
return fmt.Errorf("Could not find all required packages")
|
return fmt.Errorf("Could not find all packages")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -288,10 +288,14 @@ func packageSlices(toCheck []string) (aur []string, repo []string, err error) {
|
|||||||
db, name := splitDbFromName(_pkg)
|
db, name := splitDbFromName(_pkg)
|
||||||
found := false
|
found := false
|
||||||
|
|
||||||
if db == "aur" {
|
if db == "aur" || (mode == ModeAUR && db != "") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if db == "aur" || (mode == ModeAUR && db == "") {
|
||||||
aur = append(aur, _pkg)
|
aur = append(aur, _pkg)
|
||||||
continue
|
continue
|
||||||
} else if db != "" {
|
} else if db != "" || mode == ModeRepo {
|
||||||
repo = append(repo, _pkg)
|
repo = append(repo, _pkg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
38
upgrade.go
38
upgrade.go
@ -140,29 +140,33 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
|
|
||||||
pkgdata := make(map[string]*rpc.Pkg)
|
pkgdata := make(map[string]*rpc.Pkg)
|
||||||
|
|
||||||
fmt.Println(bold(cyan("::") + bold(" Searching databases for updates...")))
|
if mode == ModeAny || mode == ModeRepo {
|
||||||
wg.Add(1)
|
fmt.Println(bold(cyan("::") + bold(" Searching databases for updates...")))
|
||||||
go func() {
|
|
||||||
repoUp, repoErr = upRepo(local)
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
|
|
||||||
fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates...")))
|
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
aurUp, aurErr = upAUR(remote, remoteNames, pkgdata, warnings)
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
|
|
||||||
if config.Devel {
|
|
||||||
fmt.Println(bold(cyan("::") + bold(" Checking development packages...")))
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
develUp, develErr = upDevel(remote)
|
repoUp, repoErr = upRepo(local)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mode == ModeAny || mode == ModeAUR {
|
||||||
|
fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates...")))
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
aurUp, aurErr = upAUR(remote, remoteNames, pkgdata, warnings)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
if config.Devel {
|
||||||
|
fmt.Println(bold(cyan("::") + bold(" Checking development packages...")))
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
develUp, develErr = upDevel(remote)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
printLocalNewerThanAUR(remote, pkgdata)
|
printLocalNewerThanAUR(remote, pkgdata)
|
||||||
|
Loading…
Reference in New Issue
Block a user