This repository was archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindiepkg.go
82 lines (62 loc) · 1.88 KB
/
indiepkg.go
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
package main
import (
"os"
"strings"
)
// Compiles source of indiepkg.
func compSrc() {
chapLog("==>", "", "Compiling IndiePKG")
runCommandDot("make", indiePkgSrcPath, false, "make")
rawLogf("\n")
chapLog("==>", "", "Moving IndiePKG binary")
srcPath := indiePkgSrcPath + "indiepkg"
log(1, "Moving %s to %s...", bolden(srcPath), bolden(indiePkgBin))
mvPath(srcPath, indiePkgBin)
}
// Updates indiepkg.
func updateIndiePKG() {
chapLog("=>", "", "Initializing")
initDirs(false)
loadConfig()
chapLog("=>", "", "Updating IndiePKG")
chapLog("==>", "", "Pulling source code")
if pullSrcRepo(true) {
if !force {
chapLog("=>", textCol.Green, "Success")
log(0, "IndiePKG already up to date.")
os.Exit(0)
}
log(3, "IndiePKG already up to date, but force is on, so continuing.")
}
compSrc()
chapLog("=>", textCol.Green, "Success")
log(0, "Updated IndiePKG!")
}
// Checks for an update silently.
func autoUpdate() {
if config.Updating.AutoUpdate {
log(1, "Checking for an update...")
resp, err := makeReq("http://clients3.google.com/generate_204") // Make request to check if offline
if err != nil && strings.HasSuffix(err.Error(), "no such host") {
debugLog("Error of ping: %s", bolden(err.Error()))
log(3, "No internet connection, skipping auto-update.")
return
}
debugLog("StatusCode of ping: %s", bolden(resp.StatusCode))
if pullSrcRepo(true) {
return
}
_, err = runCommand(indiePkgSrcPath, "make")
errorLog(err, "An error occurred while compiling IndiePKG because of an auto-update")
mvPath(indiePkgSrcPath+"indiepkg", indiePkgBin)
log(0, "Auto-updated IndiePKG!")
}
}
// Re-clones IndiePKG source.
func reClone() {
loadConfig()
log(1, "Resetting IndiePKG source directory...")
delPath(true, indiePkgSrcPath, "An error occurred while deleting the IndiePKG source directory")
cloneSrcRepo()
log(0, "Successfully re-cloned IndiePKG source.")
}