From 63734bcde09204843d49dd1530eb37cdf581ac2c Mon Sep 17 00:00:00 2001
From: Travis Cross <tc@traviscross.com>
Date: Wed, 8 Oct 2014 19:43:29 +0000
Subject: [PATCH] Add debian build option to include avoided modules

This is a convenience option that can be passed to either
debian/bootstrap.sh or to debian/util.sh to include a module in the
build that would normally be excluded.  This option, -p, can be passed
multiple times.
---
 debian/bootstrap.sh | 16 +++++++++++++++-
 debian/util.sh      | 16 ++++++++++++++--
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh
index bc7da61c3f..225f37e6c9 100755
--- a/debian/bootstrap.sh
+++ b/debian/bootstrap.sh
@@ -1214,6 +1214,17 @@ set_modules_non_dfsg () {
   done
 }
 
+unavoid_modules () {
+  local len=${#avoid_mods}
+  for ((i=0; i<len; i++)); do
+    for x in $1; do
+      if test "${avoid_mods[$i]}" = "$x"; then
+        unset avoid_mods[$i]
+      fi
+    done
+  done
+}
+
 conf_merge () {
   local of="$1" if="$2"
   if [ -s $if ]; then
@@ -1228,10 +1239,12 @@ conf_merge () {
 
 codename="sid"
 modulelist_opt=""
-while getopts "c:m:" o; do
+modules_add=""
+while getopts "c:m:p:" o; do
   case "$o" in
     c) codename="$OPTARG" ;;
     m) modulelist_opt="$OPTARG" ;;
+    p) modules_add="$modules_add $OPTARG";;
   esac
 done
 shift $(($OPTIND-1))
@@ -1241,6 +1254,7 @@ echo >&2
 echo "Please wait, this takes a few seconds..." >&2
 
 test -z "$modulelist_opt" || set_modules_${modulelist_opt/-/_}
+test -z "$modules_add" || unavoid_modules "$modules_add"
 
 echo "Adding any new modules to control-modules..." >&2
 parse_dir=control-modules.parse
diff --git a/debian/util.sh b/debian/util.sh
index 4129326f6d..a7cb4dc400 100755
--- a/debian/util.sh
+++ b/debian/util.sh
@@ -209,10 +209,12 @@ create_dsc () {
   {
     set -e
     local OPTIND OPTARG modules_conf="" modules_list="" speed="normal" suite_postfix="" suite_postfix_p=false zl=9
-    while getopts 'f:m:s:u:z:' o "$@"; do
+    local modules_add=""
+    while getopts 'f:m:p:s:u:z:' o "$@"; do
       case "$o" in
         f) modules_conf="$OPTARG";;
         m) modules_list="$OPTARG";;
+        p) modules_add="$modules_add $OPTARG";;
         s) speed="$OPTARG";;
         u) suite_postfix="$OPTARG"; suite_postfix_p=true; ;;
         z) zl="$OPTARG";;
@@ -235,6 +237,11 @@ create_dsc () {
         bootstrap_args="-mnon-dfsg"
       else set_modules_${modules_list}; fi
     fi
+    if test -n "$modules_add"; then
+      for x in $modules_add; do
+        bootstrap_args="$bootstrap_args -p${x}"
+      done
+    fi
     (cd debian && ./bootstrap.sh -c $distro $bootstrap_args)
     case "$speed" in
       paranoid) sed -i ./debian/rules \
@@ -354,7 +361,7 @@ build_all () {
   local OPTIND OPTARG
   local orig_opts="" dsc_opts="" deb_opts="" modlist=""
   local archs="" distros="" orig="" depinst=false par=false
-  while getopts 'a:bc:df:ijkl:m:no:s:tu:v:z:' o "$@"; do
+  while getopts 'a:bc:df:ijkl:m:no:p:s:tu:v:z:' o "$@"; do
     case "$o" in
       a) archs="$archs $OPTARG";;
       b) orig_opts="$orig_opts -b";;
@@ -368,6 +375,7 @@ build_all () {
       m) orig_opts="$orig_opts -m$OPTARG"; dsc_opts="$dsc_opts -m$OPTARG";;
       n) orig_opts="$orig_opts -n";;
       o) orig="$OPTARG";;
+      p) dsc_opts="$dsc_opts -p$OPTARG";;
       s) dsc_opts="$dsc_opts -s$OPTARG";;
       t) deb_opts="$deb_opts -t";;
       u) dsc_opts="$dsc_opts -u$OPTARG";;
@@ -455,6 +463,8 @@ commands:
     -n Nightly build
     -o <orig-file>
       Specify existing .orig.tar.xz file
+    -p <module>
+      Include otherwise avoided module
     -s [ paranoid | reckless ]
       Set FS bootstrap/build -j flags
     -t Use system /etc/apt/sources.list in build environment
@@ -481,6 +491,8 @@ commands:
       Build only modules listed in this file
     -m [ quicktest | non-dfsg ]
       Choose custom list of modules to build
+    -p <module>
+      Include otherwise avoided module
     -s [ paranoid | reckless ]
       Set FS bootstrap/build -j flags
     -u <suite-postfix>