~poldi1405/BackUploader

92ab7acc27c72cc48f22aa135535c02b399b9946 — Moritz Poldrack 2 years ago 0330db2
updated Makefile and enabled go modules
5 files changed, 35 insertions(+), 28 deletions(-)

M Makefile
M controller/control.go
A go.mod
A go.sum
M main.go
M Makefile => Makefile +3 -20
@@ 1,27 1,10 @@
VERSION := $(shell git describe --always --long --dirty)
GOOS := $(shell go tool dist banner | head -2 | tail -1 | sed -r 's/[^/]* ([a-z0-9]+)\/[A-Za-z0-9 \/]*/\1/')
GOARCH := $(shell go tool dist banner | head -2 | tail -1 | sed -r 's/[^/]*\/([a-z0-9]+)[A-Za-z0-9 \/]*/\1/')

buildrelease: build compress
.PHONY: buildrelease
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GOARCH := $(shell go env GOEXE)

build: binary
.PHONY: build

jenkins:
	@if [ ${GOOS} = "windows" ]; then\
		go build -ldflags="-s -w -X main.buildVersion=${VERSION} -X main.buildArch=${GOOS}-${GOARCH}" -o BackUploader.${GOOS}.${GOARCH}.exe;\
	else\
		go build -ldflags="-s -w -X main.buildVersion=${VERSION} -X main.buildArch=${GOOS}-${GOARCH}" -o BackUploader.${GOOS}.${GOARCH};\
	fi

prepare:
	go get -v golang.org/x/sync/semaphore
	go get -v github.com/wsxiaoys/terminal
	go get -v github.com/bigkevmcd/go-configparser

binary:
	go build -ldflags="-s -w -X main.buildVersion=${VERSION} -X main.buildArch=${GOOS}-${GOARCH}"

compress:
	upx -9 --brute output/linux-amd64/FonFon

M controller/control.go => controller/control.go +6 -4
@@ 11,8 11,8 @@ import (
	"sync"
	"syscall"

	"../display"
	"golang.org/x/sync/semaphore"
	"mpldr.codes/backuploader/display"
)

var (


@@ 43,7 43,7 @@ var (
func Initialize() {
	if DebugEnabled {
		if LogToFile != "" {
			lfh, err := os.OpenFile(LogToFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
			lfh, err := os.OpenFile(LogToFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600)
			if err != nil {
				panic(err)
			}


@@ 63,10 63,12 @@ func Start(folder string, displayId int, wg *sync.WaitGroup) {
		display.Update(displayId, "@{!r}FAILED1!")
		return
	}
	replacevalues := [4]string{cpath + PATH_SEPARATOR + ".up",
	replacevalues := [4]string{
		cpath + PATH_SEPARATOR + ".up",
		GenPwd(PwdLength),
		folder,
		SuccPath + PATH_SEPARATOR}
		SuccPath + PATH_SEPARATOR,
	}
	// move out
	if err := os.Rename(cpath, Path+PATH_SEPARATOR+"._"+folder); err != nil {
		failed(cpath, folder, displayId, err)

A go.mod => go.mod +9 -0
@@ 0,0 1,9 @@
module mpldr.codes/backuploader

go 1.18

require (
	github.com/bigkevmcd/go-configparser v0.0.0-20210106142102-909504547ead
	github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0
	golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

A go.sum => go.sum +13 -0
@@ 0,0 1,13 @@
github.com/bigkevmcd/go-configparser v0.0.0-20210106142102-909504547ead h1:UhYWAphNveMty305skySR5ST/hbYDexgsgkhcy0MDhM=
github.com/bigkevmcd/go-configparser v0.0.0-20210106142102-909504547ead/go.mod h1:RI5D4DqbDX0Kb0SvKTuAKMYlkSBND3zLQZI/wiS5Ij0=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 h1:3UeQBvD0TFrlVjOeLOBz+CPAI8dnbqNSVwUwRrkp7vQ=
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0/go.mod h1:IXCdmsXIht47RaVFLEdVnh1t+pgYtTAhQGj73kz+2DM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

M main.go => main.go +4 -4
@@ 6,11 6,11 @@ import (
	"os"
	"sync"

	"./controller"
	"./display"
	"github.com/bigkevmcd/go-configparser"
	"github.com/wsxiaoys/terminal/color"
	"golang.org/x/sync/semaphore"
	"mpldr.codes/backuploader/controller"
	"mpldr.codes/backuploader/display"
)

var (


@@ 174,7 174,7 @@ func main() {
	}
	color.Println("@{g}DONE@{|}")

	var dirs = make([]string, 0)
	dirs := make([]string, 0)
	for _, dir := range subdirs {
		if dir.IsDir() {
			dirs = append(dirs, dir.Name())


@@ 187,7 187,7 @@ func main() {
		return
	}

	//TODO: Context controller
	// TODO: Context controller
	fmt.Println("a maximum of", setclimit, "jobs is performed at a time")
	controller.Running = semaphore.NewWeighted(setclimit)
	fmt.Println("a maximum of", setpclimit, "jobs is packed at a time")