Call for testing: Snapcraft 7

Snapcraft 7, the one that supports core22, is now out for testing on latest/candidate and 7.x/candidate.

The goal is to have this relases on 7.x/stable by 2022-06-02T03:00:00Z and on latest/stable on 2022-06-09T03:00:00Z. The reason for this is that the store authorization flow has changed and would need some changes (explained in the release notes further down).

Before moving to core22, please ensure you have read the release notes to verify nothing will affect you by moving over.


Release notes

Support for core22 as a base

Support for the core22 base introduces a new lifecycle with the introduction of craft-parts.

These changes are applicable when switching to core22:

  • Add craftctl tool replacing snapcraftctl (this also requires replacing snapcraftctl <step-name> with craftctl default and snapcraftctl set-version <value> with craftctl set version=<value>).
  • Define CRAFT_* environment variables during step execution, replacing SNAPCRAFT_* variables.
  • Remove try from advanced grammar, this enables a more predictable planning phase without requiring an execution environment to attest what is tried. With this change, grammar has been generalized enough to allow for adding grammar seamlessly to all snapcraft supported keywords.
  • Error when duplicate keys are used in snapcraft.yaml.
  • Root level build-packages no longer supported
  • Snapcraft now makes use of the global environment keyword instead of command-chain (which allows for easy overriding)

Follow the migration guide for hints on (micro) Howto migrate from core20 to core22 for more information.

Build Providers

With the move to craft-providers, Snapcraft now defaults to LXD as the build environment.

Command Line Interface

Packing or Snapping

The snapping process, to align with other crafting tools, is now called pack. So instead of

$ snapcraft snap

run

$ snapcraft pack

The option of running with no arguments is still supported and defaults to packing:

$ snapcraft

Store operations with externally generated credentials

Snapcraft has migrated to usinng craft-store. The authentication mechanism has changed, impacting those integrating with CI/CD. The snapcraft login --with command structure is no longer supported or required. The value of export login needs to be exported into the appropriate environment variable (i.e.; SNAPCRAFT_STORE_CREDENTIALS).

Additionally a working keyring is required to be able to store credentials locally.

Experimental login

To change the authentication mechanism, instead of snapcraft login --enable-experimental-login, instead set SNAPCRAFT_STORE_AUTH=candid

Listing snap names

While still supported, instead of running

$ snapcraft list

run:

$ snapcraft names

Missing features

Don’t migrate yet if you depend on any of these

  • Support for the architectures keyword
  • Automatic classic snap building support (ORIGIN paths and linker loader setup)
  • Plugins: ROS, crystal, qmake
  • Some source handlers: 7zip, mercurial, bazaar, deb, rpm
  • Support for user-defined plugins.

Missing features will be ported and added to upcoming 7.x releases. If your snap relies on any of these features, please wait for the next releases to port them to use base: core22.

2 Likes

I have got this error message:

Parts 'pyqt5-sip' and 'gl2ps' list the following files, but with different contents:
    lib64

That was very strange as none of them install anything under lib64.

Is that under “Automatic classic snap building support (ORIGIN paths and linker loader setup)”

This looks like 2 parts providing the same files, although this looks like directories conflicting. Can you share the yaml for those 2 parts?

  pyqt5-sip:
    source: .
    plugin: python
    python-packages:
      - pyqt5-sip
      - --no-deps
      - --target=$CRAFT_PART_INSTALL/usr/lib/python3.10/site-packages
    prime:
      - -bin/
      - -lib/
      - -share/
  gl2ps:
    source-type: tar
    source: https://geuz.org/gl2ps/src/gl2ps-1.4.2.tgz
    source-checksum: sha256/8d1c00c1018f96b4b97655482e57dcb0ce42ae2f1d349cd6d4191e7848d9ffe9
    plugin: cmake
    cmake-generator: Ninja
    cmake-parameters:
      - "-DCMAKE_BUILD_TYPE=Release"
      - "-DCMAKE_INSTALL_PREFIX=/usr"
    build-packages:
      - g++
    stage-packages:
      - libgl1
      - libpng16-16
    prime:
      - -usr/lib/libgl2ps.a
      - -usr/include
      - -usr/share

