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

Commit 002d342c authored by Jackeagle's avatar Jackeagle
Browse files

Merge branch '3664-fix-regen-manifest-issue' into 'master'

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

See merge request e/os/releases!357
parents 9673645a bfee0dc8
Loading
Loading
Loading
Loading
+52 −9
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
which xmlstarlet || (apt-get update && apt-get install -y xmlstarlet)

create_branch (){
    git checkout -b $1
@@ -70,6 +71,9 @@ then
else
    new_version_without_android=$NEW_TAG
    new_version=$NEW_TAG-$current_version
    # Extract major.minor version for branch name (e.g., v3.1.4 -> v3.1)
    version_branch_name=$(echo $NEW_TAG | sed 's/\(v[0-9]*\.[0-9]*\).*/\1/')
    version_branch=$version_branch_name-$current_version
fi


@@ -133,18 +137,57 @@ then


else
    sync_main_manifest $new_version
    # For REGENERATE_MANIFEST=false, sync from version branch (e.g., v3.1-a14) not tag branch
    if [ -n "$NEW_TAG" ]; then
        sync_main_manifest $version_branch
    else
        sync_main_manifest $CI_COMMIT_REF_NAME
    fi
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)"
    
    # Generate full manifest from repo sync (run from synced repo directory)
    cd "$SRC_DIR/$CI_COMMIT_REF_NAME"
    repo manifest -r -o $CI_PROJECT_DIR/full_manifest.xml
    
    cd $CI_PROJECT_DIR
    # Save current manifest as backup
    cp default.xml current_manifest_backup.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)
    cd "$SRC_DIR/$CI_COMMIT_REF_NAME"
    repo manifest -r -o $CI_PROJECT_DIR/default.xml
    cd $CI_PROJECT_DIR
fi
git add .
git commit -m "Update $CI_COMMIT_REF_NAME manifest" || true