Configuration files for project CI systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-image.sh 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/bash
  2. # Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13. # implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Read through this script. There are a lot of comments that might
  18. # help you!
  19. #
  20. # To run on Ubuntu 14.04, this depends on:
  21. # diskimage-builder
  22. # qemu-utils
  23. # debootstrap
  24. set -e
  25. ## Other options
  26. # export DISTRO=${DISTRO:-centos-minimal}
  27. # export DISTRO=${DISTRO:-fedora-minimal}
  28. export DISTRO=${DISTRO:-ubuntu-minimal}
  29. ## Override the release
  30. # export DIB_RELEASE=${DIB_RELEASE:-trusty}
  31. # export DIB_RELEASE=${DIB_RELEASE:-25} # fedora
  32. ## Override the arch
  33. # export ARCH=arm64
  34. export ELEMENTS_PATH=${ELEMENTS_PATH:-nodepool/elements}
  35. export IMAGE_NAME=${IMAGE_NAME:-devstack-gate}
  36. export NODEPOOL_SCRIPTDIR=${NODEPOOL_SCRIPTDIR:-nodepool/scripts}
  37. export EXTRA_ELEMENTS=${EXTRA_ELEMENTS:-}
  38. ZUUL_USER_SSH_PUBLIC_KEY=${ZUUL_USER_SSH_PUBLIC_KEY:-$HOME/.ssh/id_rsa.pub}
  39. if [ ! -f ${ZUUL_USER_SSH_PUBLIC_KEY} ]; then
  40. echo "Error: There is no SSH public key at: ${ZUUL_USER_SSH_PUBLIC_KEY}"
  41. echo "Error: Image build will fail. Exiting now."
  42. exit 1
  43. fi
  44. ## Several parts of infra node bringup require EPEL, but we don't want
  45. ## to introduce dependencies on it, so keep disabled.
  46. if [[ ${DISTRO} == "centos-minimal" ]]; then
  47. EXTRA_ELEMENTS+="epel "
  48. export DIB_EPEL_DISABLED=1
  49. fi
  50. # cache-devstack does not work on gentoo, so exclude it from the element list
  51. if [[ "${DISTRO}" != "gentoo" ]]; then
  52. EXTRA_ELEMENTS+="cache-devstack "
  53. fi
  54. ## If your firewall won't allow outbound DNS connections, you'll want
  55. ## to set these to local resolvers
  56. # export NODEPOOL_STATIC_NAMESERVER_V4=192.168.0.1
  57. # export NODEPOOL_STATIC_NAMESERVER_V6=2000::...
  58. ## This will get dib to drop you into a shell on error, useful for debugging
  59. # export break="after-error"
  60. ## If you need to debug the boot, setting this longer might help you
  61. ## break into the grub console. Or set it to 0 for fast boot.
  62. # export DIB_GRUB_TIMEOUT=10
  63. ## The openstack-repos element caches every git repo, wihch can take
  64. ## quite some time. We can override this, but some minimal repos are
  65. ## required for a successful build. For speeding up builds when
  66. ## you're testing the following should work, but be very careful
  67. ## stripping things out when generating real images.
  68. ## add to /tmp/custom_projects.yaml:
  69. ##
  70. ## - project: openstack/project-config
  71. ## - project: opendev/system-config
  72. ## - project: openstack/devstack
  73. ## - project: openstack/tempest
  74. # export DIB_CUSTOM_PROJECTS_LIST_URL='file:///tmp/custom_projects.yaml'
  75. ## If you are building test images, or dealing with networking issues,
  76. ## you will want to have a local login with password available (as
  77. ## opposed to key-based ssh only). You can use the "devuser" element
  78. ## from dib to set this up. Don't forget to enable sudo and set the
  79. ## password.
  80. ## defaults
  81. ## export DIB_DEV_USER_USERNAME=devuser
  82. ## export DIB_DEV_USER_AUTHORIZED_KEYS=$HOME/.ssh/id_rsa.pub
  83. # EXTRA_ELEMENTS+=devuser
  84. # export DIB_DEV_USER_PWDLESS_SUDO=1
  85. # export DIB_DEV_USER_PASSWORD=devuser
  86. if [[ "${ARCH:-}" == "arm64" ]]; then
  87. # ARM64 requires EFI to boot
  88. BLOCK_DEVICE=block-device-efi
  89. # These arguments might be specific to Linaro cloud?
  90. EXTRA_UPLOAD_ARGS='--property hw_firmware_type=uefi ' \
  91. '--property os_command_line="console=ttyAMA0" ' \
  92. '--property hw_disk_bus=scsi ' \
  93. '--property hw_scsi_model=virtio-scsi'
  94. fi
  95. ## The list of elements below should match those configured
  96. ## in nodepool/nodepool.yaml
  97. disk-image-create -x --no-tmpfs -o $IMAGE_NAME \
  98. $DISTRO \
  99. ${BLOCK_DEVICE:-block-device-mbr} \
  100. vm \
  101. simple-init \
  102. openstack-repos \
  103. nodepool-base \
  104. growroot \
  105. infra-package-needs \
  106. $EXTRA_ELEMENTS
  107. echo "Created new image: $IMAGE_NAME"
  108. echo "You can now upload it with:"
  109. echo " openstack image create "${DISTRO}" --file $IMAGE_NAME --disk-format=qcow2 --container-format=bare ${EXTRA_UPLOAD_ARGS:-}"