I don’t see that error message with snapcraft 6.1 + core22

The nmap snap with base:core22 builds fine on snapcraft 7.01(candidate), and it’s actually published on edge already. However, successive local builds fail while processing the icon:

$ snapcraft clean
Removed instance: snapcraft-nmap-1707314

$ snapcraft pack
Launching instance...
Installed package repositories
Executed: pull nmap
Executed: overlay nmap
Copying needed target link from the system: /usr/sbin/rmt-tar
Executed: build nmap
Executed: stage nmap
Executed: prime nmap
Executed parts lifecycle
Generated snap metadata
Created snap package

$ snapcraft pack
Launching instance...
Installed package repositories
Executed: skip pull nmap (already ran)
Executed: skip overlay nmap (already ran)
Executed: skip build nmap (already ran)
Executed: skip stage nmap (already ran)
Executed: skip prime nmap (already ran)
Executed parts lifecycle
Copying snap assets...
Traceback (most recent call last):
  File "/snap/snapcraft/x1/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/cli.py", line 161, in run
    dispatcher.run()
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 406, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 206, in run
    super().run(parsed_args)
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 82, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 150, in run
    _run_command(
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 242, in _run_command
    setup_assets(
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/setup_assets.py", line 73, in setup_assets
    icon_path = _finalize_icon(
  File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/setup_assets.py", line 136, in _finalize_icon
    shutil.copy(source_path, target_icon_path)
  File "/snap/snapcraft/x1/usr/lib/python3.8/shutil.py", line 418, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/x1/usr/lib/python3.8/shutil.py", line 244, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: PosixPath('/root/prime/meta/gui/icon.png') and PosixPath('/root/prime/meta/gui/icon.png') are the same file
Failed to execute pack in instance.
Full execution log: '/home/user/.cache/snapcraft/log/snapcraft-20220527-114837.279122.log'

$ 
1 Like

Curiously, successive local builds of htop work flawlessly.

Moving the icon from meta/gui/ to the top level fixes the issue.

Couldn’t use snapcore/action-build to build snap on GitHub with snapcraft 7.0 beta or candidate (reported in action hangs forever with snapcraft beta/7.0 · Issue #37 · snapcore/action-build (github.com)

I found a bug either in snapcraft 7 or in the documentation: Cannot use adapter: none with snapcraft 7.0.1 and base: core22

@mchinoune, thanks for finding this. core22 is including the dependencies of libpng16-16, which is causing some directory conflicts. I’m not aware of any workaround right now, let me get back to you with a solution.

@zyga, good catch, thanks. It’s not clear in the migration guide or documentation that adapter has been deprecated for core22.

Are adapters entirely gone now? Is there a way to do something similar?

Thanks for reporting. PR #3767 should fix this.

1 Like

The adapter: key and the runner script are gone (and should have left some kind of explanatory message), but the functionality is still there. The migration guide should cover the details on how to override the variables.

I have removed that dependency as a workaround (since gl2ps is just a part, and libpng16-16 is already a dependency of the app), but still get the same error.

Note that I start getting this message when building gl2ps that I don’t see with snapcraft 6.1:

fix symlink: path='/home/runner/work/makhber/makhber/parts/gl2ps/install/lib64/ld-linux-x86-64.so.2', unpack_dir='/home/runner/work/makhber/makhber/parts/gl2ps/install', root='/home/runner/work/makhber/makhber/parts/gl2ps/install/lib64'

A workaround is to not install pyqt5-sip using python plugin

  pyqt5-sip:
    source: .
    plugin: make
    build-packages:
      - python3-pip
    override-build: |
      pip3 install pyqt5-sip --target=$CRAFT_PART_INSTALL/usr/lib/python3.10/site-packages

This is a debug message from the parts processing library and shouldn’t appear to Snapcraft users in non-debug modes (@facundobatista, I believe this is another issue to address in craft-cli).

Another issue: It seems like snapcraft no longer check and warn about missing runtime libraries.

7.0.2 on candidate should address this issue

Do you mind trying 7.0.2 in candidate now?

7.0.2 now in candidate should address this issue