Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
netmon: Build netmon from the master Makefile
Browse files Browse the repository at this point in the history
This commit modifies the Makefile at the root of this repository
so that the binary kata-netmon can be built from there.

Signed-off-by: Sebastien Boeuf <[email protected]>
  • Loading branch information
Sebastien Boeuf committed Sep 14, 2018
1 parent fca7435 commit f131590
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SCRIPTS :=

# list of binaries to install
BINLIST :=
BINLIBEXECLIST :=

BIN_PREFIX = $(PROJECT_TYPE)
PROJECT_DIR = $(PROJECT_TAG)
Expand All @@ -49,6 +50,11 @@ TARGET = $(BIN_PREFIX)-runtime
TARGET_OUTPUT = $(CURDIR)/$(TARGET)
BINLIST += $(TARGET)

NETMON_DIR = netmon
NETMON_TARGET = $(PROJECT_TYPE)-netmon
NETMON_TARGET_OUTPUT = $(CURDIR)/$(NETMON_TARGET)
BINLIBEXECLIST += $(NETMON_TARGET)

DESTDIR := /

installing = $(findstring install,$(MAKECMDGOALS))
Expand Down Expand Up @@ -225,7 +231,12 @@ define SHOW_ARCH
$(shell printf "\\t%s%s\\\n" "$(1)" $(if $(filter $(ARCH),$(1))," (default)",""))
endef

all: runtime
all: runtime netmon

netmon: $(NETMON_TARGET_OUTPUT)

$(NETMON_TARGET_OUTPUT): $(SOURCES)
$(QUIET_BUILD)(cd $(NETMON_DIR) && go build -i -o $@ -ldflags "-X main.version=$(VERSION)")

runtime: $(TARGET_OUTPUT) $(CONFIG)
.DEFAULT: default
Expand Down Expand Up @@ -405,11 +416,14 @@ check-go-static:
coverage:
$(QUIET_TEST).ci/go-test.sh html-coverage

install: default runtime install-scripts install-completions install-config install-bin
install: default runtime install-scripts install-completions install-config install-bin install-bin-libexec

install-bin: $(BINLIST)
$(foreach f,$(BINLIST),$(call INSTALL_EXEC,$f,$(BINDIR)))

install-bin-libexec: $(BINLIBEXECLIST)
$(foreach f,$(BINLIBEXECLIST),$(call INSTALL_EXEC,$f,$(PKGLIBEXECDIR)))

install-config: $(CONFIG)
$(QUIET_INST)install --mode 0644 -D $(CONFIG) $(DESTDIR)/$(CONFIG_PATH)

Expand All @@ -420,7 +434,7 @@ install-completions:
$(QUIET_INST)install --mode 0644 -D $(BASH_COMPLETIONS) $(DESTDIR)/$(BASH_COMPLETIONSDIR)/$(notdir $(BASH_COMPLETIONS));

clean:
$(QUIET_CLEAN)rm -f $(TARGET) $(CONFIG) $(GENERATED_GO_FILES) $(GENERATED_FILES) $(COLLECT_SCRIPT)
$(QUIET_CLEAN)rm -f $(TARGET) $(NETMON_TARGET) $(CONFIG) $(GENERATED_GO_FILES) $(GENERATED_FILES) $(COLLECT_SCRIPT)

show-usage: show-header
@printf "• Overview:\n"
Expand Down Expand Up @@ -483,6 +497,8 @@ show-summary: show-header
@printf "\tbinaries to install :\n"
@printf \
"$(foreach b,$(sort $(BINLIST)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(BINDIR)/$(b))\\\n"))"
@printf \
"$(foreach b,$(sort $(BINLIBEXECLIST)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(PKGLIBEXECDIR)/$(b))\\\n"))"
@printf \
"$(foreach s,$(sort $(SCRIPTS)),$(shell printf "\\t - $(shell readlink -m $(DESTDIR)/$(BINDIR)/$(s))\\\n"))"
@printf "\tconfig to install (CONFIG) : %s\n" $(CONFIG)
Expand Down
8 changes: 5 additions & 3 deletions netmon/netmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ type Route struct {
}

const (
netmonName = "kata-netmon"
netmonVersion = "0.0.1"
netmonName = "kata-netmon"

kataCmd = "kata-network"
kataCLIAddIfaceCmd = "add-iface"
Expand All @@ -83,6 +82,9 @@ const (
storageFilePerm = os.FileMode(0640)
)

// version is the netmon version. This variable is populated at build time.
var version = "unknown"

type netmonParams struct {
sandboxID string
runtimePath string
Expand Down Expand Up @@ -110,7 +112,7 @@ type netmon struct {
var netmonLog = logrus.New()

func printVersion() {
fmt.Printf("%s version %s\n", netmonName, netmonVersion)
fmt.Printf("%s version %s\n", netmonName, version)
}

const componentDescription = `is a network monitoring process that is intended to be started in the
Expand Down

0 comments on commit f131590

Please sign in to comment.