spacepaste

  1.  
  2. #!/bin/bash
  3. # Copyright 2016 Matthew Thode
  4. # All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  7. # not use this file except in compliance with the License. You may obtain
  8. # a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. # License for the specific language governing permissions and limitations
  16. # under the License.
  17. if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
  18. set -x
  19. fi
  20. set -eu
  21. set -o pipefail
  22. [ -n "${ARCH}" ]
  23. [ -n "${TARGET_ROOT}" ]
  24. if [ 'amd64' = "${ARCH}" ] ; then
  25. ARCH='x86_64'
  26. fi
  27. if ! [ 'x86_64' = "${ARCH}" ] ; then
  28. echo "Only x86_64 images are currently available but ARCH is set to ${ARCH}."
  29. exit 1
  30. fi
  31. if [[ "${GENTOO_PROFILE}" != 'hardened/linux/musl/amd64' ]]; then
  32. echo 'not a musl profile'
  33. exit 1
  34. fi
  35. BASE_IMAGE_FILE="http://distfiles.gentoo.org/experimental/amd64/musl/stage4-amd64-musl-hardened-20171101.tar.bz2"
  36. BASE_IMAGE_FILE="file:///var/tmp/catalyst/builds/musl/hardened/amd64/stage4-amd64-musl-hardened-20171031.tar.bz2"
  37. CACHED_FILE="${DIB_IMAGE_CACHE}/gentoo-stage4-hardened-musl-20171101.tar.bz2"
  38. if [ -n "${DIB_OFFLINE}" -a -f "${CACHED_FILE}" ] ; then
  39. echo "Not checking freshness of cached ${CACHED_FILE}"
  40. else
  41. echo 'Fetching Base Image'
  42. "${TMP_HOOKS_PATH}"/bin/cache-url "${BASE_IMAGE_FILE}" "${CACHED_FILE}"
  43. fi
  44. # Extract the base image (use --numeric-owner to avoid UID/GID mismatch between
  45. # image tarball and host OS)
  46. sudo tar -C "${TARGET_ROOT}" --numeric-owner --xattrs -xjpf "${CACHED_FILE}"
  47.