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
9edf3677
Commit
9edf3677
authored
Jun 12, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0f46412d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
nxdbom/__init__.py
nxdbom/__init__.py
+39
-3
setup.py
setup.py
+1
-0
x.sh
x.sh
+1
-1
No files found.
nxdbom/__init__.py
View file @
9edf3677
...
...
@@ -39,6 +39,11 @@ from urllib.request import urlretrieve
import
email.parser
import
zipfile
import
shutil
from
contextlib
import
closing
from
hashlib
import
md5
import
logging
from
slapos.libnetworkcache
import
NetworkcacheClient
# PkgInfo represents information about a package
...
...
@@ -557,14 +562,43 @@ def license_of(url):
pkgfile
=
'.CACHE/pkg/'
+
basename
(
xpath
)
if
not
exists
(
pkgfile
):
mkdir_p
(
'.CACHE/pkg'
)
print
(
'DL %s ...'
%
url
,
file
=
sys
.
stderr
)
urlretrieve
(
url
,
pkgfile
)
wget
(
url
,
pkgfile
)
#shutil.unpack_archive(pkgfile, xpath)
# XXX
return
None
# wget downloads url to dstfile.
# it first tries shacache and the direct download.
_nc
=
None
def
wget
(
url
,
dstfile
):
# see src/zc/buildout/download.py
global
_nc
if
_nc
is
None
:
_nc
=
NetworkcacheClient
({
'download-cache-url'
:
'http://shacache.nxdcdn.com'
,
'download-dir-url'
:
'http://shadir.nxdcdn.com'
,
})
cachekey
=
'file-urlmd5:'
+
md5
(
url
.
encode
(
'utf-8'
)).
hexdigest
()
if
_nc
.
tryDownload
(
cachekey
):
with
_nc
:
entry
=
next
(
_nc
.
select
(
cachekey
,
{
'url'
:
url
}),
None
)
if
entry
is
not
None
:
#print('DL %s ... (cache)' % url, file=sys.stderr)
with
closing
(
_nc
.
download
(
entry
[
'sha512'
]))
as
src
,
\
open
(
dstfile
+
'.part'
,
'wb'
)
as
dst
:
shutil
.
copyfileobj
(
src
,
dst
)
os
.
rename
(
dstfile
+
'.part'
,
dstfile
)
return
# direct
print
(
'DL %s ... (direct)'
%
url
,
file
=
sys
.
stderr
)
1
/
0
#urlretrieve(url, dstfile)
# XXX temp hack: disable ipv6
# https://stackoverflow.com/a/6319043/9456786
import
socket
...
...
@@ -610,6 +644,8 @@ def main():
print
(
__doc__
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
level
=
logging
.
INFO
)
what
,
arg
=
sys
.
argv
[
1
:]
if
what
==
'software'
:
bom
=
bom_software
(
arg
)
...
...
setup.py
View file @
9edf3677
...
...
@@ -13,6 +13,7 @@ setup(
keywords
=
'Nexedi software build BOM'
,
packages
=
find_packages
(),
install_requires
=
[
'slapos.libnetworkcache'
],
extras_require
=
{
'test'
:
[
'pytest'
],
},
...
...
x.sh
View file @
9edf3677
#!/bin/bash
python3.9 nxdbom/__init__.py
software ../runner/software/7f1663e8148f227ce3c6a38fc52796e2
# erp5
nxdbom
software ../runner/software/7f1663e8148f227ce3c6a38fc52796e2
# erp5
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