add config name to .img or .iso

This commit is contained in:
Ron Williams 2022-11-12 00:18:14 -08:00 committed by Jeremy Soller
parent 7587455f23
commit f312f466f6
3 changed files with 103 additions and 2 deletions

98
build.sh Executable file
View file

@ -0,0 +1,98 @@
#!/usr/bin/env bash
###########################################################################
# #
# Build the system, with a specified processor type and filesystem config #
# #
###########################################################################
usage()
{
echo "build.sh: Invoke make for a particular architecture and configuration."
echo "Usage:"
echo "./build.sh [-X | -A | -6 | -a ARCH] [-c CONFIG] [-f FILESYSTEM_CONFIG] TARGET..."
echo " -X Equivalent to -a x86_64 (see below)."
echo " -A Equivalent to -a aarch64 (see below)."
echo " -6 Equivalent to -a i686 (see below)."
echo " -a ARCH: Processor Architecture. Normally one of x86_64, aarch64 or"
echo " i686. ARCH is not checked, so you can add a new architecture."
echo " Defaults to the directory containing the FILESYSTEM_CONFIG file,"
echo " or x86_64 if no FILESYSTEM_CONFIG is specified."
echo " -c CONFIG: The name of the config, e.g. desktop, server or demo."
echo " Determines the name of the image, build/ARCH/CONFIG_harddrive.img"
echo " e.g. build/x86_64/desktop_harddrive.img"
echo " Determines the name of FILESYSTEM_CONFIG if none is specified."
echo " Defaults to the basename of FILESYSTEM_CONFIG, or 'desktop'"
echo " if FILESYSTEM_CONFIG is not specified."
echo " -f FILESYSTEM_CONFIG:"
echo " The config file to use. It can be in any location."
echo " However, if the file is not in a directory named x86_64, aarch64"
echo " or i686, you must specify the architecture."
echo " If -f is not specified, FILESYSTEM_CONFIG is set to"
echo " config/ARCH/CONFIG.toml"
echo " If you specify both CONFIG and FILESYSTEM_CONFIG, it is not"
echo " necessary that they match, but it is recommended."
echo " Examples: ./build.sh -c demo live - make build/x86_64/demo_livedisk.iso"
echo " ./build.sh -6 qemu - make build/i686/desktop_harddrive.img and"
echo " and run it in qemu"
echo " NOTE: If you do not change ARCH or CONFIG very often, edit mk/config.mk"
echo " and set ARCH and FILESYSTEM_CONFIG. You only need to use this"
echo " script when you want to override them."
}
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
usage
exit
fi
defaultarch="x86_64"
defaultname="desktop"
ARCH=""
CONFIG_NAME=""
FILESYSTEM_CONFIG=""
while getopts ":c:f:a:dhXA6" opt
do
case "$opt" in
a) ARCH="$OPTARG";;
c) CONFIG_NAME="$OPTARG";;
f) FILESYSTEM_CONFIG="$OPTARG";;
X) ARCH="x86_64";;
A) ARCH="aarch64";;
6) ARCH="i686";;
h) usage;;
\?) echo "Unknown option -$OPTARG, try -h for help"; exit;;
:) echo "-$OPTARG requires a value"; exit;;
esac
done
shift $((OPTIND -1))
if [ -z "$ARCH" ] && [ -n "$FILESYSTEM_CONFIG" ]; then
dirname=`dirname "$FILESYSTEM_CONFIG"`
ARCH=`basename $dirname`
case "$ARCH" in
x86_64) : ;;
aarch64) : ;;
i686) : ;;
\?) ARCH=""; echo "Unknown Architecture, please specify x86_64, aarch64 or i686";;
esac
fi
if [ -z "$config_name" ] && [ -n "$FILESYSTEM_CONFIG" ]; then
CONFIG_NAME=`basename "$FILESYSTEM_CONFIG" .toml`
fi
if [ -z "$ARCH" ]; then
ARCH="$defaultarch"
fi
if [ -z "$CONFIG_NAME" ]; then
CONFIG_NAME="$defaultname"
fi
if [ -z "$FILESYSTEM_CONFIG" ]; then
FILESYSTEM_CONFIG="config/$ARCH/$CONFIG_NAME.toml"
fi
export ARCH CONFIG_NAME FILESYSTEM_CONFIG
make $@

View file

@ -11,6 +11,8 @@ REPO_BINARY?=0
FILESYSTEM_CONFIG?=config/$(ARCH)/desktop.toml
## Filesystem size in MB (default comes from filesystem_size in the FILESYSTEM_CONFIG)
FILESYSTEM_SIZE?=$(shell grep filesystem_size $(FILESYSTEM_CONFIG) | cut -d' ' -f3)
## Name of the configuration to include in the image name e.g. desktop or server
CONFIG_NAME?=$(shell basename $(FILESYSTEM_CONFIG) .toml)
## Flags to pass to redoxfs-mkfs. Add --encrypt to set up disk encryption
REDOXFS_MKFS_FLAGS?=
## Set to 1 to enable Podman build, any other value will disable it
@ -55,7 +57,7 @@ export XARGO_RUST_SRC=$(ROOT)/rust/src
## Userspace variables
export TARGET=$(ARCH)-unknown-redox
BUILD=build/$(ARCH)
BUILD=build/$(ARCH)/$(CONFIG_NAME)
INSTALLER=installer/target/release/redox_installer
ifeq ($(REPO_BINARY),0)
INSTALLER+=--cookbook=cookbook

View file

@ -11,8 +11,9 @@ CONTAINER_WORKDIR?=/mnt/redox
## Podman command with its many arguments
PODMAN_VOLUMES?=--volume "`pwd`":$(CONTAINER_WORKDIR):Z
PODMAN_ENV?=--env PATH=/home/poduser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env PODMAN_BUILD=0
PODMAN_CONFIG?=--env ARCH=$(ARCH) --env CONFIG_NAME=$(CONFIG_NAME) --env FILESYSTEM_CONFIG=$(FILESYSTEM_CONFIG)
PODMAN_OPTIONS?=--rm --workdir $(CONTAINER_WORKDIR) --userns keep-id --user `id -u` --interactive
PODMAN_RUN?=podman run $(PODMAN_OPTIONS) $(PODMAN_VOLUMES) $(PODMAN_ENV) $(IMAGE_TAG)
PODMAN_RUN?=podman run $(PODMAN_OPTIONS) $(PODMAN_VOLUMES) $(PODMAN_ENV) $(PODMAN_CONFIG) $(IMAGE_TAG)
container_shell: build/container.tag
ifeq ($(PODMAN_BUILD),1)