1bf215546Sopenharmony_ci#!/bin/bash
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ciset -e
4bf215546Sopenharmony_ciset -o xtrace
5bf215546Sopenharmony_ci
6bf215546Sopenharmony_ciCROSS_FILE=/cross_file-"$CROSS".txt
7bf215546Sopenharmony_ci
8bf215546Sopenharmony_ci# Delete unused bin and includes from artifacts to save space.
9bf215546Sopenharmony_cirm -rf install/bin install/include
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ci# Strip the drivers in the artifacts to cut 80% of the artifacts size.
12bf215546Sopenharmony_ciif [ -n "$CROSS" ]; then
13bf215546Sopenharmony_ci    STRIP=`sed -n -E "s/strip\s*=\s*'(.*)'/\1/p" "$CROSS_FILE"`
14bf215546Sopenharmony_ci    if [ -z "$STRIP" ]; then
15bf215546Sopenharmony_ci        echo "Failed to find strip command in cross file"
16bf215546Sopenharmony_ci        exit 1
17bf215546Sopenharmony_ci    fi
18bf215546Sopenharmony_cielse
19bf215546Sopenharmony_ci    STRIP="strip"
20bf215546Sopenharmony_cifi
21bf215546Sopenharmony_ciif [ -z "$ARTIFACTS_DEBUG_SYMBOLS" ]; then
22bf215546Sopenharmony_ci    find install -name \*.so -exec $STRIP {} \;
23bf215546Sopenharmony_cifi
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci# Test runs don't pull down the git tree, so put the dEQP helper
26bf215546Sopenharmony_ci# script and associated bits there.
27bf215546Sopenharmony_ciecho "$(cat VERSION) (git-$(git rev-parse HEAD | cut -b -10))" > install/VERSION
28bf215546Sopenharmony_cicp -Rp .gitlab-ci/bare-metal install/
29bf215546Sopenharmony_cicp -Rp .gitlab-ci/common install/
30bf215546Sopenharmony_cicp -Rp .gitlab-ci/piglit install/
31bf215546Sopenharmony_cicp -Rp .gitlab-ci/fossils.yml install/
32bf215546Sopenharmony_cicp -Rp .gitlab-ci/fossils install/
33bf215546Sopenharmony_cicp -Rp .gitlab-ci/fossilize-runner.sh install/
34bf215546Sopenharmony_cicp -Rp .gitlab-ci/crosvm-init.sh install/
35bf215546Sopenharmony_cicp -Rp .gitlab-ci/*.txt install/
36bf215546Sopenharmony_cicp -Rp .gitlab-ci/report-flakes.py install/
37bf215546Sopenharmony_cicp -Rp .gitlab-ci/valve install/
38bf215546Sopenharmony_cicp -Rp .gitlab-ci/vkd3d-proton install/
39bf215546Sopenharmony_cicp -Rp .gitlab-ci/*-runner.sh install/
40bf215546Sopenharmony_cifind . -path \*/ci/\*.txt \
41bf215546Sopenharmony_ci    -o -path \*/ci/\*.toml \
42bf215546Sopenharmony_ci    -o -path \*/ci/\*traces\*.yml \
43bf215546Sopenharmony_ci    | xargs -I '{}' cp -p '{}' install/
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci# Tar up the install dir so that symlinks and hardlinks aren't each
46bf215546Sopenharmony_ci# packed separately in the zip file.
47bf215546Sopenharmony_cimkdir -p artifacts/
48bf215546Sopenharmony_citar -cf artifacts/install.tar install
49bf215546Sopenharmony_cicp -Rp .gitlab-ci/common artifacts/ci-common
50bf215546Sopenharmony_cicp -Rp .gitlab-ci/lava artifacts/
51bf215546Sopenharmony_cicp -Rp .gitlab-ci/b2c artifacts/
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ciif [ -n "$MINIO_ARTIFACT_NAME" ]; then
54bf215546Sopenharmony_ci    # Pass needed files to the test stage
55bf215546Sopenharmony_ci    MINIO_ARTIFACT_NAME="$MINIO_ARTIFACT_NAME.tar.gz"
56bf215546Sopenharmony_ci    gzip -c artifacts/install.tar > ${MINIO_ARTIFACT_NAME}
57bf215546Sopenharmony_ci    ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${MINIO_ARTIFACT_NAME} https://${PIPELINE_ARTIFACTS_BASE}/${MINIO_ARTIFACT_NAME}
58bf215546Sopenharmony_cifi
59