openresty / opm

OpenResty Package Manager
https://opm.openresty.org/
459 stars 75 forks source link

Feature Request: `opm dist-install` #39

Open jvanasco opened 7 years ago

jvanasco commented 7 years ago

It would be nice if there were a way to install a dist file (as built by opm build)

It would also be nice if the output of opm build included the name of the distribution file that was just built.

i imagine the syntax could be something like:

 cd lua-resty-example
 opm build
 > found license: MIT license.
 > Package lua-resty-http-0.10 already installed.
 > a lua-resty-example-0.1
 > a lua-resty-example-0.1/dist.ini
 > a lua-resty-example-0.1/lib
 > a lua-resty-example-0.1/README.md
 > a lua-resty-example-0.1/lib/example
 > a lua-resty-example-0.1/lib/example/main.lua
 > Created distribution: lua-resty-example-0.1.tar.gz
 opm dist-install lua-resty-example-0.1.tar.gz
agentzh commented 7 years ago

@jvanasco Sounds good to me except that I don't like opm dist-install take any argument. Its usage should be similar to opm upload.

Pull requests welcome :)

agentzh commented 7 years ago

@jvanasco After some thinking, it seems to me that it might be tricky to implement since it would require many more dependencies if we want to go through all the real processing details on the package server. "Slim clients" might no longer be possible after introducing this.

jvanasco commented 7 years ago

@agentzh I don't think it should install any dependencies, just the declared package(s).

In one use case, I am porting something to opm. In order for me to test the distribution and make any necessary adjustments (based on how the opm client installs packages), I have to deploy the package to the opm repo then pull it back down. That means a non-functioning pre-release version can wind up distributed. If I were adjusting a deployed library, then I run the risk of people updating/installing a broken version of a once-working (and soon working again) library.

agentzh commented 7 years ago

@jvanasco It would depend on util/opm-pkg-indexer.pl at least.

The following command should serve your purpose well already:

cd lua-resty-example-0.1 && opm server-build
agentzh commented 7 years ago

@jvanasco BTW, it's not hard to set up your local opm server for testing. Everything is in the opm git repos.

agentzh commented 7 years ago

@jvanasco Just remember to adjust your ~/.opmrc file to point to your local opm server during testing.

agentzh commented 7 years ago

@jvanasco You'll also need to remember invoking util/opm-pkg-indexer.pl yourself after opm upload.

agentzh commented 7 years ago

Another way to tackle this is to add support for "developer releases" by differentiating such releases via special version number suffixes like "_1" and "_2". By default, users cannot install such versions unless explicitly specify the version number in the opm get command line. Pull requests are welcome.

jvanasco commented 7 years ago

I do think the easiest way is to just have a hook to install a given tarball into the site (or cwd or install-dir) using the existing infrastructure in the /bin/opm. I think I can pull this off (I haven't touched Perl in 10+ years)

The server-build is a great step for debugging (it raised some issues for me!), but it doesn't register in the local system.

hidden "developer versions" are great for a todo, but they wouldn't allow for offline development. that's kind of big for us -- we'd need to build/test locally, then hit the cloud.

running an OPM server might be an interim solution. i can see it as very useful for a full travis test. I'd really like to avoid that though, as it creates too many traps for people to fall into and use the wrong server.

let's see if i can pull anything off tonight!

agentzh commented 7 years ago

@jvanasco Existing opm get hits the package server via HTTP or HTTPS. I don't want to add an artificial code path for opm dist-install which is not really realistic for your purposes anyway.

agentzh commented 7 years ago

@jvanasco I just had another look. I now think dist-install has its own merit. The implementation should be simple, just wrap up the following operation sequence:

opm build
cd $dist-$version/
opm server-build
install $dist-$version.opm.tar.gz

The last step can reuse the code starting from the following line:

https://github.com/openresty/opm/blob/master/bin/opm#L1348

We do not need to re-invent anything here. Just some code refactoring in the opm script.

agentzh commented 7 years ago

@jvanasco Pull requests are very welcome.

jvanasco commented 7 years ago

I will have the first suggestion of a PR shortly.

The above functionality is working as build-install; I've also standardized some of the variable names so this package is easier to maintain.

I'm just cleaning up my work right now.