Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed780d57 authored by Jackeagle's avatar Jackeagle
Browse files

Fix manifest generation to preserve non-e repo revisions when REGENERATE_MANIFEST=false

When REGENERATE_MANIFEST=false, the pipeline should only update e/e-priv repository revisions
and preserve existing revisions for LineageOS/AOSP repos. The previous logic using git diff
with ignore patterns was unreliable and caused unintended updates to non-e repositories.

The fix implements proper XML-based selective manifest generation:
- Backs up current manifest to preserve existing non-e repo revisions
- Generates full manifest from repo sync to get latest e/e-priv revisions
- Uses xmlstarlet to selectively update only e/e-priv projects in the backup manifest
- Results in a manifest with updated e/e-priv repos and unchanged non-e repos
parent 9673645a
Loading
Loading
Loading
Loading
+40 −7
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ REPO="git@gitlab.e.foundation:e/os/android.git"



apt install xmlstarlet
# Install xmlstarlet if not available
apt install -y xmlstarlet

create_branch (){
    git checkout -b $1
@@ -136,15 +137,47 @@ else
    sync_main_manifest $new_version
fi

repo manifest -r -o $CI_PROJECT_DIR/default.xml
cd $CI_PROJECT_DIR
# if not beta, apply only changes on eOS projects

if [ "$REGENERATE_MANIFEST" != "true" ]
then
    git diff --ignore-matching-lines ".*LineageOS.*" --ignore-matching-lines ".*aosp.*" > file.patch
    git checkout default.xml
    git apply file.patch
    rm file.patch
    echo "REGENERATE_MANIFEST=false: Creating selective manifest (only updating e/e-priv repos)"
    
    # Save current manifest as backup
    cp default.xml current_manifest_backup.xml
    
    # Generate full manifest from repo sync
    repo manifest -r -o full_manifest.xml
    
    # Create selective manifest by merging:
    # - e/e-priv repos from full manifest (updated revisions)
    # - all other repos from current manifest (preserve existing revisions)
    
    # Start with current manifest
    cp current_manifest_backup.xml selective_manifest.xml
    
    # Extract e and e-priv projects from full manifest and update them in selective manifest
    xmlstarlet sel -t -m "//project[@remote='e' or @remote='e-priv']" \
        -v "concat(@name,'|',@path,'|',@remote,'|',@revision)" -n full_manifest.xml | while IFS='|' read -r name path remote revision; do
        
        echo "Updating e/e-priv project: $name to revision $revision"
        
        # Update revision for this project in selective manifest
        xmlstarlet ed --inplace \
            -u "//project[@name='$name']/@revision" \
            -v "$revision" selective_manifest.xml
    done
    
    # Use the selective manifest
    mv selective_manifest.xml default.xml
    
    # Cleanup temporary files
    rm -f current_manifest_backup.xml full_manifest.xml
    
else
    echo "REGENERATE_MANIFEST=true: Using full manifest (updating all repos)"
    # Generate full manifest from repo sync (original behavior)
    repo manifest -r -o $CI_PROJECT_DIR/default.xml
fi
git add .
git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true