Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpkg --add-architecture fails when using package-repositories #4289

Closed
ghost opened this issue Jul 23, 2023 · 5 comments
Closed

dpkg --add-architecture fails when using package-repositories #4289

ghost opened this issue Jul 23, 2023 · 5 comments
Assignees
Labels
bug Actual bad behavior that don't fall into maintenance or documentation

Comments

@ghost
Copy link

ghost commented Jul 23, 2023

Bug Description

Recently we were trying to snap up lutris after a break but now snapcraft build fails both with remote and the online(using launchpad as a back-end) , giving out this particular error.

dpkg: error: --add-architecture takes exactly one argument

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
Starting Snapcraft 7.5.0
Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20230723-071633.938937.log'
Running on amd64 for amd64
Initializing parts lifecycle
Installing package repositories...
Command '['dpkg', '--add-architecture', 'i386', '--root', '/']' returned non-zero exit status 2.

This was not the case earlier with us having success previously in building the lutris snap.

Full build-log --> https://launchpadlibrarian.net/678501471/buildlog_snap_ubuntu_jammy_amd64_lutris_BUILDING.txt.gz

To Reproduce

  1. Clone or fetch lutris snap yaml from launchpad.
  2. Do a snapcraft remote-build or ask launchpad to build.
  3. Face the error in seconds.

Environment

In remote builds ;
--> Lubuntu

Rest was on launchpad side so cant be sure.

snapcraft.yaml

name: lutris
base: core22
adopt-info: lutris
grade: stable
confinement: strict
compression: lzo
architectures:
  - build-on: amd64

environment:
  PYTHONPATH: ${SNAP}/usr/lib/python3/dist-packages:$PYTHONPATH
  
assumes:
  - snapd2.54
  - command-chain
  
package-repositories:
  - type: apt
    architectures: [i386,amd64]
    key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C
    key-server: keyserver.ubuntu.com
    formats: [deb]
    components: [main, multiverse, universe, restricted]
    suites: [jammy]
    url: https://archive.ubuntu.com/ubuntu

#lint:
  #ignore:
    #- library:
        #- lib/i386-linux-gnu/**
        #- usr/lib/i386-linux-gnu/**
        #- lib32/**
        #- usr/lib32/**
 
layout:
  /usr/share/libdrm:
    bind: $SNAP/graphics/usr/share/libdrm
  /usr/share/drirc.d:
    symlink: $SNAP/graphics/usr/share/drirc.d
  /usr/share/X11/XErrorDB:
    symlink: $SNAP/graphics/usr/share/X11/XErrorDB
  /usr/share/X11/locale:
    symlink: $SNAP/graphics/usr/share/X11/locale   
  /usr/share/zenity:
    bind: $SNAP/usr/share/zenity 

apps: 
  lutris:
    command-chain:
    - bin/migrate-config
    - bin/graphics-core22-wrapper
    command: usr/bin/lutris
    extensions: [gnome]
    environment:
      TMPDIR: $XDG_RUNTIME_DIR
      APPIMAGE_EXTRACT_AND_RUN: 1
    common-id: net.lutris.Lutris 
    desktop: usr/share/applications/net.lutris.Lutris.desktop 
    plugs:
      - home
      - shmem
      - audio-playback
      - network
      - network-bind
      - network-status
      - joystick
      - audio-record
      - process-control
      - bluez
      - browser-support
      - unity7
      - removable-media
      - optical-drive
      - screen-inhibit-control
      - hardware-observe
      - mount-observe
      - system-observe
      - physical-memory-observe
      - upower-observe
      - raw-usb
      
plugs:
  graphics-core22:
    interface: content
    target: $SNAP/graphics
    default-provider: mesa-core22
  shmem:
    interface: shared-memory
    private: true
  lutris-user-config:
    interface: personal-files
    read:
      - $HOME/.config/lutris
      - $HOME/.local/share/lutris 


slots:    
  lutris:
    interface: dbus
    bus: session
    name: net.lutris.Lutris  
  

