aosp-build icon indicating copy to clipboard operation
aosp-build copied to clipboard

make manifest will fail if a project revision is a hash instead of a tag

Open ubergeek77 opened this issue 5 years ago • 0 comments

I have populated my config.yml with the latest correct tags/hashes/etc for crosshatch:

build_kernel: true
...
devices:
  crosshatch:
    kernel_name: crosshatch
    kernel_ref: origin/android-msm-crosshatch-4.9-android10-qpr1
    avb_mode: vbmeta_chained
    build_id: QQ1A.200105.002
    factory_hash: 853405e1c585e2a5c28f8fdf9ea8b2a03a2868eb7cb3137dde5fc6ffa854caf4
    ota_hash: 979a51222f0726c4d6cef293c4cd1a85d653b13cd5bbc13bab4a23b8a75eeb5d
    platform_ref: android-10.0.0_r21

The kernel reference I used matches the kernel reference Google used when building the kernel for this factory image (see footnote below on how I determined this).

However, when running make DEVICE=crosshatch manifest (and modifying the Makefile to not run config due to another issue), the manifest script will fail, because it doesn't know what to do if the "reference=" field in a manifest xml is a hash.

Here is the relevant bit from the manifest file the command tries to pull for the kernel, against that tag:

  <project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" revision="pie-release" clone-depth="1" />
  <project path="prebuilts-master/clang/host/linux-x86" name="platform/prebuilts/clang/host/linux-x86" revision="4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11" clone-depth="1" groups="partner" />
  <project path="prebuilts-master/misc" name="platform/prebuilts/misc" revision="pie-release" clone-depth="1" />

As you can see, the second project has a reference that is a hash.

Here is the error output from manifest:

Locking Project: "platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
Locking Project: "platform/prebuilts/clang/host/linux-x86"
Traceback (most recent call last):
  File "/home/build/scripts/manifest", line 189, in <module>
    kernel_manifest = AndroidManifest(ref, repo).pretty_print()
  File "/home/build/scripts/manifest", line 42, in __init__
    self._lock()
  File "/home/build/scripts/manifest", line 144, in _lock
    project.attrib['revision'] = remote_refs[revision]
KeyError: 'refs/heads/4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11'
Makefile:102: recipe for target 'manifest' failed
make: *** [manifest] Error 1

I suppose it's more of a quick fix, but you could replace manifest:144 with the following to catch the error:

 try:
    project.attrib['revision'] = remote_refs[revision]
except KeyError:
    project.attrib['revision'] = revision

This will allow the script to continue.

EDIT:

Unfortunately, the solution isn't so simple. This will allow the script to continue, but if you try to repo fetch with the manifest that gets generated as a result, this happens:

Fetching projects:  90% (9/10) kernel/msm-modules/wlan-fw-apifatal: Couldn't find remote ref refs/heads/4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11
fatal: Couldn't find remote ref refs/heads/4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11
error: Cannot fetch platform/prebuilts/clang/host/linux-x86 from https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
Fetching projects: 100% (10/10), done.
error: Cannot checkout platform/prebuilts/clang/host/linux-x86: ManifestInvalidRevisionError: revision refs/heads/4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11 in platform/prebuilts/clang/host/linux-x86 not found
error: in `sync --current-branch --no-tags --force-sync --no-clone-bundle --jobs 12`: revision refs/heads/4b1f275e6b3826c86f791ae8c4d5ec3563c2fc11 in platform/prebuilts/clang/host/linux-x86 not found
Makefile:29: recipe for target 'fetch' failed

I figured I'd add this extra footnote here, since it shows why I chose that kernel reference/tag, and the method used here may help in finding a way to auto-detect the kernel reference when running config. Here is a quick bash snippet:

# From https://source.android.com/setup/start/build-numbers
BRANCH=android-10.0.0_r21

# Download the kernel binary for ${BRANCH}, and find the string that indicates the git commit was built with
curl https://android.googlesource.com/device/google/crosshatch-kernel/+/refs/tags/${BRANCH}/Image.lz4?format=TEXT | \
base64 --decode | \
lz4cat | \
grep -a 'Android' | \
grep -a 'Linux version' | \
cut -d ' ' -f3 | \
cut -d'-' -f2 | \
sed 's/^g//g'

# This will output 9f181f6db9d7

# You can also find this string on a real device running android-10.0.0_r21's corresponding factory image (QQ1A.200105.002) by issuing the command uname -a. It will be printed right after -g in the output.

# Visiting that commit ID at https://android.googlesource.com/kernel/msm/+log/9f181f6db9d7 will show you that this commit belongs to the tags android-msm-crosshatch-4.9-android10 and android-msm-crosshatch-4.9-android10-qpr1, among others. However, https://android.googlesource.com/kernel/manifest/+refs only has a tag for the latter (-qpr1 is required), so the latter one has to be used.

ubergeek77 avatar Jan 14 '20 08:01 ubergeek77