From d253ed16d85377b92983d7ddfc53d9665eb51490 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Thu, 9 Jan 2014 11:07:23 -0500 Subject: [PATCH] Add package support to source-repositories Adds a new "package" type to source-repositories. When the package type is specified in an origin-repository-* file the package name and type "package" need to be specified like so: nova package The existing map-packages mechanism can be used to map the specified package name to the actual distribution package names. The pre-configured package repositories on the image will be used to install the packages during the install.d phase of the image build. If the repo type is package, an environment.d hook script is updated with an environment variable which is sourced by dib-run-parts. This is so that other hooks, particularly in install.d, will know what repo type was used and can make the correct decision about doing a source install or not. Change-Id: Ief4e524664cd32d2087aeb3b1766f05e017de91e --- elements/source-repositories/README.md | 9 ++++++++- .../extra-data.d/98-source-repositories | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/elements/source-repositories/README.md b/elements/source-repositories/README.md index 5d0003d9..309746e6 100644 --- a/elements/source-repositories/README.md +++ b/elements/source-repositories/README.md @@ -1,4 +1,4 @@ -With this element other elements can register source code repositories by +With this element other elements can register their installation source by placing their details in the file source-repository-\*. An example of an element "custom-element" that wants to retrieve the ironic source from git and pbr from a tarball would be @@ -42,6 +42,9 @@ Tarballs will be extracted to \. Tarballs should contain a single topleval directory, regardless of the name of this top level directory it will be renamed to \ +The package type indicates the element should install from packages onto the +root filesystem of the image build during the install.d phase. + If multiple elements register a source location with the same then source-repositories will exit with an error. Care should therefore be taken to only use elements together that download source to different locations. @@ -49,3 +52,7 @@ to only use elements together that download source to different locations. The repository paths built into the image are stored in etc/dib-source-repositories, one repository per line. This permits later review of the repositories (by users or by other elements). + +The repository names and types are written to an environment.d hook script at +01-source-repositories-environment. This allows later hook scripts during the +install.d phase to know which install type to use for the element. diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index 5561246d..644a52e1 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -10,7 +10,7 @@ function get_repos_for_element(){ local REPO_SOURCES=$1 local CACHE_URL=$TMP_HOOKS_PATH/bin/cache-url - local REGEX="^([^ ]+) (git|tar|file) (/[^ ]+) ([^ ]+) ?([^ ]*)$" + local REGEX="^([^ ]+) (git|tar|file|package) ?(/[^ ]+)? ?([^ ]+)? ?([^ ]*)$" while read line ; do @@ -100,6 +100,9 @@ function get_repos_for_element(){ sudo curl $REPOLOCATION -o $REPO_DEST fi ;; + package) + echo "$REPONAME set to package source type" + ;; *) echo "Unsupported repository type: $REPOTYPE" return 1 @@ -108,6 +111,9 @@ function get_repos_for_element(){ # Capture the in-instance repository path for later review / other # elements (like a pypi dependency cache). echo "$REPOPATH" | sudo dd of=$TMP_MOUNT_PATH/etc/dib-source-repositories oflag=append conv=notrunc + # Save the $REPOTYPE used so that it can be used later by install.d + mkdir -p $TMP_HOOKS_PATH/environment.d + echo "export DIB_REPOTYPE_${REPONAME//-/_}=$REPOTYPE" >> $TMP_HOOKS_PATH/environment.d/01-source-repositories-environment else echo "Couldn't parse '$line' as a source repository" return 1