Skip to content

Commit

Permalink
make eve version from file rather than templating
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <avi@deitcher.net>
  • Loading branch information
deitch committed Jun 1, 2023
1 parent c6a45fe commit 1d1aa94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ LIVE=$(BUILD_DIR)/live
LIVE_IMG=$(BUILD_DIR)/live.$(IMG_FORMAT)
TARGET_IMG=$(BUILD_DIR)/target.img
INSTALLER=$(BUILD_DIR)/installer
VERSION_FILE=$(INSTALLER)/eve_version
VERIFICATION=$(BUILD_DIR)/verification
BUILD_DIR=$(DIST)/$(ROOTFS_VERSION)
CURRENT_DIR=$(DIST)/current
Expand Down Expand Up @@ -582,7 +583,7 @@ $(INSTALLER):
@mkdir -p $@
@cp -r pkg/eve/installer/* $@
# sample output 0.0.0-HEAD-a437e8e4-xen-amd64
@echo $(FULL_VERSION) > $(INSTALLER)/eve_version
@echo $(FULL_VERSION) > $(VERSION_FILE)

$(VERIFICATION):
@mkdir -p $@
Expand Down Expand Up @@ -631,7 +632,7 @@ $(ROOTFS)-%.img: $(ROOTFS_IMG)

$(ROOTFS_TAR): images/rootfs-$(HV).yml | $(INSTALLER)
$(QUIET): $@: Begin
./tools/makerootfs.sh tar -y $< -t $@ -a $(ZARCH)
./tools/makerootfs.sh tar -y $< -t $@ -d $(INSTALLER) -a $(ZARCH)
$(QUIET): $@: Succeeded

$(ROOTFS_IMG): $(ROOTFS_TAR) | $(INSTALLER)
Expand Down
2 changes: 1 addition & 1 deletion images/rootfs.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ services:
oomScoreAdj: -999
files:
- path: /etc/eve-release
contents: 'EVE_VERSION'
source: eve_version
- path: etc/linuxkit-eve-config.yml
metadata: yaml
- path: /etc/eve-hv-type
Expand Down
7 changes: 0 additions & 7 deletions tools/compose-image-yml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ process-image-template() {
done
}

patch_version() {
# shellcheck disable=SC2016
yq --arg version "$1" '(.files[] | select(.contents == "EVE_VERSION")).contents |= $version' "$2"
}

patch_hv() {
# shellcheck disable=SC2016
yq --arg hv "$1" '(.files[] | select(.contents == "EVE_HV")).contents |= $hv' "$2"
Expand All @@ -49,8 +44,6 @@ main() {
yq -f "${out_templ_path}".yq "${out_templ_path}" || exit 1
fi

patch_version "${eve_version}" "${out_templ_path}"

patch_hv "${eve_hv}" "${out_templ_path}"

process-image-template "${out_templ_path}" "${eve_version}"
Expand Down
28 changes: 19 additions & 9 deletions tools/makerootfs.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
# Usage:
#
# ./makerootfs.sh mode [-y <image.yml>] [-i <output rootfs image>] [-t <tar file>] [-f <filesystem format>] [-a <arch>]
# ./makerootfs.sh mode [-y <image.yml>] [-i <output rootfs image>] [-t <tar file>] [-f <filesystem format>] [-a <arch>] [-d <directory where to execute>]
# <fs> defaults to squash
# <arch> defaults to the current machine architecture

# NOTE: this will get executed from the provided -d <dir>, or else the current directory
# make NO assumptions about where this runs; if you can, use absolute paths

set -e
set -o pipefail

Expand Down Expand Up @@ -61,14 +64,16 @@ bail() {

# no mode we recognize
help() {
echo "Usage: $0 <mode> [-y <image.yml>] [-i <output rootfs image>] [-t <tarfile>] [-f {ext4|squash}] [-a <arch>]" >&2
echo "Usage: $0 <mode> [-y <image.yml>] [-i <output rootfs image>] [-t <tarfile>] [-f {ext4|squash}] [-a <arch>] [-d <directory>]" >&2
echo "must be one of the following modes:" >&2
echo " generate final image from yml:" >&2
echo " $0 image [-y <image.yml>] [-i <output rootfs image>] [-f {ext4|squash}] [-a <arch>]" >&2
echo " generate tar from yml:" >&2
echo " $0 tar [-y <image.yml>] [-t <output tarfile>] [-a <arch>]" >&2
echo " generate final image from tar:" >&2
echo " $0 imagefromtar [-i <output rootfs image>] [-f {ext4|squash}] [-t <input tarfile>]" >&2
echo
echo "setting the directory via -d will change to execute in the given directory" >&2
exit 1
}

Expand All @@ -79,24 +84,27 @@ help() {
mode="$1"
shift

unset tarfile imgfile arch format ymlfile
while getopts "t:i:a:f:y:h" o
unset tarfile imgfile arch format ymlfile execidr
while getopts "t:i:a:f:y:d:h" o
do
case $o in
t)
tarfile=$OPTARG
tarfile="$(realpath $OPTARG)"
;;
i)
imgfile=$OPTARG
imgfile="$(realpath $OPTARG)"
;;
a)
arch=$OPTARG
arch="$OPTARG"
;;
f)
format=$OPTARG
format="$OPTARG"
;;
y)
ymlfile=$OPTARG
ymlfile="$(realpath $OPTARG)"
;;
d)
execdir="$(realpath $OPTARG)"
;;
h)
help
Expand All @@ -113,6 +121,8 @@ PATH="$EVE/build-tools/bin:$PATH"
MKROOTFS_TAG="$(linuxkit pkg show-tag "$EVE/pkg/mkrootfs-${format}")"
IMAGE="$(cd "$(dirname "$imgfile")" && pwd)/$(basename "$imgfile")"

[ -n "$execdir" ] && cd "$execdir"

action="do_${mode}"
#shellcheck disable=SC2039
command -V "$action" > /dev/null 2>&1 || bail "Error: unsupported command '$mode'."
Expand Down

0 comments on commit 1d1aa94

Please sign in to comment.