github.com/cptmikhailov/conmon@v2.0.20+incompatible/contrib/cirrus/build_vm_images.sh (about)

     1  #!/bin/bash
     2  
     3  # This is assumed to be executed through ssh, on an VM running from
     4  # the 'image-builder-image', by Cirrus CI.  Running manually requires
     5  # setting all the 'req_env_var' items below, as well as
     6  # $GOOGLE_APPLICATION_CREDENTIALS = JSON credentials file cooresponding
     7  # to $SERVICE_ACCOUNT.
     8  
     9  set -e
    10  source $(dirname $0)/lib.sh
    11  
    12  req_env_var "
    13  SRC $SRC
    14  SCRIPT_BASE $SCRIPT_BASE
    15  PACKER_BASE $PACKER_BASE
    16  PACKER_VER $PACKER_VER
    17  PACKER_BUILDS $PACKER_BUILDS
    18  BUILT_IMAGE_SUFFIX $BUILT_IMAGE_SUFFIX
    19  
    20  CRIO_REPO $CRIO_REPO
    21  CRIO_SLUG $CRIO_SLUG
    22  
    23  FEDORA_BASE_IMAGE $FEDORA_BASE_IMAGE
    24  
    25  SERVICE_ACCOUNT $SERVICE_ACCOUNT
    26  GCE_SSH_USERNAME $GCE_SSH_USERNAME
    27  GCP_PROJECT_ID $GCP_PROJECT_ID
    28  "
    29  
    30  show_env_vars
    31  
    32  # Everything here is running on the 'image-builder-image' GCE image
    33  # Assume basic dependencies are all met, but there could be a newer version
    34  # of the packer binary
    35  PACKER_FILENAME="packer_${PACKER_VER}_linux_amd64.zip"
    36  # image_builder_image has packer pre-installed, check if same version requested
    37  if [[ -r "$HOME/packer/$PACKER_FILENAME" ]]
    38  then
    39      cp "$HOME/packer/$PACKER_FILENAME" "$SRC/$PACKER_BASE/"
    40  fi
    41  
    42  cd "$SRC/$PACKER_BASE"
    43  
    44  # Separate PR-produced images from those produced on master.
    45  if [[ "${CIRRUS_BRANCH:-}" == "master" ]]
    46  then
    47      POST_MERGE_BUCKET_SUFFIX="-master"
    48  else
    49      POST_MERGE_BUCKET_SUFFIX=""
    50  fi
    51  
    52  make conmon_images \
    53      SRC=$SRC \
    54      SCRIPT_BASE=$SCRIPT_BASE \
    55      PACKER_BASE=$PACKER_BASE \
    56      PACKER_VER=$PACKER_VER \
    57      PACKER_BUILDS=$PACKER_BUILDS \
    58      BUILT_IMAGE_SUFFIX=$BUILT_IMAGE_SUFFIX \
    59      CRIO_REPO=$CRIO_REPO \
    60      CRIO_SLUG=$CRIO_SLUG \
    61      FEDORA_BASE_IMAGE=$FEDORA_BASE_IMAGE \
    62      POST_MERGE_BUCKET_SUFFIX=$POST_MERGE_BUCKET_SUFFIX
    63  
    64  # When successful, upload manifest of produced images using a filename unique
    65  # to this build.
    66  URI="gs://packer-import${POST_MERGE_BUCKET_SUFFIX}-temp/manifest${BUILT_IMAGE_SUFFIX}.json"
    67  gsutil cp packer-manifest.json "$URI"
    68  
    69  echo "Finished."
    70  echo "Any tarball URI's referenced above at at $URI"
    71  echo "may be used to create VM images suitable for use in"
    72  echo ".cirrus.yml as values for the 'image_name' keys."