Need an assist - override-build for a new snap

I’m working on a new snap and attempting override-build but I’m doing something wrong - this is my first attempt in doing things this way. The build keeps failing :frowning: . I’ve been looking for documentation and through forum posts and can’t find anything like what I’m seeing.

Here’s my snapcraft.yaml:

name: tunerstudio
version: 3.1.04
summary: TunerStudio MS - an advanced MegaSquirt Tuning Software
description: |
  TunerStudio MS, the most most advanced and refined MegaSquirt Tuning software available.
  The registered and Lite! editions are the same installer.
base: core18
grade: stable
confinement: strict

architectures:
  - build-on: amd64

apps:
  tunerstudio:
    extensions: [gnome-3-28]
    command: /bin/sh $SNAP/usr/bin/TunerStudioMS/TunerStudio.sh
    plugs:
      - network
      - home
      - raw-usb
      - removable-media
      - x11
      - unity7
      - opengl
      - wayland
      - desktop
      - desktop-legacy
      - browser-support
      
parts:
  tunerstudio:
    source: https://www.efianalytics.com/TunerStudio/download/TunerStudioMS_v3.1.04.tar.gz
    source-type: tar
    plugin: nil
    override-build: |
      set -xe
      wget -O TunerStudio.tar.gz https://www.efianalytics.com/TunerStudio/download/TunerStudioMS_v3.1.04.tar.gz
      tar xvzf TunerStudio.tar.gz
      mkdir -p "$SNAPCRAFT_PART_INSTALL"/usr/bin/TunerStudioMS/
      mv TunerStudioMS/* "$SNAPCRAFT_PART_INSTALL"/usr/bin/TunerStudioMS/
      
    build-packages:
      - openjdk-11-jre-headless
      - wget
      - tar
      
    stage-packages:
      - openjdk-11-jre-headless

Here’s the error I’m seeing when attempting to build:

+ mkdir -p /build/tunerstudio/parts/tunerstudio/install/usr/bin/TunerStudioMS/
+ mv TunerStudioMS/Dash TunerStudioMS/License.rtf TunerStudioMS/License.txt TunerStudioMS/LogViewer.properties TunerStudioMS/Projects TunerStudioMS/README.TXT TunerStudioMS/Staging.class TunerStudioMS/TSicon.ico TunerStudioMS/TuneView TunerStudioMS/TunerStudio.properties TunerStudioMS/TunerStudio.sh TunerStudioMS/TunerStudioMS.jar TunerStudioMS/config TunerStudioMS/content TunerStudioMS/help TunerStudioMS/inc TunerStudioMS/lib TunerStudioMS/librxtxSerial.jnilib TunerStudioMS/plugins /build/tunerstudio/parts/tunerstudio/install/usr/bin/TunerStudioMS/
Staging gnome-3-28-extension 
Staging tunerstudio 
Priming gnome-3-28-extension 
Priming tunerstudio 
Unable to determine library dependencies for '/build/tunerstudio/prime/usr/bin/TunerStudioMS/lib/librxtxSerial.so'

There shouldn’t be any “dependency” issue for librxtxSerial.so as the lib in built into the software and the software is just java. I can extract the tarball and run it “as-is” using my terminal. So, I’m confused as to what’s happening when the snap is being built and just need some pointers.

  • Am I using the wrong syntax with "$SNAPCRAFT_PART_INSTALL"?
  • Should I be using a different PART?
  • Is it the desktop extension that’s causing the issue? ← Not sure that makes a difference…

Thanks in advance.

are you sure it is an error ? that should just be a warning and the build should still finish … statically built bnaries or foreign arch binaries usually expose this and it is normally non-fatal …

1 Like

Let me retry building - thanks again @ogra

Well, now I’m seeing this:

Priming tunerstudio 
Unable to determine library dependencies for '/build/tunerstudio/prime/usr/bin/TunerStudioMS/lib/librxtxSerial.so'
Failed to generate snap metadata: The specified command '/bin/sh $SNAP/usr/bin/TunerStudioMS/TunerStudio.sh' defined in the app 'tunerstudio' does not match the pattern expected by snapd.
The command must consist only of alphanumeric characters, spaces, and the following special characters: / . _ # : $ -
Build failed

So, I added librxtx-java to build & stage but as you can see, I’m still seeing that error, plus the metadata error - never seen that before. What’s odd, is that when run locally, no errors are thrown by the software for librxtx and I just checked to see if it was installed on my machine, it’s not.

I’m doing something wrong but I’m not sure what. Building snaps is like driving a school bus from the back seat with wet noodles, ya know? :stuck_out_tongue:

try turning it to:

command: usr/bin/TunerStudioMS/TunerStudio.sh

@ogra okay, I’ll try that.

However, quick update: Just commented out: extensions: [gnome-3-28] and the build successfully completed.

So, now the snap isn’t seeing java.

tunerstudio 
/snap/tunerstudio/25/usr/bin/TunerStudioMS/TunerStudio.sh: 30: /snap/tunerstudio/25/usr/bin/TunerStudioMS/TunerStudio.sh: java: not found

Do I need to set that up during the override-build?

Sorry, I’m all over the place and I really appreciate your help here. I think it’s close to being right.

you might need to set JAVA_HOME in an environment stanza …
like:

    environment:
      JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-$SNAP_ARCH
      PATH: $JAVA_HOME/bin:$PATH
1 Like

Now we’re making progress! It’s working via terminal, albeit not without errors. I’ll do some more research there.

Any idea why removing extensions: [gnome-3-28] allowed the build to complete?

might be that -3-28 ships too old libs … have you tried -3-34 instead ?

1 Like

You can try snapcraft expand-extensions to see how the extension affects your snap(craft.yaml). Maybe that’ll provide a clue?

1 Like

Okay,

I’ve made quite a bit of progress but there’s something driving me nuts. I keep getting failed builds (this is new) because of the following:

Priming gnome-3-34-extension 
The command 'bash' for 'bash $SNAP/launch.sh' was resolved to '/bin/bash'.
The command 'bash $SNAP/launch.sh' has been changed to '/bin/bash $SNAP/launch.sh'.
Failed to generate snap metadata: The specified command '/bin/bash $SNAP/launch.sh' defined in the app 'tunerstudio' does not match the pattern expected by snapd.
The command must consist only of alphanumeric characters, spaces, and the following special characters: / . _ # : $ -
Build failed
  • I’ve tried set -e within the script: NO GO
  • I’ve tried renaming the script to launch.sh: NO GO
  • I’ve tried changing the command to bash launch.sh: NO GO
  • I’ve tried changing the command to sh launch.sh: NO GO
  • I’ve tried changing the command to ./launch.sh: NO GO
  • I’ve tried just using launch as the command: NO GO

What’s driving me bonkers is that this snapcraft.yaml differs very little from mc-installer that @galgalesh helped me with.

Here’s the new version:

name: tunerstudio
version: 3.1.04
summary: TunerStudio MS - an advanced MegaSquirt Tuning Software
description: |
  TunerStudio MS, the most most advanced and refined MegaSquirt Tuning software available.
  The registered and Lite! editions are the same installer.
  After installing, run the following commands:
  
  sudo snap connect tunerstudio:raw-usb
  sudo snap connect tunerstudio:removable-media
  
  This is NOT an officially supported snap from TunerStudio. It is basically an automated
  installer for the software on 64-bit Linux systems running snapd. 
base: core18
grade: stable
confinement: strict

architectures:
  - build-on: amd64

apps:
  tunerstudio: 
    extensions: 
      - gnome-3-34
    command: launch
    plugs:
      - network
      - home
      - raw-usb
      - removable-media
      - opengl
      - browser-support
      - audio-playback
      - pulseaudio  # compatibility with snapd <2.41
          
    environment:      
      JAVA_HOME: $SNAP/usr/lib/jvm/java-1.8.0-openjdk-amd64
      
parts:
  launcher:
    plugin: dump
    source: scripts
    
  tool:
    plugin: nil      
    build-packages:
      - openjdk-8-jre
      - librxtx-java
      - ca-certificates
      - ca-certificates-java
    stage-packages:
      - openjdk-8-jre
      - librxtx-java
      - fontconfig
      - fontconfig-config
      - libfontconfig1
      - x11-xserver-utils
      - curl
      - tar
    
  # https://snapcraft-utils-library.readthedocs.io/en/latest/lib/cleanup.html
  cleanup:
    after:  # Make this part run last; list all your other parts here
      - tool
      - launcher
    plugin: nil
    build-snaps:  # List all content-snaps and base snaps you're using here
      - core18
      - gnome-3-28-1804
    override-prime: |
      set -eux
      for snap in "core18" "gnome-3-28-1804"; do  # List all content-snaps and base snaps you're using here
        cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
      done

Are you guys seeing something I’m not?

Here’s my tunerstudio repo if anyone sees something I’ve missed. Again, thank SO much.

Here’s a link to mc-installer for reference of an existing snap that works just fine - same format.

In case you’re wondering (maybe you’re not) this software is meant for tuning vehicle ECU’s for racing, etc.

is the script executable ?

could there be tabs in your snapcraft.yaml where there should be spaces ?

1 Like

:man_facepalming:

Yeah…I forgot to chmod the file before pushing it.

I have this saying, “the more difficult it becomes to find a problem, the easier the solution actually is”

Now I have a “working” snap - just need to fix some errors with /usr/bin/xprop and I think I saw something about how to do that.

Thanks again!

1 Like