From 48daefb685a67ca8734307df738401c3d14edd02 Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Thu, 18 Aug 2016 15:26:30 +1000
Subject: [PATCH 01/35] Use temp file for du calculations

Storing the du output in a variable seemed convenient, but I didn't
realise just how big it could get especially with things like infra
images -- there's something like 100MiB of text being stored in a bash
variable here.

Convert this to work with a temporary file

Change-Id: I6a6d22c2142e0f199490c39cca8c94769e4b0232
---
 bin/disk-image-create | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/bin/disk-image-create b/bin/disk-image-create
index acb504923..ad811a8fd 100755
--- a/bin/disk-image-create
+++ b/bin/disk-image-create
@@ -338,26 +338,28 @@ mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built
 # logs with du output below.
 xtrace=$(set +o | grep xtrace)
 
+# temp file for holding du output
+du_output=${TMP_BUILD_DIR}/du_output.tmp
+
 if [ -n "$DIB_IMAGE_SIZE" ]; then
     du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}')
 else
     set +o xtrace
     echo "Calculating image size (this may take a minute)..."
-    du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
+    sudo du -a -c -x ${TMP_BUILD_DIR}/built > ${du_output}
     # the last line is the total size from "-c".
     # scale this by 0.6 to create a slightly bigger image
-    du_size=$(echo "$du_output" | tail -n1 | cut -f1 | \
-                     awk '{print int($1 / 0.6)}')
+    du_size=$(tail -n1 ${du_output} | cut -f1 | awk '{print int($1 / 0.6)}')
     $xtrace
 fi
 
 if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then
     set +o xtrace
-    if [ -z "$du_output" ]; then
-        du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
+    if [ ! -f "$du_output" ]; then
+        sudo du -a -c -x ${TMP_BUILD_DIR}/built > ${du_output}
     fi
 
-    du_output_show="sort -nr |
+    du_output_show="sort -nr ${du_output} |
                      numfmt --to=iec-i --padding=7
                        --suffix=B --field=1 --from-unit=1024"
 
@@ -376,7 +378,7 @@ if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then
         echo "================="
     fi
 
-    eval ${du_output_show} <<< "$du_output"
+    eval ${du_output_show}
 
     echo
     echo "===== end image size report ====="
@@ -385,6 +387,8 @@ if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then
     $xtrace
 fi
 
+rm -f ${du_output}
+
 if [ "$FS_TYPE" = "ext4" ] ; then
   # Very conservative to handle images being resized a lot
   # We set journal size to 64M so our journal is large enough when we

From 6180d82f1431b8b0c9348de6cd2ee3b14ff4cc9e Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Fri, 19 Aug 2016 16:04:32 +0000
Subject: [PATCH 02/35] Allow ramdisk-create to run without $USER set

It's possible this is run form an environment where $USER isn't set,
properly fallback to whoami in this case.

Change-Id: I1181f714c3c456ee264b34d282bac5c0adb67a0e
---
 elements/ironic-agent/cleanup.d/99-ramdisk-create | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/elements/ironic-agent/cleanup.d/99-ramdisk-create b/elements/ironic-agent/cleanup.d/99-ramdisk-create
index 16229dede..5e04a18ea 100755
--- a/elements/ironic-agent/cleanup.d/99-ramdisk-create
+++ b/elements/ironic-agent/cleanup.d/99-ramdisk-create
@@ -11,6 +11,8 @@ set -o pipefail
 
 [ -n "$TARGET_ROOT" ]
 
+USER=${USER:-$(whoami)}
+
 source $_LIB/img-functions
 
 IMAGE_PATH=$(readlink -f $IMAGE_NAME)

From 07f22a338861485a610db65d0d3a47df421414a7 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Thu, 1 Sep 2016 14:46:03 -0700
Subject: [PATCH 03/35] Document source glean installs in simple-init

It is possible and often desired to install glean from a source
repository when using the simple-init element. Document the process for
doing this.

Change-Id: Ie7c690406b14aae07d73261879b7ce8a2ed9dd8d
---
 elements/simple-init/README.rst | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/elements/simple-init/README.rst b/elements/simple-init/README.rst
index b5ad10221..dd131d9f8 100644
--- a/elements/simple-init/README.rst
+++ b/elements/simple-init/README.rst
@@ -33,3 +33,28 @@ not there.
 
 Finally, glean will handle ssh-keypair-injection from config
 drive if cloud-init is not installed.
+
+Chosing glean installation source
+---------------------------------
+
+By default glean is installed using pip using the latest release on pypi.
+It is also possible to install glean from a specified git repository
+location. This is useful for debugging and testing new glean changes
+for example. To do this you need to set these variables::
+
+  DIB_INSTALLTYPE_simple_init=repo
+  DIB_REPOLOCATION_glean=/path/to/glean/repo
+  DIB_REPOREF_glean=name_of_git_ref
+
+For example to test glean change 364516 do::
+
+  git clone https://git.openstack.org/openstack-infra/glean /tmp/glean
+  cd /tmp/glean
+  git review -d 364516
+  git checkout -b my-test-ref
+
+Then set your DIB env vars like this before running DIB::
+
+  DIB_INSTALLTYPE_simple_init=repo
+  DIB_REPOLOCATION_glean=/tmp/glean
+  DIB_REPOREF_glean=my-test-ref

From 20bb6a02551d1608e8e1b7a5a51cbc8aeac2284a Mon Sep 17 00:00:00 2001
From: Andreas Florath <andreas@florath.net>
Date: Wed, 20 Jul 2016 23:34:50 +0200
Subject: [PATCH 04/35] Add option to be able to run_functests.sh in parallel

Running the functional tests is time consuming.  This patch adds the
option `-j <job count>` to the tests/run_functests.sh: when given the
test run in parallel up the <job count> jobs.
When using this, be sure to have enough resources (CPUs, RAM and HD
space) on the host.

In addition there was the need to change two things:
o Global /tmp/dib-test-should-fail was move to temporary build
  directory of each execution.
o Because the logs might now interleave, each log line has now a
  prefix of the name of the testcase.

[In my environment running functests sequential takes 15+ minutes,
running them parallel takes less than 6 minutes.]

Change-Id: Id9ea5131f0026c292ca6453ba2c80fe12c47f808
Signed-off-by: Andreas Florath <andreas@florath.net>
---
 doc/source/developer/developing_elements.rst |   5 +
 tests/run_functests.sh                       | 129 +++++++++++++++++--
 2 files changed, 126 insertions(+), 8 deletions(-)

diff --git a/doc/source/developer/developing_elements.rst b/doc/source/developer/developing_elements.rst
index 0cee5946e..aa5364406 100644
--- a/doc/source/developer/developing_elements.rst
+++ b/doc/source/developer/developing_elements.rst
@@ -385,6 +385,11 @@ line to run it.  If it should not be run as part of the default CI
 run, you can submit a change with it added to ``DEFAULT_SKIP_TESTS``
 in that file.
 
+Running the functional tests is time consuming.  Multiple parallel
+jobs can be started by specifying ``-j <job count>``.  Each of the
+jobs uses a lot resources (CPU, disk space, RAM) - therefore the job
+count must carefully be chosen.
+
 python
 """"""
 
diff --git a/tests/run_functests.sh b/tests/run_functests.sh
index f43c1e2f7..4c6801eea 100755
--- a/tests/run_functests.sh
+++ b/tests/run_functests.sh
@@ -23,21 +23,65 @@ DEFAULT_SKIP_TESTS=(
     debian-minimal/testing-build-succeeds
 )
 