parts:
  migrate-script:
    plugin: dump
    source: .
    stage-packages:
      - zenity
    override-pull: |
      craftctl default
      chmod +x migrate-config
    stage:
      - bin/migrate-config
      - usr/bin/zenity
      - usr/share/zenity
    organize:
      migrate-config: bin/migrate-config
      
  lutris:
    source: https://github.com/lutris/lutris.git
    source-tag: v0.5.13
    source-depth: 1
    after: [lutris-runtime]
    plugin: meson
    parse-info: [usr/share/metainfo/net.lutris.Lutris.metainfo.xml]
    meson-parameters:
      - --prefix=/snap/lutris/current/usr
    override-pull: |
      craftctl default
      craftctl set version=$(git describe --tags --abbrev=0 | cut -c 2-)
    override-build: |
      craftctl default
      # WORKAROUND: Use python from search path, the path detected by meson doesn't exist when running the Snap
      sed -e '1c#!/usr/bin/env python3' -i ${CRAFT_PART_INSTALL}/snap/lutris/current/usr/bin/lutris
    organize:
      snap/lutris/current/usr: usr 
  
  lutris-runtime:
    plugin: nil
    stage-packages:
      - cabextract
      - curl
      - fluid-soundfont-gs
      - psmisc
      - python3-dbus
      - python3-gi
      - python3-pil
      - python3-requests
      - python3-setproctitle
      - python3-yaml
      - python3-distro
      - python3-cairo
      - python3-lxml
      - python3-evdev
      - python3-magic
      - unzip
      - xterm
      - pciutils
      - xz-utils
      - mesa-utils
      - vulkan-tools
    prime:
      - -usr/lib/*/libatk-1.0.so*
      - -usr/lib/*/libcairo-gobject.so*
      - -usr/lib/*/libcairo.so*
      - -usr/lib/*/libgdk-3.so*
      - -usr/lib/*/libgdk_pixbuf-2.0.so*
      - -usr/lib/*/libgtk-3.so*
      - -usr/lib/*/libharfbuzz.so*
      - -usr/lib/*/libpango-1.0.so*
      - -usr/lib/*/libpangocairo-1.0.so*
      - -usr/lib/*/libpangoft2-1.0.so*
      - -usr/lib/*/libpixman-1.so*
      - -usr/lib/*/libwayland-client.so*
      - -usr/lib/*/libwayland-cursor.so*
      - -usr/lib/*/libwayland-egl.so*   
    stage:
      - -lib/ld-linux.so.2
      - -usr/bin/cpp-7
      - -usr/lib/*/libjavascript*
      - -usr/lib/*/libwebkit*
      - -usr/share/doc/cpp/README.Debian
      - -usr/share/man/man1/cpp-7.1.gz
 
  graphics-core22:
    after: [lutris]
    source: https://github.com/MirServer/graphics-core22.git
# ext:updatesnap
#   version-format:
#     ignore: true    
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/graphics-core22-cleanup mesa-core22 nvidia-core22
    prime:
      - bin/graphics-core22-wrapper

      
  cleanup:
    after: [graphics-core22]
    plugin: nil
    build-snaps: [core22, gtk-common-themes, gnome-42-2204]
    override-prime: |
      set -eux
      for snap in "core22" "gtk-common-themes" "gnome-42-2204"; do
        cd "/snap/$snap/current" && find . -type f,l -name *.so.* -exec rm -f "$CRAFT_PRIME/{}" \;
      done   

In non-remote builds we do use lint part only disabled it for remote-builds.

Relevant log output

--> https://launchpadlibrarian.net/678501471/buildlog_snap_ubuntu_jammy_amd64_lutris_BUILDING.txt.gz

Additional context

This error recently occurs no such errors were faced earlier i.e June and before.

@ghost ghost added the bug Actual bad behavior that don't fall into maintenance or documentation label Jul 23, 2023
@renatgalimov
Copy link
Contributor

renatgalimov commented Jul 27, 2023

I can confirm the same on MacOS snapcraft. (snapcraft 7.3.1). Inside the building instance it reports snapcraft 7.5.0.

