Install existing deb file as part of snap installation


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:

    override-pull: |
      aws s3 cp s3://XXXX/my.deb ./
    source: ./my.deb
    source-type: deb
    plugin: nil
      - 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:

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

what is the proper way to do it?

Thank you,

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:

    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
      - dbus
    after: [desktop-qt5] 

Here’s the full example snapcraft.yaml

1 Like

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?

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.

1 Like

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.

1 Like

Sorry for opening an old thread, but is it possible to download a zip with some *.deb inside and “install” or extract all of those into the snap?

why not … ? you can always use override-build:| and run arbitrary shell code from your snapcraft.yaml …

Sure, so what would be an equivalent command to what source-type: deb does?

there is a gazillion ways … here is one:

    plugin: nil
    override-build: |
      dpkg -x bash_5.1-3ubuntu1_amd64.deb $SNAPCRAFT_PART_INSTALL/
      - dpkg
      - wget

this could technically be better handled in an override-pull

1 Like

told ya … a gazillion … (and one !) :wink:

Seems that $SNAPCRAFT_PART_INSTALL is not defined during pull stage.

It is not, the general concept I wanted to expose is that if you download in pull and build or operate with those sources in build, then you can iterate a bit more easily.