Create snap package

From Lazarus wiki
Revision as of 18:26, 3 May 2021 by Chronos (talk | contribs)
Jump to navigationJump to search

Create snapcraft.yaml

  • Install snapcraft to your Ubuntu machine with sudo apt install snapcraft
  • Create snap subdirectory in your project
  • Execute snapcraft init to create snap/snapcraft.yaml initial file
  • Example file:
name: myapp
version: '1.0.0'
summary: Short description of package.
description: |
  Some more detailed multi-line description.
confinement: devmode
base: core20
grade: devel

    plugin: nil
    source: .
    source-type: local
    - fpc
    - lazarus
    - lcl
    - lcl-utils
    # Autodetected dependencies
    - libatk1.0-0
    - libcairo2
    - libdatrie1
    - libfontconfig1
    - libfreetype6
    - libfribidi0
    - libgdk-pixbuf2.0-0
    - libgraphite2-3
    - libgtk2.0-0
    - libharfbuzz0b
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpixman-1-0
    - libpng16-16
    - libthai0
    - libx11-6
    - libxau6
    - libxcb-render0
    - libxcb-shm0
    - libxcb1
    - libxcomposite1
    - libxcursor1
    - libxdamage1
    - libxdmcp6
    - libxext6
    - libxfixes3
    - libxi6
    - libxinerama1
    - libxrandr2
    - libxrender1
    override-build: |
      lazbuild --build-mode=Release myapp.lpi
      install -d -m 755 $ROOT/usr/share/myapp
      install -s -m 755 myapp $ROOT/usr/share/myapp
      install -d -m 755 $ROOT/usr/share/applications
      install -m 755 Install/deb/myapp.desktop $ROOT/usr/share/applications
      - etc
      - lib
      - usr
      - usr/share/myapp
      - usr/share/applications/myapp.desktop

    command: usr/share/myapp/myapp
    desktop: usr/share/applications/myapp.desktop
      - home
      - desktop
  • Build snap using snapcraft command
  • Install newly created snap with sudo snap install --dangerous --devmode myapp_1.0.0_amd64.snap

Publish your package in Snap Store

  • snapcraft register
  • snapcraft login
  • snapcraft push myapp.snap
  • snapcraft release myapp 1 edge
  • Now your snap should be released and available on store.

Debug snap

To get to console of snap virtual filesystem use:

snap run --shell myapp
cd $SNAP

Type exit to leave snap environment. See Debugging snaps for more information.

Sound support

Snap supports sound through plugs pulseaudio and audio-playback.

      - pulseaudio
      - audio-playback

See The alsa interface and snapcraft-alsa for ALSA support in snap.

You can play wav and mp3 files from command line using play command. See Play Sound Multiplatform. Then you also need to add stage-packages to myapp part:

    - sox
    - libsox-fmt-mp3
    - libsox-fmt-pulse
    - libpulse0 

snapcraft.yaml file in non-standard subdirectory

Snapcraft normally expect snapcraft.yaml file in snap directory. If your project has packaging for multiple other packaging formats, then you need to use build workaround script. Such shell script can put into directory like myapp/install/snap/local as file.

ln -s install/snap ../../../snap
pushd ../../..
rm ../../../snap

Register app in snap store

Setup build on Launchpad

Snap packages can be built automatically on Launchpad. Open Create snap package link form your application branch page.

See also

External links