clib icon indicating copy to clipboard operation
clib copied to clipboard

Support multiple registries and repositories

Open nouwaarom opened this issue 3 years ago • 7 comments

Towards fixing #105 In order to support multiple registries and be able to download packages from multiple sources I had to change quite a few things.

  • An abstraction for registries so that multiple registries can be added. (currently github wiki pages and gitlab files are supported)
  • Add extra registries in clib.json in a registries item.
  • Store secrets in clib_secrets.json so that we can connect with private registries and repositories
  • Make an abstraction for repositories, a repository is a place we can download packages from (currently implemented gitlab and github)

Changes

  • Changed the "has pthread?" test because it doesn't work when cross-compiling with dockcross.
  • Move instructions for building from Readme.md to Building.md and add instructions for cross-compiling for windows (as it took me some time to figure this out)
  • Changed the windows test build in github actions to use pthread as that seems to work fine (after fixing the pthread detection script)
  • Add instructions for how to install from other sources to Usage.md
  • Fix multithreading when downloading package files.

Todo

  • [x] Add a test for reading and using secrets from clib_secrets.json
  • [x] Add a test for reading packages from an extra registry.
  • [x] Add a test for installing a package from gitlab.com

nouwaarom avatar Mar 25 '21 15:03 nouwaarom

@nouwaarom i can give this a try this afternoon (UTC-4) - I do not know of any clib packages hosted on Gitlab, do you have some instructions that I can use to try this stuff out?

jwerle avatar Mar 26 '21 13:03 jwerle

Okay, cool. I have been using a private gitlab instance to develop this. I will setup a small demo on gitlab.com now and add some instructions.

nouwaarom avatar Mar 26 '21 14:03 nouwaarom

I create a small demo. It can be found at https://gitlab.com/nouwaarom/clib-demo with some instructions in the readme. I have developed on ubuntu. I don't know what system you use but I hope it compiles ;) Please let me know if you have questions or issues.

nouwaarom avatar Mar 26 '21 17:03 nouwaarom

This is great! Fantastic work @nouwaarom! Thank you for putting this together.

A PR this big may take some time to review, so please be patient with us. I will try to spend some time testing this out in the next few days.

stephenmathieson avatar Mar 27 '21 18:03 stephenmathieson

I am very excited for this! I am working through the changes locally now and have some initial notes:

running clib install . on the clib-demo project root before moving clib_secrets.json.dist to clib_secrets.json results in a segfault:

 $ clib install .                                                                                                                                                           
       error : Secrets file clib_secrets.json does not exist.
        info : reading local clib.json
Segmentation fault (core dumped)

after moving the file, if I run, clib install . before setting my personal access token in the file I get:

 $ clib install .                                                                                                                                                           
        info : reading local clib.json
REGISTRY: could not list packages from. https://gitlab.com/api/v4/projects/25447829/repository/files/README.md/raw?ref=master
     warning : missing "repo" in  clib.json
     warning : missing repo in clib.json or package.json file for clib-demo
       error : no such file: package.json

we should probably have more helpful error messages

after setting the personal access token in the clibs_secrets.json file I was able to successful install the dependencies

I echo @stephenmathieson on being patient as this is a big change. Perhaps we can get some tests in this change too?

jwerle avatar Mar 27 '21 18:03 jwerle

I echo @stephenmathieson on being patient as this is a big change. Perhaps we can get some tests in this change too?

Yes, I think that adding some tests is a good idea. I am currently working on passing all current tests again because most of them still fail :) After that I will add some tests for the new functionality. What is the current strategy for writing tests?

nouwaarom avatar Mar 27 '21 22:03 nouwaarom

Hi Stephen. I'm sorry to hear that you could not install those dependencies. The problem with sha1 is that package.json in master specifies that the latest version is 0.0.1 but this tag is missing. (I think we should add an error message saying the last tag is missing.

The problem with module is that it is not listed in a registry. The registry is required to lookup where a package can be downloaded from. (gitlab or github). We could add a fallback to github.com but it is better to just add module to the registry IMHO.

nouwaarom avatar May 02 '21 10:05 nouwaarom