Creating Drafsight snap from deb source

Hey,
I’m trying to create a Draftsight snap from a deb file to use on Solus. Here’s the snapcraft.yaml https://hastebin.com/ibupivijik.sql. At build time snapcraft notifies:
'draftsight-snap/parts/draftsight/build/opt/dassault-systemes/DraftSight/Linux/K2GestureWidget.tx' is a broken symlink pointing outside the snap' .
The link points to /home/builduser/workspace2/BUILD_ARES_2017.2.0_COMPILE_LinuxX64/Argon/_build/linux_release64/draftsight/lib//libK2GestureWidget.so.1. Is there a way around this?

This looks like a serious bug in the deb package and you should talk to upstream to fix it (a deb package should never link to something outside if this “outside” is not provided at least via a package dependency) …

That said … it is unlikely this file exists anywhere on any target system where you would install the deb, so the snap wont need it either and you should be able to remove the symlink via a prepare snippet in your snapcraft.yaml like:

...
source: http://dl-ak.solidworks.com/nonsecure/draftsight/2017SP02/draftSight.deb
source-type: deb
prepare: |
  rm opt/dassault-systemes/DraftSight/Linux/K2GestureWidget.tx
  rm opt/dassault-systemes/DraftSight/Linux/WinOpenGL.txv
stage-packages:
  - libaudio2
...

Looking at your snapcraft.yaml there seem to be other errors as well… the “command:” entry is relative to your snap so drop the $SNAP there … and the .desktop file lives in a different place than the one you point to … you should fix it like below:

...
apps:
  draftsight:
    command: opt/dassault-systemes/DraftSight/Linux/DraftSight
    desktop: opt/dassault-systemes/DraftSight/Resources/dassault-systemes_draftsight.desktop
    plugs:
...

Last but not least, never use xdg-utils in stage-packages if you want xdg-open to work, the core snap (which is the context your snap gets executed in) ships an xdg-open implementation to allow you to open links, when you use xdg-utils in stage packages this will be overwritten and blocked by snapd…

Your snap should build fine with something like:

name: draftsight
version: '2017.2.0.3085'
summary: Powerful 2D CAD software
description: |
  With DraftSight, you can easily create professional CAD drawings. Supported file formats are DWT, DXF and DWG.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  draftsight:
    plugin: dump
    source: http://dl-ak.solidworks.com/nonsecure/draftsight/2017SP02/draftSight.deb
    source-type: deb
    prepare: |
      rm opt/dassault-systemes/DraftSight/Linux/K2GestureWidget.tx
      rm opt/dassault-systemes/DraftSight/Linux/WinOpenGL.txv
    stage-packages:
      - libaudio2

apps:
  draftsight:
    command: opt/dassault-systemes/DraftSight/Linux/DraftSight
    desktop: opt/dassault-systemes/DraftSight/Resources/dassault-systemes_draftsight.desktop
    plugs:
      - home
      - mount-observe
      - network
      - pulseaudio
      - x11

All in all you might want to use a snapcraft desktop part though, i guess it will not start properly without this …

Well, on Ubuntu, getting it to work outside of Ubuntu is still WIP? :stuck_out_tongue: But yeah, people are just gonna have to wait for that…

indeed, but staging xdg-utils will simply break it completely, no matter what, perhaps snapcraft should stop building packages that stage it and spill an error …

also, perhaps @ikey likes to package snapd-xdg-open in solus as an interim solution :wink:

1 Like

Fiiine :stuck_out_tongue:

@Ikey you know you love it when we make more work for you! :laughing:

1 Like

Thanks guys. I got the snap to build and I think I’m pretty close to getting it work. I added

after:
      - desktop-qt5
    stage-packages:
      - libaudio2
      - libqt5gui5

and

command: desktop-launch opt/dassault-systemes/DraftSight/Linux/DraftSight

but when I try to run the snap I get following message

/snap/draftsight/x5/bin/desktop-launch: line 289: /home/user/snaps/draftsight-snap/opt/dassault-systemes/DraftSight/Linux/DraftSight: No such file or directory

I guess there’s a very simple solution to this? :slight_smile:

hmm, seems something does “cd $HOME” … try adding $SNAP back to the line …

how did you get on with this snap conversion @vkivela? Draftsight is the best 2D CAD package around and it would be great having it running on more distros! Will put a bump on the Solus dev package request site too :slight_smile:

Hey, pretty much hit a wall and don’t have time to finish it. I would appreciate if someone could continue with it :slight_smile: Here’s a hastebin link for the snapcraft.yaml. Link for Solus phabricator task.