1#!/usr/bin/env bash 2# shellcheck disable=SC2038 # TODO: rewrite the find 3# shellcheck disable=SC2086 # we want word splitting 4# shellcheck disable=SC1091 # paths only become valid at runtime 5 6. "${SCRIPTS_DIR}/setup-test-env.sh" 7 8section_switch prepare-artifacts "artifacts: prepare" 9 10set -e 11set -o xtrace 12 13CROSS_FILE=/cross_file-"$CROSS".txt 14 15# Delete unused bin and includes from artifacts to save space. 16rm -rf install/bin install/include 17rm -f install/lib/*.a 18 19# Strip the drivers in the artifacts to cut 80% of the artifacts size. 20if [ -n "$CROSS" ]; then 21 STRIP=$(sed -n -E "s/strip\s*=\s*\[?'(.*)'\]?/\1/p" "$CROSS_FILE") 22 if [ -z "$STRIP" ]; then 23 echo "Failed to find strip command in cross file" 24 exit 1 25 fi 26else 27 STRIP="strip" 28fi 29if [ -z "$ARTIFACTS_DEBUG_SYMBOLS" ]; then 30 find install -name \*.so -exec $STRIP --strip-debug {} \; 31fi 32 33# Test runs don't pull down the git tree, so put the dEQP helper 34# script and associated bits there. 35echo "$(cat VERSION) (git-$(git rev-parse HEAD | cut -b -10))" > install/VERSION 36cp -Rp .gitlab-ci/bare-metal install/ 37cp -Rp .gitlab-ci/common install/ 38cp -Rp .gitlab-ci/piglit install/ 39cp -Rp .gitlab-ci/fluster install/ 40cp -Rp .gitlab-ci/fossils.yml install/ 41cp -Rp .gitlab-ci/fossils install/ 42cp -Rp .gitlab-ci/fossilize-runner.sh install/ 43cp -Rp .gitlab-ci/crosvm-init.sh install/ 44cp -Rp .gitlab-ci/*.txt install/ 45cp -Rp .gitlab-ci/report-flakes.py install/ 46cp -Rp .gitlab-ci/setup-test-env.sh install/ 47cp -Rp .gitlab-ci/*-runner.sh install/ 48cp -Rp .gitlab-ci/bin/structured_logger.py install/ 49cp -Rp .gitlab-ci/bin/custom_logger.py install/ 50 51mapfile -t duplicate_files < <( 52 find src/ -path '*/ci/*' \ 53 \( \ 54 -name '*.txt' \ 55 -o -name '*.toml' \ 56 -o -name '*traces*.yml' \ 57 \) \ 58 -exec basename -a {} + | sort | uniq -d 59) 60if [ ${#duplicate_files[@]} -gt 0 ]; then 61 echo 'Several files with the same name in various ci/ folders:' 62 printf -- ' %s\n' "${duplicate_files[@]}" 63 exit 1 64fi 65 66find src/ -path '*/ci/*' \ 67 \( \ 68 -name '*.txt' \ 69 -o -name '*.toml' \ 70 -o -name '*traces*.yml' \ 71 \) \ 72 -exec cp -p {} install/ \; 73 74# Tar up the install dir so that symlinks and hardlinks aren't each 75# packed separately in the zip file. 76mkdir -p artifacts/ 77tar -cf artifacts/install.tar install 78cp -Rp .gitlab-ci/common artifacts/ci-common 79cp -Rp .gitlab-ci/lava artifacts/ 80cp -Rp .gitlab-ci/b2c artifacts/ 81cp bin/ci/structured_logger.py artifacts/ 82 83if [ -n "$S3_ARTIFACT_NAME" ]; then 84 # Pass needed files to the test stage 85 S3_ARTIFACT_NAME="$S3_ARTIFACT_NAME.tar.zst" 86 zstd --quiet --threads ${FDO_CI_CONCURRENT:-0} artifacts/install.tar -o ${S3_ARTIFACT_NAME} 87 ci-fairy s3cp --token-file "${S3_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${S3_ARTIFACT_NAME} 88fi 89 90section_end prepare-artifacts 91