Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nxd-bom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
nxd-bom
Commits
a14348e6
Commit
a14348e6
authored
Jun 12, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
56539a3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
2 deletions
+40
-2
nxdbom/__init__.py
nxdbom/__init__.py
+40
-2
No files found.
nxdbom/__init__.py
View file @
a14348e6
...
@@ -30,13 +30,15 @@ An example of generated bill of material is provided in example/ors-bom.txt .
...
@@ -30,13 +30,15 @@ An example of generated bill of material is provided in example/ors-bom.txt .
from
__future__
import
print_function
from
__future__
import
print_function
import
sys
,
configparser
,
re
,
codecs
import
sys
,
os
,
configparser
,
re
,
codecs
from
os.path
import
basename
,
isdir
from
os.path
import
basename
,
isdir
,
exists
from
glob
import
glob
from
glob
import
glob
from
collections
import
namedtuple
from
collections
import
namedtuple
from
urllib.parse
import
unquote
from
urllib.parse
import
unquote
from
urllib.request
import
urlretrieve
import
email.parser
import
email.parser
import
zipfile
import
zipfile
import
shutil
# PkgInfo represents information about a package
# PkgInfo represents information about a package
...
@@ -69,6 +71,7 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
...
@@ -69,6 +71,7 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
ver
=
removeprefix
(
ver
,
name
+
'-'
)
# wendelin.core-2.0.alpha3-0-g6315384 -> 2.0.alpha3-0-g6315384
ver
=
removeprefix
(
ver
,
name
+
'-'
)
# wendelin.core-2.0.alpha3-0-g6315384 -> 2.0.alpha3-0-g6315384
if
'//'
in
urlpath
:
if
'//'
in
urlpath
:
url
=
urlpath
url
=
urlpath
license
=
license_of
(
url
)
else
:
else
:
if
kind
==
'egg'
:
if
kind
==
'egg'
:
# XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg
# XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg
...
@@ -542,6 +545,41 @@ def spdx_license_canon(license_name):
...
@@ -542,6 +545,41 @@ def spdx_license_canon(license_name):
return
spdx
return
spdx
# license_of returns license of package at url.
def
license_of
(
url
):
assert
'//'
in
url
,
url
_
,
xpath
=
url
.
split
(
'//'
,
1
)
# https://tukaani.org/xz/xz-5.2.5.tar.bz2 -> tukaani.org/xz/xz-5.2.5.tar.bz
assert
'//'
not
in
xpath
,
xpath
assert
'..'
not
in
xpath
,
xpath
xpath
=
'.CACHE/src/'
+
xpath
if
not
exists
(
xpath
):
# download + unpack -> xpath
print
(
'DL %s ...'
%
url
,
file
=
sys
.
stderr
)
mkdir_p
(
'.CACHE/pkg'
)
pkgfile
=
'.CACHE/pkg/'
+
basename
(
xpath
)
urlretrieve
(
url
,
pkgfile
)
shutil
.
unpack_archive
(
pkgfile
,
xpath
)
# XXX
return
None
# XXX temp hack: disable ipv6
# https://stackoverflow.com/a/6319043/9456786
import
socket
origGetAddrInfo
=
socket
.
getaddrinfo
def
getAddrInfoWrapper
(
host
,
port
,
family
=
0
,
socktype
=
0
,
proto
=
0
,
flags
=
0
):
return
origGetAddrInfo
(
host
,
port
,
socket
.
AF_INET
,
socktype
,
proto
,
flags
)
# replace the original socket.getaddrinfo by our version
socket
.
getaddrinfo
=
getAddrInfoWrapper
def
mkdir_p
(
path
):
os
.
makedirs
(
path
,
exist_ok
=
True
)
# ----------------------------------------
# ----------------------------------------
# fmt_bom formats BOM into text.
# fmt_bom formats BOM into text.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment