Skip to content

Commit 05ae0b1

Browse files
bia1708nunojsa
authored andcommitted
ci: Prepare and upload artifacts
Add script which prepares the artifacts and uploads them to Artifactory. Also create `extlinux.conf` files for arria10 and cyclone5 platforms. Save information about the current build to be used at the following stage (the Test Harness stage) in the pipeline. Signed-off-by: bia1708 <bianca-maria.popu@analog.com>
1 parent 241ab7e commit 05ae0b1

File tree

1 file changed

+112
-56
lines changed

1 file changed

+112
-56
lines changed

ci/travis/prepare_artifacts.sh

Lines changed: 112 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,125 @@
1-
# SPDX-License-Identifier: (GPL-1.0-only OR BSD-2-Clause)
1+
# SPDX-License-Identifier: GPL-2.0-only
22
#!/bin/bash -e
33

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")
4+
TIMESTAMP=$(date +%Y_%m_%d-%H_%M)
5+
# For PRs, Azure makes a merge commit (HEAD) because of the shallow copy option
6+
# (which we want). So, GIT_SHA in this case is the actual correct commit inside
7+
# the PR, and MERGE_COMMIT is the commit made by Azure (which we extract the date
8+
# from)
9+
echo "$SYSTEM_PULLREQUEST_TARGETBRANCH"
10+
if [[ "$SYSTEM_PULLREQUEST_SOURCECOMMITID" != "" ]]; then
11+
GIT_SHA=$SYSTEM_PULLREQUEST_SOURCECOMMITID
12+
else
13+
GIT_SHA=$BUILD_SOURCEVERSION
14+
fi
15+
MERGE_COMMIT_SHA=$(git rev-parse --short HEAD)
16+
GIT_SHA_DATE=$(git show -s --format=%cd --date=format:'%Y-%m-%d %H:%M' ${MERGE_COMMIT_SHA} | sed -e "s/ \|\:/-/g")
17+
SERVER_PATH="linux/"
18+
if [ "$SYSTEM_PULLREQUEST_TARGETBRANCH" != "" ]; then
19+
BRANCH_NAME="$SYSTEM_PULLREQUEST_TARGETBRANCH"
20+
SERVER_PATH+="PRs/"
21+
else
22+
BRANCH_NAME="$(echo $BUILD_SOURCEBRANCH | awk -F'/' '{print $NF}')"
23+
fi
724

8-
#prepare the structure of the folder containing artifacts
9-
artifacts_structure() {
10-
cd ${SOURCE_DIRECTORY}
11-
mkdir ${timestamp}
25+
set_artifactory_path() {
26+
if [ "$SYSTEM_PULLREQUEST_TARGETBRANCH" != "" ]; then
27+
SERVER_PATH+="$BRANCH_NAME/pr_$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
28+
else
29+
if [ "$BRANCH_NAME" == "main" ]; then
30+
SERVER_PATH+="main"
31+
else
32+
SERVER_PATH+="releases/$BRANCH_NAME"
33+
fi
34+
fi
35+
}
1236

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
37+
create_extlinux() {
38+
local platform=$1
1639

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-
}
40+
touch extlinux.conf
41+
if [ "${platform}" == "arria10" ]; then
42+
dtb_name="socfpga_arria10_socdk_sdmmc.dtb"
43+
else
44+
dtb_name="socfpga.dtb"
45+
fi
3246

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"
47+
echo "LABEL Linux Default" > extlinux.conf
48+
echo " KERNEL ../zImage" >> extlinux.conf
49+
echo " FDT ../${dtb_name}" >> extlinux.conf
50+
echo " APPEND root=/dev/mmcblk0p2 rw rootwait earlyprintk console=ttyS0,115200n8" >> extlinux.conf
4051
}
4152

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))
53+
# Prepare the structure of the folder containing artifacts
54+
artifacts_structure() {
55+
cd ${SOURCE_DIRECTORY}
56+
57+
# Create folder to be uploaded
58+
mkdir ${TIMESTAMP}
5059

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}
60+
# Generate properties file
61+
echo "git_branch=${BUILD_SOURCEBRANCHNAME}" >> ${TIMESTAMP}/git_properties.txt
62+
echo "git_sha=${GIT_SHA}" >> ${TIMESTAMP}/git_properties.txt
63+
echo "git_sha_date=${GIT_SHA_DATE}" >> ${TIMESTAMP}/git_properties.txt
5664

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
65+
declare -A typeARCH
66+
typeARCH=( ["arm"]="arria10 cyclone5 zynq"
67+
["arm64"]="versal zynqmp"
68+
["microblaze"]="kc705 kcu105 vc707 vcu118 vcu128" )
6469

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}
70+
declare -A image_to_copy
71+
image_to_copy=( ["arria10"]="socfpga_adi_defconfig/zImage"
72+
["cyclone5"]="socfpga_adi_defconfig/zImage"
73+
["zynq"]="zynq_xcomm_adv7511_defconfig/uImage"
74+
["versal"]="adi_versal_defconfig/Image"
75+
["zynqmp"]="adi_zynqmp_defconfig/Image" )
76+
77+
for arch in "${!typeARCH[@]}"; do
78+
mkdir ${TIMESTAMP}/${arch}
79+
for platform in ${typeARCH[$arch]}; do
80+
# First copy kernels and make extlinux files.
81+
if [ "${arch}" != "microblaze" ]; then
82+
image_location="${TIMESTAMP}/${arch}/${platform}"
83+
mkdir ${image_location}
84+
if [ "${platform}" == "arria10" ] || [ "${platform}" == "cyclone5" ]; then
85+
create_extlinux ${platform}
86+
cp ./extlinux.conf ${image_location}
87+
fi
88+
echo "IMAGE: ${image_to_copy[${platform}]}!"
89+
cp ${image_to_copy[${platform}]} ${image_location}
90+
fi
91+
done
92+
93+
if [ "${arch}" == "microblaze" ]; then
94+
dtbs_to_copy=$(ls -d -1 Microblaze/*)
95+
else
96+
dtbs_to_copy=$(ls -d -1 DTBs/* | grep "${platform}")
97+
fi
98+
99+
# Copy DTBs to the correct location
100+
for dtb in ${dtbs_to_copy}; do
101+
cp ${dtb} "${TIMESTAMP}/${arch}"
102+
done
103+
done
67104
}
68105

69-
artifacts_${1}
106+
#### Start
107+
artifacts_structure
108+
set_artifactory_path
109+
python3 ../ci/travis/upload_to_artifactory.py \
110+
--base_path="${ARTIFACTORY_PATH}" \
111+
--server_path="${SERVER_PATH}" \
112+
--local_path="${TIMESTAMP}" \
113+
--props_level="2" \
114+
--properties="git_sha=${GIT_SHA};commit_date=${TIMESTAMP}" \
115+
--token="${ARTIFACTORY_TOKEN}" \
116+
--log_file="upload_to_artifactory.log"
117+
118+
# Set these Azure env vars to be used later in the pipeline
119+
echo "##vso[task.setvariable variable=TIMESTAMP;isOutput=true]${TIMESTAMP}"
120+
echo "##vso[task.setvariable variable=BRANCH;isOutput=true]${BRANCH_NAME}"
121+
if [ "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" != "" ]; then
122+
echo "##vso[task.setvariable variable=PR_ID;isOutput=true]$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
123+
else
124+
echo "##vso[task.setvariable variable=PR_ID;isOutput=true]commit"
125+
fi

0 commit comments

Comments
 (0)