summaryrefslogtreecommitdiff
path: root/doListRepos.go
blob: 9d9137505ca9ab573266cb48fd54aaed9a2e9004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"fmt"
	"os"
	"path/filepath"

	"go.wit.com/log"
)

func doListRepos() {
	for check := range me.forge.Repos.IterAll() {

		repotype := check.GetRepoType()
		if repotype == "binary" || repotype == "plugin" {
			// we only want to process things that can be compiled with 'go build'
		} else {
			// log.Info("skipping repo", check.GetGoPath(), repotype)
			continue
		}

		if me.forge.Config.IsReadOnly(check.GetGoPath()) {
			// ignore read only stuff
			continue
		}

		// var cmd []string
		var start string
		var end string

		// add te repotype
		end += check.GetRepoType()

		manufactured := check.GetCurrentVersion()
		ver := trimNonNumericFromStart(manufactured)
		name := me.forge.Config.DebName(check.GetGoPath())
		var realver string
		if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil {
			realver = installedPackage.Version
		}
		if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
			end += " (version match) " + actualp.Version + " " + ver + " "
			check.State = "on mirrors"
		} else {
			if realver != "" {
				end += fmt.Sprintf(" (version  miss) %s vs %s ", realver, ver)
			}
			// end += "" + ver + " "
		}
		if me.machine.IsInstalled(name) {
			if actualp := me.machine.FindInstalledByName(name); actualp != nil {
				if ver != actualp.Version {
					end += "(installed " + actualp.Version + ") "
				} else {
					end += "(installed ok) "
				}
			} else {
				end += "(installed) "
			}
		}

		debname := name + "_" + ver + "_amd64.deb"
		// debnames[check] = debname
		outdir := getOutdir(check)
		_, err := os.Stat(filepath.Join(outdir, debname))
		if err == nil {
			// log.Info("exists", filepath.Join(outdir, debname))
			check.State = "in incoming"
		} else {
			// log.Info(debname, "does not exist")
		}

		if check.State == "" {
			check.State = "need to build"
		}
		start = fmt.Sprintf("%-15s %-20s %-50s", check.State, ver, debname)

		if check.State == "need to build" {
			end += " (will build) "
		}

		log.Info(start, end)
		if name == "" {
			// err := fmt.Sprintf("name is blank error %+v", repo)
			log.Warn("name is blank error", check.GetGoPath())
		}
	}
}