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
21f5789f
Commit
21f5789f
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Add extract command
parent
ad06b952
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
bin/is
+18
-0
18 additions, 0 deletions
bin/is
installsystems/image.py
+23
-1
23 additions, 1 deletion
installsystems/image.py
installsystems/tools.py
+1
-1
1 addition, 1 deletion
installsystems/tools.py
with
42 additions
and
2 deletions
bin/is
+
18
−
0
View file @
21f5789f
...
...
@@ -144,6 +144,14 @@ def c_del(parser, args):
raise
Exception
(
"
Abort
"
)
repo
.
delete
(
img
.
name
,
img
.
version
)
def
c_extract
(
parser
,
args
):
'''
Extract an image package inside a directory
'''
repoman
=
load_repositories
(
args
)
img
,
repo
=
select_image
(
args
.
image
,
repoman
)
img
.
extract
(
args
.
directory
,
payload
=
args
.
payload
,
force
=
args
.
force
)
def
c_get
(
parser
,
args
):
'''
Get a remove image in current directory
...
...
@@ -325,6 +333,16 @@ p_del.add_argument("-f", "--force", action="store_true", default=False,
help
=
"
delete image without confirmation
"
)
p_del
.
set_defaults
(
func
=
c_del
)
# extract command parser
p_extract
=
subparsers
.
add_parser
(
"
extract
"
,
help
=
c_extract
.
__doc__
.
lower
())
p_extract
.
add_argument
(
"
-p
"
,
action
=
"
store_true
"
,
dest
=
"
payload
"
,
default
=
False
,
help
=
"
extract payload
"
)
p_extract
.
add_argument
(
"
-f
"
,
"
--force
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
overwrite existing directories
"
)
p_extract
.
add_argument
(
"
image
"
,
help
=
"
image to extract
"
)
p_extract
.
add_argument
(
"
directory
"
,
help
=
"
directory where image will be extracted
"
)
p_extract
.
set_defaults
(
func
=
c_extract
)
# get command parser
p_get
=
subparsers
.
add_parser
(
"
get
"
,
help
=
c_get
.
__doc__
.
lower
())
p_get
.
set_defaults
(
func
=
c_get
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/image.py
+
23
−
1
View file @
21f5789f
...
...
@@ -461,6 +461,25 @@ class PackageImage(Image):
arrow
(
filename
)
out
(
self
.
_tarball
.
get_str
(
filename
))
def
extract
(
self
,
directory
,
force
=
False
,
payload
=
False
):
'''
Extract content of the image inside a repository
'''
# check destination
if
not
os
.
path
.
isdir
(
directory
):
istools
.
mkdir
(
directory
)
if
not
force
and
len
(
os
.
listdir
(
directory
))
!=
0
:
raise
Exception
(
"
%s is not empty
"
%
directory
)
# extract content
arrow
(
"
Extracting image in %s
"
%
directory
)
self
.
_tarball
.
extractall
(
directory
)
# launch payload extract
if
payload
:
for
payname
in
self
.
payload
:
dest
=
os
.
path
.
join
(
directory
,
"
payload
"
,
payname
)
arrow
(
"
Extracting payload %s in %s
"
%
(
payname
,
dest
))
self
.
payload
[
payname
].
extract
(
dest
,
force
=
force
)
def
run_parser
(
self
,
**
kwargs
):
'''
Run parser scripts
...
...
@@ -658,7 +677,7 @@ class Payload(object):
if
not
force
and
len
(
os
.
listdir
(
dest
))
>
0
:
raise
Exception
(
"
Directory %s is not empty (need force)
"
%
dest
)
else
:
o
s
.
mkdir
(
dest
)
istool
s
.
mkdir
(
dest
)
# try to open payload file
try
:
fo
=
istools
.
uopen
(
self
.
path
)
...
...
@@ -688,6 +707,9 @@ class Payload(object):
# if dest is a directory try to create file inside
if
os
.
path
.
isdir
(
dest
):
dest
=
os
.
path
.
join
(
dest
,
self
.
name
)
# try to create leading directories
elif
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
dest
)):
istools
.
mkdir
(
os
.
path
.
dirname
(
dest
))
# check validity of dest
if
os
.
path
.
exists
(
dest
):
if
os
.
path
.
isdir
(
dest
):
...
...
This diff is collapsed.
Click to expand it.
installsystems/tools.py
+
1
−
1
View file @
21f5789f
...
...
@@ -81,7 +81,7 @@ def mkdir(path, uid=None, gid=None, mode=None):
'''
Create a directory and set rights
'''
os
.
m
k
dir
(
path
)
os
.
m
ake
dir
s
(
path
)
chrights
(
path
,
uid
,
gid
,
mode
)
def
chrights
(
path
,
uid
=
None
,
gid
=
None
,
mode
=
None
,
mtime
=
None
):
...
...
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