-
Couldn't load subscription status.
- Fork 326
Skip online repo interaction for packaged build #2538
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
base: master
Are you sure you want to change the base?
Skip online repo interaction for packaged build #2538
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@dveeden Could you suggest what is the best entry-point to this? I've read |
|
I'll have a look at this tomorrow as I'm attending a conference today |
|
Maybe it will be easy to change mirror to local path(yes, we can set it to local filesystem) automatically. Then adding a fallback for unexisted localpath. |
|
What do you mean by local mirror? Which function/code path did you have in
mind?
I am trying to avoid using any mirror or copying binaries into users home
directories. Instead the existing system binaries should be used as-is.
|
It is possible to set If you hack through this path, e.g. BTW: |
Could you please comment / provide guidance so it is easier for me to finish this with the optimal approach? |
I think the local mirror that @xhebox suggested would probably be a good approach. Disabling the version update check would be good. However if we disable access to online repository info and components then the functionality of the tool is very limited. Should we consider shipping a functional local mirror with the package as data? |
So the issue is that |
|
Maybe something like this? diff --git a/cmd/list.go b/cmd/list.go
index e1b889a1..c1cbe97e 100644
--- a/cmd/list.go
+++ b/cmd/list.go
@@ -111,7 +111,13 @@ func showComponentList(env *environment.Environment, opt listOptions) (*listResu
}
index := v1manifest.Index{}
- _, exists, err := env.V1Repository().Local().LoadManifest(&index)
+ repo := env.V1Repository()
+
+ if repo == nil {
+ return nil, errors.New("invalid or corrupt repository")
+ }
+
+ _, exists, err := repo.Local().LoadManifest(&index)
if err != nil {
return nil, err
}
diff --git a/pkg/repository/v1_repository.go b/pkg/repository/v1_repository.go
index ca443d90..fc813af3 100644
--- a/pkg/repository/v1_repository.go
+++ b/pkg/repository/v1_repository.go
@@ -531,6 +531,10 @@ func (r *V1Repository) PurgeTimestamp() {
// has the same value of our local one. (not hashing the snapshot file itself)
// Return weather the manifest is changed compared to the one in local ts and the FileHash of snapshot.
func (r *V1Repository) fetchTimestamp() (changed bool, manifest *v1manifest.Manifest, err error) {
+ if r == nil {
+ return false, nil, errors.New("repo is nil")
+ }
+
// check cache first
if r.timestamp != nil {
return false, r.timestamp, nil |
|
Isn't the mirror used to fetch the components that get installed in That seems overkill. I just want to bypass the mandatory version check and download for the binaries that are already in the package. Running I am currently testing Daniël's patch. |
|
@ottok Yes, I agree with that. |
7ca5987 to
8227887
Compare
|
@dveeden Any comments about the overall direction of the latest version of this PR? |
|
There are a few places in the provided code where a nil pointer dereference (segfault) could occur when the IsPackagedBuild flag is true. When IsPackagedBuild is true, the v1Repo field in the Environment struct is explicitly set to nil. Any method call on this nil interface would then cause a panic. I have an improved version of this commit on my Debian packaging branch, and I will update it here once I get the Debian packaging stabilized. |
Enable TiUP to operate correctly and robustly when installed via an external package manager (e.g., Debian, RPM, Homebrew). Allow TiUP to run without requiring network access to its online repository for initial setup or updates, which is crucial for production systems and environments with restricted connectivity. Achieve this by introducing the boolean flag `IsPackagedBuild`, which is intended to be hard-coded to `true` in binaries produced by package maintainers. When `IsPackagedBuild` is true: - The initial environment setup skips connecting to the online repository, relying instead on local files. - The automatic update check before running a component is skipped. - A message is printed to stderr indicating that online interaction is skipped, informing the user of the different behavior. - Functions related to *forced* self-updating TiUP return an error, explicitly disabling these operations in packaged builds. Users should still be able to install/update when explicitly running those commands. - Use the system-wide location `/usr/share/tiup/root.json` for initial trust setup and assume this file came with the package. This aligns with typical system package practices.
8227887 to
bcc2654
Compare
THIS IS WORK-IN-PROGRESS, DO NOT MERGE
This is not functional yet. E.g.
tiup listsegfaults.However, with this applied, one can run
tiup --helpwithout triggering forces network lookups.Introduce boolean flag
IsPackagedBuildin the environment package. This flag is intended to be set totruein builds of Debian, Fedora, Homebrew etc packages.This change allows TiUP to run when installed via an external package manager. This also allows TiUP to run without requiring network access to the TiUP repository for initial setup or updates.
When this flag is true:
The initial environment setup skips connecting to the online repository.
The automatic update check before running a component is skipped.
A message is printed to stderr indicating that online interaction is skipped.
Functions related to updating components or self-updating TiUP return an error, as these operations are disabled in the package build.
What problem does this PR solve?
See #123 and #2508.
What is changed and how it works?
See commit messages for details.
Check List TODO
Tests
Code changes
Side effects
Related changes
Release notes: