opm icon indicating copy to clipboard operation
opm copied to clipboard

Feature Request: `opm dist-install`

Open jvanasco opened this issue 9 years ago • 13 comments

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

  • It would be much easier for local testing by module authors, before uploading to server
  • It would allow for offline caching of dists, which is useful for testing and build scripts

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
 

jvanasco avatar Nov 29 '16 21:11 jvanasco

@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 avatar Nov 29 '16 22:11 agentzh

@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.

agentzh avatar Nov 29 '16 22:11 agentzh

@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.

jvanasco avatar Nov 29 '16 22:11 jvanasco

@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 avatar Nov 29 '16 22:11 agentzh

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

agentzh avatar Nov 29 '16 22:11 agentzh

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

agentzh avatar Nov 29 '16 22:11 agentzh

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

agentzh avatar Nov 29 '16 22:11 agentzh

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.

agentzh avatar Nov 29 '16 23:11 agentzh

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!

jvanasco avatar Nov 29 '16 23:11 jvanasco

@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 avatar Nov 29 '16 23:11 agentzh

@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 avatar Nov 29 '16 23:11 agentzh

@jvanasco Pull requests are very welcome.

agentzh avatar Nov 29 '16 23:11 agentzh

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.

jvanasco avatar Nov 30 '16 20:11 jvanasco