Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Seblu
installsystems
Commits
19ee776a
Commit
19ee776a
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Donwloading image from repository verify md5
parent
5fd0ead5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/repository.py
+4
-1
4 additions, 1 deletion
installsystems/repository.py
installsystems/tools.py
+10
-21
10 additions, 21 deletions
installsystems/tools.py
with
14 additions
and
22 deletions
installsystems/repository.py
+
4
−
1
View file @
19ee776a
...
...
@@ -148,7 +148,10 @@ class Repository(object):
def
get
(
self
,
name
,
version
):
'''
return a package from a name and version of pakage
'''
desc
=
self
.
db
.
get
(
name
,
version
)
return
PackageImage
(
os
.
path
.
join
(
self
.
config
.
path
,
desc
[
"
md5
"
]),
verbose
=
self
.
verbose
)
p
=
PackageImage
(
os
.
path
.
join
(
self
.
config
.
path
,
desc
[
"
md5
"
]),
verbose
=
self
.
verbose
)
if
p
.
md5
!=
desc
[
"
md5
"
]:
raise
Exception
(
"
Invalid package MD5
"
)
return
p
class
RepositoryConfig
(
object
):
'''
Repository configuration container
'''
...
...
This diff is collapsed.
Click to expand it.
installsystems/tools.py
+
10
−
21
View file @
19ee776a
...
...
@@ -12,10 +12,18 @@ import shutil
import
urllib2
from
installsystems.tarball
import
Tarball
def
md5sum
(
path
):
def
md5sum
(
path
=
None
,
fileobj
=
None
):
'''
Compute md5 of a file
'''
if
path
is
None
and
fileobj
is
None
:
raise
ValueError
(
"
No path or fileobj specified
"
)
if
fileobj
is
None
:
fileobj
=
uopen
(
path
)
m
=
hashlib
.
md5
()
m
.
update
(
open
(
path
,
"
r
"
).
read
())
while
True
:
buf
=
fileobj
.
read
(
1024
*
m
.
block_size
)
if
len
(
buf
)
==
0
:
break
m
.
update
(
buf
)
return
m
.
hexdigest
()
def
copy
(
source
,
destination
,
uid
=
None
,
gid
=
None
,
mode
=
None
,
timeout
=
None
):
...
...
@@ -92,22 +100,3 @@ def uopen(path):
return
urllib2
.
urlopen
(
path
)
else
:
raise
NotImplementedError
def
extractdata
(
image
,
name
,
target
,
filelist
=
None
):
'''
Extract a databall name into target
This will be done accross a forking to allow higher performance and
on the fly checksumming
'''
filename
=
"
%s-%s%s
"
%
(
image
.
id
,
name
,
image
.
extension_data
)
if
filename
not
in
image
.
datas
.
keys
():
raise
Exception
(
"
No such data tarball in %s
"
%
image
.
name
)
datainfo
=
image
.
datas
[
filename
]
fileobject
=
ropen
(
filename
)
tarball
=
Tarball
.
open
(
fileobj
=
fileobject
,
mode
=
"
r|gz
"
)
if
filelist
is
None
:
tarball
.
extractall
(
target
)
else
:
for
f
in
filelist
:
tarball
.
extract
(
f
,
target
)
tarball
.
close
()
fileobject
.
close
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment