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