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
1a56a5d0
Commit
1a56a5d0
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Adding md5 of script tarball in repository
parent
19c4e26e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
installsystems/database.py
+11
-2
11 additions, 2 deletions
installsystems/database.py
installsystems/image.py
+19
-20
19 additions, 20 deletions
installsystems/image.py
installsystems/repository.py
+6
-6
6 additions, 6 deletions
installsystems/repository.py
with
36 additions
and
28 deletions
installsystems/database.py
+
11
−
2
View file @
1a56a5d0
...
...
@@ -40,15 +40,24 @@ class Database(object):
def
add
(
self
,
package
):
'''
Add a packaged image to a db
'''
arrow
(
"
Adding metadata to db
"
,
1
,
self
.
verbose
)
name
=
"
%s.json
"
%
package
.
name
()
# naming
name
=
"
%s.json
"
%
package
.
name
newdb_path
=
"
%s.new
"
%
self
.
path
# compute md5
arrow
(
"
Compute MD5 of %s
"
%
os
.
path
.
relpath
(
package
.
path
),
2
,
self
.
verbose
)
md5
=
package
.
md5
arrow
(
"
Formating metadata
"
,
2
,
self
.
verbose
)
desc
=
package
.
description
desc
[
"
md5
"
]
=
md5
jdesc
=
json
.
dumps
(
desc
)
try
:
arrow
(
"
Adding to tarball
"
,
2
,
self
.
verbose
)
db
=
Tarball
.
open
(
self
.
path
,
mode
=
'
r:bz2
'
)
newdb
=
Tarball
.
open
(
newdb_path
,
mode
=
'
w:bz2
'
)
for
ti
in
db
.
getmembers
():
if
ti
.
name
!=
name
:
newdb
.
addfile
(
ti
,
db
.
extractfile
(
ti
))
newdb
.
add_str
(
name
,
package
.
jdescription
()
,
tarfile
.
REGTYPE
,
0444
)
newdb
.
add_str
(
name
,
jdesc
,
tarfile
.
REGTYPE
,
0444
)
db
.
close
()
newdb
.
close
()
# preserve permission and stats when moving
...
...
This diff is collapsed.
Click to expand it.
installsystems/image.py
+
19
−
20
View file @
1a56a5d0
...
...
@@ -13,7 +13,6 @@ import json
import
StringIO
import
ConfigParser
import
subprocess
import
json
import
tarfile
import
re
import
installsystems.template
as
istemplate
...
...
@@ -267,6 +266,22 @@ class PackageImage(Image):
self
.
tarball
=
Tarball
.
open
(
self
.
path
,
mode
=
'
r:bz2
'
)
self
.
parse
()
@property
def
md5
(
self
):
'''
Return md5sum of the current tarball
'''
return
istools
.
md5sum
(
self
.
path
)
@property
def
name
(
self
):
'''
Return image name
'''
return
"
%s-%s
"
%
(
self
.
description
[
"
name
"
],
self
.
description
[
"
version
"
])
@property
def
databalls
(
self
):
'''
Create a dict of image and data tarballs
'''
return
[
os
.
path
.
join
(
self
.
base_path
,
d
)
for
d
in
self
.
description
[
"
data
"
]
]
def
parse
(
self
):
'''
Parse tarball and extract metadata
'''
# extract metadata
...
...
@@ -289,29 +304,13 @@ class PackageImage(Image):
arrow
(
"
Check MD5
"
,
1
,
self
.
verbose
)
databalls
=
self
.
description
[
"
data
"
]
for
databall
in
databalls
:
arrow
(
databall
,
2
,
self
.
verbose
)
md5_path
=
os
.
path
.
join
(
self
.
base_path
,
databall
)
arrow
(
os
.
path
.
relpath
(
md5_path
),
2
,
self
.
verbose
)
md5_meta
=
databalls
[
databall
][
"
md5
"
]
md5_file
=
istools
.
md5sum
(
os
.
path
.
join
(
self
.
base_path
,
databall
)
)
md5_file
=
istools
.
md5sum
(
md5_path
)
if
md5_meta
!=
md5_file
:
raise
Exception
(
"
Invalid md5: %s
"
%
databall
)
def
description
(
self
):
'''
Return metadatas of a tarball
'''
return
self
.
description
def
jdescription
(
self
):
'''
Return json formated metadatas
'''
return
json
.
dumps
(
self
.
description
)
def
name
(
self
):
'''
Return image name
'''
return
"
%s-%s
"
%
(
self
.
description
[
"
name
"
],
self
.
description
[
"
version
"
])
def
databalls
(
self
):
'''
Create a dict of image and data tarballs
'''
return
[
os
.
path
.
join
(
self
.
base_path
,
d
)
for
d
in
self
.
description
[
"
data
"
]
]
def
run_parser
(
self
,
gl
):
'''
Run parser scripts
'''
self
.
run_scripts
(
gl
,
"
parser
"
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
6
−
6
View file @
1a56a5d0
...
...
@@ -73,10 +73,10 @@ class Repository(object):
'''
Add a packaged image to repository
'''
# copy file to directory
arrow
(
"
Adding file to directories
"
,
1
,
self
.
verbose
)
arrow
(
"
Adding %s
"
%
os
.
path
.
basename
(
package
.
path
),
2
,
self
.
verbose
)
arrow
(
"
Adding %s
"
%
os
.
path
.
relpath
(
package
.
path
),
2
,
self
.
verbose
)
istools
.
copy
(
package
.
path
,
self
.
config
.
image
,
self
.
config
.
chown
,
self
.
config
.
chgroup
,
self
.
config
.
fchmod
)
for
db
in
package
.
databalls
()
:
for
db
in
package
.
databalls
:
arrow
(
"
Adding %s
"
%
os
.
path
.
basename
(
db
),
2
,
self
.
verbose
)
istools
.
copy
(
db
,
self
.
config
.
data
,
self
.
config
.
chown
,
self
.
config
.
chgroup
,
self
.
config
.
fchmod
)
...
...
@@ -92,8 +92,8 @@ class Repository(object):
error
(
"
Unable to find %s version %s in database
"
%
(
name
,
version
))
# removing script tarballs
arrow
(
"
Removing script tarball
"
,
1
,
self
.
verbose
)
tpath
=
os
.
path
.
join
(
self
.
config
.
image
,
"
%s-%s%s
"
%
(
name
,
version
,
Image
.
image_extension
))
tpath
=
os
.
path
.
join
(
self
.
config
.
image
,
"
%s-%s%s
"
%
(
name
,
version
,
Image
.
image_extension
))
if
os
.
path
.
exists
(
tpath
):
os
.
unlink
(
tpath
)
arrow
(
"
%s removed
"
%
os
.
path
.
basename
(
tpath
),
2
,
self
.
verbose
)
...
...
@@ -201,8 +201,8 @@ class RepositoryCache(object):
arrow
(
"
Updating repositories
"
,
1
,
self
.
verbose
)
for
r
in
self
.
repos
:
debug
(
"
%s: remote_last: %s, local_last:%s
"
%
(
r
,
self
.
repos
[
r
].
last
(),
self
.
last
(
r
)))
self
.
repos
[
r
].
last
(),
self
.
last
(
r
)))
if
self
.
repos
[
r
].
last
()
>
self
.
last
(
r
):
# copy last file
istools
.
copy
(
self
.
repos
[
r
].
last_path
,
os
.
path
.
join
(
self
.
last_path
,
r
))
...
...
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