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

Update to Bob v0.2.0 among other fixes #48

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
25 changes: 0 additions & 25 deletions .cirrus.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ rootfs/
my-aquarium
.build
*.sw[nop]
.bob
.cache
compile_commands.json
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ With [Bob the Builder](https://github.com/inobulles/bob) installed:
```console
bob test install
```

## Installed directory structure

- `/usr/local/aquarium/`: The base directory for all aquarium-related stuff. This can be modified with `-r`.
- `/usr/local/aquarium/tmpls.remote`: List of sanctioned templates.
- `/usr/local/aquarium/db`: Database of all aquariums.
- `/usr/local/aquarium/tmpls/`: All cached templates.
- `/usr/local/aquarium/tmpls/amd64.freebsd.14.1-RELEASE-p5.txz`: Example of a cached template.
- `/usr/local/aquarium/kerns/`: All cached kernels.
- `/usr/local/aquarium/kerns/amd64.freebsd.14.1-RELEASE-p5.txz`: Example of a cached kernel.
- `/usr/local/aquarium/roots/`: Physical locations of the root file systems of the aquariums.
- `/usr/local/aquarium/roots/7538ef/`: Example of a root file system.
60 changes: 60 additions & 0 deletions build.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This Source Form is subject to the terms of the AQUA Software License, v. 1.0.
# Copyright (c) 2024 Aymeric Wibo

import bob

assert Platform.os() == "FreeBSD", "Aquariums are only supported on FreeBSD"

let OPENZFS_INCLUDES = "/usr/src/sys/contrib/openzfs/include"
assert Fs.exists(OPENZFS_INCLUDES), "OpenZFS includes not found (is /usr/src populated?)"

let LIBSPL_INCLUDES = "/usr/src/sys/contrib/openzfs/lib/libspl/include"
assert Fs.exists(OPENZFS_INCLUDES), "libspl includes not found (is /usr/src populated?)"

let OS_LIBSPL_INCLUDES = "/usr/src/sys/contrib/openzfs/lib/libspl/include/os/freebsd"
assert Fs.exists(OS_LIBSPL_INCLUDES), "OS-specific libspl includes not found (is /usr/src populated?)"

deps = [
Dep.git("https://github.com/inobulles/libcopyfile", "v0.1.1"),
Dep.git("https://github.com/inobulles/libmkfs_msdos", "v0.1.0"),
]

# Compile library and frontend sources.

let lib_src = Fs.list("src/lib").where(|path| path.endswith(".c"))
let cmd_src = Fs.list("src/aquarium").where(|path| path.endswith(".c"))

let cc = Cc([
"-g", "-std=c11", "-fPIC",
"-I" + OPENZFS_INCLUDES,
"-I" + LIBSPL_INCLUDES,
"-I" + OS_LIBSPL_INCLUDES,
"-Isrc", "-isystem=/usr/local/include",
"-Wall", "-Wextra", "-Werror"
])

let lib_obj = cc.compile(lib_src)
let cmd_obj = cc.compile(cmd_src)

# Create static & dynamic libraries and frontend executable.
# It's best we statically link in libaquarium to the frontend as it is a setuid binary.
# This also means it will be runnable in the temporary prefix by Bob, as LD_LIBRARY_PATH doesn't work with setuid binaries (see rtld(1)).

let libs = ["-larchive", "-lcrypto", "-lfetch", "-lgeom", "-ljail", "-lzfs", "-lcopyfile", "-lmkfs_msdos", "-lnvpair"]

let archive = Linker([]).archive(lib_obj)
let dyn_lib = Linker(["-shared"] + libs).link(lib_obj)
let cmd = Linker([archive] + libs).link(cmd_obj)

# Installation map.

install = {
archive: "lib/libaquarium.a",
dyn_lib: "lib/libaquarium.so",
cmd: "bin/aquarium",
"src/aquarium.h": "include/aquarium.h",
}

# Default runner.

run = ["aquarium"]
100 changes: 0 additions & 100 deletions build.wren

This file was deleted.

8 changes: 7 additions & 1 deletion src/aquarium.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef enum {
typedef enum {
AQUARIUM_TEMPLATE_KIND_BASE,
AQUARIUM_TEMPLATE_KIND_KERNEL,
AQUARIUM_TEMPLATE_KIND_OVERLAY,
} aquarium_template_kind_t;

typedef enum {
Expand Down Expand Up @@ -76,6 +77,7 @@ typedef struct {
char* base_path;
char* templates_path;
char* kernels_path;
char* overlays_path;
char* aquariums_path;

// file paths
Expand Down Expand Up @@ -156,7 +158,11 @@ int aquarium_os_load_epair_kmod(void);
int aquarium_os_load_bridge_kmod(void);

int aquarium_create_struct(aquarium_opts_t* opts);
int aquarium_create(aquarium_opts_t* opts, char const* path, char const* template, char const* kernel_template);
int aquarium_create(
aquarium_opts_t* opts, char const* pointer_path,
char const* template, char const* kernel_template,
char const* const* overlays, size_t overlay_count
);

int aquarium_enter(aquarium_opts_t* opts, char const* path, aquarium_enter_cb_t cb, void* param);
int aquarium_enter_setdown(char const* path, aquarium_os_t os);
Expand Down
Loading