#!/bin/bash [ -f /.dockerenv ] || { echo "please run in supplied container"; exit 1; } set -e; source environment heads_dir="${HOME}/heads" heads_repo="${HEADS_REPO?}" heads_ref=${HEADS_REF?} heads_external=${HEADS_EXTERNAL?} devices=${DEVICES?} target=${TARGET?} unset FAKETIME [[ -f ~/.gitconfig ]] || \ printf "[color]\nui=auto\n[user]\nemail=build@local\nname=Build User" \ > ~/.gitconfig [ "$(ls -A "${heads_dir}")" ] \ || git clone "$heads_repo" "$heads_dir" ( cd "$heads_dir"; git checkout "$heads_ref"; git reset --hard; git tag airgap || : current_ref="$(git rev-parse --verify HEAD)" [ "$current_ref" == "$heads_ref" ] || { echo "Error: $heads_ref was not successfully checked out"; exit 1; } if [ "$(ls -A "${heads_external}/patches")" ]; then for patch in "${heads_external}"/patches/*; do echo "Applying patch: ${patch}"; patch -p1 --no-backup-if-mismatch < "${patch}"; done; fi [ -d "${heads_external}/boards" ] && \ rsync -Pav "${heads_external}/boards/" "${heads_dir}/boards/" [[ "$devices" =~ "librem" ]] \ && (cd "$heads_dir/blobs/librem_kbl" && ./get_blobs.sh) )