+function log_with_prefix {
+    local pr=$1
+
+    while read a; do
+        echo $(date +"%Y%m%d-%H%M%S.%N") "[$pr] $a"
+    done
+}
+
+# Log job control messages
+function log_jc {
+    local msg="$1"
+    printf "[JOB-CONTROL] %s %s\n" "$(date)" "${msg}"
+}
+
+function job_cnt {
+    running_jobs=$(jobs -p)
+    echo ${running_jobs} | wc -w
+}
+
+# This is needed, because the better 'wait -n' is
+# available since bash 4.3 only.
+function wait_minus_n {
+    if [ "${BASH_VERSINFO[0]}" -gt 4 \
+                               -o "${BASH_VERSINFO[0]}" = 4 \
+                               -a "${BASH_VERSINFO[1]}" -ge 3 ]; then
+        # Good way: wait on any job
+        wait -n
+        return $?
+    else
+        # Not that good way: wait on one specific job
+        # (others may be finished in the mean time)
+        local wait_for_pid=$(jobs -p | head -1)
+        wait ${wait_for_pid}
+        return $?
+    fi
+}
+
 # run_disk_element_test <test_element> <element>
 #  Run a disk-image-build .tar build of ELEMENT including any elements
 #  specified by TEST_ELEMENT
 function run_disk_element_test() {
     local test_element=$1
     local element=$2
+    local dont_use_tmp=$3
+    local use_tmp_flag=""
     local dest_dir=$(mktemp -d)
 
-    trap "rm -rf $dest_dir /tmp/dib-test-should-fail" EXIT
+    trap "rm -rf $dest_dir" EXIT
+
+    if [ "${dont_use_tmp}" = "yes" ]; then
+        use_tmp_flag="--no-tmpfs"
+    fi
 
     if break="after-error" break_outside_target=1 \
-        break_cmd="cp \$TMP_MOUNT_PATH/tmp/dib-test-should-fail /tmp/ 2>&1 > /dev/null || true" \
+        break_cmd="cp -v \$TMP_MOUNT_PATH/tmp/dib-test-should-fail ${dest_dir} || true" \
         DIB_SHOW_IMAGE_USAGE=1 \
         ELEMENTS_PATH=$DIB_ELEMENTS:$DIB_ELEMENTS/$element/test-elements \
-        $DIB_CMD -x -t tar,qcow2 -o $dest_dir/image -n $element $test_element; then
+        $DIB_CMD -x -t tar,qcow2 ${use_tmp_flag} -o $dest_dir/image -n $element $test_element 2>&1 \
+           | log_with_prefix "${element}/${test_element}"; then
 
         if ! [ -f "$dest_dir/image.qcow2" ]; then
             echo "Error: qcow2 build failed for element: $element, test-element: $test_element."
@@ -58,7 +102,7 @@ function run_disk_element_test() {
             fi
         fi
     else
-        if [ -f "/tmp/dib-test-should-fail" ]; then
+        if [ -f "${dest_dir}/dib-test-should-fail" ]; then
             echo "PASS: Element $element, test-element: $test_element"
         else
             echo "Error: Build failed for element: $element, test-element: $test_element."
@@ -79,7 +123,8 @@ function run_ramdisk_element_test() {
     local dest_dir=$(mktemp -d)
 
     if ELEMENTS_PATH=$DIB_ELEMENTS/$element/test-elements \
-        $DIB_CMD -x -o $dest_dir/image $element $test_element; then
+        $DIB_CMD -x -o $dest_dir/image $element $test_element \
+            | log_with_prefix "${element}/${test_element}"; then
         # TODO(dtantsur): test also kernel presence once we sort out its naming
         # problem (vmlinuz vs kernel)
         if ! [ -f "$dest_dir/image.initramfs" ]; then
@@ -109,12 +154,15 @@ for e in $DIB_ELEMENTS/*/test-elements/*; do
     TESTS+=("$element/$test_element")
 done
 
-while getopts ":hl" opt; do
+JOB_MAX_CNT=1
+
+while getopts ":hlpj:" opt; do
     case $opt in
         h)
             echo "run_functests.sh [-h] [-l] <test> <test> ..."
             echo "  -h : show this help"
             echo "  -l : list available tests"
+            echo "  -p : run all tests in parallel"
             echo "  <test> : functional test to run"
             echo "           Special test 'all' will run all tests"
             exit 0
@@ -128,6 +176,10 @@ while getopts ":hl" opt; do
             echo
             exit 0
             ;;
+        j)
+            JOB_MAX_CNT=${OPTARG}
+            echo "Running parallel - using [${JOB_MAX_CNT}] jobs"
+            ;;
         \?)
             echo "Invalid option: -$OPTARG"
             exit 1
@@ -136,6 +188,15 @@ while getopts ":hl" opt; do
 done
 shift $((OPTIND-1))
 
+DONT_USE_TMP="no"
+if [ "${JOB_MAX_CNT}" -gt 1 ]; then
+    # switch off using tmp dir for image building
+    # (The mem check using the tmp dir is currently done
+    #  based on the available memory - and not on the free.
+    #  See #1618124 for more details)
+    DONT_USE_TMP="yes"
+fi
+
 # cull the list of tests to run into TESTS_TO_RUN
 TESTS_TO_RUN=()
 title=""
@@ -171,7 +232,36 @@ for test in "${TESTS_TO_RUN[@]}"; do
 done
 echo "------"
 
+function wait_and_exit_on_failure {
+    local pid=$1
+
+    wait ${pid}
+    result=$?
+
+    if [ "${result}" -ne 0 ]; then
+        exit ${result}
+    fi
+    return 0
+}
+
+EXIT_CODE=0
 for test in "${TESTS_TO_RUN[@]}"; do
+    running_jobs_cnt=$(job_cnt)
+    log_jc "Number of running jobs [${running_jobs_cnt}] max jobs [${JOB_MAX_CNT}]"
+    if [ "${running_jobs_cnt}" -ge "${JOB_MAX_CNT}" ]; then
+        log_jc "Waiting for job to finish"
+        wait_minus_n
+        result=$?
+
+        if [ "${result}" -ne 0 ]; then
+            EXIT_CODE=1
+            # If a job fails, do not start any new ones.
+            break
+        fi
+    fi
+
+    log_jc "Starting new job"
+
     # from above; each array value is element/test_element.  split it
     # back up
     element=${test%/*}
@@ -186,7 +276,30 @@ for test in "${TESTS_TO_RUN[@]}"; do
     fi
 
     echo "Running $test ($element_type)"
-    run_${element_type}_element_test $test_element $element
+    run_${element_type}_element_test $test_element $element ${DONT_USE_TMP} &
 done
 
-echo "Tests passed!"
+# Wait for the rest of the jobs
+while true; do
+    running_jobs_cnt=$(job_cnt)
+    log_jc "Number of running jobs left [${running_jobs_cnt}]"
+
+    if [ "${running_jobs_cnt}" -eq 0 ]; then
+        break;
+    fi
+
+    wait_minus_n
+    result=$?
+
+    if [ "${result}" -ne 0 ]; then
+        EXIT_CODE=1
+    fi
+done
+
+if [ "${EXIT_CODE}" -eq 0 ]; then
+    echo "Tests passed!"
+    exit 0
+else
+    echo "At least one test failed"
+    exit 1
+fi

From bc80572061eb4c638e4c64d7d96fac39e6d79eab Mon Sep 17 00:00:00 2001
From: Waldemar Znoinski <waldemar.znoinski@intel.com>
Date: Thu, 8 Sep 2016 17:11:32 +0000
Subject: [PATCH 05/35] don't configure 'lo' for dhcp

On systemd-based operating systems that don't
use /etc/sysconfig/network-scripts
dhcp-all-interfaces configures 'lo' for dhcp.
This causes errors and fails networking.target
causing system-wide issues. This change excludes
'lo' at dhcp-all-interfaces udev rules level.

Closes-bug: #1621501
Change-Id: I7563b766827bedbea7ae1de35e5bdfcbf1fc0d1e
Co-Authored-By: Jeremy Stanley <fungi@yuggoth.org>
---
 .../install.d/dhcp-all-interfaces-udev.rules                    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces-udev.rules b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces-udev.rules
index 302f41bae..a8c3cf513 100644
--- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces-udev.rules
+++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces-udev.rules
@@ -1 +1 @@
-SUBSYSTEM=="net", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="dhcp-interface@$name.service"
+SUBSYSTEM=="net", KERNEL!="lo", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="dhcp-interface@$name.service"

From 0ddea940adf0f80d8ff54c1c4289d3a0aa46d032 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Fri, 16 Sep 2016 11:04:56 +0100
Subject: [PATCH 06/35] elements: opensuse: Add support for openSUSE Leap

Add support for new openSUSE Leap releases. Moreover, document
common environment variables and remove old note.

Change-Id: I8cf0b215cb4d9231e5658d49e3fd598dfbb5fd37
---
 elements/opensuse/README.rst                  | 18 +++++++++++++-----
 .../10-opensuse-distro-name.bash              |  8 ++++++++
 .../opensuse/pre-install.d/00-opensuse-setup  |  2 +-
 .../opensuse/root.d/10-opensuse-cloud-image   | 19 ++++++++++++++++---
 4 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/elements/opensuse/README.rst b/elements/opensuse/README.rst
index 48adc40eb..5ca0da5e4 100644
--- a/elements/opensuse/README.rst
+++ b/elements/opensuse/README.rst
@@ -13,6 +13,19 @@ For example, the images of openSUSE 13.2 can be found here:
 These images should be considered experimental. There are curently only x86_64
 images.
 
+Environment Variables
+---------------------
+
+DIB_RELEASE
+  :Required: No
+  :Default: 13.1
+  :Description: Set the desired openSUSE release.
+
+DIB_CLOUD_IMAGES
+  :Required: No
+  :Default: http://download.opensuse.org/repositories/Cloud:/Images:/(openSUSE|Leap)_${DIB_RELEASE}
+  :Description: Set the desired URL to fetch the images from.
+
 Notes:
 
 * There are very frequently new automated builds that include changes that
@@ -21,8 +34,3 @@ Notes:
   point to the latest image, but will frequently change its content. The versioned
   one will never change content, but will frequently be deleted and replaced
   by a newer build with a higher version-release number.
-
-* Building with DIB\_EXTLINUX=1 doesn't work.  It fails with:
-  /tmp/in\_target.d/finalise.d/51-bootloader: line 14: 16286 Segmentation fault
-  extlinux --install /boot/syslinux
-  (https://bugzilla.novell.com/show_bug.cgi?id=852856)
diff --git a/elements/opensuse/environment.d/10-opensuse-distro-name.bash b/elements/opensuse/environment.d/10-opensuse-distro-name.bash
index 22db6c1c0..38efb86fc 100644
--- a/elements/opensuse/environment.d/10-opensuse-distro-name.bash
+++ b/elements/opensuse/environment.d/10-opensuse-distro-name.bash
@@ -1 +1,9 @@
 export DISTRO_NAME=opensuse
+export DIB_RELEASE=${DIB_RELEASE:-13.1}
+case ${DIB_RELEASE} in
+    # Old openSUSE releases
+    13*) export OPENSUSE_REPO_DIR=openSUSE_${DIB_RELEASE} ;;
+    # New Leap releases
+    42*) export OPENSUSE_REPO_DIR=openSUSE_Leap_${DIB_RELEASE} ;;
+    *) echo "Unsupported openSUSE release: ${DIB_RELEASE}"; exit 1 ;;
+esac
diff --git a/elements/opensuse/pre-install.d/00-opensuse-setup b/elements/opensuse/pre-install.d/00-opensuse-setup
index ecc7efc29..b681dfeed 100755
--- a/elements/opensuse/pre-install.d/00-opensuse-setup
+++ b/elements/opensuse/pre-install.d/00-opensuse-setup
@@ -7,4 +7,4 @@ fi
 set -eu
 set -o pipefail
 
-zypper ar -f http://download.opensuse.org/repositories/X11:/Bumblebee/openSUSE_13.1/X11:Bumblebee.repo
+zypper ar -f http://download.opensuse.org/repositories/X11:/Bumblebee/${OPENSUSE_REPO_DIR}/X11:Bumblebee.repo
diff --git a/elements/opensuse/root.d/10-opensuse-cloud-image b/elements/opensuse/root.d/10-opensuse-cloud-image
index a6734b922..dc56e5366 100755
--- a/elements/opensuse/root.d/10-opensuse-cloud-image
+++ b/elements/opensuse/root.d/10-opensuse-cloud-image
@@ -18,11 +18,24 @@ if ! [ 'x86_64' = "$ARCH" ] ; then
     exit 1
 fi
 
-DIB_RELEASE=${DIB_RELEASE:-13.1}
+# Set some image defaults
+case ${DIB_RELEASE} in
+    # Old openSUSE releases
+    13*)
+        OPENSUSE_IMAGE_BASEDIR=openSUSE
+        OPENSUSE_IMAGE_FILE=openSUSE-${DIB_RELEASE}-OS
+        ;;
+    # New Leap releases
+    42*)
+        OPENSUSE_IMAGE_BASEDIR=Leap
+        OPENSUSE_IMAGE_FILE=openSUSE-Leap-${DIB_RELEASE}-OpenStack
+        ;;
+    # We handle unknown cases in environment.d/10-opensuse-distro-name.bash
+esac
 # NOTE(toabctl): if something changes here on the buildservice side, please
 # first ask in #opensuse-cloud on freenode before you change the format here!
-DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://download.opensuse.org/repositories/Cloud:/Images:/openSUSE_${DIB_RELEASE}/images/}
-BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-openSUSE-${DIB_RELEASE}-OS-rootfs.${ARCH}.tbz}
+DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://download.opensuse.org/repositories/Cloud:/Images:/${OPENSUSE_IMAGE_BASEDIR}_${DIB_RELEASE}/images/}
+BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-${OPENSUSE_IMAGE_FILE}-rootfs.${ARCH}.tbz}
 SHA256SUMS_FILE=${SHA256SUMS_FILE:-${BASE_IMAGE_FILE}.sha256}
 
 CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE

From 2747613ca2fc51118526f4ad6e28ed7b49e50632 Mon Sep 17 00:00:00 2001
From: Ben Nemec <bnemec@redhat.com>
Date: Thu, 22 Sep 2016 14:25:31 -0500
Subject: [PATCH 07/35] Shorten DHCP timeout in dhcp-all-interfaces

We are currently wasting about 10 minutes per deploy waiting for
DHCP on interfaces that will never get it.  By default, the timeout
seems to be 5 minutes (the 10 minutes is because we boot both the
IPA ramdisk and the deployed image, and each waits for 5 minutes),
which is excessively long to get a DHCP response.  This change
shortens the time to 30 seconds.  If an interface hasn't gotten a
response in 30 seconds, chances are it's not going to.  A 30
second wait should reduce our wasted time to 1 minute, which is
more reasonable.

This is being done in the systemd unit file because the -timeout
option to dhclient doesn't seem to override what is configured in
dhclient.conf, and doing it in the systemd file means that this
change will be limited to only the interfaces configured by
dhcp-all-interfaces.

Change-Id: Ia8610e3def39c937eb0c861fdc9bc571ec39f9f4
Closes-Bug: 1626673
---
 elements/dhcp-all-interfaces/install.d/dhcp-interface@.service | 1 +
 1 file changed, 1 insertion(+)

diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-interface@.service b/elements/dhcp-all-interfaces/install.d/dhcp-interface@.service
index 14c473057..112765029 100644
--- a/elements/dhcp-all-interfaces/install.d/dhcp-interface@.service
+++ b/elements/dhcp-all-interfaces/install.d/dhcp-interface@.service
@@ -11,6 +11,7 @@ User=root
 ExecStartPre=/usr/local/sbin/dhcp-all-interfaces.sh %I
 ExecStart=/sbin/ifup %I
 RemainAfterExit=true
+TimeoutStartSec=30s
 
 [Install]
 WantedBy=multi-user.target

From 93425d14ce251139e0518a3a9533506dd1615f97 Mon Sep 17 00:00:00 2001
From: Jiri Stransky <jistr@redhat.com>
Date: Fri, 23 Sep 2016 14:09:02 +0200
Subject: [PATCH 08/35] Fix grub installation for RHEL

Grub is first removed and then installed during RHEL image building. The
grub2 package typically requires the same version of grub2-tools, so if
we just remove and install the grub2 package, the installation can
potentially fail on being out of sync with grub2-tools version. Removing
and reinstalling both packages fixes this issue. Those packages are
already in package map for RHEL as "grub-pc", so we can use this alias.

Change-Id: Iefd9c17fffd43de3fea260510ad218b1322eecb3
Closes-Bug: #1627000
---
 elements/redhat-common/pre-install.d/15-remove-grub | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elements/redhat-common/pre-install.d/15-remove-grub b/elements/redhat-common/pre-install.d/15-remove-grub
index f116a8524..ba1d922a1 100755
--- a/elements/redhat-common/pre-install.d/15-remove-grub
+++ b/elements/redhat-common/pre-install.d/15-remove-grub
@@ -23,7 +23,7 @@ fi
 # XXX : it is not clear this is necessary for fedora/centos7 and it's
 # install hooks.  Investigation is required.
 if rpm -q grub2; then
-    install-packages -e grub2
+    install-packages -e grub-pc
 fi
 
 # now configure things to re-install grub at the end.  We don't want
@@ -43,5 +43,5 @@ fi
 # So we download the latest grub2 package and setup the install script
 # to just install the single-package, which will be called later by
 # vm/finalise.d/51-bootloader
-install-packages -d /tmp/grub grub2
+install-packages -d /tmp/grub grub-pc
 echo "rpm -i /tmp/grub/*.rpm" > /tmp/grub/install

From 45467e4229b6222c63a1d274331c6fe81bca8442 Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Wed, 21 Sep 2016 16:02:16 -0400
Subject: [PATCH 09/35] Create runtime-ssh-host-keys element

Move managing of SSH host keys into a dedicated element.

Because glean doesn't generate SSH host keys anymore, we need to do it
with a systemd script. This is already handled by CentOS / Fedora so
we don't want to add it there.

This was done to address the upstream bug in debian:

  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500192

Change-Id: I31ad667672e08350872db21a83445fe0aa7a4a39
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
---
 elements/runtime-ssh-host-keys/README.rst     | 10 ++++++
 .../cleanup.d/90-remove-ssh-host-keys         |  3 --
 elements/runtime-ssh-host-keys/element-deps   |  1 +
 .../init-scripts/systemd/ssh-keygen.service   | 22 +++++++++++++
 .../init-scripts/upstart/ssh-keygen.conf      |  8 +++++
 .../package-installs.yaml                     |  1 +
 elements/runtime-ssh-host-keys/pkg-map        |  7 +++++
 .../post-install.d/80-ssh-keygen              | 31 +++++++++++++++++++
 elements/simple-init/element-deps             |  2 +-
 ...untime-ssh-host-keys-7a2fc873cc90d33e.yaml |  6 ++++
 10 files changed, 87 insertions(+), 4 deletions(-)
 create mode 100644 elements/runtime-ssh-host-keys/README.rst
 rename elements/{simple-init => runtime-ssh-host-keys}/cleanup.d/90-remove-ssh-host-keys (78%)
 create mode 100644 elements/runtime-ssh-host-keys/element-deps
 create mode 100644 elements/runtime-ssh-host-keys/init-scripts/systemd/ssh-keygen.service
 create mode 100644 elements/runtime-ssh-host-keys/init-scripts/upstart/ssh-keygen.conf
 create mode 100644 elements/runtime-ssh-host-keys/package-installs.yaml
 create mode 100644 elements/runtime-ssh-host-keys/pkg-map
 create mode 100755 elements/runtime-ssh-host-keys/post-install.d/80-ssh-keygen
 create mode 100644 releasenotes/notes/runtime-ssh-host-keys-7a2fc873cc90d33e.yaml

diff --git a/elements/runtime-ssh-host-keys/README.rst b/elements/runtime-ssh-host-keys/README.rst
new file mode 100644
index 000000000..b00a2402e
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/README.rst
@@ -0,0 +1,10 @@
+=====================
+runtime-ssh-host-keys
+=====================
+An element to generate SSH host keys on first boot.
+
+Since ssh key generation is not yet common to all operating systems, we need to
+create a DIB element to manage this. We force the removal of the SSH host keys,
+then add init scripts to generate them on first boot.
+
+This element currently supports Debian and Ubuntu (both systemd and upstart).
diff --git a/elements/simple-init/cleanup.d/90-remove-ssh-host-keys b/elements/runtime-ssh-host-keys/cleanup.d/90-remove-ssh-host-keys
similarity index 78%
rename from elements/simple-init/cleanup.d/90-remove-ssh-host-keys
rename to elements/runtime-ssh-host-keys/cleanup.d/90-remove-ssh-host-keys
index c90626a8a..b14e03f1c 100755
--- a/elements/simple-init/cleanup.d/90-remove-ssh-host-keys
+++ b/elements/runtime-ssh-host-keys/cleanup.d/90-remove-ssh-host-keys
@@ -10,9 +10,6 @@ set -o pipefail
 # in so that they are regenerated on first boot and
 # are unique.
 
-# TODO(greghaynes) This should be a thing we do for all images, not just
-# simple-init.
-
 if [ -d $TARGET_ROOT/etc/ssh ] ; then
     sudo find $TARGET_ROOT/etc/ssh -name 'ssh_host*' -type f -delete
 fi
diff --git a/elements/runtime-ssh-host-keys/element-deps b/elements/runtime-ssh-host-keys/element-deps
new file mode 100644
index 000000000..3a0277624
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/element-deps
@@ -0,0 +1 @@
+dib-init-system
diff --git a/elements/runtime-ssh-host-keys/init-scripts/systemd/ssh-keygen.service b/elements/runtime-ssh-host-keys/init-scripts/systemd/ssh-keygen.service
new file mode 100644
index 000000000..90a831362
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/init-scripts/systemd/ssh-keygen.service
@@ -0,0 +1,22 @@
+[Unit]
+Description=OpenSSH Server Key Generation
+Before=ssh.service
+
+ConditionPathExists=|!/etc/ssh/ssh_host_key
+ConditionPathExists=|!/etc/ssh/ssh_host_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_rsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_rsa_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_dsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_dsa_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_ecdsa_key
+ConditionPathExists=|!/etc/ssh/ssh_host_ecdsa_key.pub
+ConditionPathExists=|!/etc/ssh/ssh_host_ed25519_key
+ConditionPathExists=|!/etc/ssh/ssh_host_ed25519_key.pub
+
+[Service]
+ExecStart=/usr/bin/ssh-keygen -A
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/elements/runtime-ssh-host-keys/init-scripts/upstart/ssh-keygen.conf b/elements/runtime-ssh-host-keys/init-scripts/upstart/ssh-keygen.conf
new file mode 100644
index 000000000..3fa2c0126
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/init-scripts/upstart/ssh-keygen.conf
@@ -0,0 +1,8 @@
+description "OpenSSH Server Key Generation"
+
+start on starting ssh
+console output
+
+task
+
+exec /usr/bin/ssh-keygen -A
diff --git a/elements/runtime-ssh-host-keys/package-installs.yaml b/elements/runtime-ssh-host-keys/package-installs.yaml
new file mode 100644
index 000000000..c5017af3f
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/package-installs.yaml
@@ -0,0 +1 @@
+openssh-client:
diff --git a/elements/runtime-ssh-host-keys/pkg-map b/elements/runtime-ssh-host-keys/pkg-map
new file mode 100644
index 000000000..413d584e7
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/pkg-map
@@ -0,0 +1,7 @@
+{
+  "family": {
+    "redhat": {
+      "openssh-client": "openssh"
+    }
+  }
+}
diff --git a/elements/runtime-ssh-host-keys/post-install.d/80-ssh-keygen b/elements/runtime-ssh-host-keys/post-install.d/80-ssh-keygen
new file mode 100755
index 000000000..926a12d69
--- /dev/null
+++ b/elements/runtime-ssh-host-keys/post-install.d/80-ssh-keygen
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
+    set -x
+fi
+set -eu
+set -o pipefail
+
+case "$DIB_INIT_SYSTEM" in
+    upstart)
+        # nothing to do
+        exit 0
+        ;;
+    systemd)
+        if [[ $DISTRO_NAME = "ubuntu" || $DISTRO_NAME = "debian" ]]; then
+            # NOTE(pabelanger): Only support ubuntu / debian today.
+            systemctl enable ssh-keygen.service
+        else
+            # Since we are not enabling it, delete it.
+            rm /usr/lib/systemd/system/ssh-keygen.service
+        fi
+        ;;
+    openrc)
+        # let dib-init-system's postinstall handle enabling init scripts
+        exit 0
+        ;;
+    *)
+        echo "Unsupported init system"
+        exit 1
+        ;;
+esac
diff --git a/elements/simple-init/element-deps b/elements/simple-init/element-deps
index d92bc778c..5c7f9bb38 100644
--- a/elements/simple-init/element-deps
+++ b/elements/simple-init/element-deps
@@ -1,5 +1,5 @@
 cloud-init-datasources
-dib-init-system
 install-types
 pip-and-virtualenv
+runtime-ssh-host-keys
 source-repositories
diff --git a/releasenotes/notes/runtime-ssh-host-keys-7a2fc873cc90d33e.yaml b/releasenotes/notes/runtime-ssh-host-keys-7a2fc873cc90d33e.yaml
new file mode 100644
index 000000000..3475ae7d0
--- /dev/null
+++ b/releasenotes/notes/runtime-ssh-host-keys-7a2fc873cc90d33e.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - New element (runtime-ssh-host-keys) to manage SSH host keys at boot. Since
+    SSH host key generation is not standard across operating systems, add
+    support for both Debian and Ubuntu to handle it. While this is a new
+    element, simple-init has been updated to depend on it.

From f6e11c91c30b7983142b676c700398b17eb760d5 Mon Sep 17 00:00:00 2001
From: Yolanda Robla Mota <yroblamo@redhat.com>
Date: Tue, 27 Sep 2016 09:41:32 +0200
Subject: [PATCH 10/35] Fix typo in extracting root partition

Change-Id: Ie8dfd958d57ef92988647166f2031adb8406b0d7
---
 elements/redhat-common/bin/extract-image | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elements/redhat-common/bin/extract-image b/elements/redhat-common/bin/extract-image
index 1dec0368c..ee01f689f 100755
--- a/elements/redhat-common/bin/extract-image
+++ b/elements/redhat-common/bin/extract-image
@@ -59,7 +59,7 @@ function extract_image() {
 
             qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $RAW_FILE
 
-            ROOT_PARTITON=p$(sudo kpartx -l $RAW_FILE | awk "/loop[0-9]+p/"|wc -l)
+            ROOT_PARTITION=p$(sudo kpartx -l $RAW_FILE | awk "/loop[0-9]+p/"|wc -l)
             sudo udevadm settle
 
             # kpartx fails if no /dev/loop* exists, "losetup -f" prints first unused
@@ -69,7 +69,7 @@ function extract_image() {
             # XXX: Parsing stdout is dangerous, would like a better way to discover
             #      the device used for the image.
             ROOT_LOOPDEV=$(sudo kpartx -av $RAW_FILE | \
-                awk "/loop[0-9]+$ROOT_PARTITON/ {print \$3}")
+                awk "/loop[0-9]+$ROOT_PARTITION/ {print \$3}")
             # If running inside Docker, make our nodes manually, because udev will not be working.
             if [ -f /.dockerenv ]; then
                 sudo dmsetup --noudevsync mknodes

From c6b4e639b02fc6d1a4b0cc54152361b6e3034f75 Mon Sep 17 00:00:00 2001
From: Yolanda Robla Mota <yroblamo@redhat.com>
Date: Tue, 27 Sep 2016 10:09:35 +0200
Subject: [PATCH 11/35] Disabling all previous repos registered in the system

Depending on the pool id used, so many repos are brought,
including not valid ones that cause image to crash, or repos
that include conflicting packages.
Before enabling repos, disable all previous ones, so we
can be sure that we only bring the repos specified in the
parameters.

Change-Id: Ifd4d8d1d4fa954cd2593669e516e3201f2d6f6c1
---
 elements/rhel-common/pre-install.d/00-rhel-registration | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/elements/rhel-common/pre-install.d/00-rhel-registration b/elements/rhel-common/pre-install.d/00-rhel-registration
index dcb69d8f8..60c449d85 100755
--- a/elements/rhel-common/pre-install.d/00-rhel-registration
+++ b/elements/rhel-common/pre-install.d/00-rhel-registration
@@ -97,6 +97,8 @@ case "${REG_METHOD:-}" in
             echo "Attaching with options: $attach_opts"
             subscription-manager attach $attach_opts
         fi
+        echo "Disabling all previous repos"
+        subscription-manager repos --disable=\*
         echo "Enabling repos: $repos"
         subscription-manager $repos
         ;;
@@ -108,6 +110,8 @@ case "${REG_METHOD:-}" in
         rpm -Uvh "$REG_SAT_URL/pub/katello-ca-consumer-latest.noarch.rpm" || true
         echo "Registering with options: $sanitized_opts"
         subscription-manager register $opts
+        echo "Disabling all previous repos"
+        subscription-manager repos --disable=\*
         echo "Enabling repos: $user_repos"
         subscription-manager $repos
         echo "Disabling satellite repo because it is no longer needed"

From b9e9e2091e42d03e377b2cc7e8e03e67a7ba60b6 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Thu, 29 Sep 2016 22:43:20 +0100
Subject: [PATCH 12/35] Move opensuse utils to zypper so they can be shared by
 SUSE-based distros

Move the opensuse utilities to the zypper element so they can be used by
SUSE or zypper based elements. This brings the zypper element somewhat
in line with the rest of the package manager elements.

Change-Id: I8aa2849231454216cdd47629a5e2d6e45769dbbe
---
 elements/opensuse/element-deps                     | 1 -
 elements/{opensuse => zypper}/bin/install-packages | 0
 elements/{opensuse => zypper}/bin/map-packages     | 0
 elements/{opensuse => zypper}/bin/map-services     | 0
 elements/zypper/element-deps                       | 1 +
 5 files changed, 1 insertion(+), 1 deletion(-)
 rename elements/{opensuse => zypper}/bin/install-packages (100%)
 rename elements/{opensuse => zypper}/bin/map-packages (100%)
 rename elements/{opensuse => zypper}/bin/map-services (100%)
 create mode 100644 elements/zypper/element-deps

diff --git a/elements/opensuse/element-deps b/elements/opensuse/element-deps
index c0fd568db..14ee0a470 100644
--- a/elements/opensuse/element-deps
+++ b/elements/opensuse/element-deps
@@ -1,5 +1,4 @@
 cache-url
 dib-run-parts
-install-bin
 package-installs
 zypper
diff --git a/elements/opensuse/bin/install-packages b/elements/zypper/bin/install-packages
similarity index 100%
rename from elements/opensuse/bin/install-packages
rename to elements/zypper/bin/install-packages
diff --git a/elements/opensuse/bin/map-packages b/elements/zypper/bin/map-packages
similarity index 100%
rename from elements/opensuse/bin/map-packages
rename to elements/zypper/bin/map-packages
diff --git a/elements/opensuse/bin/map-services b/elements/zypper/bin/map-services
similarity index 100%
rename from elements/opensuse/bin/map-services
rename to elements/zypper/bin/map-services
diff --git a/elements/zypper/element-deps b/elements/zypper/element-deps
new file mode 100644
index 000000000..d888ae5c2
--- /dev/null
+++ b/elements/zypper/element-deps
@@ -0,0 +1 @@
+install-bin

From 1f10f4fa3530eaebd9e8f0578da87796825e070d Mon Sep 17 00:00:00 2001
From: OpenStack Proposal Bot <openstack-infra@lists.openstack.org>
Date: Fri, 30 Sep 2016 19:58:01 +0000
Subject: [PATCH 13/35] Updated from global requirements

Change-Id: I0f152cb4160915bbcad273bca7d28f947b82eae4
---
 requirements.txt      | 4 ++--
 test-requirements.txt | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index 47f5abbbe..16b55619b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,7 +4,7 @@
 Babel>=2.3.4 # BSD
 dib-utils # Apache-2.0
 pbr>=1.6 # Apache-2.0
-PyYAML>=3.1.0 # MIT
+PyYAML>=3.10.0 # MIT
 flake8<2.6.0,>=2.5.4 # MIT
 six>=1.9.0 # MIT
-oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
+oslosphinx>=4.7.0 # Apache-2.0
diff --git a/test-requirements.txt b/test-requirements.txt
index 04ab6d6b9..8671a4497 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -7,8 +7,8 @@ oslotest>=1.10.0 # Apache-2.0
 testrepository>=0.0.18 # Apache-2.0/BSD
 
 # Doc requirements
-sphinx!=1.3b1,<1.3,>=1.2.1 # BSD
-oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
+sphinx!=1.3b1,<1.4,>=1.2.1 # BSD
+oslosphinx>=4.7.0 # Apache-2.0
 
 # releasenotes
 reno>=1.8.0 # Apache2

From 7dc9465ed107368c300db99ae474b0ee5c84bcb9 Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Tue, 27 Sep 2016 17:25:37 -0400
Subject: [PATCH 14/35] Default to http://ftp.us.debian.org/debian for
 debian-minimal

Since http://httpredir.debian.org is unreliable is selecting a mirror
to use, we'll now default to http://ftp.us.debian.org/debian.  In
fact, in openstack-infra we have been overriding httpredir.debian.org
for a while, now make this default in diskimage-builder.

Change-Id: I48658bc076e13a0913821197e4120c73618fef8f
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
---
 elements/debian-minimal/README.rst                   | 12 ++++++------
 .../environment.d/10-debian-minimal.bash             |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/elements/debian-minimal/README.rst b/elements/debian-minimal/README.rst
index 04f1fbdeb..66f017218 100644
--- a/elements/debian-minimal/README.rst
+++ b/elements/debian-minimal/README.rst
@@ -11,16 +11,16 @@ There are two ways to configure apt-sources:
    and security repositories is the default. In this case you can
    overwrite the two environment variables to adapt the behavior:
    `DIB_DISTRIBUTION_MIRROR`: the mirror to use
-      default: http://httpredir.debian.org/debian
+      default: http://ftp.us.debian.org/debian
    `DIB_DEBIAN_COMPONENTS`: (default) `main`
       a comma separated list of components. For Debian this can be
       e.g. `main,contrib,non-free`.
 
-   Note that the default Debian series is `unstable`, and the default
-   mirrors for Debian can be problematic for `unstable`. Because apt
-   does not handle changing Packages files well across multiple out of
-   sync mirrors, it is recommended that you choose a single mirror of
-   Debian, and pass it in via `DIB_DISTRIBUTION_MIRROR`.
+   Note it is not recommended to use http://httpredir.debian.org/ for
+   `DIB_DISTRIBUTION_MIRROR` due to how unreliable it is.  Be sure to
+   select a mirror from the official mirror list:
+
+       https://www.debian.org/mirror/list
 
    By default only `main` component is used. If
    `DIB_DEBIAN_COMPONENTS` (comma separated) from the `debootstrap`
diff --git a/elements/debian-minimal/environment.d/10-debian-minimal.bash b/elements/debian-minimal/environment.d/10-debian-minimal.bash
index 3f2200226..13ac22fc0 100644
--- a/elements/debian-minimal/environment.d/10-debian-minimal.bash
+++ b/elements/debian-minimal/environment.d/10-debian-minimal.bash
@@ -1,6 +1,6 @@
 export DISTRO_NAME=debian
 export DIB_RELEASE=${DIB_RELEASE:-stable}
-export DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://httpredir.debian.org/debian}
+export DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://ftp.us.debian.org/debian}
 export DIB_DEBIAN_COMPONENTS=${DIB_DEBIAN_COMPONENTS:-main}
 export DIB_DEBIAN_COMPONENTS_WS=${DIB_DEBIAN_COMPONENTS//,/ }
 

From 30b3fc8dcc810725819f92c91ba68061f81229dc Mon Sep 17 00:00:00 2001
From: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
Date: Tue, 4 Oct 2016 22:22:26 +0900
Subject: [PATCH 15/35] Fix a command in Developer Documentation

Fix a command for creating a new virtualenv.

Change-Id: Ia4981af390bf5218f22ea753db86a5edfbb602f2
---
 doc/source/developer/index.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/source/developer/index.rst b/doc/source/developer/index.rst
index 470041bfd..738c82c51 100644
--- a/doc/source/developer/index.rst
+++ b/doc/source/developer/index.rst
@@ -13,7 +13,7 @@ To get started developing with ``diskimage-builder``, install to a
 
  $ mkdir dib
  $ cd dib
- $ virtualenv create env
+ $ virtualenv env
  $ source env/bin/activate
  $ git clone https://git.openstack.org/openstack/diskimage-builder
  $ cd diskimage-builder

From 8dde310cf3a1b24696822fe2fd2850aee07ea3d6 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Fri, 30 Sep 2016 12:06:09 +0100
Subject: [PATCH 16/35] Move the opensuse mkinitrd script to the zypper element

All SUSE-based elements can benefit from the mkinitrd phase to move it
to a more generic location.

Change-Id: Ife171d462a393b6ac0bf2c5eaa48ea25eaf4d1cc
---
 elements/{opensuse => zypper}/post-install.d/10-mkinitrd | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename elements/{opensuse => zypper}/post-install.d/10-mkinitrd (100%)

diff --git a/elements/opensuse/post-install.d/10-mkinitrd b/elements/zypper/post-install.d/10-mkinitrd
similarity index 100%
rename from elements/opensuse/post-install.d/10-mkinitrd
rename to elements/zypper/post-install.d/10-mkinitrd

From c69c6c5a84da59bf3f7d6b8e79063d70d0ff4fe6 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Fri, 30 Sep 2016 11:13:09 +0100
Subject: [PATCH 17/35] Add zypper-minimal element

Add a new zypper-minimal element to bootstrap SUSE-based distributions

Change-Id: Id63397e412a929d61247cfd3d9f8d4e758c1248a
---
 elements/zypper-minimal/README.rst            | 19 ++++
 elements/zypper-minimal/element-deps          |  3 +
 .../zypper-minimal/install.d/15-zypper-fstab  | 27 ++++++
 elements/zypper-minimal/package-installs.yaml | 10 +++
 .../zypper-minimal/root.d/08-zypper-chroot    | 87 +++++++++++++++++++
 5 files changed, 146 insertions(+)
 create mode 100644 elements/zypper-minimal/README.rst
 create mode 100644 elements/zypper-minimal/element-deps
 create mode 100755 elements/zypper-minimal/install.d/15-zypper-fstab
 create mode 100644 elements/zypper-minimal/package-installs.yaml
 create mode 100755 elements/zypper-minimal/root.d/08-zypper-chroot

diff --git a/elements/zypper-minimal/README.rst b/elements/zypper-minimal/README.rst
new file mode 100644
index 000000000..d9c8fd323
--- /dev/null
+++ b/elements/zypper-minimal/README.rst
@@ -0,0 +1,19 @@
+==============
+zypper-minimal
+==============
+Base element for creating minimal SUSE-based images
+
+This element is incomplete by itself so you probaby want to use it along
+with the opensuse-minimal one. It requires 'zypper' to be installed on the
+host.
+
+Repositories
+------------
+
+This element expects the `ZYPPER_REPOS` variable to be exported by the
+operating system element. This variable contains repository mappings in 
+the following format: `${repo_name}==>${repo_url}`. For example::
+
+ ZYPPER_REPOS="update=>http://download.opensuse.org/update/leap/42.1/oss/ "
+ ZYPPER_REPOS+="oss=>http://download.opensuse.org/distribution/leap/42.1/repo/oss/"
+ export ZYPPER_REPOS
diff --git a/elements/zypper-minimal/element-deps b/elements/zypper-minimal/element-deps
new file mode 100644
index 000000000..846428bd8
--- /dev/null
+++ b/elements/zypper-minimal/element-deps
@@ -0,0 +1,3 @@
+dib-run-parts
+package-installs
+zypper
diff --git a/elements/zypper-minimal/install.d/15-zypper-fstab b/elements/zypper-minimal/install.d/15-zypper-fstab
new file mode 100755
index 000000000..cffbe1df5
--- /dev/null
+++ b/elements/zypper-minimal/install.d/15-zypper-fstab
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
+    set -x
+fi
+set -eu
+set -o pipefail
+
+cat << EOF > /etc/fstab
+proc /proc proc nodev,noexec,nosuid 0 0
+LABEL=${DIB_ROOT_LABEL} / ${FS_TYPE} errors=remount-ro 0 1
+EOF
diff --git a/elements/zypper-minimal/package-installs.yaml b/elements/zypper-minimal/package-installs.yaml
new file mode 100644
index 000000000..d2ccc1605
--- /dev/null
+++ b/elements/zypper-minimal/package-installs.yaml
@@ -0,0 +1,10 @@
+# kernel
+linux-image-generic:
+# And a few useful tools. Some are pulled
+# as dependencies but that may change so lets
+# be explicit.
+bash:
+lsb-release:
+openssl:
+sed:
+sudo:
diff --git a/elements/zypper-minimal/root.d/08-zypper-chroot b/elements/zypper-minimal/root.d/08-zypper-chroot
new file mode 100755
index 000000000..e6d55c30a
--- /dev/null
+++ b/elements/zypper-minimal/root.d/08-zypper-chroot
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# Copyright 2016 SUSE Linux Products Gmb
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+# dib-lint: disable=safe_sudo
+
+if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
+    set -x
+fi
+set -eu
+set -o pipefail
+
+[ -n "${ZYPPER_REPOS}" ]
+
+function cleanup() {
+    sudo umount $TMP_MOUNT_PATH/var/cache/zypp
+}
+
+trap cleanup EXIT
+
+ZYPPER_TARGET_OPTS="--non-interactive --gpg-auto-import-keys --root $TARGET_ROOT"
+ZYPPER_INSTALL_OPTS="--no-confirm --no-recommends"
+
+for repo in ${ZYPPER_REPOS}; do
+    reponame=repo-${repo%%=>*}
+    repouri=${repo##*=>}
+    sudo zypper ${ZYPPER_TARGET_OPTS} addrepo --name ${reponame} --keep-packages ${repouri} ${reponame}
+done
+
+# Refresh it
+sudo zypper ${ZYPPER_TARGET_OPTS} refresh
+
+# It appears that zypper will clean up the repo's cache when it (re-)adds the
+# repo so we need to add the cache now, once the repos are added. This is
+# similar to what the zypper/50-zypper-cache script does
+ZYPPER_CACHE_DIR=$DIB_IMAGE_CACHE/zypper
+mkdir -p $ZYPPER_CACHE_DIR
+
+sudo mkdir -p $TMP_MOUNT_PATH/var/cache/zypp
+sudo mount --bind $ZYPPER_CACHE_DIR $TMP_MOUNT_PATH/var/cache/zypp
+
+# Install filesystem, base and useful tools
+sudo zypper ${ZYPPER_TARGET_OPTS} install ${ZYPPER_INSTALL_OPTS} filesystem
+# Install basic components in order
+sudo zypper ${ZYPPER_TARGET_OPTS} install ${ZYPPER_INSTALL_OPTS} -t pattern base
+# Install a few useful tools
+sudo zypper ${ZYPPER_TARGET_OPTS} install ${ZYPPER_INSTALL_OPTS} python zypper
+
+# Put in a dummy /etc/resolv.conf over the temporary one we used
+# to bootstrap.  systemd has a bug/feature [1] that it will assume
+# you want systemd-networkd as the network manager and create a
+# broken symlink to /run/... if the base image doesn't have one.
+# This broken link confuses things like dhclient.
+# [1] https://bugzilla.redhat.com/show_bug.cgi?id=1197204
+echo -e "# This file intentionally left blank\n" | \
+    sudo tee $TARGET_ROOT/etc/resolv.conf
+
+# set the most reliable UTF-8 locale
+echo -e 'LANG="en_US.UTF-8"' | \
+sudo tee $TARGET_ROOT/etc/locale.conf
+# default to UTC
+sudo -E chroot $TARGET_ROOT ln -sf /usr/share/zoneinfo/UTC \
+    /etc/localtime
+
+# RPM doesn't know whether files have been changed since install
+# At this point though, we know for certain that we have changed no
+# config files, so anything marked .rpmnew is just a bug.
+for newfile in $(sudo find $TARGET_ROOT -type f -name '*rpmnew') ; do
+    sudo mv $newfile $(echo $newfile | sed 's/.rpmnew$//')
+done
+
+# Unmounting of the /var/cache/zypp is handled by the cleanup EXIT
+# handler so there is nothing else to do here

From 90536dbab3e425d71a626f534307304389a2b7fd Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Mon, 3 Oct 2016 15:51:18 +0100
Subject: [PATCH 18/35] Add opensuse-minimal element

Add a new opensuse-minimal element to build small and highly
configurable openSUSE based images using the zypper-minimal element
as the main building mechanism

Change-Id: Iebfc4ad4aff763e511b093f1607b55851ccbddcb
---
 elements/opensuse-minimal/README.rst          | 28 +++++++++++++++++++
 elements/opensuse-minimal/element-deps        |  1 +
 elements/opensuse-minimal/element-provides    |  1 +
 .../10-opensuse-distro-name.bash              | 20 +++++++++++++
 .../install.d/01-ccache-symlinks              |  0
 .../install.d/01-login-defs                   |  0
 .../opensuse-minimal-45267f5be1112c22.yaml    |  6 ++++
 7 files changed, 56 insertions(+)
 create mode 100644 elements/opensuse-minimal/README.rst
 create mode 100644 elements/opensuse-minimal/element-deps
 create mode 100644 elements/opensuse-minimal/element-provides
 create mode 100644 elements/opensuse-minimal/environment.d/10-opensuse-distro-name.bash
 rename elements/{opensuse => zypper}/install.d/01-ccache-symlinks (100%)
 rename elements/{opensuse => zypper}/install.d/01-login-defs (100%)
 create mode 100644 releasenotes/notes/opensuse-minimal-45267f5be1112c22.yaml

diff --git a/elements/opensuse-minimal/README.rst b/elements/opensuse-minimal/README.rst
new file mode 100644
index 000000000..46df3c17c
--- /dev/null
+++ b/elements/opensuse-minimal/README.rst
@@ -0,0 +1,28 @@
+================
+opensuse-minimal
+================
+
+This element will build a minimal openSUSE image. It requires 'zypper' to be
+installed on the host.
+
+These images should be considered experimental. There are curently only x86_64
+images.
+
+Environment Variables
+---------------------
+
+DIB_RELEASE
+  :Required: No
+  :Default: 42.1
+  :Description: Set the desired openSUSE release.
+
+DIB_OPENSUSE_MIRROR:
+   :Required: No
+   :Default: http://download.opensuse.org
+   :Description: To use a specific openSUSE mirror, set this variable to the
+                 mirror URL before running bin/disk-image-create. This URL
+                 should point to the root directory as indicated in the
+                 http://mirrors.opensuse.org/ webpage. You normally
+                 don't want to change that since the default setting will
+                 pick the mirror closest to you.
+   :Example: ``DIB_OPENSUSE_MIRROR=http://ftp.cc.uoc.gr/mirrors/linux/opensuse/opensuse/``
diff --git a/elements/opensuse-minimal/element-deps b/elements/opensuse-minimal/element-deps
new file mode 100644
index 000000000..ac6b190dd
--- /dev/null
+++ b/elements/opensuse-minimal/element-deps
@@ -0,0 +1 @@
+zypper-minimal
diff --git a/elements/opensuse-minimal/element-provides b/elements/opensuse-minimal/element-provides
new file mode 100644
index 000000000..a72e04969
--- /dev/null
+++ b/elements/opensuse-minimal/element-provides
@@ -0,0 +1 @@
+operating-system
diff --git a/elements/opensuse-minimal/environment.d/10-opensuse-distro-name.bash b/elements/opensuse-minimal/environment.d/10-opensuse-distro-name.bash
new file mode 100644
index 000000000..58fff6d2e
--- /dev/null
+++ b/elements/opensuse-minimal/environment.d/10-opensuse-distro-name.bash
@@ -0,0 +1,20 @@
+export DISTRO_NAME=opensuse
+export DIB_RELEASE=${DIB_RELEASE:-42.1}
+export DIB_OPENSUSE_MIRROR=${DIB_OPENSUSE_MIRROR:-http://download.opensuse.org}
+case ${DIB_RELEASE} in
+    # We are using "=>" as the assignment symbol since "@" "=" etc could be used in the URI itself.
+    # Remember, we can't export an array in bash so we use a string instead.
+    # Repo format: {name}=>{uri}
+    # Old openSUSE releases
+    13*)
+        ZYPPER_REPOS="update=>${DIB_OPENSUSE_MIRROR}/update/${DIB_RELEASE}/ "
+        ZYPPER_REPOS+="oss=>${DIB_OPENSUSE_MIRROR}/distribution/${DIB_RELEASE}/repo/oss/"
+        ;;
+    # New Leap releases
+    42*)
+        ZYPPER_REPOS="update=>${DIB_OPENSUSE_MIRROR}/update/leap/${DIB_RELEASE}/oss/ "
+        ZYPPER_REPOS+="oss=>${DIB_OPENSUSE_MIRROR}/distribution/leap/${DIB_RELEASE}/repo/oss/"
+        ;;
+    *) echo "Unsupported openSUSE release: ${DIB_RELEASE}"; exit 1 ;;
+esac
+export ZYPPER_REPOS
diff --git a/elements/opensuse/install.d/01-ccache-symlinks b/elements/zypper/install.d/01-ccache-symlinks
similarity index 100%
rename from elements/opensuse/install.d/01-ccache-symlinks
rename to elements/zypper/install.d/01-ccache-symlinks
diff --git a/elements/opensuse/install.d/01-login-defs b/elements/zypper/install.d/01-login-defs
similarity index 100%
rename from elements/opensuse/install.d/01-login-defs
rename to elements/zypper/install.d/01-login-defs
diff --git a/releasenotes/notes/opensuse-minimal-45267f5be1112c22.yaml b/releasenotes/notes/opensuse-minimal-45267f5be1112c22.yaml
new file mode 100644
index 000000000..4480aeddf
--- /dev/null
+++ b/releasenotes/notes/opensuse-minimal-45267f5be1112c22.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - New zypper-minimal and opensuse-minimal elements to create basic
+    openSUSE images. These two new elements are also making use of the
+    existing zypper element which has been extended to include the
+    functionality previously present in the opensuse element.

From 2ea5feca5c4b64867ac327736edfb20408f8840e Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Fri, 30 Sep 2016 15:59:46 -0400
Subject: [PATCH 19/35] Create (md5|sha256) checksum files for images

In shade, we use both md5 and sha256 checksums to help validate the
integrity of an image. Rather then having nodepool do this each time
for every time, have diskimage-builder create these files when we
build the image.

We've added a flag (disabled by default) to toggle this functionality.

Change-Id: I5815ba69b7d477f1e91dc8ec0c69c86168770964
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
---
 bin/disk-image-create |  4 +++-
 lib/common-defaults   |  1 +
 lib/common-functions  | 10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/bin/disk-image-create b/bin/disk-image-create
index ad811a8fd..45d8024bd 100755
--- a/bin/disk-image-create
+++ b/bin/disk-image-create
@@ -109,6 +109,7 @@ function show_options () {
     echo "    -x -- turn on tracing (use -x -x for very detailed tracing)"
     echo "    -u -- uncompressed; do not compress the image - larger but faster"
     echo "    -c -- clear environment before starting work"
+    echo "    --checksum -- generate MD5 and SHA256 checksum files for the created image"
     echo "    --image-size size -- image size in GB for the created image"
     echo "    --image-cache directory -- location for cached images(default ~/.cache/image-create)"
     echo "    --max-online-resize size -- max number of filesystem blocks to support when resizing."
@@ -172,7 +173,7 @@ DIB_DEFAULT_INSTALLTYPE=${DIB_DEFAULT_INSTALLTYPE:-"source"}
 MKFS_OPTS=""
 ACI_MANIFEST=${ACI_MANIFEST:-}
 DOCKER_TARGET=""
-TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,version,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type:,docker-target: -n $SCRIPTNAME -- "$@"`
+TEMP=`getopt -o a:ho:t:xucnp: -l checksum,no-tmpfs,offline,help,version,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type:,docker-target: -n $SCRIPTNAME -- "$@"`
 if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
 
 # Note the quotes around `$TEMP': they are essential!
@@ -190,6 +191,7 @@ while true ; do
         -c) shift ; export CLEAR_ENV=1;;
         -n) shift; export SKIP_BASE="1";;
         -p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;;
+        --checksum) shift; export DIB_CHECKSUM=1;;
         --image-size) export DIB_IMAGE_SIZE=$2; shift 2;;
         --image-cache) export DIB_IMAGE_CACHE=$2; shift 2;;
         --max-online-resize) export MAX_ONLINE_RESIZE=$2; shift 2;;
diff --git a/lib/common-defaults b/lib/common-defaults
index ee33eb470..e04718559 100644
--- a/lib/common-defaults
+++ b/lib/common-defaults
@@ -34,6 +34,7 @@ fi
 ARCH=${ARCH:-$_ARCH}
 export ARCH
 
+export DIB_CHECKSUM=${DIB_CHECKSUM:-0}
 export DIB_NO_TMPFS=${DIB_NO_TMPFS:-0}
 export DIB_MIN_TMPFS=${DIB_MIN_TMPFS:-2}
 # Set via the CLI normally.
diff --git a/lib/common-functions b/lib/common-functions
index 152a48718..254525868 100644
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -51,9 +51,19 @@ function finish_image () {
       old_image="${1%.*}"-$(date +%Y.%m.%d-%H.%M.%S).${1##*.}
       echo "Old image found. Renaming it to $old_image"
       mv "$1" "$old_image"
+      if [ -f "$1.md5" ]; then
+        mv "$1.md5" "$old_image.md5"
+      fi
+      if [ -f "$1.sha256" ]; then
+        mv "$1.sha256" "$old_image.sha256"
+      fi
     fi
 
     mv $OUT_IMAGE_PATH $1
+    if [ "$DIB_CHECKSUM" == "1" ]; then
+      md5sum $1 > $1.md5
+      sha256sum $1 > $1.sha256
+    fi
     echo "Image file $1 created..."
 }
 

From 3571647692558c29cb26f1b20e1fa908477b6a7e Mon Sep 17 00:00:00 2001
From: Matthew Thode <mthode@mthode.org>
Date: Thu, 6 Oct 2016 11:57:34 -0500
Subject: [PATCH 20/35] Add pkg-map for gentoo to runtime-ssh-host-keys

Openssh is provided by default so it is not needed to be installed here.

Change-Id: Id86f9a1d214c775570f0c9e2df4ea81367bb5b7e
---
 elements/runtime-ssh-host-keys/pkg-map | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/elements/runtime-ssh-host-keys/pkg-map b/elements/runtime-ssh-host-keys/pkg-map
index 413d584e7..ce9fd939e 100644
--- a/elements/runtime-ssh-host-keys/pkg-map
+++ b/elements/runtime-ssh-host-keys/pkg-map
@@ -2,6 +2,9 @@
   "family": {
     "redhat": {
       "openssh-client": "openssh"
+    },
+    "gentoo": {
+      "openssh-client": ""
     }
   }
 }

From a74b5fe399c4955015fb9dac0ca5257abf4a1415 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Thu, 6 Oct 2016 20:26:07 +0200
Subject: [PATCH 21/35] Enable release notes translation

Releasenote translation publishing is being prepared. 'locale_dirs'
needs to be defined in conf.py to generate translated version of the
release notes.

Note that this repository might not get translated release notes - or
no translations at all - but we add the entry here nevertheless to
prepare for it.

Change-Id: Ib3cfb6a2cc014b72c32db7434975d4bb75d480d7
---
 releasenotes/source/conf.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py
index 117ef54aa..ed01c8f27 100644
--- a/releasenotes/source/conf.py
+++ b/releasenotes/source/conf.py
@@ -235,3 +235,6 @@ texinfo_documents = [
 
 # If true, do not generate a @detailmenu in the "Top" node's menu.
 #texinfo_no_detailmenu = False
+
+# -- Options for Internationalization output ------------------------------
+locale_dirs = ['locale/']

From 9a8d67e36f305e9e966e715b4b4905ee078b101a Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 14:49:08 -0700
Subject: [PATCH 22/35] Add bugs link to docs

Change-Id: I09dcfe5abbc76e1383851282f063f4c338f6d93a
---
 doc/source/index.rst | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/doc/source/index.rst b/doc/source/index.rst
index cf2b21732..35b13402f 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -30,6 +30,15 @@ The code is available at:
    <https://git.openstack.org/cgit/openstack/diskimage-builder/>`__
 
 
+Issues
+------
+
+Issues are tracked on launchpad at:
+
+ * `https://bugs.launchpad.net/diskimage-builder/+bugs`
+   <https://bugs.launchpad.net/diskimage-builder/+bugs>
+
+
 Communication
 -------------
 

From 3e4889cd6af380b25b94801dc0486a27fd6352f4 Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 14:50:46 -0700
Subject: [PATCH 23/35] Add low-hanging-fruit bug tag to docs

This is useful in the developer quickstart guide.

Change-Id: I54e7166bace055ae583f5dc84b648bba5f4f9cf4
---
 doc/source/developer/index.rst | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/doc/source/developer/index.rst b/doc/source/developer/index.rst
index 738c82c51..7d23539c8 100644
--- a/doc/source/developer/index.rst
+++ b/doc/source/developer/index.rst
@@ -24,6 +24,15 @@ and testing your changes.  When you are done editing, use ``git
 review`` to submit changes to the upstream gerrit.
 
 
+Finding Work
+------------
+
+We maintain a list of low-hanging-fruit tags on launchpad:
+
+ * `https://bugs.launchpad.net/diskimage-builder/+bugs?field.tag=low-hanging-fruit`
+   <https://bugs.launchpad.net/diskimage-builder/+bugs?field.tag=low-hanging-fruit>
+
+
 .. toctree::
    :maxdepth: 2
 

From c80cf9ec583ab734417de142b4be05cbd8500bf4 Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 13:47:21 -0700
Subject: [PATCH 24/35] Fix developer guide TOC

The table of contents for our developer guide does not show due to the
fact that it is past the first sub-header.

Change-Id: I8459a4949e3e4822b0a3cd4f163475d2c60b0f2e
---
 doc/source/developer/index.rst | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/doc/source/developer/index.rst b/doc/source/developer/index.rst
index 7d23539c8..4988baada 100644
--- a/doc/source/developer/index.rst
+++ b/doc/source/developer/index.rst
@@ -1,6 +1,17 @@
 Developer Documentation
 =======================
 
+.. toctree::
+   :maxdepth: 1
+
+   design
+   components
+   invocation
+   caches
+   developing_elements
+   dib_lint
+   stable_interfaces
+
 This documentation explains how to get started with creating your own
 disk-image-builder elements as well as some high level concepts for element
 creation.
@@ -31,15 +42,3 @@ We maintain a list of low-hanging-fruit tags on launchpad:
 
  * `https://bugs.launchpad.net/diskimage-builder/+bugs?field.tag=low-hanging-fruit`
    <https://bugs.launchpad.net/diskimage-builder/+bugs?field.tag=low-hanging-fruit>
-
-
-.. toctree::
-   :maxdepth: 2
-
-   design
-   components
-   invocation
-   caches
-   developing_elements
-   dib_lint
-   stable_interfaces

From 14b9d7ff3e634c3d7b5d5164d8a29414a74ccc77 Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 13:54:28 -0700
Subject: [PATCH 25/35] Use globaltoc in docs for sidebar

By default sphinx uses localtoc which means 'show TOC for this page'.
Using a global table of contents on the sidebar is much more user
friendly wih our docs structure.

Change-Id: I215732d3848b4b75d9171bdbaaf2ff2e4dcc01f0
---
 doc/source/conf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/source/conf.py b/doc/source/conf.py
index 88cd76824..7577476ba 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -124,7 +124,7 @@ html_theme = 'default'
 #html_use_smartypants = True
 
 # Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'], }
 
 # Additional templates that should be rendered to pages, maps page names to
 # template names.

From 9f3bb9652a3bbae407814cda717e962f3242c68f Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 13:58:28 -0700
Subject: [PATCH 26/35] Remove copyright from docs / toc

This is redundant (we have these copyright notices elsewhere) and
provide no value to the user.

Change-Id: I3699c01f0d4126cdffb3e3edf87ce62325f9f67a
---
 doc/source/copyright.rst | 20 --------------------
 doc/source/index.rst     |  1 -
 2 files changed, 21 deletions(-)
 delete mode 100644 doc/source/copyright.rst

diff --git a/doc/source/copyright.rst b/doc/source/copyright.rst
deleted file mode 100644
index e9734d578..000000000
--- a/doc/source/copyright.rst
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright
-=========
-
-Copyright 2012 Hewlett-Packard Development Company, L.P.
-
-Copyright (c) 2012 NTT DOCOMO, INC.
-
-All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may
-not use this file except in compliance with the License. You may obtain
-a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations
-under the License.
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 35b13402f..7d277349c 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -55,4 +55,3 @@ Table of Contents
    user_guide/index
    developer/index
    elements
-   copyright

From 5758176a4237c91aa60503175d8aebd8749f7c83 Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 14:01:18 -0700
Subject: [PATCH 27/35] Rename devloper documentation to developer guide

We currently have 'user guide' and 'developer documentation'. Lets
rename to 'developer guide' for consistency.

Change-Id: I834ea313bc34275ef33e8c49a1689dff41892015
---
 doc/source/developer/index.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/source/developer/index.rst b/doc/source/developer/index.rst
index 4988baada..cc063806b 100644
--- a/doc/source/developer/index.rst
+++ b/doc/source/developer/index.rst
@@ -1,5 +1,5 @@
-Developer Documentation
-=======================
+Developer Guide
+===============
 
 .. toctree::
    :maxdepth: 1

From 7f9506962a394769b4459c07c482e073674309d3 Mon Sep 17 00:00:00 2001
From: Gregory Haynes <greg@greghaynes.net>
Date: Thu, 6 Oct 2016 14:04:42 -0700
Subject: [PATCH 28/35] Fix formatting for supported distros in docs

The supported distros table is not formatted consistently.

Change-Id: Ic9e32786419243c118088f933d86329480f3345b
---
 doc/source/user_guide/supported_distros.rst | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/source/user_guide/supported_distros.rst b/doc/source/user_guide/supported_distros.rst
index 99030adda..011c149a1 100644
--- a/doc/source/user_guide/supported_distros.rst
+++ b/doc/source/user_guide/supported_distros.rst
@@ -13,9 +13,9 @@ Distributions which are supported as a build host:
 
 Distributions which are supported as a target for an image:
 
-  - Centos 6, 7
-  - Debian 8 ("jessie")
-  - Fedora 20, 21, 22
-  - RHEL 6, 7
-  - Ubuntu 12.04 ("precise"), 14.04 ("trusty")
-  - Gentoo
+- Centos 6, 7
+- Debian 8 ("jessie")
+- Fedora 20, 21, 22
+- RHEL 6, 7
+- Ubuntu 12.04 ("precise"), 14.04 ("trusty")
+- Gentoo

From 82b299bbdfb4df55c44b1526491be64cdf89e181 Mon Sep 17 00:00:00 2001
From: Matthew Thode <mthode@mthode.org>
Date: Fri, 7 Oct 2016 11:16:28 -0500
Subject: [PATCH 29/35] start cloud-init-local in the boot runlevel

cloud-init-local needs to be run in the boot runlevel because it
modifies services in the default runlevel. When a runlevel is started
it is cached, so modifications that happen to the current runlevel while
you are in it are not acted upon.

Change-Id: Ifeae0071fc9e738ec223ec0df271559ad6e0196b
---
 elements/cloud-init/post-install.d/20-enable-cloud-init | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elements/cloud-init/post-install.d/20-enable-cloud-init b/elements/cloud-init/post-install.d/20-enable-cloud-init
index 6368bea5a..36be728aa 100755
--- a/elements/cloud-init/post-install.d/20-enable-cloud-init
+++ b/elements/cloud-init/post-install.d/20-enable-cloud-init
@@ -10,6 +10,6 @@ set -o pipefail
 if [[ "${DISTRO_NAME}" == "gentoo" ]]; then
     rc-update add cloud-config default
     rc-update add cloud-final default
-    rc-update add cloud-init-local default
+    rc-update add cloud-init-local boot
     rc-update add cloud-init default
 fi

From bb29082910b822aae2c27cdf39c67545e3f326f9 Mon Sep 17 00:00:00 2001
From: Matthew Thode <mthode@mthode.org>
Date: Tue, 11 Oct 2016 20:17:49 -0500
Subject: [PATCH 30/35] Document install of diskimage-builder on Gentoo

Change-Id: I27bf3499f998dcbdeb5cfebddde306e5200cc0b5
---
 doc/source/user_guide/installation.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/doc/source/user_guide/installation.rst b/doc/source/user_guide/installation.rst
index 169c088d3..ee10e35a4 100644
--- a/doc/source/user_guide/installation.rst
+++ b/doc/source/user_guide/installation.rst
@@ -55,3 +55,13 @@ Installing via pip is as simple as:
 
     pip install diskimage-builder
 
+
+Package Installation
+--------------------
+
+On Gentoo you can emerge diskimage-builder directly.
+
+::
+
+    emerge app-emulation/diskimage-builder
+

From 1fe1e3f606aacabad8de78d36c0ba1f91962bc9e Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Wed, 19 Oct 2016 16:16:35 +0100
Subject: [PATCH 31/35] elements: growroot: Add SUSE package mappings

Add growpart and e2fsprogs package mappings for SUSE.

Change-Id: I4544c3b5bd561f7483cd10f65e2d6366b52d57cd
---
 elements/growroot/README.rst | 1 +
 elements/growroot/pkg-map    | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/elements/growroot/README.rst b/elements/growroot/README.rst
index 33a5d27e5..f0e8de585 100644
--- a/elements/growroot/README.rst
+++ b/elements/growroot/README.rst
@@ -9,3 +9,4 @@ This is only supported on:
 * ubuntu trusty or later
 * gentoo
 * fedora & centos
+* suse & opensuse
diff --git a/elements/growroot/pkg-map b/elements/growroot/pkg-map
index 43d4ec7cf..f34ea6af5 100644
--- a/elements/growroot/pkg-map
+++ b/elements/growroot/pkg-map
@@ -8,6 +8,10 @@
             "growpart": "cloud-utils",
             "e2fsprogs": "e2fsprogs"
         },
+        "suse": {
+            "growpart": "growpart",
+            "e2fsprogs": "e2fsprogs"
+        },
         "gentoo": {
             "growpart": "sys-fs/growpart",
             "e2fsprogs": "sys-fs/e2fsprogs"

From cfcbd4ffbefe4d5bc2bd78b510a3eb1f619af377 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Wed, 19 Oct 2016 17:53:01 +0100
Subject: [PATCH 32/35] elements: source-repositories: Add git package mapping
 for SUSE

The 'git' command line tool is in the git-core SUSE package

Change-Id: Ib2c5dc5ab9bbde2520f43682c654a9c3270bac09
---
 elements/source-repositories/pkg-map | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/elements/source-repositories/pkg-map b/elements/source-repositories/pkg-map
index d6bba0f29..7dfcd72ff 100644
--- a/elements/source-repositories/pkg-map
+++ b/elements/source-repositories/pkg-map
@@ -2,6 +2,9 @@
   "family": {
     "gentoo": {
       "git": "dev-vcs/git"
+    },
+    "suse": {
+      "git": "git-core"
     }
   },
   "default": {

From a44b55ccaaff7f252f048a180a26006c86d21ceb Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Thu, 20 Oct 2016 15:19:31 +1100
Subject: [PATCH 33/35] Turn down yum install-packages

When debugging, this is very noisy for very little value.  If we need
to specifically debug this script we can turn up the level.

Change-Id: Ie15f16397c37e718aa919853697cbf2c5c08503c
---
 elements/yum/bin/install-packages | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elements/yum/bin/install-packages b/elements/yum/bin/install-packages
index 2bef134a0..3dc72c846 100755
--- a/elements/yum/bin/install-packages
+++ b/elements/yum/bin/install-packages
@@ -14,7 +14,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
+if [ ${DIB_DEBUG_TRACE:-0} -gt 1 ]; then
     set -x
 fi
 set -eu

From 7f1494a43348da65c0006c8d2477c6ab36bd5fb1 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Wed, 19 Oct 2016 18:59:07 +0100
Subject: [PATCH 34/35] elements: zypper: Do not pull recommended packages

Recommended packages are usually useful but we normally don't need
them in order to have a working system. As a result, avoid pulling
them in when doing a regular package installation or a distribution
update. Extra packages can be pulled in using the usual '-p' parameter
or from within the elements that actually need them. The results of
this change are quite significant, resulting to gains from a few dozen
of MBs up to a few hundred depending on the selected elements.

Change-Id: I5838829c631990c7a1f3b67548accd9a603fe20c
---
 elements/zypper/bin/install-packages | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elements/zypper/bin/install-packages b/elements/zypper/bin/install-packages
index 0460ce21e..7728b2e46 100755
--- a/elements/zypper/bin/install-packages
+++ b/elements/zypper/bin/install-packages
@@ -20,7 +20,7 @@ fi
 set -eu
 set -o pipefail
 
-EXTRA_ARGS=""
+EXTRA_ARGS="--no-recommends"
 MAP_ELEMENT=""
 ACTION=install
 
@@ -47,7 +47,7 @@ eval set -- "$TEMP"
 
 while true ; do
     case "$1" in
-        -u) run_zypper dist-upgrade; exit 0;;
+        -u) run_zypper dist-upgrade --no-recommends; exit 0;;
         -e) ACTION="remove"; shift;;
         -d) EXTRA_ARGS="--download-only"; shift;;
         -m) MAP_ELEMENT=$2; shift 2;;

From 872da68a9032036d392e7b6236d730b7c17b7eb7 Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Sun, 23 Oct 2016 18:49:33 -0400
Subject: [PATCH 35/35] Add support for bindep.txt

Currently, this is a noop, since diskimage-builder currently uses
tests/install_test_deps.sh to manage OS dependencies. The next patch
in the series, will complete the migration to bindep.

Change-Id: I3b599983106b87fec6a4b6348469ed037654810e
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
---
 bindep.txt | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 bindep.txt

diff --git a/bindep.txt b/bindep.txt
new file mode 100644
index 000000000..4f9b42547
--- /dev/null
+++ b/bindep.txt
@@ -0,0 +1,2 @@
+# This is a cross-platform list tracking distribution packages needed by tests;
+# see http://docs.openstack.org/infra/bindep/ for additional information.