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/<element-name>-<install-type>-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
This commit is contained in:
James Slagle 2014-01-14 16:51:49 -05:00
parent 79f31d0476
commit 57ba300be4
2 changed files with 40 additions and 2 deletions

View file

@ -45,6 +45,31 @@ it will be renamed to \<destination\>
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
<element-name>-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 <element-name>-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
<element-name>-package-install or <element-name>-source-install.
If multiple elements register a source location with the same <destination>
then source-repositories will exit with an error. Care should therefore be taken
to only use elements together that download source to different locations.

View file

@ -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