Skip to content
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

What happens when I install go-ipfs? #204

Open
schomatis opened this issue Aug 19, 2018 · 1 comment
Open

What happens when I install go-ipfs? #204

schomatis opened this issue Aug 19, 2018 · 1 comment
Assignees

Comments

@schomatis
Copy link
Collaborator

(Part of #203.)

I need to put this in a document PR but before that I'm leaving a rough description here so someone can validate if this is correct.

The make install in go-ipfs command ends up calling (not sure how) gx install --global.

The InstallCommand is called where the branch with no arguments is executed (because the install process is being done in the package of the current directory),

gx/main.go

Lines 359 to 380 in a904dc7

if len(c.Args()) == 0 {
cwd, err := os.Getwd()
if err != nil {
return err
}
err = gx.TryRunHook("req-check", pkg.Language, pkg.SubtoolRequired, cwd)
if err != nil {
return err
}
ipath, err := gx.InstallPath(pkg.Language, cwd, global)
if err != nil {
return err
}
err = pm.InstallDeps(pkg, ipath)
if err != nil {
return fmt.Errorf("install deps: %s", err)
}
return nil
}

In InstallPath the --global flag is forwarded and gx-go will return $GOPATH/src. The --global flag seems to be used only for this call and for the post-install hook which it appears to ignore it, so right now it seems this flag is only used to determine the install path, its purpose should be clearly documented.

The InstallDeps function will do two things (more clearly differentiated in #197), fetch all the dependencies (direct and transitive ones), saving them in the install path returned by the gx-go sub-tool and then it will call the post-install hook of this same sub-tool. gx-go will implement that hook rewriting the import statements in the .go files of those dependencies making them point to the install path with the gx/ipfs path appended (and how do we call that sub-path of the install path?), i.e., $GOPATH/src/gx/ipfs/.

It may be useful to open an in issue in gx-go to review the rewrite process and document it here.

@schomatis schomatis self-assigned this Aug 19, 2018
@schomatis
Copy link
Collaborator Author

Also, the load of the package file a the start of InstallCommand needs to be clarified

gx/main.go

Lines 342 to 360 in a904dc7

Action: func(c *cli.Context) error {
pkg, err := LoadPackageFile(PkgFileName)
if err != nil {
return err
}
save := c.Bool("save")
global := c.BoolT("global")
if c.Bool("local") {
global = false
}
pm.SetGlobal(global)
pm.ProgMeter = progmeter.NewProgMeter(c.Bool("nofancy"))
if len(c.Args()) == 0 {
cwd, err := os.Getwd()

This undocumented exported function in turn calls another (also undocumented) function with the same name and a confusing gx prefix that is actually an abbreviation of the gxutil package,

gx/main.go

Lines 31 to 51 in a904dc7

func LoadPackageFile(path string) (*gx.Package, error) {
if path == PkgFileName {
root, err := gx.GetPackageRoot()
if err != nil {
return nil, err
}
path = filepath.Join(root, PkgFileName)
}
var pkg gx.Package
err := gx.LoadPackageFile(&pkg, path)
if err != nil {
return nil, err
}
if pkg.GxVersion == "" {
pkg.GxVersion = gx.GxVersion
}
if pkg.SubtoolRequired {

gx.LoadPackageFile, despite its name, actually loads the Package (through the location of the package.json file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant