Skip to content

Commit 1335860

Browse files
committed
implement version, and fix build by updating stacker
Signed-off-by: Serge Hallyn <[email protected]>
1 parent b97396e commit 1335860

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
all: atomfs
2+
3+
MAIN_VERSION ?= $(shell git describe --always --dirty || echo no-git)
4+
ifeq ($(MAIN_VERSION),$(filter $(MAIN_VERSION), "", no-git))
5+
$(error "Bad value for MAIN_VERSION: '$(MAIN_VERSION)'")
6+
endif
7+
8+
GO_SRC_DIRS := .
9+
10+
GO_SRC := $(shell find $(GO_SRC_DIRS) -name "*.go")
11+
12+
VERSION_LDFLAGS=-X main.Version=$(MAIN_VERSION)
13+
14+
.PHONY: gofmt
15+
gofmt: .made-gofmt
16+
.made-gofmt: $(GO_SRC)
17+
o=$$(gofmt -l -w $(GO_SRC_DIRS) 2>&1) && [ -z "$$o" ] || \
18+
{ echo "gofmt made changes: $$o" 1>&2; exit 1; }
19+
@touch $@
20+
21+
atomfs: .made-gofmt $(GO_SRC)
22+
go build -buildvcs=false -ldflags "$(VERSION_LDFLAGS)" -o atomfs ./...
23+
24+
clean:
25+
rm -f atomfs

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/urfave/cli"
99
)
1010

11-
const Version = "0.1"
11+
var Version string
1212

1313
func main() {
1414
app := cli.NewApp()

mount.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
"strings"
77
"syscall"
88

9-
"golang.org/x/sys/unix"
109
"github.com/urfave/cli"
10+
"golang.org/x/sys/unix"
1111
satomfs "stackerbuild.io/stacker/pkg/atomfs"
1212
)
1313

1414
var mountCmd = cli.Command{
15-
Name: "mount",
16-
Usage: "mount atomfs image",
17-
Action: doMount,
15+
Name: "mount",
16+
Usage: "mount atomfs image",
17+
Action: doMount,
1818
Flags: []cli.Flag{
1919
cli.BoolFlag{
2020
Name: "ro",
@@ -62,10 +62,10 @@ func doMount(ctx *cli.Context) error {
6262
}
6363

6464
opts := satomfs.MountOCIOpts{
65-
OCIDir: ocidir,
65+
OCIDir: ocidir,
6666
MetadataPath: metadir,
67-
Tag: tag,
68-
Target: rodest,
67+
Tag: tag,
68+
Target: rodest,
6969
}
7070

7171
mol, err := satomfs.BuildMoleculeFromOCI(opts)

umount.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
)
1212

1313
var umountCmd = cli.Command{
14-
Name: "umount",
15-
Usage: "unmount atomfs image",
16-
Action: doUmount,
14+
Name: "umount",
15+
Usage: "unmount atomfs image",
16+
Action: doUmount,
1717
}
1818

1919
func umountUsage(me string) error {

0 commit comments

Comments
 (0)