Cross compile to aarch64? -- used to work

I am trying to cross compile from x86_64 to aarch64. I can build a x86_64 package, but when I attempt an aarch64 the build crashes. I am using electron and the crash is around the time that the ‘zypak-wrapper’ script is being used.

Some time ago, maybe months, I could succsesfully compile my app for aarch64.

I have checked and I have the aarch64 flatpak packages installed for my app.

My biggest concern is that flatpak does not support aarch64 cross compiling any more.

Below is some terminal output.

    $ flatpak --supported-arches
    x86_64
    i386

    $ flatpak install org.freedesktop.Sdk.Extension.node14/aarch64/21.08
    Looking for matches…
    Skipping: org.freedesktop.Sdk.Extension.node14/aarch64/21.08 is already installed

    $ flatpak install org.electronjs.Electron2.BaseApp/aarch64/21.08
    Looking for matches…
    Skipping: org.electronjs.Electron2.BaseApp/aarch64/21.08 is already installed

Note: I can go through all the required flatpak packages and the flatpak program will tell me they are there.

Here is some crash output.

    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! electron@18.1.0 postinstall: `node install.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the electron@18.1.0 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm timing npm Completed in 483509ms

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /run/build/gpt-etc/flatpak-node/npm-cache/_logs/2022-09-15T15_39_46_810Z-debug.log
    Error: module gpt-etc: Child process exited with code 1

and btw, I cannot find the /run/build/ dir for the log on my system.

It never did support cross compilation. At best you can run it with qemu, where the whole build process with be emulated.

does not flatpak builder support an --arch=aarch64 target achitecture?

This is my yaml file. Breifly I could not even build the x86_64 arch. Then I realized that I had edited the node16 to read node14. This really baffled me. Now x86_64 works again. Now when I try to build for aarch64 I get an error, again somewhere around the zypak wrapper. It has something to do with electron-builder in the packaging stage. I then added zypak sources to the yaml file. Still I get the same error. I updated electron-builder to 23.5.1, but the error remains the same.

    app-id: org.theguy.GptEtc
    runtime: org.freedesktop.Platform
    runtime-version: '21.08'
    sdk: org.freedesktop.Sdk
    base: org.electronjs.Electron2.BaseApp
    base-version: '21.08'
    sdk-extensions:
      - org.freedesktop.Sdk.Extension.node16 
    command: run.sh
    separate-locales: false
    finish-args:
      - --share=ipc
      - --socket=x11
      - --socket=pulseaudio
      - --share=network
      - --filesystem=home
      - --filesystem=/tmp/
      - --filesystem=host
      - --filesystem=/var/local:ro 
      - --socket=system-bus
      - --device=dri
      - --filesystem=xdg-config/gtk-3.0:ro 
      - --env=GOOGLE_APPLICATION_CREDENTIALS=/var/local/google-application-credentials.json
      - --env=GPT_ETC_AUTO_FILE=gpt.txt 
      - --env=GPT_ETC_NOT_HANDHELD=true
    build-options:
      append-path: /usr/lib/sdk/node16/bin:/app/main/dist
      cflags: -O2 -g
      cxxflags: -O2 -g
      env:
        NPM_CONFIG_LOGLEVEL: info
    modules:

      - name: zypak
        sources:
          - type: git
            url: https://github.com/refi64/zypak
            commit: 55a60d110301e8dd37b631503c3524ab7baaf7aa

      - name: sox
        buildsystem: autotools
        config-opts: []
        sources: 
          - type: archive
            url: https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2Fsox-14.4.2.tar.gz%2Fdownload&ts=1549545438
            sha256: b45f598643ffbd8e363ff24d61166ccec4836fea6d3888881b8df53e3bb55f6c 

      - name: iputils
        buildsystem: meson 
        config-opts: []
        sources: 
          - type: git 
            url: https://github.com/iputils/iputils.git 
            commit: 309f28518adbe161b5dfd6717f91a3fbe3ab8eab
     
      - name: curl
        buildsystem: cmake
        config-opts: []
        sources: 
          - type: git 
            url: https://github.com/curl/curl.git 
            commit: 5e9a703cf211a892e9b74ec11129994dcc241623 
     
      - name: gpt-etc
        buildsystem: simple
        build-options:
          env:
            electron_config_cache: /run/build/gpt-etc/npm-cache
            XDG_CACHE_HOME: /run/build/gpt-etc/flatpak-node/cache
            npm_config_cache: /run/build/gpt-etc/flatpak-node/npm-cache
            npm_config_nodedir: /usr/lib/sdk/node16  
            npm_config_offline: 'true'
        subdir: main
        sources:
          - type: dir
            path: ..
            dest: main
          - generated-sources.json
          # Wrapper to launch the app
          - type: script
            dest-filename: run.sh
            commands:
              - zypak-wrapper.sh /app/main/gpt-etc "$@"
        build-commands:
          # Install npm dependencies
          #- cat /app/bin/zypak-wrapper.sh 
          - jq '.scripts.start="electron --disable-gpu ."' <<<$(<package.json) > package.json

          #- pwd
          - install -Dm755 integration/org.theguy.GptEtc.desktop /app/share/applications/org.theguy.GptEtc.desktop
          - install -Dm755 integration/*.png /app/share/icons/hicolor/128x128/apps/org.theguy.GptEtc.png

          - npm install --offline
          # Build the app; in this example the `dist` script
          # in package.json runs electron-builder
          - |
            . ../flatpak-node/electron-builder-arch-args.sh
            npm run dist -- $ELECTRON_BUILDER_ARCH_ARGS   --linux --dir 
          # Bundle app and dependencies
          - 'cp -a dist/linux*unpacked /app/main'
          - 'install -Dm755 -t /app/bin/ ../run.sh'

This is the actual error.

Running: cp -a dist/linux*unpacked /app/main
cp: target ‘/app/main’ is not a directory
Error: module gpt-etc: Child process exited with code 1

Well, if dist/linux*unpacked resolve into more than one file/directory than /app/main must exist prior to it.

I think you are right. maybe special cp commands need to be written for the right content to end up in /app/main too.