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/fossils.yml install/ 40cp -Rp .gitlab-ci/fossils install/ 41cp -Rp .gitlab-ci/fossilize-runner.sh install/ 42cp -Rp .gitlab-ci/crosvm-init.sh install/ 43cp -Rp .gitlab-ci/*.txt install/ 44cp -Rp .gitlab-ci/report-flakes.py install/ 45cp -Rp .gitlab-ci/setup-test-env.sh install/ 46cp -Rp .gitlab-ci/*-runner.sh install/ 47cp -Rp .gitlab-ci/bin/structured_logger.py install/ 48cp -Rp .gitlab-ci/bin/custom_logger.py install/ 49 50mapfile -t duplicate_files < <( 51 find src/ -path '*/ci/*' \ 52 \( \ 53 -name '*.txt' \ 54 -o -name '*.toml' \ 55 -o -name '*traces*.yml' \ 56 \) \ 57 -exec basename -a {} + | sort | uniq -d 58) 59if [ ${#duplicate_files[@]} -gt 0 ]; then 60 echo 'Several files with the same name in various ci/ folders:' 61 printf -- ' %s\n' "${duplicate_files[@]}" 62 exit 1 63fi 64 65find src/ -path '*/ci/*' \ 66 \( \ 67 -name '*.txt' \ 68 -o -name '*.toml' \ 69 -o -name '*traces*.yml' \ 70 \) \ 71 -exec cp -p {} install/ \; 72 73# Tar up the install dir so that symlinks and hardlinks aren't each 74# packed separately in the zip file. 75mkdir -p artifacts/ 76tar -cf artifacts/install.tar install 77cp -Rp .gitlab-ci/common artifacts/ci-common 78cp -Rp .gitlab-ci/lava artifacts/ 79cp -Rp .gitlab-ci/b2c artifacts/ 80cp bin/ci/structured_logger.py artifacts/ 81 82if [ -n "$S3_ARTIFACT_NAME" ]; then 83 # Pass needed files to the test stage 84 S3_ARTIFACT_NAME="$S3_ARTIFACT_NAME.tar.zst" 85 zstd --quiet --threads ${FDO_CI_CONCURRENT:-0} artifacts/install.tar -o ${S3_ARTIFACT_NAME} 86 ci-fairy s3cp --token-file "${S3_JWT_FILE}" ${S3_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${S3_ARTIFACT_NAME} 87fi 88 89section_end prepare-artifacts 90