architectures:
  - build-on: [arm64]
    build-for: armhf
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.873 Command '['dpkg', '--add-architecture', 'armhf', '--root', '/']' returned non-zero exit status 2.
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876 Traceback (most recent call last):
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 168, in run
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     self._install_package_repositories()
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 204, in _install_package_repositories
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     refresh_required = repo.install(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/craft_archives/repo/installer.py", line 44, in install
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     return _install_repos(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/craft_archives/repo/installer.py", line 94, in _install_repos
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     refresh_required |= sources_manager.install_package_repository_sources(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/craft_archives/repo/apt_sources_manager.py", line 294, in install_package_repository_sources
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     _add_architecture(architectures, root=self._signed_by_root)
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/craft_archives/repo/apt_sources_manager.py", line 304, in _add_architecture
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     subprocess.run(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/usr/lib/python3.8/subprocess.py", line 516, in run
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     raise CalledProcessError(retcode, process.args,
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876 subprocess.CalledProcessError: Command '['dpkg', '--add-architecture', 'armhf', '--root', '/']' returned non-zero exit status 2.
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876 The above exception was the direct cause of the following exception:
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876 Traceback (most recent call last):
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 302, in _run_command
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     _run_lifecycle_and_pack(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 345, in _run_lifecycle_and_pack
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     lifecycle.run(
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876   File "/snap/snapcraft/9511/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 192, in run
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876     raise errors.PartsLifecycleError(str(err)) from err
2023-07-27 20:46:09.292 :: 2023-07-27 20:46:08.876 snapcraft.errors.PartsLifecycleError: Command '['dpkg', '--add-architecture', 'armhf', '--root', '/']' returned non-zero exit status 2.

@mr-cal
Copy link
Collaborator

mr-cal commented Jul 31, 2023

This looks similar to #4298

@sergiusens
Copy link
Collaborator



sergiusens@imladris:~$ dpkg --root /tmp/foo --add-architecture arm64
sergiusens@imladris:~$ dpkg --add-architecture arm64 --root /tmp/foo 
dpkg: error: --add-architecture takes exactly one argument

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

@sergiusens sergiusens changed the title Build Failures With 32 bit libs enabled dpkg --add-architecture fails Aug 1, 2023
@sergiusens sergiusens changed the title dpkg --add-architecture fails dpkg --add-architecture fails when using package-repositories Aug 1, 2023
tigarmo added a commit that referenced this issue Aug 4, 2023
Version 1.1.3 fixes the issue with package-repositories that declare
architectures. In addition to addressing the wrong parameter order, the
new version also improves the handling of architectures.

The summary of the change is: if the host system is amd64 and the arch
of the package repository is i386, _or_ if the host is arm64 and the
repo armhf, then `dpkg --add-architecture <repo_arch>` will be called.
Otherwise, the command is not called. This lets us preserve the
behavior of enabling i386 in the official repositories when a repo
using i386 is added, with the improvement of _not breaking_ apt update
when an "incompatible" architecture combination is declared.

The new spread tests reflect this. Both run in amd64 and add the
deadsnakes ppa to fetch Python in a foreign arch:

- For i386, only the deadsnakes ppa is necessary, as the architecture
will be added "globally" and Python's dependencies are found in the
default archives;
- For armhf, the ports.ubuntu.com repo is necessary in addition to the
deadsnakes one. This lets the dependencies be found in the ports repo,
_and_ doesn't break the build (this combination is broken in Snapcraft
7.2, 7.3 and 7.4).

Fixes #4289 and #4298
@sergiusens
Copy link
Collaborator

Can you please try Snapcraft from candidate? It shall be released as soon as build issues with armhf, ppc64el and riscv64 are solved

@ghost
Copy link
Author

ghost commented Aug 7, 2023

@sergiusens Ok, although it will take some time as i have removed that part for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Actual bad behavior that don't fall into maintenance or documentation
Projects
None yet
Development

No branches or pull requests

3 participants