@@ -50,33 +50,73 @@ components of the ZFSBootMenu repository:
5050
5151- ` 90zfsbootmenu ` , the Dracut module encapsulating ZFSBootMenu functionality;
5252- ` bin/generate-zbm ` , the executable script that creates ZFSBootMenu images;
53- - ` contrib/docker ` , providing either ` config.yaml ` or ` config.yaml.default ` .
54-
55- If the build script finds the volume mounted at ` /zbm ` empty, it will install
56- the ` git ` package and clone the master branch of the upstream ZFSBootMenu
57- repository. This makes the image capable of producing default images without
58- needing a local clone of the repository. To build anything but the head commit
59- of the upstream master branch, clone the repository, checkout an aribtrary
60- commit or make local changes, and mount that repository at ` /zbm ` .
61-
62- ## Contents of ` contrib/docker `
63-
64- The build script expects to find a valid ZFSBootMenu configuration file at
65- ` /zbm/contrib/docker/config.yaml ` within the container. If this file does not
66- exist, the file ` /zbm/contrib/docker/config.yaml.default ` will be copied to the
67- expected location. At least one of these files must exist or the build script
68- will fail. The default configuration will store images in the directory
69- ` contrib/docker/build ` , which will be created by ` generate-zbm ` if it does not
70- already exist.
71-
72- Builder containers do not have access to local files ` /etc/zfs/zpool.cache ` or
73- ` /etc/hostid ` . If one or both of these components are desired in the output
74- image (for example, to ensure consistency with the build host), copy the
75- desired files to ` contrib/docker/zpool.cache ` or ` contrib/docker/hostid ` ,
76- respectively. If the build script finds these files, it will copy them into the
77- container where the ZFSBootMenu Dracut module expects to find them. If one of
78- these files is missing, any corresponding file already installed in the
79- container will be * removed* .
53+
54+ If the build script finds the volume mounted at ` /zbm ` empty, it will fetch an
55+ archive of the official ZFSBootMenu repository on github.com. This makes the
56+ image capable of producing default images without needing a local clone of the
57+ repository. The specific commit, tag or branch to fetch can be specified at
58+ container run time.
59+
60+ ## Command-Line Arguments and Environment Variables
61+
62+ The build script accepts several command-line arguments or environment
63+ variables that override its default behavior. Run the container with the ` -h `
64+ command-line argument to see a summary of build options and their default
65+ options. The options are:
66+
67+ - ` $BUILDROOT ` specifies a default root for image builds. The build root is
68+ expected to hold a default default configuration file and output directory,
69+ as well as optional hostid and pool cache files. If an output directory,
70+ specific configuration and (when appropriate) hostid or pool cache are
71+ specified, then ` $BUILDROOT ` is not relevant.
72+
73+ The environment variable or default can be overridden with the ` -b ` option.
74+
75+ - ` $ZBMCONF ` specifies the in-container path to a specific configuration file.
76+ The build script will override any ` ImageDir ` paths and remove any
77+ ` Global.BootMountPoint ` option but otherwise uses the configuration as-is.A
78+
79+ The environment variable or default can be overridded with the ` -c ` option.
80+
81+ - ` $ZBMOUTPUT ` specifies the in-container path to an output directory. As noted
82+ above, the build script overrides any ` ImageDir ` path in a configuration,
83+ pointing it instead to a temporary output directory. After the script
84+ successfully runs ` generate-zbm ` , it will copy any artifacts from the
85+ temporary build directory to ` $ZBMOUTPUT ` .
86+
87+ The environment variable or default can be overridded with the ` -o ` option.
88+
89+ - ` $HOSTID ` specifies the in-container path to a hostid file. If this file is
90+ specified, it will be copied to ` /etc/hostid ` inside the container for
91+ inclusion in ZFSBootMenu images. If not, any ` /etc/hostid ` in the container
92+ will be removed. (Note: unless the ` zfsbootmenu ` dracut module is configured
93+ with ` release_mode=1 ` , the module may still create an ` /etc/hostid ` with
94+ potentially arbitrary contents in output images.
95+
96+ The environment variable or default can be overridded with the ` -H ` option.
97+
98+ - ` $POOLCACHE ` specifies the in-container path to a ZFS pool cache file. If
99+ this file is specified, it will be copied to ` /etc/zfs/zpool.cache ` inside
100+ the container for inclusion in ZFSBootMenu images. If not, any
101+ ` /etc/zfs/zpool.cache ` in the container will be removed.
102+
103+ The environment variable or default can be overridded with the ` -C ` option.
104+
105+ - ` $ZBMTAG ` specifies any "commit-ish" label recognized by ` git ` as a pointer
106+ to a specific git commit. This can be a branch name (to grab the head of that
107+ branch), tag or commit hash. If ` /zbm ` in the container is not pre-populated,
108+ the container will fetch and unpack the named tag. By default, the value of
109+ ` $ZBMTAG ` will be taken from the contents of ` /etc/zbm-commit-hash ` if the
110+ container was built with the ` ZBM_COMMIT_HASH ` build argument; otherwise, the
111+ default is ` master ` . The tag is ignored if ` /zbm ` in the container is not
112+ empty.
113+
114+ The environment variable or default can be overridded with the ` -t ` option.
115+
116+ An additional command-line argument, ` -e ` , allows the ZFSBootMenu configuration
117+ to be modified with ` yq-go eval ` statements at container run time. Do not use
118+ this unless you review the build script and understand, without documentation,
119+ what will happen!
80120
81121## Build Examples
82122
@@ -85,7 +125,7 @@ default configuration using a local ZFSBootMenu repository `/sw/zfsbootmenu`,
85125simply run
86126
87127``` sh
88- podman run -v /sw/zfsbootmenu:/zbm / zbm
128+ podman run -v /sw/zfsbootmenu:/zbm zbm
89129```
90130
91131After some console output, the container should terminate and the directory
@@ -101,7 +141,18 @@ directory:
101141
102142``` sh
103143cp /etc/hostid /sw/zfsbootmenu/contrib/docker/hostid
104- podman run -v /sw/zfsbootmenu:/zbm /zbm
144+ podman run -v /sw/zfsbootmenu:/zbm zbm
145+ ```
146+
147+ To create an image from the current ` master ` branch without having a local
148+ repository, store the output images in ` /boot/efi/EFI/zfsbootmenu ` and include
149+ the hostid of the current system, assuming a ` zbm ` builder container is tagged
150+ locally:
151+
152+ ``` sh
153+ mkdir -p /boot/efi/EFI/zfsbootmenu
154+ podman run -v /boot/efi/EFI/zfsbootmenu:/output \
155+ -v /etc/hostid:/hostid:ro zbm -o /output -H /hostid
105156```
106157
107158# Using Docker Compose
0 commit comments