Last active
March 4, 2024 21:53
-
-
Save DragoonAethis/0fdddc0f71c044d64581f9b10b7ae807 to your computer and use it in GitHub Desktop.
Intel GFX CI firmware prep scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script configuration | |
# You can override any of these via env vars set outside of this script. | |
# Optional proxy env var script: | |
: ${PROXY_SCRIPT="/etc/profile.d/proxy.sh"} | |
# Repo to download the firmware files from: | |
: ${DRM_FW_REPO:="https://gitlab.freedesktop.org/drm/firmware.git/"} | |
: ${DRM_FW_GITLAB_PROJECT_ID:=21143} | |
# API endpoints to fetch commit hashes to compare against: | |
: ${GITLAB_API_BASE_URL:="https://gitlab.freedesktop.org/api/v4"} | |
: ${GITLAB_API_BRANCHES_URL:="$GITLAB_API_BASE_URL/projects/$DRM_FW_GITLAB_PROJECT_ID/repository/branches"} | |
# Persistent data location: | |
: ${TARGET_DIR:="/opt/archive/scripts"} | |
: ${TARGET_FILE:="linux-firmware.tar.gz"} | |
: ${MARKER_FILE:="linux-firmware.marker"} | |
# --- | |
echo "PROXY_SCRIPT=$PROXY_SCRIPT" | |
echo "DRM_FW_REPO=$DRM_FW_REPO" | |
echo "DRM_FW_GITLAB_PROJECT_ID=$DRM_FW_GITLAB_PROJECT_ID" | |
echo "GITLAB_API_BASE_URL=$GITLAB_API_BASE_URL" | |
echo "GITLAB_API_BRANCHES_URL=$GITLAB_API_BRANCHES_URL" | |
echo "TARGET_DIR=$TARGET_DIR" | |
echo "TARGET_FILE=$TARGET_FILE" | |
echo "MARKER_FILE=$MARKER_FILE" | |
# --- | |
if [[ -f "$PROXY_SCRIPT" ]]; then | |
source "$PROXY_SCRIPT" | |
else | |
echo "Proxy script does not exist, ignoring" | |
fi | |
# Check if we've got anything to do first. Get 'em hashes: | |
INTEL_STAGING_COMMIT=$(curl "$GITLAB_API_BRANCHES_URL/intel-staging" | jq --raw-output ".commit.id") | |
INTEL_FOR_CI_COMMIT=$(curl "$GITLAB_API_BRANCHES_URL/intel-for-ci" | jq --raw-output ".commit.id") | |
NEW_MARKER="intel-staging=$INTEL_STAGING_COMMIT;intel-for-ci=$INTEL_FOR_CI_COMMIT" | |
echo "Marker from GitLab branches: $NEW_MARKER" | |
if [[ -f "$TARGET_DIR/$MARKER_FILE" ]]; then | |
OLD_MARKER=$(cat "$TARGET_DIR/$MARKER_FILE") | |
echo "Marker file: $TARGET_DIR/$MARKER_FILE => $OLD_MARKER" | |
else | |
OLD_MARKER="nope-sorry-go-fetch-me-some-firmware-now-pls" | |
echo "Marker file does not exist, will fetch firmware." | |
fi | |
if [[ "$NEW_MARKER" == "$OLD_MARKER" ]]; then | |
echo "No new firmware to fetch, bye!" | |
# This is important for CI_Loop: | |
exit 1 | |
else | |
echo "Marker updated, processing new firmware..." | |
fi | |
# --- | |
# Okay, we've got new firmware to fetch. Make us a workspace: | |
TEMP_FETCH_DIR=$(mktemp --directory) | |
pushd "$TEMP_FETCH_DIR" | |
# Clone just the required files from intel-staging: | |
git clone --depth 1 --no-checkout --filter=blob:none --branch=intel-staging "$DRM_FW_REPO" intel-staging | |
git -C intel-staging sparse-checkout set --no-cone "i915" "xe" | |
git -C intel-staging checkout | |
# Clone just the required files from intel-for-ci: | |
git clone --depth 1 --no-checkout --filter=blob:none --branch=intel-for-ci "$DRM_FW_REPO" intel-for-ci | |
git -C intel-for-ci sparse-checkout set --no-cone "intel-ci" | |
git -C intel-for-ci checkout | |
# Create the firmware package: | |
mkdir target | |
cp -r intel-staging/i915 intel-staging/xe target/ | |
cp -r intel-for-ci/intel-ci target/ | |
tar -C target -zcvf firmware.tar.gz i915 xe intel-ci | |
# And deploy it: | |
if [[ ! -d "$TARGET_DIR" ]]; then | |
mkdir -p "$TARGET_DIR" | |
fi | |
mv firmware.tar.gz "$TARGET_DIR/$TARGET_FILE" | |
echo -n "$NEW_MARKER" | tee "$TARGET_DIR/$MARKER_FILE" | |
$JENKINS_SSH build Artifactory_Push -p DEPLOY_NAME=FW_$BUILD_ID | |
# Clean up: | |
popd | |
rm -rf "$TEMP_FETCH_DIR" | |
JENKINS_SSH="ssh localhost -p 8022" | |
$JENKINS_SSH build CI_Loop | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set +x | |
. /etc/profile.d/proxy.sh | |
FILE=latest_Firmware | |
cd /opt/linux-firmware/ | |
SINCE=$(cat $FILE 2>/dev/null) | |
# initialize SINCE if none | |
if test -z "$SINCE"; then | |
SINCE=$(date +"%Y-%m-%dT%H:%M:%S") | |
echo $SINCE >$FILE | |
exit 1 | |
fi | |
TMP=`mktemp` | |
/opt/scripts/tools/patchwork_check.py -s "$SINCE" -e pull-request-new -p intel-gfx | tr -d '\r' > $TMP | |
cat $TMP | |
if ! test -s "$TMP"; then | |
echo "ERROR: No new since" | |
exit 1 | |
fi | |
set `tail -1 $TMP` | |
SINCE=$1 | |
echo NEW SINCE: $SINCE | |
if test -z "$2"; then | |
echo "No new pull request events, quitting" | |
rm $TMP; exit 1 | |
fi | |
# We got something here. Prevent loop by marking timestamp early | |
echo $SINCE >$FILE | |
set `head -1 $TMP` | |
URL=$3 | |
BRANCH=$4 | |
if test -z "$BRANCH"; then BRANCH=master; fi | |
echo URL $URL BRANCH $BRANCH | |
REMOTE=`git remote -v | tr "\t" " " | grep " $URL (fetch)$" | cut -d" " -f1` | |
if test -z $REMOTE; then | |
echo "Not a recognized repository, quitting" | |
rm $TMP; exit 1 | |
fi | |
echo Recognized repository $REMOTE | |
# git:// to freedesktop.org is flaky from Intel network | |
[ "$REMOTE" == "freedesktop.org" ] && REMOTE="s_freedesktop.org" | |
git fetch $REMOTE | |
# What are we checking out? | |
if git rev-parse --quiet --verify "$BRANCH^{commit}"; then | |
# PR contained a plain commit hash | |
git checkout -f $BRANCH | |
else | |
# PR contained a new branch | |
git checkout -f $REMOTE/$BRANCH | |
fi | |
GITDIR=/opt/linux-firmware | |
TARDIR=/opt/archive/scripts | |
cp -a $GITDIR/i915/* $TARDIR/linux-firmware/i915/ | |
cp -a $GITDIR/xe/* $TARDIR/linux-firmware/xe/ | |
tar -C $TARDIR/linux-firmware/ --exclude .git -zcvf $TARDIR/linux-firmware-new.tar.gz i915 xe | |
mv $TARDIR/linux-firmware-new.tar.gz $TARDIR/linux-firmware.tar.gz | |
$JENKINS_SSH build Artifactory_Push -p DEPLOY_NAME=FW_$BUILD_ID | |
rm $TMP | |
JENKINS_SSH="ssh localhost -p 8022" | |
$JENKINS_SSH build CI_Loop | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment