canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 440 forks source link

remote build: legacy builder doesn't send icon to Launchpad #4471

Open merlijn-sebrechts opened 9 months ago

merlijn-sebrechts commented 9 months ago

Bug Description

remote-build doesn't send the icon to Launchpad if the icon is in the root of the repository.

To Reproduce

remote-build a snap where the icon is in the root of the repository.

Example repo: discord at this commit https://github.com/snapcrafters/discord/tree/d3344c01a930f831ae7779381e8a0d292c569268

Environment

remote-build, both on Ubuntu 22.04 and GitHub actions

snapcraft.yaml

name: discord
title: Discord
summary: Chat for Communities and Friends
description: |
  Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

  Snaps are confined, as such Discord may be unable to perform some of the tasks it typically does when unconfined. This may result in the system log getting spammed with apparmor errors. Granting access to the system-observe interface when in the snap will enable the features, and thus reduce the logging.

    snap connect discord:system-observe

  **Authors**

  This snap is maintained by the Snapcrafters community, and is not necessarily endorsed or officially maintained by the upstream developers.

website: https://discord.com/
contact: https://github.com//snapcrafters/discord/issues
issues: https://github.com//snapcrafters/discord/issues
source-code: https://github.com//snapcrafters/discord
license: Proprietary
icon: discord.png
version: 0.0.36

base: core22
grade: stable
confinement: strict
assumes:
- snapd2.54

architectures:
  - build-on: amd64
compression: lzo

parts:
  disable-updater:
    plugin: nil
    override-pull: |
      cat <<'EOF' > disable-updater.sh
      #!/bin/bash
      if [ ! -d "$SNAP_USER_DATA"/.config/discord ]; then
        mkdir -p "$SNAP_USER_DATA"/.config/discord
      fi
      CONFIG_FILE="$SNAP_USER_DATA"/.config/discord/settings.json
      if ! [ -f "$CONFIG_FILE" ]; then
        echo '{}' > "$CONFIG_FILE"
      fi
      ORIG_JSON=$(cat "$CONFIG_FILE")
      NEW_JSON=$(jq '.SKIP_HOST_UPDATE = true' < "$CONFIG_FILE")
      if [ "$ORIG_JSON" != "$NEW_JSON" ]; then
        echo "$NEW_JSON" > "$CONFIG_FILE"
      fi
      exec "$@"
      EOF
    override-build: |
      install -m755 -D -t $CRAFT_PART_INSTALL/bin disable-updater.sh
    stage-packages:
      - jq

  launcher:
    plugin: dump
    source: launcher
    override-build: |
      cp launcher $CRAFT_PART_INSTALL/

  discord:
    plugin: nil
    override-build: |
      craftctl default
      curl -o discord.deb "https://dl.discordapp.net/apps/linux/${SNAPCRAFT_PROJECT_VERSION}/discord-${SNAPCRAFT_PROJECT_VERSION}.deb"
      dpkg-deb -xv discord.deb $CRAFT_PART_INSTALL/

      rm $CRAFT_PART_INSTALL/usr/share/discord/chrome-sandbox
      # Correct path to icon.
      sed -i 's|Icon=discord|Icon=/usr/share/discord/discord\.png|' ${CRAFT_PART_INSTALL}/usr/share/discord/discord.desktop
    build-packages:
      - curl
      - sed
    stage-packages:
      - libatomic1
      - libc++1
      - libnspr4
      - libnss3
      - libxss1
      - xdg-utils
    prime:
      - -usr/bin/xdg-open

  cleanup:
    after: [discord]
    plugin: nil
    build-snaps: [ gnome-42-2204 ]
    override-prime: |
        set -eux
        cd /snap/gnome-42-2204/current
        find . -type f,l -exec rm -f $CRAFT_PRIME/{} \;

plugs:
  shmem:
    interface: shared-memory
    private: true

apps:
  discord:
    extensions: [gnome]
    command: launcher
    command-chain: [bin/disable-updater.sh]
    autostart: discord.desktop
    desktop: usr/share/applications/discord.desktop
    environment:
      # Correct the TMPDIR path for Chromium Framework/Electron to
      # ensure libappindicator has readable resources
      TMPDIR: $XDG_RUNTIME_DIR
      GTK_USE_PORTAL: 1
      DISABLE_WAYLAND: 1
    plugs:
      - audio-playback
      - audio-record
      - camera
      - home
      - mount-observe
      - network
      - network-observe
      - opengl
      - process-control
      - removable-media
      - screen-inhibit-control
      - shmem
      - system-observe
      - unity7

Relevant log output

Running on amd64 for amd64
Specified icon 'discord.png' does not exist.
Full execution log: '/root/.local/state/snapcraft/log/snapcraft-20231202-120056.334830.log'
Build failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 265, in run
    self.pull()
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 205, in pull
    self.run_build_command(
  File "/usr/lib/python3/dist-packages/lpbuildd/target/operation.py", line 62, in run_build_command
    return self.backend.run(args, cwd=cwd, env=full_env, **kwargs)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/lxd.py", line 716, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-jammy-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/lpbuildd-git-proxy', '--env', 'SNAPPY_STORE_NO_CDN=1', '--env', 'SNAPCRAFT_LOCAL_SOURCES=1', '--env', 'SNAPCRAFT_SETUP_CORE=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-84317756", "build-request-timestamp": "2023-12-02T11:59:01Z", "build_url": "https://launchpad.net/~snapcrafters-bot/+snap/snapcraft-discord-2ce38607310745e1e17f995dfa82de56/+build/2315373"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--', '/bin/sh', '-c', 'cd /build/snapcraft-discord-2ce38607310745e1e17f995dfa82de56 && linux64 snapcraft pull']' returned non-zero exit status 1.
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=jammy --arch=amd64 SNAPBUILD-2315373
Scanning for processes to kill in build SNAPBUILD-2315373

Additional context

No response

JGCarroll commented 9 months ago

I've had similar issues with the Remote Build service not shipping the entire folder over to Launchpad. In my cases it was with .patch files that live separately to the project code which is pulled as a part but external to the Snapcraft.yaml.

As a workaround, I'd moved them into snap/local/patches and refer to them in the code like so:

patch -i $CRAFT_PROJECT_DIR/snap/local/patches/ROOT/ACliC.patch -p 1

I'm wondering if moving your icon file there might be a suitable workaround?

Edit: Just seen that your linked issue essentially does this, my apologies! Still, I guess this can be taken as a +1 from me, preferably Remote-Build would send over the entire folder and not just the bits of it it considers relevant.

syncronize-issues-to-jira[bot] commented 3 weeks ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3282.

This message was autogenerated