Difference between revisions of "Create snap package"

From Lazarus wiki
Jump to navigationJump to search
Line 3: Line 3:
 
* Create '''snap''' subdirectory in your project
 
* Create '''snap''' subdirectory in your project
 
* Execute '''snapcraft init''' to create '''snap/snapcraft.yaml''' initial file
 
* Execute '''snapcraft init''' to create '''snap/snapcraft.yaml''' initial file
* Sample file:
+
* Example file:
 
<pre>
 
<pre>
 
name: myapp
 
name: myapp
version: '1.0'
+
version: '1.0.0'
 
summary: Short description of package.
 
summary: Short description of package.
 
description: |
 
description: |
Line 16: Line 16:
 
parts:
 
parts:
 
   myapp:
 
   myapp:
     plugin: dump
+
     plugin: nil
 
     source: https://somehost/source/location
 
     source: https://somehost/source/location
 
     source-type: subversion
 
     source-type: subversion
Line 24: Line 24:
 
     - lcl
 
     - lcl
 
     - lcl-utils
 
     - lcl-utils
 +
    stage-packages:
 +
    # 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: |
 
     override-build: |
 
       lazbuild --build-mode=Release myapp.lpi
 
       lazbuild --build-mode=Release myapp.lpi
 +
      ROOT=/root/parts/myapp/install
 +
      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
 +
    stage:
 +
      - usr/share/myapp
 +
      - usr/share/applications/myapp.desktop
  
 
apps:
 
apps:
 
   myapp:
 
   myapp:
 
     command: myapp
 
     command: myapp
     desktop: /usr/share/applications/myapp.desktop
+
     desktop: usr/share/applications/myapp.desktop
 
</pre>
 
</pre>
 
See [https://snapcraft.io/docs/snapcraft-yaml-reference Snapcraft.yaml reference] for full list of supported properties.
 
See [https://snapcraft.io/docs/snapcraft-yaml-reference Snapcraft.yaml reference] for full list of supported properties.
 +
 +
* Build snap using '''snapcraft''' command
 +
* Install newly created snap with '''sudo snap install --dangerous --devmode myapp_1.0.0_amd64.snap'''
 +
 +
=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 build.sh file.
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
ln -s install/snap ../../../snap
 +
pushd ../../..
 +
snapcraft
 +
popd
 +
rm ../../../snap
 +
</syntaxhighlight>
  
 
=Register app in snap store=
 
=Register app in snap store=

Revision as of 18:03, 24 April 2021

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

parts:
  myapp:
    plugin: nil
    source: https://somehost/source/location
    source-type: subversion
    build-packages: 
    - fpc
    - lazarus
    - lcl
    - lcl-utils
    stage-packages:
    # 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
      ROOT=/root/parts/myapp/install
      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
    stage:
      - usr/share/myapp
      - usr/share/applications/myapp.desktop

apps:
  myapp:
    command: myapp
    desktop: usr/share/applications/myapp.desktop

See Snapcraft.yaml reference for full list of supported properties.

  • Build snap using snapcraft command
  • Install newly created snap with sudo snap install --dangerous --devmode myapp_1.0.0_amd64.snap

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 build.sh file.

#!/bin/bash
ln -s install/snap ../../../snap
pushd ../../..
snapcraft
popd
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