mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
First version of fully working vcs updates
This commit is contained in:
parent
d9b793b695
commit
fd6b2be76b
|
@ -36,6 +36,13 @@ Yay was created with a few objectives in mind and based on the design of yaourt
|
|||
|
||||
### Changelog
|
||||
|
||||
#### 2.
|
||||
- Fetching backend changed to Mikkel Oscar's [Aur](https://github.com/mikkeloscar/aur)
|
||||
- Added support for development packages from github.
|
||||
- Pacman backend rewritten and simplified
|
||||
- Added config framework.
|
||||
|
||||
|
||||
#### 1.115
|
||||
- Added AUR completions (updates on first completion every 48h)
|
||||
|
||||
|
|
44
aur/aur.go
44
aur/aur.go
|
@ -8,6 +8,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
alpm "github.com/jguer/go-alpm"
|
||||
vcs "github.com/jguer/yay/aur/vcs"
|
||||
"github.com/jguer/yay/config"
|
||||
"github.com/jguer/yay/pacman"
|
||||
|
@ -109,29 +110,31 @@ func CreateDevelDB() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func DevelUpgrade(flags []string) {
|
||||
func develUpgrade(foreign map[string]alpm.Package, flags []string) error {
|
||||
fmt.Println(" Checking development packages...")
|
||||
develUpdates := vcs.CheckUpdates(foreign)
|
||||
if len(develUpdates) != 0 {
|
||||
for _, q := range develUpdates {
|
||||
fmt.Printf("\x1b[1m\x1b[32m==>\x1b[33;1m %s\x1b[0m\n", q)
|
||||
}
|
||||
// Install updated packages
|
||||
if !config.ContinueTask("Proceed with upgrade?", "nN") {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := Install(develUpdates, flags)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Upgrade tries to update every foreign package installed in the system
|
||||
func Upgrade(flags []string) error {
|
||||
fmt.Println("\x1b[1;36;1m::\x1b[0m\x1b[1m Starting AUR upgrade...\x1b[0m")
|
||||
|
||||
if config.YayConf.Devel {
|
||||
fmt.Println(" Checking development packages...")
|
||||
develUpdates := vcs.CheckUpdates()
|
||||
if len(develUpdates) != 0 {
|
||||
// Install updated packages
|
||||
if !config.ContinueTask("\nProceed with upgrade?", "nN") {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := Install(develUpdates, flags)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreign, err := pacman.ForeignPackages()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -143,6 +146,13 @@ func Upgrade(flags []string) error {
|
|||
i++
|
||||
}
|
||||
|
||||
if config.YayConf.Devel {
|
||||
err := develUpgrade(foreign, flags)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
q, err := rpc.Info(keys)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -66,12 +66,7 @@ func printDeps(repoDeps []string, aurDeps []string) {
|
|||
}
|
||||
}
|
||||
|
||||
// PkgInstall handles install from Info Result.
|
||||
func PkgInstall(a *rpc.Pkg, flags []string) (finalmdeps []string, err error) {
|
||||
fmt.Printf("\x1b[1;32m==> Installing\x1b[33m %s\x1b[0m\n", a.Name)
|
||||
if a.Maintainer == "" {
|
||||
fmt.Println("\x1b[1;31;40m==> Warning:\x1b[0;;40m This package is orphaned.\x1b[0m")
|
||||
}
|
||||
func setupPackageSpace(a *rpc.Pkg) (err error) {
|
||||
dir := config.YayConf.BuildDir + a.PackageBase + "/"
|
||||
|
||||
if _, err = os.Stat(dir); !os.IsNotExist(err) {
|
||||
|
@ -99,11 +94,29 @@ func PkgInstall(a *rpc.Pkg, flags []string) (finalmdeps []string, err error) {
|
|||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
vcs.SaveBranchInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = os.Chdir(dir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// PkgInstall handles install from Info Result.
|
||||
func PkgInstall(a *rpc.Pkg, flags []string) (finalmdeps []string, err error) {
|
||||
fmt.Printf("\x1b[1;32m==> Installing\x1b[33m %s\x1b[0m\n", a.Name)
|
||||
if a.Maintainer == "" {
|
||||
fmt.Println("\x1b[1;31;40m==> Warning:\x1b[0;;40m This package is orphaned.\x1b[0m")
|
||||
}
|
||||
|
||||
if err = setupPackageSpace(a); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if specialDBsauce {
|
||||
return
|
||||
}
|
||||
|
@ -158,16 +171,14 @@ func PkgInstall(a *rpc.Pkg, flags []string) (finalmdeps []string, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
err = os.Chdir(dir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
args := []string{"-sri"}
|
||||
args = append(args, flags...)
|
||||
makepkgcmd := exec.Command(config.YayConf.MakepkgBin, args...)
|
||||
makepkgcmd.Stdin, makepkgcmd.Stdout, makepkgcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
err = makepkgcmd.Run()
|
||||
if err == nil {
|
||||
_ = vcs.SaveBranchInfo()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
alpm "github.com/jguer/go-alpm"
|
||||
)
|
||||
|
||||
// branch contains the information of a repository branch
|
||||
|
@ -103,10 +105,15 @@ func (info *Info) needsUpdate() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func CheckUpdates() (toUpdate []string) {
|
||||
// CheckUpdates returns list of outdated packages
|
||||
func CheckUpdates(foreign map[string]alpm.Package) (toUpdate []string) {
|
||||
for _, e := range savedInfo {
|
||||
if e.needsUpdate() {
|
||||
toUpdate = append(toUpdate, e.Package)
|
||||
if _, ok := foreign[e.Package]; ok {
|
||||
toUpdate = append(toUpdate, e.Package)
|
||||
} else {
|
||||
RemovePackage([]string{e.Package})
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -121,8 +128,23 @@ func inStore(url string) *Info {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RemovePackage removes package from VCS information
|
||||
func RemovePackage(pkgs []string) {
|
||||
for _, pkgName := range pkgs {
|
||||
for i, e := range savedInfo {
|
||||
if e.Package == pkgName {
|
||||
savedInfo[i] = savedInfo[len(savedInfo)-1]
|
||||
savedInfo = savedInfo[:len(savedInfo)-1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ = SaveBranchInfo()
|
||||
return
|
||||
}
|
||||
|
||||
// BranchInfo updates saved information
|
||||
func BranchInfo(pkgname string, owner string, repo string) (err error) {
|
||||
func BranchInfo(pkgName string, owner string, repo string) (err error) {
|
||||
Updated = true
|
||||
var newRepo branches
|
||||
url := "https://api.github.com/repos/" + owner + "/" + repo + "/branches"
|
||||
|
@ -139,11 +161,11 @@ func BranchInfo(pkgname string, owner string, repo string) (err error) {
|
|||
for _, e := range newRepo {
|
||||
if e.Name == "master" {
|
||||
if packinfo != nil {
|
||||
packinfo.Package = pkgname
|
||||
packinfo.Package = pkgName
|
||||
packinfo.URL = url
|
||||
packinfo.SHA = e.Commit.SHA
|
||||
} else {
|
||||
savedInfo = append(savedInfo, Info{Package: pkgname, URL: url, SHA: e.Commit.SHA})
|
||||
savedInfo = append(savedInfo, Info{Package: pkgName, URL: url, SHA: e.Commit.SHA})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue