Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edk2: fetch submodules manually for 202408 #353800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 6, 2024

  1. edk2: fetch submodules manually for 202408

    Original submodule sources are no longer available, so the submodules are fetched manually,
    with unavailable sources replaced by mirrors. (tianocore/edk2#6402)
    
    fix NixOS#353769
    
    submodules-202408.nix was generated using the following script.
    
        #!/usr/bin/env nix-shell
        #!nix-shell -i bash -p coreutils git jq nixfmt-rfc-style nix-prefetch-git
    
        set -eu -o pipefail
    
        version=202408
        git_remote=origin
        git_repo=https://github.com/tianocore/edk2
        git_rev=refs/tags/edk2-stable$version
    
        tmp=$(mktemp -d)
        trap 'rm -rf -- "$tmp"' EXIT
    
        git_dir=$tmp/git
        git init --bare "$git_dir"
        git -C "$git_dir" remote add "$git_remote" "$git_repo"
        git -C "$git_dir" fetch --depth 1 --filter=blob:none "$git_remote" "$git_rev:$git_rev"
        git -C "$git_dir" show "$git_rev:.gitmodules" > "$tmp/submodules"
    
        submodules="{}"
    
        for module in $(git config get -f "$tmp/submodules" --all \
                            --name-only --show-names --regexp '^submodule\.[^.]+\.path$'); do
    
            module=${module#submodule.}
            module=${module%.path}
    
            module_path=$(git config get -f "$tmp/submodules" "submodule.$module.path")
            module_url=$(git config get -f "$tmp/submodules" "submodule.$module.url")
            module_rev=$(git -C "$git_dir" ls-tree --object-only "$git_rev" "$module_path")
    
            # tianocore/edk2#6402
            case $module_url in
                https://github.com/Zeex/subhook.git)
                    module_url=https://github.com/tianocore/edk2-subhook.git;;
            esac
    
            module_repo=${module_url#https://github.com/}
            module_repo=${module_repo%.git}
            module_owner=${module_repo%/*}
            module_repo=${module_repo#*/}
    
            module_hash=$(nix-prefetch-git --fetch-submodules "$module_url" "$module_rev" | jq -r .hash)
    
            submodules=$(jq --argjson submodules "$submodules" \
                            --arg path "$module_path" \
                            --arg owner "$module_owner" \
                            --arg repo "$module_repo" \
                            --arg rev "$module_rev" \
                            --arg hash "$module_hash" \
                            -n '$submodules + {$path: {"owner": $owner, "repo": $repo, "rev": $rev, "hash": $hash}}')
        done
    
        echo "$submodules" > "$tmp/result.json"
        nix eval --impure --expr "builtins.fromJSON (builtins.readFile \"$tmp/result.json\")" | \
            nixfmt > submodules-$version.nix
    mjoerg committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    f0a7086 View commit details
    Browse the repository at this point in the history