[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 3/4] Add support for producing disks with (optional) extra variants.



This patch just adds the generic support code:
   * CONF.sh:		Add $(VARIANTS) configuration variable.
   * eash-build.sh:	Add command line parameter to enable variants.
   * Makefile:		Define VARIANT_xxx when preprocessing package list.
   * boot/?/common.sh:	Add a function for checking if a variant is enabled.
   * generate_di_list: 	Allow variant overrides in udeb exclusion list.

The generate_di_list change introduces an extended syntax to the udeb
exclusion lists. A line in the exclusion list may now include zero or
more conditionals in the form of a positive "variant" or negative
"!variant". In the positive case the relevant udeb will only be
excluded if the given variant is enabled. In the negative case the
relevant udeb will only be excluded if the given variant is
disabled. (This seems like a double negative but I think in the
context of reading the exclude list it is the least confusing was
around). If multiple conditions are given then if any condition is
satisfied the udeb will be excluded.

The intention is to use this support to add support for installing a
Xen guest from an ISO image.

Thanks to Frans Pop for suggesting the approach.
---
 CONF.sh                      |    3 +++
 Makefile                     |    5 ++++-
 easy-build.sh                |    7 +++++--
 tools/boot/squeeze/common.sh |    7 +++++++
 tools/generate_di_list       |   18 +++++++++++++++---
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/CONF.sh b/CONF.sh
index 2cf848a..d92f534 100644
--- a/CONF.sh
+++ b/CONF.sh
@@ -189,6 +189,9 @@ export DISKTYPE=CD
 # included. See tasks/README.tasksel for further info.
 export TASK_LANGLIST=tasksel_d-i.languages
 
+# Extra variants to enable:
+export VARIANTS=
+
 # We don't want certain packages to take up space on CD1...
 #export EXCLUDE1=exclude
 # ...but they are okay for other CDs (UNEXCLUDEx == may be included
diff --git a/Makefile b/Makefile
index 1a9b377..ce8f3ec 100755
--- a/Makefile
+++ b/Makefile
@@ -311,9 +311,12 @@ $(BDIR)/rawlist:
 		ARCHDEFS="$$ARCHDEFS -D ARCH_$(subst -,_,$$ARCH)"; \
 		ARCHUNDEFS="$$ARCHUNDEFS -U $$ARCH"; \
 	done; \
+	for VARIANT in $(VARIANTS); do \
+		VARIANTDEFS="$$VARIANTDEFS -D VARIANT_$$VARIANT)"; \
+	done; \
 	if [ "$(SOURCEONLY)"x != "yes"x ] ; then \
 		cat $(TASKDIR)/$(TASK) | \
-		cpp -nostdinc -nostdinc++ -P -undef $$ARCHDEFS \
+		cpp -nostdinc -nostdinc++ -P -undef $$ARCHDEFS $$VARIANTDEFS\
 	   		$$ARCHUNDEFS -U i386 -U linux -U unix \
 		    -DFORCENONUSONCD1=0 \
 		    -I $(TASKDIR) - - >> $(BDIR)/rawlist; \
diff --git a/easy-build.sh b/easy-build.sh
index d85d810..8076620 100755
--- a/easy-build.sh
+++ b/easy-build.sh
@@ -6,7 +6,7 @@ set -e
 ## See also CONF.sh for the meaning of variables used here.
 
 show_usage() {
-	echo "Usage: $(basename $0) [-d gnome|kde|lxde|xfce|light|all] BC|NETINST|CD|DVD [<ARCH> ...]"
+	echo "Usage: $(basename $0) [-d gnome|kde|lxde|xfce|light|all] [-v VARIANTS] BC|NETINST|CD|DVD [<ARCH> ...]"
 }
 
 
@@ -25,7 +25,8 @@ if [ $# -eq 0 ]; then
 fi
 
 desktop=
-while getopts d:h OPT ; do
+VARIANTS=
+while getopts d:hV: OPT ; do
 	case $OPT in
 	    d)
 		case $OPTARG in
@@ -38,11 +39,13 @@ while getopts d:h OPT ; do
 			exit 1
 			;;
 		esac ;;
+	    V) VARIANTS="$VARIANTS $OPTARG" ;;
 	    h) show_usage; exit 1;;
 	esac
 done
 shift $(expr $OPTIND - 1)
 
+export VARIANTS
 export DISKTYPE="$1"
 shift
 
diff --git a/tools/boot/squeeze/common.sh b/tools/boot/squeeze/common.sh
index 7735837..d3ccc00 100644
--- a/tools/boot/squeeze/common.sh
+++ b/tools/boot/squeeze/common.sh
@@ -48,3 +48,10 @@ add_mkisofs_opt() {
        echo -n "$NEW_OPT " >> $OPTS_FILE
    fi
 }
+
+variant_enabled() {
+    VARIANT=$1
+
+    echo ${VARIANTS} | grep -qw "${VARIANT}"
+    return $?
+}
diff --git a/tools/generate_di_list b/tools/generate_di_list
index f148d62..8ee7349 100755
--- a/tools/generate_di_list
+++ b/tools/generate_di_list
@@ -18,6 +18,8 @@ if ( $ENV{ARCHES} ) {
 }
 @ARCHES = qw{i386 amd64} unless @ARCHES;
 
+@VARIANTS = split(" ", $ENV{VARIANTS});
+
 my $DATE=`date`;
 chomp $DATE;
 open(OUT, ">debian-installer") || die "write: $!";
@@ -78,9 +80,19 @@ sub read_exclude {
 		chomp;
 		s/^#.*//;
 		next unless length;
-		$_=quotemeta($_);
-		$_=~s/\\\*/.*/g;
-		push @ret, $_;
+		my ($pkg,@cond) = split(" ", $_);
+		my $skip = 0;
+		foreach my $cond ( @cond ) {
+		    if ($cond =~ /^!(.*)/) {
+			$skip = 1 if grep { $_ eq $1 } @VARIANTS;
+		    } else {
+			$skip = 1 unless grep { $_ eq $cond } @VARIANTS;
+		    }
+		}
+		next if $skip;
+		$pkg=quotemeta($pkg);
+		$pkg=~s/\\\*/.*/g;
+		push @ret, $pkg;
 	}
 	close IN;
 	return @ret;
-- 
1.6.3.3


Reply to: