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

Conversation

mjoerg
Copy link
Contributor

@mjoerg mjoerg commented Nov 5, 2024

Description of changes

Original submodule sources are no longer available, so the submodules are fetched manually,
with unavailable sources replaced by mirrors. (tianocore/edk2#6402)

fix #353769

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review


x86_64-linux

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 0 This PR does not cause any packages to rebuild labels Nov 5, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 0 This PR does not cause any packages to rebuild
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure: edk2
1 participant