fix 'dirty build' logic
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
09793249ee
commit
fe87679bd6
|
@ -5,7 +5,7 @@
|
||||||
# the binaries were built, how they were
|
# the binaries were built, how they were
|
||||||
# built. what version was built, etc
|
# built. what version was built, etc
|
||||||
# TODO: find a better way (not via ldflags)
|
# TODO: find a better way (not via ldflags)
|
||||||
resources/build
|
resources/build.*
|
||||||
resources/BUILDREF
|
resources/BUILDREF
|
||||||
resources/BUILDDATE
|
resources/BUILDDATE
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,8 @@ func build(tag string) *bool {
|
||||||
|
|
||||||
// setup the files that will end up in the binary
|
// setup the files that will end up in the binary
|
||||||
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
||||||
shell.Write("./resources/BUILDDATE", epoch)
|
shell.Write("./resources/build.DATE", epoch)
|
||||||
shell.Write("./resources/BUILDREF", gitref)
|
shell.Write("./resources/build.REF", gitref)
|
||||||
|
|
||||||
// rebuild the binary (always remove the old one
|
// rebuild the binary (always remove the old one
|
||||||
shell.Run("rm " + filename)
|
shell.Run("rm " + filename)
|
||||||
|
|
|
@ -15,6 +15,23 @@ var filename string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
shell.Quiet(false)
|
shell.Quiet(false)
|
||||||
|
|
||||||
|
md5sum := build()
|
||||||
|
log.Println("\tmd5sum =", md5sum)
|
||||||
|
|
||||||
|
if (md5sum == "") {
|
||||||
|
log.Println("\tBUILD FAILED")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// upload test
|
||||||
|
sess := shell.SSH("mirrors.wit.com", 22, "jcarr", "")
|
||||||
|
shell.Scp(sess, filename, "/tmp/jcarr-testing")
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
func build() string {
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
log.Println("user.HomeDir =", user.HomeDir)
|
log.Println("user.HomeDir =", user.HomeDir)
|
||||||
|
|
||||||
|
@ -24,8 +41,26 @@ func main() {
|
||||||
|
|
||||||
// setup the files that will end up in the binary
|
// setup the files that will end up in the binary
|
||||||
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
||||||
shell.Write("./resources/BUILDDATE", epoch)
|
shell.Write("./resources/build.DATE", epoch)
|
||||||
shell.Write("./resources/BUILDREF", gitref)
|
shell.Write("./resources/build.REF", gitref)
|
||||||
|
|
||||||
|
// make a dirty file if this build is dirty
|
||||||
|
shell.Run("rm ./resources/build.DIRTY")
|
||||||
|
|
||||||
|
version := shell.Run("cat ./resources/VERSION")
|
||||||
|
versionref := shell.Run("git rev-list -1 v" + version)
|
||||||
|
|
||||||
|
if (gitref != versionref) {
|
||||||
|
log.Println("build is DIRTY", gitref, "!=", versionref)
|
||||||
|
shell.Write("./resources/build.DIRTY", versionref)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if there are pending diffs. If so, also mark this as dirty.
|
||||||
|
diff := shell.Run("git diff HEAD")
|
||||||
|
if (diff != "") {
|
||||||
|
log.Println("build is DIRTY -- pending diffs")
|
||||||
|
shell.Write("./resources/build.DIRTY", "pending diffs")
|
||||||
|
}
|
||||||
|
|
||||||
// rebuild the binary (always remove the old one
|
// rebuild the binary (always remove the old one
|
||||||
shell.Run("rm " + filename)
|
shell.Run("rm " + filename)
|
||||||
|
@ -34,16 +69,7 @@ func main() {
|
||||||
|
|
||||||
md5sum := shell.Md5sum(filename)
|
md5sum := shell.Md5sum(filename)
|
||||||
log.Println("\tmd5sum =", md5sum)
|
log.Println("\tmd5sum =", md5sum)
|
||||||
|
|
||||||
if (md5sum == "") {
|
|
||||||
log.Println("\tBUILD FAILED")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
shell.Write("/tmp/build.md5sum", md5sum)
|
shell.Write("/tmp/build.md5sum", md5sum)
|
||||||
|
|
||||||
/*
|
return md5sum
|
||||||
// upload test
|
|
||||||
sess := shell.SSH("mirrors.wit.com", 22, "jcarr", "")
|
|
||||||
shell.Scp(sess, filename, "/tmp/jcarr-testing")
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,4 +221,10 @@ func parseConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.Dirty = false
|
config.Dirty = false
|
||||||
|
|
||||||
|
dirty, err := packrBox.FindString("build.DIRTY")
|
||||||
|
if (err == nil) {
|
||||||
|
log.Println("dirty =", dirty)
|
||||||
|
config.Dirty = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
09793249ee459e6d60e9957924a33812728d5738
|
|
@ -22,7 +22,7 @@ func upgrade() {
|
||||||
mirrorsBUILDDATE := shell.Chomp(shell.Wget(builddateURL))
|
mirrorsBUILDDATE := shell.Chomp(shell.Wget(builddateURL))
|
||||||
epoch := time.Now().Unix()
|
epoch := time.Now().Unix()
|
||||||
|
|
||||||
myBUILDDATE, _ := packrBox.FindString("BUILDDATE")
|
myBUILDDATE, _ := packrBox.FindString("build.DATE")
|
||||||
myBUILDDATE = shell.Chomp(myBUILDDATE)
|
myBUILDDATE = shell.Chomp(myBUILDDATE)
|
||||||
myBUILDVERSION, _ := packrBox.FindString("VERSION")
|
myBUILDVERSION, _ := packrBox.FindString("VERSION")
|
||||||
myBUILDVERSION = shell.Chomp(myBUILDVERSION)
|
myBUILDVERSION = shell.Chomp(myBUILDVERSION)
|
||||||
|
|
Loading…
Reference in New Issue