From 57ba300be4ac7b932748d32466f653d1975282a2 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Tue, 14 Jan 2014 16:51:49 -0500 Subject: [PATCH] Symlink correct element install type The source-repositories element will now symlink the install scripts corresponding to the set install type for an element into the install.d directory. Different install types are implemented by elements by writing scripts to do the install type under install.d/--install directories. For example, the nova element would provide: nova/install.d/nova-package-install/74-nova nova/install.d/nova-source-install/74-nova source-repositories will create the following symlink for the package install type: $TMP_HOOKS_PATH/install.d/74-nova -> nova-package-install/74-nova Or, for the source install type: $TMP_HOOKS_PATH/install.d/74-nova -> nova-source-install/74-nova Change-Id: I1bfaf39e5a98b2af904fbc6d674dbada30b27ed9 --- elements/source-repositories/README.md | 25 +++++++++++++++++++ .../extra-data.d/98-source-repositories | 17 +++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/elements/source-repositories/README.md b/elements/source-repositories/README.md index 309746e6..f72168f0 100644 --- a/elements/source-repositories/README.md +++ b/elements/source-repositories/README.md @@ -45,6 +45,31 @@ 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. +Git and Tarballs are treated as source installs. If the element provides an +-source-install directory under it's install.d hook directory, +symlinks to the scripts in that directory will be created under install.d for +the image build. Alternatively for the package install type, if the element +provides an -package-install directory, symlinks will be created +for those scripts instead. + +For example, the nova element would provide: + + nova/install.d/nova-package-install/74-nova + nova/install.d/nova-source-install/74-nova + +source-repositories will create the following symlink for the package install +type: + + install.d/74-nova -> nova-package-install/74-nova + +Or, for the source install type: + + install.d/74-nova -> nova-source-install/74-nova + +All other scripts that exist under install.d for an element will be executed as +normal. This allows common install code to live in a script outside of +-package-install or -source-install. + 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. diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index 644a52e1..3b14ef57 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -108,12 +108,25 @@ function get_repos_for_element(){ return 1 ;; esac + # 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 + if [ "$REPOTYPE" = "package" ]; then + REPOINSTALLTYPE="package" + else + REPOINSTALLTYPE="source" + fi + + # Create symlink for correct install type + pushd $TMP_HOOKS_PATH/install.d + if [ -e $REPONAME-$REPOINSTALLTYPE-install ]; then + ln -sf $REPONAME-$REPOINSTALLTYPE-install/* . + fi + popd + else echo "Couldn't parse '$line' as a source repository" return 1