Install existing deb file as part of snap installation


#1

Hi

i have an app which i already created a deb file for it.
now i try to write down a snapcraft.yml file and add this deb file as a ‘snap part’

the part looks like this:

my-service:
    override-pull: |
      aws s3 cp s3://XXXX/my.deb ./
    source: ./my.deb
    source-type: deb
    plugin: nil
    stage-packages:
      - awscli

A snap file is created successfully, but the problem is that it doesn’t ‘install’ the deb once i install the snap.

i’ve try to add:
override-build:
dpkg -x my.deb $SNAPCRAFT_PART_INSTALL/

which extract the deb parts, but again doesn’t install the deb.

what is the proper way to do it?

Thank you,
Yuval


#2

You’re missing the dump plugin, which just dumps the contents of your deb (or other archive types like .zip, .tar.gz, etc) into your snap tree.
It is not required to install a deb with dpkg because a deb is just an archive.
As an example, here’s how I’ve done it:

parts:
  iota-cooler:
    source: https://github.com/joshirio/iota-cooler/releases/download/v1.1/iotacooler-1.1-x86_64.deb
    plugin: dump
    source-type: deb
    override-build: |
      snapcraftctl build
      #fix icon path
      sed -i 's|Icon=iotacooler|Icon=${SNAP}/usr/share/pixmaps/iotacooler.png|g' $SNAPCRAFT_PART_INSTALL/usr/share/applications/iotacooler.desktop
    stage-packages:
      - dbus
    after: [desktop-qt5] 

Here’s the full example snapcraft.yaml


#3

Hi joshirio,

does the use of plugin: dump, means that while i install my .snap file, the deb file will be installed as well?
if i understood properly, it will just dump the deb file into the snap part folder. if so how can i install the deb during the snap installation?


#4

The contents of your deb package will be extracted into the snap (parts folder) and shipped alongside, so no need to do anything. What you then need are the snap specific definitions like the app part with its command section and plugs. Please see the full example linked above, as it includes everything to basically convert a deb into a snap package.

You can inspect your snap contents after building and navigate the tree structure to check with:
snapcraft --shell-after
this will open a shell chrooted inside your snap after the build has finished.


#5

OK, i think i understood the differences:
in your source: you wrote a URL, which snapcraft takes and then the ‘dump’ plugin extract the deb to the snap folders.
In my example above, I override the pull and downloaded the deb from S3, therefore when using the ‘dump’ plugin it just copy the deb file itself to the snap folder instead of extract it.
once i change the source to URL (as your example) the dump plugin works as expected.

anyway - thanks a lot for your help.