diff --git a/elements/pypi/README.md b/elements/pypi/README.md index c32e23897..96e3085cc 100644 --- a/elements/pypi/README.md +++ b/elements/pypi/README.md @@ -2,8 +2,9 @@ Inject a PyPI mirror ==================== Use a custom PyPI mirror to build images. The default is to bind mount one from -~/.cache/image-create/pypi/mirror into the build environment. The element -temporarily overwrites /root/.pip.conf and .pydistutils.cfg to use it. +~/.cache/image-create/pypi/mirror into the build environment as mirror URL +file:///tmp/pypi. The element temporarily overwrites /root/.pip.conf +and .pydistutils.cfg to use it. When online, the official pypi.python.org pypi index is supplied as an extra-url, so uncached dependencies will still be available. When offline, only @@ -23,6 +24,7 @@ you have more than 9 additional mirrors, some care will be needed. A typical use of this element is thus: export PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10 export PYPI\_MIRROR\_URL\_1=http://site/pypi/ +export PYPI\_MIRROR\_URL\_2=file:///tmp/pypi [pypi-mirror](https://git.openstack.org/cgit/openstack-infra/pypi-mirror) can be useful in making a partial PyPI mirror suitable for building images. For diff --git a/elements/pypi/extra-data.d/00-mount-pypi-mirror b/elements/pypi/extra-data.d/00-mount-pypi-mirror index 709a11e82..0a3edd82a 100755 --- a/elements/pypi/extra-data.d/00-mount-pypi-mirror +++ b/elements/pypi/extra-data.d/00-mount-pypi-mirror @@ -3,13 +3,10 @@ set -eu set -o pipefail -PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''} -if [ -n "$PYPI_MIRROR_URL" ]; then - # External mirror URL being used - no need to bind mount anything. - exit 0 -fi MIRROR_SOURCE=~/.cache/image-create/pypi/mirror/ -MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi +if [ -d "$MIRROR_SOURCE" ]; then + MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi -sudo mkdir -p $MIRROR_SOURCE $MIRROR_TARGET -sudo mount --bind $MIRROR_SOURCE $TMP_MOUNT_PATH/tmp/pypi + sudo mkdir -p $MIRROR_SOURCE $MIRROR_TARGET + sudo mount --bind $MIRROR_SOURCE $MIRROR_TARGET +fi