2023-10-17 01:37:35 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-03-02 18:33:29 +01:00
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2023 The Calyx Institute
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
2023-10-17 01:37:35 +02:00
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y git-core gnupg flex bison build-essential zip curl zlib1g-dev \
|
|
|
|
libc6-dev-i386 libncurses5 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev \
|
|
|
|
libxml2-utils xsltproc unzip fontconfig python3 npm pip e2fsprogs python3-protobuf \
|
|
|
|
fonts-dejavu diffutils rsync ccache
|
|
|
|
|
|
|
|
npm install --global yarn
|
|
|
|
|
|
|
|
mkdir -p ~/bin
|
|
|
|
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
|
|
|
|
chmod a+x ~/bin/repo
|
|
|
|
ln -s /usr/bin/python3 /usr/bin/python
|
|
|
|
export PATH=~/bin:$PATH
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
retry() {
|
|
|
|
set +e
|
|
|
|
local max_attempts=${ATTEMPTS-5}
|
|
|
|
local timeout=${TIMEOUT-1}
|
|
|
|
local attempt=0
|
|
|
|
local exitCode=0
|
|
|
|
|
|
|
|
while [[ $attempt < $max_attempts ]]
|
|
|
|
do
|
|
|
|
"$@"
|
|
|
|
exitCode=$?
|
|
|
|
|
|
|
|
if [[ $exitCode == 0 ]]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Failure! Retrying ($*) in $timeout.."
|
|
|
|
sleep "${timeout}"
|
|
|
|
attempt=$(( attempt + 1 ))
|
|
|
|
timeout=$(( timeout * 2 ))
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $exitCode != 0 ]]
|
|
|
|
then
|
|
|
|
echo "Failed too many times! ($*)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
return $exitCode
|
|
|
|
}
|
|
|
|
|
|
|
|
DEVICE=$1
|
2024-03-06 17:31:20 +01:00
|
|
|
RELEASE=$2
|
|
|
|
TARGET=$3
|
|
|
|
BRANCH=$4
|
2023-10-17 01:37:35 +02:00
|
|
|
|
|
|
|
git config --global user.email "seedvault@example.com"
|
|
|
|
git config --global user.name "Seedvault CI"
|
|
|
|
|
|
|
|
retry curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
|
|
|
|
chmod a+x ~/bin/repo
|
|
|
|
|
|
|
|
mkdir -p /aosp
|
|
|
|
cd /aosp
|
|
|
|
retry yes | repo init -u https://android.googlesource.com/platform/manifest -b "$BRANCH" --depth=1
|
|
|
|
|
|
|
|
mkdir -p .repo/local_manifests
|
|
|
|
cat << EOF > .repo/local_manifests/seedvault.xml
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<manifest>
|
|
|
|
|
|
|
|
<remote name="seedvault"
|
|
|
|
fetch="https://github.com/$CIRRUS_REPO_OWNER" />
|
|
|
|
|
|
|
|
<project name="seedvault" path="external/seedvault"
|
|
|
|
revision="$CIRRUS_CHANGE_IN_REPO" remote="$CIRRUS_REPO_NAME" />
|
|
|
|
|
|
|
|
</manifest>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
retry repo sync -c -j8 --fail-fast --force-sync
|
|
|
|
|
|
|
|
# Cirrus CI seems to (possibly) reschedule tasks that aren't sending out logs for a while?
|
|
|
|
while true; do echo "Still building..."; sleep 30; done &
|
|
|
|
|
|
|
|
source build/envsetup.sh
|
2024-03-06 17:31:20 +01:00
|
|
|
lunch $DEVICE-$RELEASE-$TARGET
|
|
|
|
m -j1 nothing
|
|
|
|
m -j2 Seedvault
|
2023-10-17 01:37:35 +02:00
|
|
|
|
|
|
|
mv /aosp/out/target/product/generic_arm64/system/system_ext/priv-app/Seedvault/Seedvault.apk "$CIRRUS_WORKING_DIR"
|