whyrusleeping / gx

A package management tool
MIT License
1.88k stars 110 forks source link

What happens when I install `go-ipfs`? #204

Open schomatis opened 6 years ago

schomatis commented 6 years ago

(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),

https://github.com/whyrusleeping/gx/blob/a904dc7b51445cbe7a6f3b1b46018c4c140a6148/main.go#L359-L380

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 commented 6 years ago

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

https://github.com/whyrusleeping/gx/blob/a904dc7b51445cbe7a6f3b1b46018c4c140a6148/main.go#L342-L360

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,

https://github.com/whyrusleeping/gx/blob/a904dc7b51445cbe7a6f3b1b46018c4c140a6148/main.go#L31-L51

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