-
-
Notifications
You must be signed in to change notification settings - Fork 25
Add Homebrew Package support #44
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
Changes from 3 commits
3d85342
bc24444
54ad427
daa099a
d5ae02d
ecd26a5
443af63
7cc56bf
3cb01dc
de295e7
72456f1
6804289
3505cf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,8 @@ def get_cargo_data_from_purl(purl): | |
| ) | ||
| versions = response.get("versions", []) | ||
| for version in versions: | ||
| version_purl = PackageURL(type=purl.type, name=name, version=version.get("num")) | ||
| version_purl = PackageURL( | ||
| type=purl.type, name=name, version=version.get("num")) | ||
| dl_path = version.get("dl_path") | ||
| if dl_path: | ||
| download_url = f"{base_url}/{dl_path}" | ||
|
|
@@ -327,3 +328,26 @@ def get_rubygems_data_from_purl(purl): | |
| download_url=download_url, | ||
| **purl.to_dict(), | ||
| ) | ||
|
|
||
|
|
||
| @router.route("pkg:brew/.*") | ||
| def get_homebrew_data_from_purl(purl): | ||
|
pombredanne marked this conversation as resolved.
|
||
| """ | ||
| Generate `Package` object from the `purl` string of brew type | ||
| """ | ||
| purl = PackageURL.from_string(purl) | ||
| name = purl.name | ||
| base_path = "https://formulae.brew.sh/api/formula" | ||
| api_url = f"{base_path}/{name}.json" | ||
| response = get_response(api_url) | ||
| declared_license = response.get("license") or None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change it. |
||
| homepage_url = response.get("homepage") | ||
| version = response.get("versions") or None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change it. |
||
| download_url = response.get("urls")["stable"]["url"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if response does not have "urls" ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I add
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation of the homebrew json api tells that the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look how these things are done in the above block of code
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, will look into it. Thanks for the feedback, will do the changes by tomorrow. |
||
| yield Package( | ||
| homepage_url=homepage_url, | ||
| api_url=api_url, | ||
| declared_license=declared_license, | ||
| download_url=download_url, | ||
| **purl.to_dict(), | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "0": { | ||
| "type": "brew", | ||
| "namespace": null, | ||
| "name": "node", | ||
| "version": null, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should collect version data; it seems like there is a bug in your code, as I see you attempt to collect this version data in package.py (on line 344-345)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MaJuRG, Thanks for pointing out the bug, I know this is supposed to be a good first issue, but I am really new to the development side, I appreciate all the help. But I am stuck here, as you said I changed the version in the Here is the diff of the test when I ran I also tried to check the above code and see if I could implement it in a way it is implemented above, but did not understand that, I am really sorry for this. |
||
| "qualifiers": {}, | ||
| "subpath": null, | ||
| "primary_language": null, | ||
| "description": null, | ||
| "release_date": null, | ||
| "parties": [], | ||
| "keywords": [], | ||
| "homepage_url": "https://nodejs.org/", | ||
| "download_url": "https://nodejs.org/dist/v14.13.1/node-v14.13.1.tar.gz", | ||
| "api_url": "https://formulae.brew.sh/api/formula/node.json", | ||
| "size": null, | ||
| "sha1": null, | ||
| "md5": null, | ||
| "sha256": null, | ||
| "sha512": null, | ||
| "bug_tracking_url": null, | ||
| "code_view_url": null, | ||
| "vcs_url": null, | ||
| "copyright": null, | ||
| "license_expression": null, | ||
| "declared_license": "MIT", | ||
| "notice_text": null, | ||
| "root_path": null, | ||
| "dependencies": [], | ||
| "contains_source_code": null, | ||
| "source_packages": [], | ||
| "purl": "pkg:brew/node", | ||
| "repository_homepage_url": null, | ||
| "repository_download_url": null, | ||
| "api_data_url": null | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| { | ||
| "name": "node", | ||
| "full_name": "node", | ||
| "oldname": null, | ||
| "aliases": [ | ||
| "node.js", | ||
| "node@14", | ||
| "nodejs", | ||
| "npm" | ||
| ], | ||
| "versioned_formulae": [ | ||
| "node@12", | ||
| "node@10" | ||
| ], | ||
| "desc": "Platform built on V8 to build network applications", | ||
| "license": "MIT", | ||
| "homepage": "https://nodejs.org/", | ||
| "versions": { | ||
| "stable": "14.13.1", | ||
| "head": "HEAD", | ||
| "bottle": true | ||
| }, | ||
| "urls": { | ||
| "stable": { | ||
| "url": "https://nodejs.org/dist/v14.13.1/node-v14.13.1.tar.gz", | ||
| "tag": null, | ||
| "revision": null | ||
| } | ||
| }, | ||
| "revision": 0, | ||
| "version_scheme": 0, | ||
| "bottle": { | ||
| "stable": { | ||
| "rebuild": 0, | ||
| "cellar": ":any", | ||
| "prefix": "/usr/local", | ||
| "root_url": "https://homebrew.bintray.com/bottles", | ||
| "files": { | ||
| "catalina": { | ||
| "url": "https://homebrew.bintray.com/bottles/node-14.13.1.catalina.bottle.tar.gz", | ||
| "sha256": "c5574d926c10ecb8a18faa551f6a15c362512134577110c2678d52db3382ba42" | ||
| }, | ||
| "mojave": { | ||
| "url": "https://homebrew.bintray.com/bottles/node-14.13.1.mojave.bottle.tar.gz", | ||
| "sha256": "3d42a543356788cb20a3cd91306e9e533c2939b7609c3dc91ffdd405fab1b25f" | ||
| }, | ||
| "high_sierra": { | ||
| "url": "https://homebrew.bintray.com/bottles/node-14.13.1.high_sierra.bottle.tar.gz", | ||
| "sha256": "8c9d9dd8a341bd74aec4e8ba1a8abb8ba92e137d771290613676798f0b4a61ba" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "keg_only": false, | ||
| "bottle_disabled": false, | ||
| "options": [], | ||
| "build_dependencies": [ | ||
| "pkg-config", | ||
| "python@3.8" | ||
| ], | ||
| "dependencies": [ | ||
| "icu4c" | ||
| ], | ||
| "recommended_dependencies": [], | ||
| "optional_dependencies": [], | ||
| "uses_from_macos": [], | ||
| "requirements": [], | ||
| "conflicts_with": [], | ||
| "caveats": null, | ||
| "installed": [], | ||
| "linked_keg": null, | ||
| "pinned": false, | ||
| "outdated": false, | ||
| "deprecated": false, | ||
| "disabled": false, | ||
| "analytics": { | ||
| "install": { | ||
| "30d": { | ||
| "node": 405637, | ||
| "node --HEAD": 44, | ||
| "node --with-full-icu": 1, | ||
| "node --without-npm": 1 | ||
| }, | ||
| "90d": { | ||
| "node": 1074821, | ||
| "node --HEAD": 117, | ||
| "node --without-npm": 3, | ||
| "Node": 1, | ||
| "node --with-full-icu": 1 | ||
| }, | ||
| "365d": { | ||
| "node": 4314220, | ||
| "node --HEAD": 617, | ||
| "node --without-npm": 29, | ||
| "node --without-icu4c": 13, | ||
| "node --with-openssl@1.1": 6 | ||
| } | ||
| }, | ||
| "install_on_request": { | ||
| "30d": { | ||
| "node": 294250, | ||
| "node --HEAD": 15 | ||
| }, | ||
| "90d": { | ||
| "node": 787407, | ||
| "node --HEAD": 52, | ||
| "Node": 1 | ||
| }, | ||
| "365d": { | ||
| "node": 3134446, | ||
| "node --HEAD": 343, | ||
| "node --without-icu4c": 13, | ||
| "node --without-npm": 9, | ||
| "node --with-openssl@1.1": 6 | ||
| } | ||
| }, | ||
| "build_error": { | ||
| "30d": { | ||
| "node": 0 | ||
| } | ||
| } | ||
| }, | ||
| "generated_date": "2020-10-11" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change these lines :), they are out of scope of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have a setting of
Format on saveon my vscode, it happened unknowingly, will take care in the future. Thanks for the feedback.