kdrag0n/adevtool

Generate-prep/all throws various errors depending by node version

Giovix92 opened this issue · 7 comments

Hello there, I'm running Ubuntu 20.04 with npm installed through nvm-sh.
While using generate-prep (or generate-all), the error vary depending on node version:

Command used: adevtool generate-prep -s ~/dump/denniz_a16/ -b rp1a.200720.011 denniz.yaml

Dump used: https://gitlab.com/Giovix92/denniz_dump

Tinkered a bit with nvm, and found out the errors are different depending by node version:

  • Node v12.22.0 (suggested): SyntaxError: Unexpected token '?'
  • Node v16.13.2 (lts/Gallium): ReferenceError: structuredClone is not defined
  • Node v17.x.0: [...] Extracting properties ⠋ TypeError: Cannot read properties of undefined (reading 'split')

YAML used:

device:
  name: denniz
  vendor: oneplus

platform:
  product_makefile: device/oneplus/denniz/lineage_denniz.mk

  namespaces:
    - hardware/oplus

generate:
  files: true
  props: true
  overlays: true
  vintf: true

Does that depend by my system config, my dump or by node/node package itself?

Thank you in advance!

The first two errors are caused by incompatible Node.js versions, but the last one looks like a bug. Please run it with export DEBUG='*' to get a stack trace.

The first two errors are caused by incompatible Node.js versions, but the last one looks like a bug. Please run it with export DEBUG='*' to get a stack trace.

Sure thing. Here you go:

giovix92@server:~/LineageOS-18.1$ export DEBUG='*'; adevtool generate-prep -s ~/dump/denniz_a16/ -b rp1a.200720.011 denniz.yaml
  @oclif/config reading core plugin /usr/local/lib/node_modules/adevtool +0ms
  @oclif/config loadJSON /usr/local/lib/node_modules/adevtool/package.json +0ms
  @oclif/config loadJSON /usr/local/lib/node_modules/adevtool/oclif.manifest.json +3ms
  @oclif/config:adevtool using manifest from /usr/local/lib/node_modules/adevtool/oclif.manifest.json +0ms
  @oclif/config reading user plugins pjson /home/giovix92/.local/share/adevtool/package.json +0ms
  @oclif/config loadJSON /home/giovix92/.local/share/adevtool/package.json +2ms
  @oclif/config loading plugins [ '@oclif/plugin-help' ] +0ms
  @oclif/config reading core plugin /usr/local/lib/node_modules/adevtool/node_modules/@oclif/plugin-help +0ms
  @oclif/config loadJSON /usr/local/lib/node_modules/adevtool/node_modules/@oclif/plugin-help/package.json +3ms
  @oclif/config loadJSON /usr/local/lib/node_modules/adevtool/node_modules/@oclif/plugin-help/oclif.manifest.json +1ms
  @oclif/config:@oclif/plugin-help using manifest from /usr/local/lib/node_modules/adevtool/node_modules/@oclif/plugin-help/oclif.manifest.json +0ms
  @oclif/config config done +4ms
  @oclif/config start init hook +1ms
  @oclif/config init hook done +0ms
  adevtool init version: @oclif/command@1.8.16 argv: [ 'generate-prep', '-s', '/home/giovix92/dump/denniz_a16/', '-b', 'rp1a.200720.011', 'denniz.yaml' ] +0ms
  @oclif/config runCommand generate-prep [ '-s', '/home/giovix92/dump/denniz_a16/', '-b', 'rp1a.200720.011', 'denniz.yaml' ] +4ms
  @oclif/config:adevtool require /usr/local/lib/node_modules/adevtool/lib/commands/generate-prep.js +13ms
  @oclif/config start prerun hook +87ms
  @oclif/config prerun hook done +0ms
  adevtool:generate-prep init version: @oclif/command@1.8.16 argv: [ '-s', '/home/giovix92/dump/denniz_a16/', '-b', 'rp1a.200720.011', 'denniz.yaml' ] +0ms
Extracting stock system source   /home/giovix92/dump/denniz_a16/
Enumerating files   odm
Copying files   
Extracting properties ⠋ TypeError: Cannot read properties of undefined (reading 'split')
    at extractProps (/usr/local/lib/node_modules/adevtool/lib/frontend/generate.js:113:86)
    at async withSpinner (/usr/local/lib/node_modules/adevtool/lib/util/cli.js:24:15)
    at async /usr/local/lib/node_modules/adevtool/lib/commands/generate-prep.js:33:23
    at async withTempDir (/usr/local/lib/node_modules/adevtool/lib/util/fs.js:46:16)
    at async /usr/local/lib/node_modules/adevtool/lib/commands/generate-prep.js:45:13
    at async forEachDevice (/usr/local/lib/node_modules/adevtool/lib/frontend/devices.js:21:13)
    at async GeneratePrep.run (/usr/local/lib/node_modules/adevtool/lib/commands/generate-prep.js:44:9)
    at async GeneratePrep._run (/usr/local/lib/node_modules/adevtool/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/usr/local/lib/node_modules/adevtool/node_modules/@oclif/config/lib/config.js:173:24)
    at async Main.run (/usr/local/lib/node_modules/adevtool/node_modules/@oclif/command/lib/main.js:27:9)

nvm outputs, just to be sure the entire env is 'good':

giovix92@server:~/LineageOS-18.1$ nvm which node   
/home/giovix92/.nvm/versions/node/v17.4.0/bin/node
giovix92@server:~/LineageOS-18.1$ nvm version
v17.4.0
Bicet commented

Did you ever find a solution?

@Bicet nope.

I can confirm this bug.
It was annoying as fuck to pinpoint.
I tried to install this program with yarn (I didn't know this build system before).

Since I was running Ubuntu 20.04, I did "sudo apt install yarn".
But it seems the yarn command supported by 20.04 was outdated (was complaining about "install" command not known) so I did update yarn with:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt dist-upgrade

I then did "yarn install" and it complained that node was not recent (was 10.19 or something from ubuntu repos) and asked for node >= 12. So I did install the current Node LTS (16.XX).

So I was able to "yarn install", but after that, I didn't get the "generate-all" command when running adevtool. Other commands are ok.

It was linked to this "structuredClone" error that @Giovix92 encountered. So I did update to node 17.XX, and this time, it was ok...

...until I encounter the next error, very similar to @Giovix92:

Extracting properties ⠙ TypeError: Cannot read properties of undefined (reading 'get')

This error comes from generate.ts at line 172.

EDIT: it seems that product.img wasn't selected for the simg2img pass, so I did it manually and named it product.img.raw like other partitions and now the code executes a little further, until I encounter another error.
Here it is:

Extracting overlays ⠸ /tmp/adevtool-13599859/sysroot/sunfish-sp2a.220305.012/product/overlay/framework-res__auto_generated_rro_product.apkTypeError: Cannot read properties of undefined (reading 'entries')
    at filterValues (/mnt/storage/aosp/vendor/adevtool/src/blobs/overlays.ts:329:38)

@ConradGyllenhaal
Did you solve the error with the framework-res__ file? i've got the same error running node 18.0

@koen01 I finally tried the GrapheneOS fork and got the same error.

But I've been told that adevtool was "never used for sunfish and march update".

So I simply tried with april update and magically, didn't get this error anymore.

Makes no sense to me that adevtool throw errors on march OTA but not on april OTA. Like if the OTA format did change between march and april?

If you can target a more recent OTA file like april, give it a try maybe?