Basic payloads: Data payloads: make one, read one (2 of 5)
The basic payloads series, hands-on: data payloads: make one, read one.
The Tebako team
github.com/tamatebako|
Note
|
Post 2 of 5 in the series Basic payloads. ○ ● ○ ○ ○
|
|
Note
|
Reference guide: Create a data payload. |
The simplest payload there is: a directory of files. Fonts, schemas, dictionaries, word lists, datasets — anything versioned that applications read. No code, no compilation, one command. This post makes one and then reads it back two ways.
Figure 1 — A directory with a manifest becomes one image; applications mount it at a path, or you read it directly with the tfs commands.
Make the payload
Give the directory a manifest and press it into an image:
$ mkdir -p acme-fonts/fonts acme-fonts/__tpkg__
$ cp ~/Downloads/acme-*.ttf acme-fonts/fonts/
$ cat > acme-fonts/__tpkg__/manifest.yaml <<EOF
schema_version: 1
kind: data
name: acme-fonts
version: 2.1.0
provides:
paths:
- /fonts
EOF
$ tfs mkimage acme-fonts/ -o acme-fonts-2.1.0.tfs
You now have one file — acme-fonts-2.1.0.tfs — that is a complete,
versioned, self-describing payload.
Read it back
The tfs commands inspect and unpack any image on any machine, with
nothing installed:
$ tfs info acme-fonts-2.1.0.tfs # kind, manifest, byte counts
$ tfs ls acme-fonts-2.1.0.tfs # list the tree
$ tfs cat acme-fonts-2.1.0.tfs /fonts/acme-bold.ttf > acme-bold.ttf
$ tfs extract acme-fonts-2.1.0.tfs -o ./unpacked/
info and ls never leave the image in place faster than a
directory listing; cat pulls out one file; extract unpacks the
whole tree.
Mount it into an application
The other way to consume a data payload is to mount it, so an application reads the files in place. That is a press-time decision, and it belongs to the next post’s subject.
$ tebako press -r ./myapp -e bin/myapp -o myapp \
--image acme-fonts-2.1.0.tfs:/usr/share/fonts/acme
When that packaged app runs, /usr/share/fonts/acme is the mounted
image — the same bytes, no copies on disk.
What you can do now
You can turn any directory of files into a versioned payload, inspect it, pull files out of it, and mount it into an application. The next post packages the application itself.
|
Note
|
Continue with part 3 of 5: Package a Ruby application. |