docs: Add "Hello World" example
Let's get practical faster in the manual and have a simple "Hello World" example right off the bat to hopefully make it easier to grok how OSTree works. Also some minor tweaks on wording around comparisons to git. Closes: #1581 Approved by: cgwalters
This commit is contained in:
parent
a3295ee584
commit
053efeb23a
|
|
@ -20,9 +20,9 @@ bootloader configuration.
|
||||||
|
|
||||||
The core OSTree model is like git in that it checksums individual files and has
|
The core OSTree model is like git in that it checksums individual files and has
|
||||||
a content-addressed-object store. It's unlike git in that it "checks out" the
|
a content-addressed-object store. It's unlike git in that it "checks out" the
|
||||||
files via hardlinks, and they should thus be immutable. Therefore, another way
|
files via hardlinks, and they thus need to be immutable to prevent corruption.
|
||||||
to think of OSTree is that it's just a more polished version
|
Therefore, another way to think of OSTree is that it's just a more polished
|
||||||
of
|
version of
|
||||||
[Linux VServer hardlinks](http://linux-vserver.org/index.php?title=util-vserver:Vhashify&oldid=2285).
|
[Linux VServer hardlinks](http://linux-vserver.org/index.php?title=util-vserver:Vhashify&oldid=2285).
|
||||||
|
|
||||||
**Features:**
|
**Features:**
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,78 @@ replicating them to clients.
|
||||||
The underlying architecture might be summarized as "git for
|
The underlying architecture might be summarized as "git for
|
||||||
operating system binaries". It operates in userspace, and will
|
operating system binaries". It operates in userspace, and will
|
||||||
work on top of any Linux filesystem. At its core is a git-like
|
work on top of any Linux filesystem. At its core is a git-like
|
||||||
content-addressed object store, and layered on top of that is
|
content-addressed object store with branches (or "refs") to track
|
||||||
bootloader configuration, management of
|
meaningful filesystem trees within the store. Similarly, one can
|
||||||
`/etc`, and other functions to perform an
|
check out or commit to these branches.
|
||||||
upgrade beyond just replicating files.
|
|
||||||
|
Layered on top of that is bootloader configuration, management of
|
||||||
|
`/etc`, and other functions to perform an upgrade beyond just
|
||||||
|
replicating files.
|
||||||
|
|
||||||
You can use OSTree standalone in the pure replication model,
|
You can use OSTree standalone in the pure replication model,
|
||||||
but another approach is to add a package manager on top,
|
but another approach is to add a package manager on top,
|
||||||
thus creating a hybrid tree/package system.
|
thus creating a hybrid tree/package system.
|
||||||
|
|
||||||
|
## Hello World example
|
||||||
|
|
||||||
|
OSTree is mostly used as a library, but a quick tour of using its
|
||||||
|
CLI tools can give a general idea of how it works at its most
|
||||||
|
basic level.
|
||||||
|
|
||||||
|
You can create a new OSTree repository using `init`:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ostree --repo=repo init
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a new `repo` directory containing your
|
||||||
|
repository. Feel free to inspect it.
|
||||||
|
|
||||||
|
Now, let's prepare some data to add to the repo:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir tree
|
||||||
|
$ echo "Hello world!" > tree/hello.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
We can now import our `tree/` directory using the `commit`
|
||||||
|
command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ostree --repo=repo commit --branch=foo tree/
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a new branch `foo` pointing to the full tree
|
||||||
|
imported from `tree/`. In fact, we could now delete `tree/` if we
|
||||||
|
wanted to.
|
||||||
|
|
||||||
|
To check that we indeed now have a `foo` branch, you can use the
|
||||||
|
`refs` command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ostree --repo=repo refs
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
|
||||||
|
We can also inspect the filesystem tree using the `ls` and `cat`
|
||||||
|
commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ostree --repo=repo ls foo
|
||||||
|
d00775 1000 1000 0 /
|
||||||
|
-00664 1000 1000 13 /hello.txt
|
||||||
|
$ ostree --repo=repo cat foo /hello.txt
|
||||||
|
Hello world!
|
||||||
|
```
|
||||||
|
|
||||||
|
And finally, we can check out our tree from the repository:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ostree --repo=repo checkout foo tree-checkout/
|
||||||
|
$ cat tree-checkout/hello.txt
|
||||||
|
Hello world!
|
||||||
|
```
|
||||||
|
|
||||||
## Comparison with "package managers"
|
## Comparison with "package managers"
|
||||||
|
|
||||||
Because OSTree is designed for deploying core operating
|
Because OSTree is designed for deploying core operating
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue