mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Resolves #57. Added Package ignoring to AUR. Handles made private.
This commit is contained in:
parent
893196bd82
commit
8fa7c4069e
6
cmd.go
6
cmd.go
@ -75,13 +75,13 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
AlpmConf, err = readAlpmConfig(config.PacmanConf)
|
||||
alpmConf, err = readAlpmConfig(config.PacmanConf)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to read Pacman conf", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
AlpmHandle, err = AlpmConf.CreateHandle()
|
||||
alpmHandle, err = alpmConf.CreateHandle()
|
||||
if err != nil {
|
||||
fmt.Println("Unable to CreateHandle", err)
|
||||
os.Exit(1)
|
||||
@ -253,7 +253,7 @@ func main() {
|
||||
|
||||
}
|
||||
|
||||
erra = AlpmHandle.Release()
|
||||
erra = alpmHandle.Release()
|
||||
if erra != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func createAURList(out *os.File) (err error) {
|
||||
|
||||
//CreatePackageList appends Repo packages to completion cache
|
||||
func createRepoList(out *os.File) (err error) {
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ var updated bool
|
||||
var config Configuration
|
||||
|
||||
// AlpmConf holds the current config values for pacman.
|
||||
var AlpmConf alpm.PacmanConfig
|
||||
var alpmConf alpm.PacmanConfig
|
||||
|
||||
// AlpmHandle is the alpm handle used by yay.
|
||||
var AlpmHandle *alpm.Handle
|
||||
var alpmHandle *alpm.Handle
|
||||
|
||||
func readAlpmConfig(pacmanconf string) (conf alpm.PacmanConfig, err error) {
|
||||
file, err := os.Open(pacmanconf)
|
||||
|
@ -10,12 +10,12 @@ import (
|
||||
// BuildDependencies finds packages, on the second run
|
||||
// compares with a baselist and avoids searching those
|
||||
func buildDependencies(baselist []string) func(toCheck []string, isBaseList bool, last bool) (repo []string, notFound []string) {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -54,11 +54,11 @@ func buildDependencies(baselist []string) func(toCheck []string, isBaseList bool
|
||||
// DepSatisfier receives a string slice, returns a slice of packages found in
|
||||
// repos and one of packages not found in repos. Leaves out installed packages.
|
||||
func depSatisfier(toCheck []string) (repo []string, notFound []string, err error) {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func getPkgbuild(pkg string) (err error) {
|
||||
|
||||
// GetPkgbuild downloads pkgbuild from the ABS.
|
||||
func getPkgbuildfromABS(pkgN string, path string) (err error) {
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
6
print.go
6
print.go
@ -21,7 +21,7 @@ func human(size int64) string {
|
||||
|
||||
// PrintSearch handles printing search results in a given format
|
||||
func (q aurQuery) printSearch(start int) {
|
||||
localDb, _ := AlpmHandle.LocalDb()
|
||||
localDb, _ := alpmHandle.LocalDb()
|
||||
|
||||
for i, res := range q {
|
||||
var toprint string
|
||||
@ -75,7 +75,7 @@ func (s repoQuery) printSearch() {
|
||||
toprint += fmt.Sprint(res.Groups().Slice(), " ")
|
||||
}
|
||||
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err == nil {
|
||||
if _, err = localDb.PkgByName(res.Name()); err == nil {
|
||||
toprint += fmt.Sprintf("\x1b[32;40mInstalled\x1b[0m")
|
||||
@ -163,7 +163,7 @@ func PrintInfo(a *rpc.Pkg) {
|
||||
|
||||
// BiggestPackages prints the name of the ten biggest packages in the system.
|
||||
func biggestPackages() {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
14
query.go
14
query.go
@ -33,11 +33,11 @@ func (q aurQuery) Swap(i, j int) {
|
||||
// FilterPackages filters packages based on source and type from local repository.
|
||||
func filterPackages() (local []alpm.Package, remote []alpm.Package,
|
||||
localNames []string, remoteNames []string, err error) {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -249,7 +249,7 @@ func localStatistics(version string) error {
|
||||
|
||||
// Search handles repo searches. Creates a RepoSearch struct.
|
||||
func queryRepo(pkgInputN []string) (s repoQuery, n int, err error) {
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -299,7 +299,7 @@ func queryRepo(pkgInputN []string) (s repoQuery, n int, err error) {
|
||||
|
||||
// PackageSlices separates an input slice into aur and repo slices
|
||||
func packageSlices(toCheck []string) (aur []string, repo []string, err error) {
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -336,7 +336,7 @@ func packageSlices(toCheck []string) (aur []string, repo []string, err error) {
|
||||
// HangingPackages returns a list of packages installed as deps
|
||||
// and unneeded by the system
|
||||
func hangingPackages() (hanging []string, err error) {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -368,7 +368,7 @@ func statistics() (info struct {
|
||||
var nPkg int
|
||||
var ePkg int
|
||||
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -395,7 +395,7 @@ func statistics() (info struct {
|
||||
// SliceHangingPackages returns a list of packages installed as deps
|
||||
// and unneeded by the system from a provided list of package names.
|
||||
func sliceHangingPackages(pkgS []string) (hanging []string) {
|
||||
localDb, err := AlpmHandle.LocalDb()
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
47
upgrade.go
47
upgrade.go
@ -141,6 +141,26 @@ loop:
|
||||
return
|
||||
}
|
||||
|
||||
func isIgnored(pkg alpm.Package) bool {
|
||||
for _, p := range alpmConf.IgnorePkg {
|
||||
if p == pkg.Name() {
|
||||
fmt.Printf("\x1b[33mwarning:\x1b[0m %s (ignored pkg) ignoring upgrade (%s)\n", pkg.Name(), pkg.Version())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for _, g := range alpmConf.IgnoreGroup {
|
||||
for _, pg := range pkg.Groups().Slice() {
|
||||
if g == pg {
|
||||
fmt.Printf("\x1b[33mwarning:\x1b[0m %s (ignored pkg) ignoring upgrade (%s)\n", pkg.Name(), pkg.Version())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// upAUR gathers foreign packages and checks if they have new versions.
|
||||
// Output: Upgrade type package list.
|
||||
func upAUR(remote []alpm.Package, remoteNames []string) (toUpgrade upSlice, err error) {
|
||||
@ -173,6 +193,9 @@ func upAUR(remote []alpm.Package, remoteNames []string) (toUpgrade upSlice, err
|
||||
var missing, x int
|
||||
|
||||
for i := range local {
|
||||
if isIgnored(local[i]) {
|
||||
continue
|
||||
}
|
||||
x = i - missing
|
||||
if x > max {
|
||||
break
|
||||
@ -207,34 +230,20 @@ func upAUR(remote []alpm.Package, remoteNames []string) (toUpgrade upSlice, err
|
||||
// upRepo gathers local packages and checks if they have new versions.
|
||||
// Output: Upgrade type package list.
|
||||
func upRepo(local []alpm.Package) (upSlice, error) {
|
||||
dbList, err := AlpmHandle.SyncDbs()
|
||||
dbList, err := alpmHandle.SyncDbs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
slice := upSlice{}
|
||||
primeloop:
|
||||
|
||||
for _, pkg := range local {
|
||||
if isIgnored(pkg) {
|
||||
continue
|
||||
}
|
||||
newPkg := pkg.NewVersion(dbList)
|
||||
|
||||
if newPkg != nil {
|
||||
for _, ignorePkg := range AlpmConf.IgnorePkg {
|
||||
if pkg.Name() == ignorePkg {
|
||||
fmt.Printf("\x1b[33mwarning:\x1b[0m %s (ignored pkg) ignoring upgrade (%s -> %s)\n", pkg.Name(), pkg.Version(), newPkg.Version())
|
||||
continue primeloop
|
||||
}
|
||||
}
|
||||
|
||||
for _, ignoreGroup := range AlpmConf.IgnoreGroup {
|
||||
for _, group := range pkg.Groups().Slice() {
|
||||
if group == ignoreGroup {
|
||||
fmt.Printf("\x1b[33mwarning:\x1b[0m %s (ignored group) ignoring upgrade (%s -> %s)\n", pkg.Name(), pkg.Version(), newPkg.Version())
|
||||
continue primeloop
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user