|
| 1 | +# SPDX-License-Identifier: GPL-2.0-only |
| 2 | +#!/bin/bash -e |
| 3 | + |
| 4 | +timestamp=$(date +%Y_%m_%d-%H_%M) |
| 5 | +GIT_SHA=$(git rev-parse --short HEAD) |
| 6 | +GIT_SHA_DATE=$(git show -s --format=%cd --date=format:'%Y-%m-%d %H:%M' ${GIT_SHA} | sed -e "s/ \|\:/-/g") |
| 7 | + |
| 8 | +#prepare the structure of the folder containing artifacts |
| 9 | +artifacts_structure() { |
| 10 | + cd ${SOURCE_DIRECTORY} |
| 11 | + mkdir ${timestamp} |
| 12 | + |
| 13 | + echo "git_branch=${BUILD_SOURCEBRANCHNAME}" >> ${timestamp}/rpi_git_properties.txt |
| 14 | + echo "git_sha=${GIT_SHA}" >> ${timestamp}/rpi_git_properties.txt |
| 15 | + echo "git_sha_date=${GIT_SHA_DATE}" >> ${timestamp}/rpi_git_properties.txt |
| 16 | + |
| 17 | + typeBCM=( "bcm2709" "bcm2711" "bcmrpi" ) |
| 18 | + typeKERNEL=( "kernel7" "kernel7l" "kernel" ) |
| 19 | + for index in "${!typeBCM[@]}"; do |
| 20 | + cd adi_"${typeBCM[$index]}"_defconfig |
| 21 | + mkdir overlays modules |
| 22 | + mv ./*.dtbo ./overlays |
| 23 | + tar -xf rpi_modules.tar.gz -C modules |
| 24 | + rm rpi_modules.tar.gz |
| 25 | + mv ./zImage ./"${typeKERNEL[$index]}".img |
| 26 | + cd ../ |
| 27 | + cp -r ./adi_"${typeBCM[$index]}"_defconfig/* ./${timestamp} |
| 28 | + done |
| 29 | + tar -C ${SOURCE_DIRECTORY}/${timestamp}/modules -czvf ${SOURCE_DIRECTORY}/${timestamp}/rpi_modules.tar.gz . |
| 30 | + rm -r ${SOURCE_DIRECTORY}/${timestamp}/modules |
| 31 | +} |
| 32 | + |
| 33 | +#upload artifacts to Artifactory |
| 34 | +artifacts_artifactory() { |
| 35 | + artifacts_structure |
| 36 | + cd ${SOURCE_DIRECTORY} |
| 37 | + python ../ci/travis/upload_to_artifactory.py --base_path="${ARTIFACTORY_PATH}" \ |
| 38 | + --server_path="linux_rpi/${BUILD_SOURCEBRANCHNAME}" --local_path="${timestamp}" \ |
| 39 | + --token="${ARTIFACTORY_TOKEN}" --log_file="upload_to_artifactory.log" |
| 40 | +} |
| 41 | + |
| 42 | +#archive artifacts and upload to SWDownloads |
| 43 | +artifacts_swdownloads() { |
| 44 | + artifacts_structure |
| 45 | + cd ${SOURCE_DIRECTORY}/${timestamp} || exit 1 |
| 46 | + chmod 600 ${KEY_FILE} |
| 47 | + scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss \ |
| 48 | + -i ${KEY_FILE} -r *.tar.gz ${DEST_SERVER}/${BUILD_SOURCEBRANCHNAME} |
| 49 | + md5_modules=($(md5sum rpi_modules.tar.gz| cut -d ' ' -f 1)) |
| 50 | + |
| 51 | + rm rpi_modules.tar.gz rpi_git_properties.txt |
| 52 | + tar -C ${PWD} -czvf rpi_latest_boot.tar.gz * |
| 53 | + md5_boot=($(md5sum rpi_latest_boot.tar.gz| cut -d ' ' -f 1)) |
| 54 | + scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss \ |
| 55 | + -i ${KEY_FILE} -r rpi_latest_boot.tar.gz ${DEST_SERVER}/${BUILD_SOURCEBRANCHNAME} |
| 56 | + |
| 57 | + echo "git_branch=${BUILD_SOURCEBRANCHNAME}" >> rpi_archives_properties.txt |
| 58 | + echo "https://swdownloads.analog.com/cse/linux_rpi/${BUILD_SOURCEBRANCHNAME}/rpi_modules.tar.gz" >> rpi_archives_properties.txt |
| 59 | + echo "https://swdownloads.analog.com/cse/linux_rpi/${BUILD_SOURCEBRANCHNAME}/rpi_latest_boot.tar.gz" >> rpi_archives_properties.txt |
| 60 | + echo "checksum_modules=${md5_modules}" >> rpi_archives_properties.txt |
| 61 | + echo "checksum_boot_files=${md5_boot}" >> rpi_archives_properties.txt |
| 62 | + echo "git_sha=${GIT_SHA}" >> rpi_archives_properties.txt |
| 63 | + echo "git_sha_date=${GIT_SHA_DATE}" >> rpi_archives_properties.txt |
| 64 | + |
| 65 | + scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss \ |
| 66 | + -i ${KEY_FILE} -r rpi_archives_properties.txt ${DEST_SERVER}/${BUILD_SOURCEBRANCHNAME} |
| 67 | +} |
| 68 | + |
| 69 | +artifacts_${1} |
0 commit comments