Skip to content

Commit

Permalink
snapcraft: Fix LXD snap bash completions
Browse files Browse the repository at this point in the history
This commit changes the permissions, location, and file extension of the
`lxc` bash completions script to ensure correct execution.

Signed-off-by: Kadin Sayani <[email protected]>
  • Loading branch information
kadinsayani committed Dec 20, 2024
1 parent 78a3419 commit fcda538
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ apps:

lxc:
command: commands/lxc
completer: etc/bash_completion.d/snap.lxd.lxc
completer: lxc-completer.sh
plugs:
- lxd-support
- system-observe
Expand Down Expand Up @@ -1394,6 +1394,7 @@ parts:
stage-packages:
- acl
- attr
- bash-completion
- dnsmasq-base
- gdisk
- iw
Expand Down Expand Up @@ -1471,9 +1472,10 @@ parts:
# 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/bin/lxc __complete ${args[*]}"|'
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}/etc/bash_completion.d/snap.lxd.lxc"
"${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/
Expand All @@ -1494,7 +1496,7 @@ parts:

- lib/*/libidn.so.*

- etc/bash_completion.d/snap.lxd.lxc
- lxc-completer.sh

- share/lxd-documentation*
- share/misc/pci.ids
Expand Down

0 comments on commit fcda538

Please sign in to comment.