| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- name: 'Download Kernel Repository'
- description: 'Initialize and sync Android kernel source repository'
- inputs:
- android_version:
- description: 'Android version (e.g., android14)'
- required: true
- kernel_version:
- description: 'Kernel version (e.g., 5.15, 6.1)'
- required: true
- os_patch_level:
- description: 'OS patch level (e.g., 2024-01)'
- required: true
- use_repo:
- description: 'Use repo for downloading kernel source'
- required: false
- outputs:
- deprecated_branch:
- description: 'Whether the branch is deprecated'
- value: ${{ steps.sync.outputs.deprecated }}
- runs:
- using: composite
- steps:
- - name: Initialize and Sync Kernel Repository
- if: ${{ inputs.use_repo == 'true' }}
- id: sync
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -e
- FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
- init_repo() {
- repo init -u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --depth=1 --partial-clone
- REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
- DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
- DEPRECATED=false
- if grep -q deprecated <<< "$REMOTE_BRANCH"; then
- sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" "$DEFAULT_MANIFEST_PATH"
- echo "⚠ Note: Branch ${FORMATTED_BRANCH} is considered deprecated."
- DEPRECATED=true
- fi
- echo "deprecated=$DEPRECATED" >> $GITHUB_OUTPUT
- }
- init_repo
- MAX_RETRIES=3
- RETRY_DELAY_SHORT=15
- SYNC_TIMEOUT="10m"
- attempt=1
- while [ $attempt -le $MAX_RETRIES ]; do
- echo "Attempt $attempt/$MAX_RETRIES: repo sync (timeout $SYNC_TIMEOUT)..."
- if timeout $SYNC_TIMEOUT repo sync -c -j16 --fail-fast --no-tags --force-sync --no-clone-bundle --optimized-fetch --retry-fetches=3; then
- echo "repo sync succeeded on attempt $attempt."
- break
- fi
- rc=$?
- if [ $rc -eq 124 ]; then
- echo "repo sync timed out after $SYNC_TIMEOUT."
- else
- echo "repo sync failed with exit code $rc."
- fi
- if [ $attempt -lt $MAX_RETRIES ]; then
- echo "Cleaning workspace and retrying after ${RETRY_DELAY_SHORT}s..."
- rm -rf .repo || true
- sleep $RETRY_DELAY_SHORT
- init_repo
- else
- echo "All $MAX_RETRIES attempts failed." >&2
- exit $rc
- fi
- attempt=$((attempt+1))
- done
- - name: Download manifest.xml for branch (with deprecated fallback)
- shell: bash
- if: ${{ inputs.use_repo != 'true' }}
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -e
- FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
- MAIN_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
- DEPRECATED_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/deprecated/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
- echo "Trying to fetch manifest from $MAIN_MANIFEST_URL"
- if curl -fsSL "$MAIN_MANIFEST_URL" | base64 -d > manifest.xml; then
- echo "Fetched manifest from $MAIN_MANIFEST_URL"
- else
- echo "Main manifest fetch failed, trying deprecated branch."
- echo "⚠ Note: Branch common-${FORMATTED_BRANCH} is considered deprecated."
- if curl -fsSL "$DEPRECATED_MANIFEST_URL" | base64 -d > manifest.xml; then
- echo "Fetched manifest from $DEPRECATED_MANIFEST_URL"
- else
- echo "ERROR: Neither main nor deprecated branch exists for $FORMATTED_BRANCH" >&2
- exit 22
- fi
- fi
- - name: Debug Show manifest.xml
- shell: bash
- if: ${{ inputs.use_repo != 'true' }}
- working-directory: ${{ github.workspace }}/kernel
- run: cat manifest.xml
-
- - name: Fast Parallel Archive Download
- shell: bash
- if: ${{ inputs.use_repo != 'true' }}
- working-directory: ${{ github.workspace }}/kernel
- run: |
- python "${{ github.workspace }}/.github/actions/download-kernel/fast_parallel_download.py"
|