Skip to content

Commit 2baff05

Browse files
committed
Create yq.lima symlink on host and in VM
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
1 parent 5893a7d commit 2baff05

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ help-targets:
8787
@echo 'Targets for files in _output/bin/:'
8888
@echo '- limactl : Build limactl, and lima'
8989
@echo '- lima : Copy lima, and lima.bat'
90-
@echo '- helpers : Copy nerdctl.lima, apptainer.lima, docker.lima, podman.lima, and kubectl.lima'
90+
@echo '- helpers : Copy nerdctl.lima, apptainer.lima, docker.lima, podman.lima, kubectl.lima, and yq.lima'
9191
@echo
9292
@echo 'Targets for files in _output/share/lima/:'
9393
@echo '- guestagents : Build guestagents'
@@ -277,10 +277,17 @@ LIMA_CMDS = $(sort lima lima$(bat)) # $(sort ...) deduplicates the list
277277
LIMA_DEPS = $(addprefix _output/bin/,$(LIMA_CMDS))
278278
lima: $(LIMA_DEPS)
279279

280-
HELPER_CMDS = nerdctl.lima apptainer.lima docker.lima podman.lima kubectl.lima
280+
HELPER_CMDS = nerdctl.lima apptainer.lima docker.lima podman.lima kubectl.lima yq.lima$(exe)
281281
HELPERS_DEPS = $(addprefix _output/bin/,$(HELPER_CMDS))
282282
helpers: $(HELPERS_DEPS)
283283

284+
_output/bin/yq.lima$(exe): _output/bin/limactl$(exe)
285+
ifneq ($(GOOS),windows)
286+
ln -sf limactl$(exe) $@
287+
else
288+
cp -aL $< $@
289+
endif
290+
284291
_output/bin/%: ./cmd/% | _output/bin
285292
cp -a $< $@
286293

@@ -493,6 +500,7 @@ uninstall:
493500
"$(DEST)/bin/docker.lima" \
494501
"$(DEST)/bin/podman.lima" \
495502
"$(DEST)/bin/kubectl.lima" \
503+
"$(DEST)/bin/yq.lima$(exe)" \
496504
"$(DEST)/share/man/man1/lima.1" \
497505
"$(DEST)/share/man/man1/limactl"*".1" \
498506
"$(DEST)/share/lima" "$(DEST)/share/doc/lima"

cmd/yq/yq.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func main() {
3535
// Only returns to caller if os.Args doesn't contain a `yq` command.
3636
func MaybeRunYQ() {
3737
progName := filepath.Base(os.Args[0])
38-
progName = strings.TrimSuffix(progName, filepath.Ext(progName))
38+
// remove all extensions, so we match "yq.lima.exe"
39+
progName, _, _ = strings.Cut(progName, ".")
3940
if progName == "yq" {
4041
main()
4142
}

pkg/cidata/cidata.TEMPLATE.d/boot.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ deref() {
5757
eval echo \$"$1"
5858
}
5959

60+
# Add yq.lima to the PATH
61+
export PATH="${LIMA_CIDATA_GUEST_INSTALL_PREFIX}/bin:$PATH"
62+
6063
if [ -d "${LIMA_CIDATA_MNT}"/provision.data ]; then
6164
for f in "${LIMA_CIDATA_MNT}"/provision.data/*; do
6265
filename=$(basename "$f")

pkg/cidata/cidata.TEMPLATE.d/boot/25-guestagent-base.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fi
1919

2020
# Install or update the guestagent binary
2121
install -m 755 "${LIMA_CIDATA_MNT}"/lima-guestagent "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/lima-guestagent
22+
ln -sf "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/lima-guestagent "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/yq.lima
2223

2324
# Launch the guestagent service
2425
if [ -f /sbin/openrc-run ]; then

0 commit comments

Comments
 (0)