summaryrefslogtreecommitdiff
path: root/doDebian.go
blob: 8d6aa3e87df10cdc621f00747e9c79041108b2f5 (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
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"path/filepath"

	"go.wit.com/lib/gui/shell"
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

func doDebian() {
	// clean out old deb files
	globPattern := filepath.Join(me.homedir, "incoming", "*.deb")
	files, err := filepath.Glob(globPattern)
	if err != nil {
		log.Info("Error during globbing:", err)
		badExit(err)
	}
	if len(files) > 0 {
		cmd := []string{"rm"}
		cmd = append(cmd, files...)
		exitOnErrorRealtime(cmd)
	}

	initForge()

	found := gitpb.NewRepos()
	for check := range me.forge.Repos.IterAll() {
		if me.forge.Config.IsReadOnly(check.GetGoPath()) {
			continue
		}

		if !check.IsBinary() {
			continue
		}

		if check.IsGoPlugin() {
			continue
		}
		found.Append(check)
	}
	me.forge.PrintForgedTable(found)

	if argv.DryRun {
		doInstallScan()
		okExit("")
	}

	me.forge.ConfigRill(16, 16)
	stats := me.forge.RunOnRepos(found, doInstallRepo)
	for s, stat := range stats {
		if stat.Err == nil {
			continue
		}
		dur := stat.End.Sub(stat.Start)
		log.Info("CRAP. INSTALL FAILED", shell.FormatDuration(dur), s, stat.Err)
		badExit(stat.Err)
	}

	me.forge.ConfigRill(16, 16)
	stats = me.forge.RunOnRepos(found, buildDeb)
	for s, stat := range stats {
		log.Info(s, stat.Err)
		if stat.Err != nil {
			badExit(stat.Err)
		}
	}

	exitOnErrorRealtime([]string{"do-aptly"})
}