Browse Source

Adds makefile

master
sloum 2 years ago
parent
commit
d1eb4e3e1f
  1. 28
      Makefile
  2. 27
      main.go

28
Makefile

@ -0,0 +1,28 @@
GOCMD := go
BINARY := scbm
PREFIX := /usr/local
EXEC_PREFIX := ${PREFIX}
BINDIR := ${EXEC_PREFIX}/bin
DATAROOTDIR := ${PREFIX}/share
MANDIR := ${DATAROOTDIR}/man
MAN1DIR := ${MANDIR}/man1
.PHONY: build
build:
${GOCMD} build -o ${BINARY}
.PHONY: install
install: install-bin clean
.PHONY: install-bin
install-bin: build
install -d ${DESTDIR}${BINDIR}
install -m 0755 ./${BINARY} ${DESTDIR}${BINDIR}
.PHONY: clean
clean:
${GOCMD} clean
.PHONY: uninstall
uninstall: clean
rm -f ${DESTDIR}${BINDIR}/${BINARY}

27
main.go

@ -213,10 +213,17 @@ func parseArgs() {
}
thaw(a[2:])
case "revert":
if len(a) != 3 {
errorExit("Incorrect number of arguments to revert. Expected 1 argument: program-name", nil)
revertCommand := flag.NewFlagSet("revert", flag.ExitOnError)
swapFlag := revertCommand.Bool("swap", false, "When set, the previous commit ID will be made current, like in a standard revert; but the current will become the previous, so the revert can be reverted.")
if len(a) < 3 {
errorExit("Incorrect number of arguments to revert. Expected 1 argument and optionally one flag", nil)
}
revertCommand.Parse(os.Args[2:])
prog := revertCommand.Args()
if len(prog) > 1 {
errorExit("Incorrect number of arguments to revert. Expected 1 argument and optionally one flag", nil)
}
revert(a[2], false)
revert(prog[0], *swapFlag)
case "set":
if len(a) != 4 {
errorExit("Too few arguments to set. Expected 2 arguments: program-name and command.", nil)
@ -510,7 +517,7 @@ func update(progs []string) {
// currently only master branch is supported
repo, err := git.OpenRepository(fp)
if err != nil {
fmt.Sprintf("Error accessing %s repository @ %s:", prog, fp)
errorExit(fmt.Sprintf("Error accessing %s repository @ %s:", prog, fp), err)
}
commit, err := repo.GetBranchCommitID("master")
if err != nil {
@ -588,21 +595,21 @@ func install(progs []string) {
for _, prog := range progs {
fmt.Printf("\033[1mInstalling\033[0m %s...\n", prog)
if _, ok := m.m[prog]; !ok {
fmt.Sprintf(" \\_Program %s does not exist in the scbm manifest\n \\_skipping...", prog)
fmt.Printf(" \\_Program %s does not exist in the scbm manifest\n \\_skipping...\n", prog)
continue
}
rec, err := getRecord(prog)
if err != nil {
fmt.Sprintf(" \\_Unable to retrieve record for %s: ", prog)
fmt.Println(err.Error())
fmt.Printf(" \\_Unable to retrieve record for %s: ", prog)
fmt.Print(err.Error())
fmt.Println(" \\_Skipping...")
continue
}
if rec.command == "" {
fmt.Printf(" \\_Empty command string for %s... aborting install.", prog)
if strings.TrimSpace(rec.command) == "" {
fmt.Printf(" \\_Empty command string for %s... aborting install.\n", prog)
continue
}
fmt.Printf("%s => %s", prog, rec.command)
fmt.Printf("%s => %s\n", prog, rec.command)
cmd := exec.Command("sh", "-c", fmt.Sprintf("%s", rec.command))
cmd.Dir = filepath.Join(SCBM_FOLDER, prog)
cmd.Stdout = os.Stdout

Loading…
Cancel
Save