mirror of
https://github.com/Jguer/yay.git
synced 2025-12-09 00:03:52 -05:00
fix(config): vcs filepath fix
This commit is contained in:
parent
2dc01d8a3e
commit
9b49f76bbd
2
clean.go
2
clean.go
@ -28,7 +28,7 @@ func removeVCSPackage(pkgs []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if updated {
|
if updated {
|
||||||
err := saveVCSInfo()
|
err := saveVCSInfo(config.Runtime.VCSPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
}
|
}
|
||||||
|
|||||||
2
cmd.go
2
cmd.go
@ -226,7 +226,7 @@ func handlePrint() (err error) {
|
|||||||
|
|
||||||
func handleYay() error {
|
func handleYay() error {
|
||||||
if cmdArgs.ExistsArg("gendb") {
|
if cmdArgs.ExistsArg("gendb") {
|
||||||
return createDevelDB()
|
return createDevelDB(config.Runtime.VCSPath)
|
||||||
}
|
}
|
||||||
if cmdArgs.ExistsDouble("c") {
|
if cmdArgs.ExistsDouble("c") {
|
||||||
return cleanDependencies(true)
|
return cleanDependencies(true)
|
||||||
|
|||||||
@ -29,9 +29,6 @@ var localePath = "/usr/share/locale"
|
|||||||
// savedInfo holds the current vcs info
|
// savedInfo holds the current vcs info
|
||||||
var savedInfo vcsInfo
|
var savedInfo vcsInfo
|
||||||
|
|
||||||
// vcsfile holds yay vcs info file path.
|
|
||||||
var vcsFile string
|
|
||||||
|
|
||||||
// YayConf holds the current config values for yay.
|
// YayConf holds the current config values for yay.
|
||||||
var config *settings.Configuration
|
var config *settings.Configuration
|
||||||
|
|
||||||
|
|||||||
@ -972,7 +972,7 @@ func buildInstallPkgbuilds(
|
|||||||
return errShow
|
return errShow
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saveVCSInfo()
|
err = saveVCSInfo(config.Runtime.VCSPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
}
|
}
|
||||||
@ -1157,7 +1157,7 @@ func buildInstallPkgbuilds(
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for _, pkg := range base {
|
for _, pkg := range base {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go updateVCSData(pkg.Name, srcinfo.Source, &mux, &wg)
|
go updateVCSData(config.Runtime.VCSPath, pkg.Name, srcinfo.Source, &mux, &wg)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
10
main.go
10
main.go
@ -45,17 +45,17 @@ func initConfig(configPath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initVCS() error {
|
func initVCS(vcsFilePath string) error {
|
||||||
vfile, err := os.Open(vcsFile)
|
vfile, err := os.Open(vcsFilePath)
|
||||||
if !os.IsNotExist(err) && err != nil {
|
if !os.IsNotExist(err) && err != nil {
|
||||||
return errors.New(gotext.Get("failed to open vcs file '%s': %s", vcsFile, err))
|
return errors.New(gotext.Get("failed to open vcs file '%s': %s", vcsFilePath, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer vfile.Close()
|
defer vfile.Close()
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
decoder := json.NewDecoder(vfile)
|
decoder := json.NewDecoder(vfile)
|
||||||
if err = decoder.Decode(&savedInfo); err != nil {
|
if err = decoder.Decode(&savedInfo); err != nil {
|
||||||
return errors.New(gotext.Get("failed to read vcs file '%s': %s", vcsFile, err))
|
return errors.New(gotext.Get("failed to read vcs file '%s': %s", vcsFilePath, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
config.ExpandEnv()
|
config.ExpandEnv()
|
||||||
exitOnError(initBuildDir())
|
exitOnError(initBuildDir())
|
||||||
exitOnError(initVCS())
|
exitOnError(initVCS(runtime.VCSPath))
|
||||||
exitOnError(initAlpm(config.PacmanConf))
|
exitOnError(initAlpm(config.PacmanConf))
|
||||||
exitOnError(handleCmd())
|
exitOnError(handleCmd())
|
||||||
os.Exit(cleanup())
|
os.Exit(cleanup())
|
||||||
|
|||||||
12
vcs.go
12
vcs.go
@ -27,7 +27,7 @@ type shaInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createDevelDB forces yay to create a DB of the existing development packages
|
// createDevelDB forces yay to create a DB of the existing development packages
|
||||||
func createDevelDB() error {
|
func createDevelDB(vcsFilePath string) error {
|
||||||
var mux sync.Mutex
|
var mux sync.Mutex
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ func createDevelDB() error {
|
|||||||
for i := range srcinfos {
|
for i := range srcinfos {
|
||||||
for iP := range srcinfos[i].Packages {
|
for iP := range srcinfos[i].Packages {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go updateVCSData(srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source, &mux, &wg)
|
go updateVCSData(vcsFilePath, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source, &mux, &wg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ func parseSource(source string) (url, branch string, protocols []string) {
|
|||||||
return url, branch, protocols
|
return url, branch, protocols
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateVCSData(pkgName string, sources []gosrc.ArchString, mux sync.Locker, wg *sync.WaitGroup) {
|
func updateVCSData(vcsFilePath, pkgName string, sources []gosrc.ArchString, mux sync.Locker, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
if savedInfo == nil {
|
if savedInfo == nil {
|
||||||
@ -145,7 +145,7 @@ func updateVCSData(pkgName string, sources []gosrc.ArchString, mux sync.Locker,
|
|||||||
|
|
||||||
savedInfo[pkgName] = info
|
savedInfo[pkgName] = info
|
||||||
text.Warnln(gotext.Get("Found git repo: %s", cyan(url)))
|
text.Warnln(gotext.Get("Found git repo: %s", cyan(url)))
|
||||||
err := saveVCSInfo()
|
err := saveVCSInfo(vcsFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
}
|
}
|
||||||
@ -238,12 +238,12 @@ func (infos shaInfos) needsUpdate() bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveVCSInfo() error {
|
func saveVCSInfo(vcsFilePath string) error {
|
||||||
marshalledinfo, err := json.MarshalIndent(savedInfo, "", "\t")
|
marshalledinfo, err := json.MarshalIndent(savedInfo, "", "\t")
|
||||||
if err != nil || string(marshalledinfo) == "null" {
|
if err != nil || string(marshalledinfo) == "null" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
in, err := os.OpenFile(vcsFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
in, err := os.OpenFile(vcsFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user