6c997fda97
The fedora element downloads images too, so we should re-use the caching code from the ubuntu element. There doesn't seem to be other examples of code shared between root.d scripts. In the fedora and dpkg elements we copy install-packages into the chroot, but that model doesn't apply when we're running scripts outside of the chroot. Seems sane to just run it directly from the bin/ dir in the temporary hooks directory. Change-Id: Iaa6aca660042fea323cab4271633a4bdbbc271b8
26 lines
917 B
Bash
Executable File
26 lines
917 B
Bash
Executable File
#!/bin/bash
|
|
# These are useful, or at worst not harmful, for all images we build.
|
|
|
|
set -e
|
|
|
|
[ -n "$ARCH" ]
|
|
[ -n "$TARGET_ROOT" ]
|
|
|
|
shopt -s extglob
|
|
|
|
IMG_PATH=~/.cache/image-create
|
|
DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud-images.ubuntu.com/}
|
|
DIB_RELEASE=${DIB_RELEASE:-quantal}
|
|
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$DIB_RELEASE-server-cloudimg-$ARCH-root.tar.gz}
|
|
SHA256SUMS=${SHA256SUMS:-https://${DIB_CLOUD_IMAGES##http?(s)://}/$DIB_RELEASE/current/SHA256SUMS}
|
|
|
|
echo "Fetching Base Image"
|
|
$TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $IMG_PATH/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH
|
|
$TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $IMG_PATH/$BASE_IMAGE_FILE
|
|
pushd $IMG_PATH
|
|
grep "$BASE_IMAGE_FILE" SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH | sha256sum --check -
|
|
popd
|
|
# Extract the base image
|
|
sudo tar -C $TARGET_ROOT -xzf $IMG_PATH/$BASE_IMAGE_FILE
|
|
sudo rmdir $TARGET_ROOT/lost+found
|