forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kata-containers#41 from jcvenegas/install-target
makefile: Add install target
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
kata-agent | ||
kata-agent.service | ||
agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,44 @@ | ||
TARGET = kata-agent | ||
|
||
$(TARGET): | ||
DESTDIR := | ||
PREFIX := /usr | ||
BINDIR := $(PREFIX)/bin | ||
# Define if agent will be installed as init | ||
INIT := no | ||
# Path to systemd unit directory if installed as not init. | ||
UNIT_DIR := /usr/lib/systemd/system | ||
|
||
GENERATED_FILES := | ||
|
||
ifeq ($(INIT),no) | ||
# Unit file to start kata agent in systemd systems | ||
UNIT_FILES = kata-agent.service | ||
GENERATED_FILES := $(UNIT_FILES) | ||
# Target to be reached in systemd services | ||
UNIT_FILES += kata-containers.target | ||
endif | ||
|
||
$(TARGET): $(GENERATED_FILES) | ||
go build -o $@ | ||
|
||
install: | ||
install -D $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET) | ||
ifeq ($(INIT),no) | ||
@echo "Installing systemd unit files..." | ||
$(foreach f,$(UNIT_FILES),$(call INSTALL_FILE,$f,$(UNIT_DIR))) | ||
endif | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(TARGET) | ||
rm -f $(TARGET) $(GENERATED_FILES) | ||
|
||
define INSTALL_FILE | ||
install -D -m 644 $1 $(DESTDIR)$2/$1 || exit 1; | ||
endef | ||
|
||
$(GENERATED_FILES): %: %.in | ||
@mkdir -p `dirname $@` | ||
@sed \ | ||
-e 's|[@]bindir[@]|$(BINDIR)|g' \ | ||
-e 's|[@]kata-agent[@]|$(TARGET)|g' \ | ||
"$<" > "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=Kata Containers Agent | ||
Documentation=https://github.com/kata-containers/agent | ||
Wants=kata-containers.target | ||
|
||
[Service] | ||
# Send agent output to tty to allow capture debug logs | ||
# from a VM serial port | ||
StandardOutput=tty | ||
Type=simple | ||
ExecStart=@bindir@/@kata-agent@ | ||
LimitNOFILE=infinity | ||
ExecStop=/bin/sync ; /usr/bin/systemctl --force poweroff | ||
FailureAction=poweroff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Unit] | ||
Description=Kata Containers Agent Target | ||
Requires=basic.target | ||
Requires=kata-agent.service | ||
Conflicts=rescue.service rescue.target | ||
After=basic.target rescue.service rescue.target | ||
AllowIsolate=yes |