-
Notifications
You must be signed in to change notification settings - Fork 180
Makefile: use linuxkit env vars for org and builder config #5700
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
Open
europaul
wants to merge
2
commits into
lf-edge:master
Choose a base branch
from
europaul:linuxkit-env-vars
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+121
−48
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .*Makefile.* | ||
| .*\.mk | ||
| .*\.go | ||
| .*\.dts | ||
| .*\.md | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Copyright (c) 2026 Zededa, Inc. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't make much sense to create a folder for only one file. Are you planning to migrate other .mk files to this folder? If so, ok. Otherwise, please, remove it from the folder and just let in the root of the repo, like the kernel ones.... |
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # mk/linuxkit.mk — linuxkit binary acquisition | ||
| # | ||
| # Priority (first match wins): | ||
| # 1. LINUXKIT_SRC=/path build from local source tree, no network | ||
| # 2. LINUXKIT_GIT_URL set clone at LINUXKIT_GIT_REF (commit hash) and build | ||
| # 3. (neither) download official release binary | ||
| # | ||
| # Set LINUXKIT_GIT_URL="" to use the release binary (case 3). | ||
| # LINUXKIT_VERSION must remain a published semver tag — it is used only for | ||
| # the release-download URL in case 3. | ||
|
|
||
| # linuxkit version. This **must** be a published semver version so it can be | ||
| # downloaded already compiled from the release page at | ||
| # https://github.com/linuxkit/linuxkit/releases | ||
| LINUXKIT_VERSION ?= v1.8.1 | ||
| LINUXKIT_SOURCE ?= https://github.com/linuxkit/linuxkit | ||
|
|
||
| # LINUXKIT_GIT_REF must be a commit hash (reproducible, no ls-remote needed). | ||
| # Update by running: git ls-remote https://github.com/linuxkit/linuxkit master | ||
| LINUXKIT_GIT_URL ?= https://github.com/linuxkit/linuxkit | ||
| LINUXKIT_GIT_REF ?= 4cfb70d3cc9256024bb0d4de760c631df0ad06f6 | ||
| # Optional local source tree — takes priority over LINUXKIT_GIT_URL. | ||
| # make LINUXKIT_SRC=/path/to/linuxkit <target> | ||
| LINUXKIT_SRC ?= | ||
|
|
||
| .PHONY: linuxkit | ||
| linuxkit: $(LINUXKIT) | ||
|
|
||
| ifneq ($(LINUXKIT_SRC),) | ||
| # ── Case 1: local source tree ──────────────────────────────────────────────── | ||
| # Rebuild whenever Go sources change; no network access needed. | ||
| $(LINUXKIT): $(PARALLEL_BUILD_LOCK) | $(BUILDTOOLS_BIN) | ||
| @echo "Building linuxkit from local source: $(LINUXKIT_SRC)" | ||
| $(QUIET)$(MAKE) -C $(LINUXKIT_SRC) local-build LOCAL_TARGET=$(abspath $@) | ||
| $(QUIET)docker stop linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET)docker rm linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET): $@: Succeeded | ||
|
|
||
| else ifneq ($(LINUXKIT_GIT_URL),) | ||
| # ── Case 2: commit hash from a git repo ────────────────────────────────────── | ||
| # The hash is used directly as the versioned binary name — no network call at | ||
| # parse time. Make skips the recipe if the binary already exists (cached). | ||
| _LK_VERSION := $(shell printf '%s' '$(LINUXKIT_GIT_REF)' | cut -c1-12) | ||
|
|
||
| $(LINUXKIT): $(BUILDTOOLS_BIN)/linuxkit-$(_LK_VERSION) $(PARALLEL_BUILD_LOCK) | ||
| $(QUIET)docker stop linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET)docker rm linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET)ln -sf $(notdir $<) $@ | ||
| $(QUIET): $@: Succeeded | ||
|
|
||
| $(BUILDTOOLS_BIN)/linuxkit-$(_LK_VERSION): | $(BUILDTOOLS_BIN) | ||
| @echo "Building linuxkit from $(LINUXKIT_GIT_URL) at $(LINUXKIT_GIT_REF)" | ||
| $(QUIET)tmp=$$(mktemp -d) && \ | ||
| git clone --filter=blob:none $(LINUXKIT_GIT_URL) $$tmp && \ | ||
| git -C $$tmp checkout $(LINUXKIT_GIT_REF) && \ | ||
| $(MAKE) -C $$tmp local-build LOCAL_TARGET=$(abspath $@) && \ | ||
| rm -rf $$tmp | ||
| $(QUIET): $@: Succeeded | ||
|
|
||
| else | ||
| # ── Case 3: download upstream release binary ────────────────────────────────── | ||
| $(LINUXKIT): $(BUILDTOOLS_BIN)/linuxkit-$(LINUXKIT_VERSION) $(PARALLEL_BUILD_LOCK) | ||
| $(QUIET)docker stop linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET)docker rm linuxkit-builder >/dev/null 2>&1 || true | ||
| $(QUIET)ln -sf $(notdir $<) $@ | ||
| $(QUIET): $@: Succeeded | ||
|
|
||
| $(BUILDTOOLS_BIN)/linuxkit-$(LINUXKIT_VERSION): | $(BUILDTOOLS_BIN) | ||
| @echo "Downloading linuxkit release $(LINUXKIT_VERSION)" | ||
| $(QUIET)curl -fsSL -o $@ \ | ||
| $(LINUXKIT_SOURCE)/releases/download/$(LINUXKIT_VERSION)/linuxkit-$(LOCAL_GOOS)-$(HOSTARCH) \ | ||
| && chmod +x $@ | ||
| $(QUIET): $@: Succeeded | ||
|
|
||
| endif | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this syntax correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rene yes, correct. by default we override docker.io AFAIR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is better to specify a full syntax of-course like here linuxkit/linuxkit#4205
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if the registry like
docker.io=isn't set then it's applied to all registrieshttps://github.com/linuxkit/linuxkit/blob/master/docs/packages.md#L394
https://github.com/linuxkit/linuxkit/blob/master/src/cmd/linuxkit/cmd.go#L124