Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
.idea

34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
INSTALL = /usr/sbin/install
BINDIR = /usr/lib
MANIFESTDIR = /lib/svc/manifest/system

PRE_HASH = pre\#
HASH = $(PRE_HASH:pre\%=%)

SET_OWNER ?= $(HASH)
$(SET_OWNER)OWNER_BIN = -u root -g bin
$(SET_OWNER)OWNER_SMF = -u root -g sys

INSTALL_BIN = $(INSTALL) -s -f $(DESTDIR)$(BINDIR) $(OWNER_BIN) -m 0755
INSTALL_SMF = $(INSTALL) -s -f $(DESTDIR)$(MANIFESTDIR) $(OWNER_SMF) -m 0644

build: build-debug

build-debug:
cargo build

build-release:
cargo build --release

install-%: build-%
mkdir -p $(DESTDIR)/usr/lib
mkdir -p $(DESTDIR)/lib/svc/manifest/system
$(INSTALL_BIN) target/$(@:install-%=%)/metadata
$(INSTALL_BIN) userscript.sh
$(INSTALL_SMF) metadata.xml
$(INSTALL_SMF) userscript.xml

install: install-release

clean:
cargo clean
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ distributions:

## Building and Usage

This software must be built with Rust and Cargo.
This software must be built with Rust and Cargo. For convenience a Makefile is provided

```
$ cargo build --release
$ gmake MODE=release
```

The built artefact, `target/release/metadata`, is intended to be installed as
Expand All @@ -45,8 +45,23 @@ for both the metadata service (`metadata.xml`) and the service which executes a
user-provided script (`userscript.xml`), and are intended to be included in the
image in `/lib/svc/manifest/system`.

The Makefile automates this aswell if wanted
```
$ gmake install MODE=release
```

It is desirable to include these services in the SMF seed repository for an
image so that they are already imported when the image first boots in the
guest. The services include dependent relationships with several early boot
networking and identity services in an attempt to ensure the metadata agent
runs before network services are completely online.

## Packaging
If you would like to package this binary use the following command in your build
system to create a prototype directory tree.

`proto` can be any directory path of your choosing.

```
$ gmake DESTDIR=proto
```