From 455c48a4cb1e95f24a89c18e6607bdaefddbc2a1 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Fri, 7 Aug 2009 14:01:16 +0100 Subject: [PATCH] Support os variants This is a Ganeti 2.1 design feature. It's not implemented yet in 2.1, but its implementation in the debootstrap OS is totally backwards compatible. If no OS_VARIANT environment variable is passed in, everything proceeds as before, otherwise a instance-deboostrap tries to load a config file from a specially configured directory, which can be used to override any variable in the defaults file (which is sourced at the beginning as it was before. By default only the "default" variant is exported, which is shipped as an empty config file. Signed-off-by: Guido Trotter Reviewed-by: Iustin Pop --- Makefile.am | 7 ++++++- common.sh.in | 25 +++++++++++++++++++++++++ variants.list | 1 + 3 files changed, 32 insertions(+), 1 deletions(-) create mode 100644 variants.list diff --git a/Makefile.am b/Makefile.am index de9dcf9..7df7151 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,10 @@ osname=$(subst ganeti-instance-,,$(PACKAGE)) osdir=$(OS_DIR)/$(osname) +variantsdir="$(DESTDIR)${sysconfdir}/ganeti/instance-debootstrap/variants" dist_os_SCRIPTS = create import export rename -dist_os_DATA = ganeti_api_version +dist_os_DATA = ganeti_api_version variants os_DATA = common.sh dist_doc_DATA = COPYING NEWS README @@ -18,4 +19,8 @@ common.sh: common.sh.in Makefile $(do_subst) < $< > $@ chmod +x $@ +install-exec-local: + @mkdir_p@ "$(variantsdir)" + touch "$(variantsdir)/default.conf" + CLEANFILES = common.sh diff --git a/common.sh.in b/common.sh.in index 167bb00..130201f 100644 --- a/common.sh.in +++ b/common.sh.in @@ -143,6 +143,7 @@ fi : ${ARCH:=""} : ${EXTRA_PKGS:=""} : ${CUSTOMIZE_DIR:="@sysconfdir@/ganeti/instance-debootstrap.d"} +: ${VARIANTS_DIR:="@sysconfdir@/ganeti/instance-debootstrap/variants"} : ${GENERATE_CACHE:="yes"} : ${CLEAN_CACHE:="14"} # number of days to keep a cache file if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then @@ -178,3 +179,27 @@ else log_error "Unknown OS API VERSION $OS_API_VERSION" exit 1 fi + +if [ -n "$OS_VARIANT" ]; then + if [ ! -d "$VARIANTS_DIR" ]; then + log_error "OS Variants directory $VARIANTS_DIR doesn't exist" + exit 1 + fi + VARIANT_CONFIG="$VARIANTS_DIR/$OS_VARIANT.conf" + if [ -f "$VARIANTS_CONFIG" ]; then + . "$VARIANTS_CONFIG" + else + if grep -qxF "$OS_VARIANT" variants.list; then + log_error "ERROR: instance-debootstrap configuration error" + log_error " Published variant $OS_VARIANT is missing its config file" + log_error " Please create $VARIANT_CONFIG or unpublish the variant" + log_error " (by removing $OS_VARIANT from variants.list)" + else + log_error "Unofficial variant $OS_VARIANT is unsupported" + log_error "Most probably this is a user error, forcing a wrong name" + log_error "To support this variant please create file $VARIANT_CONFIG" + fi + exit 1 + fi +fi + diff --git a/variants.list b/variants.list new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/variants.list @@ -0,0 +1 @@ +default -- 1.7.2.5