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
1a257a8f
Commit
1a257a8f
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
repoman is always used to handle repositories from is
parent
3f907f82
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
bin/is
+41
-39
41 additions, 39 deletions
bin/is
installsystems/repository.py
+13
-0
13 additions, 0 deletions
installsystems/repository.py
with
54 additions
and
39 deletions
bin/is
+
41
−
39
View file @
1a257a8f
...
...
@@ -21,22 +21,26 @@ from installsystems.config import MainConfigFile, RepoConfigFile
def
load_repositories
(
args
):
'''
Load repositor
y
on a
rg line
Load repositor
ies
on a
repository manager
'''
repos
=
[]
# remove cache is asked
if
args
.
no_cache
:
args
.
cache
=
None
# init repo cache object
repoman
=
RepositoryManager
(
args
.
cache
,
timeout
=
args
.
timeout
)
# register repositories (order matter)
# load repo configs
if
args
.
repo_path
is
not
None
:
# from command line
repo
s
=
[
RepositoryConfig
(
None
,
path
=
args
.
repo_path
)
]
repo
man
.
register
(
RepositoryConfig
(
None
,
path
=
args
.
repo_path
)
)
else
:
# from config
repos
+=
RepoConfigFile
(
args
.
repo_config
).
repos
# filtering on repository name if present
if
args
.
repo_filter
is
not
None
:
repos
=
filter
(
lambda
x
:
x
.
name
==
args
.
repo_filter
,
repos
)
# print selected repositories
debug
(
"
Loaded repositories: %s
"
%
[
x
.
name
for
x
in
repos
])
return
repos
for
repoconf
in
RepoConfigFile
(
args
.
repo_config
).
repos
:
# filtering on repository name if present
if
args
.
repo_filter
is
not
None
and
repoconf
.
name
!=
args
.
repo_filter
:
continue
repoman
.
register
(
repoconf
)
return
repoman
def
c_init_image
(
parser
,
args
):
'''
...
...
@@ -52,11 +56,13 @@ def c_init_repo(parser, args):
Create a empty repository
'''
try
:
repos
=
load_repositories
(
args
)
if
len
(
repos
)
!=
1
:
raise
Exception
(
"
Please select one repository
"
)
Repository
.
create
(
repos
[
0
])
debug
(
"
Repository: %s
"
%
repos
[
0
])
repoman
=
load_repositories
(
args
)
if
len
(
repoman
)
==
0
:
raise
Exception
(
"
No repository selected
"
)
elif
len
(
repoman
)
>
1
:
raise
Exception
(
"
Please select only one repository
"
)
Repository
.
create
(
repoman
[
0
])
debug
(
"
Repository: %s
"
%
repoman
[
0
])
except
Exception
as
e
:
raise
Exception
(
"
init repo failed: %s
"
%
e
)
...
...
@@ -83,10 +89,12 @@ def c_add(parser, args):
Add an image package into a repository
'''
try
:
repos
=
load_repositories
(
args
)
if
len
(
repos
)
!=
1
:
raise
Exception
(
"
Please select one repository
"
)
repo
=
Repository
(
repos
[
0
])
repoman
=
load_repositories
(
args
)
if
len
(
repoman
)
==
0
:
raise
Exception
(
"
No repository selected
"
)
elif
len
(
repoman
)
>
1
:
raise
Exception
(
"
Please select only one repository
"
)
repo
=
repoman
[
0
]
pkg
=
PackageImage
(
args
.
path
)
repo
.
add
(
pkg
,
delete
=
not
args
.
preserve
)
except
Exception
as
e
:
...
...
@@ -97,10 +105,12 @@ def c_del(parser, args):
Remove an image package from a repository
'''
try
:
repos
=
load_repositories
(
args
)
if
len
(
repos
)
!=
1
:
raise
Exception
(
"
Please select one repository
"
)
repo
=
Repository
(
repos
[
0
])
repoman
=
load_repositories
(
args
)
if
len
(
repoman
)
==
0
:
raise
Exception
(
"
No repository selected
"
)
elif
len
(
repoman
)
>
1
:
raise
Exception
(
"
Please select only one repository
"
)
repo
=
repoman
[
0
]
repo
.
delete
(
args
.
image_name
,
args
.
image_version
)
except
Exception
as
e
:
raise
Exception
(
"
del failed: %s
"
%
e
)
...
...
@@ -113,17 +123,8 @@ def c_install(parser, args):
if
istools
.
pathtype
(
args
.
image
)
==
"
file
"
and
os
.
path
.
isfile
(
args
.
image
):
pkg
=
PackageImage
(
istools
.
abspath
(
args
.
image
))
elif
PackageImage
.
check_image_name
(
args
.
image
):
# remove cache is asked
if
args
.
no_cache
:
args
.
cache
=
None
# init repo cache object
repoman
=
RepositoryManager
(
args
.
cache
,
timeout
=
args
.
timeout
)
# load repositories
repos_config
=
load_repositories
(
args
)
# register repositories (order matter)
for
repo_conf
in
repos_config
:
repoman
.
register
(
repo_conf
)
# get image package
repoman
=
load_repositories
(
args
)
pkg
=
repoman
.
get
(
args
.
image
,
args
.
image_version
)
else
:
args
.
subparser
.
print_usage
()
...
...
@@ -183,8 +184,13 @@ p_main.add_argument("-f", "--repo-filter", default=None,
help
=
"
select repository by name in config files
"
)
p_main
.
add_argument
(
"
-r
"
,
"
--repo-path
"
,
default
=
None
,
help
=
"
repository path
"
)
p_main
.
add_argument
(
"
-t
"
,
"
--timeout
"
,
dest
=
"
timeout
"
,
type
=
int
,
default
=
None
,
help
=
"
download timeout
"
)
p_main
.
add_argument
(
"
-C
"
,
"
--cache
"
,
default
=
None
,
help
=
"
path of the repository cache
"
)
p_main
.
add_argument
(
"
--no-cache
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
Not use persistent db caching
"
)
p_main
.
add_argument
(
"
-t
"
,
"
--timeout
"
,
dest
=
"
timeout
"
,
type
=
int
,
default
=
3
,
help
=
"
download timeout (default 3)
"
)
# create a subparsers for each command
subparsers
=
p_main
.
add_subparsers
()
...
...
@@ -225,10 +231,6 @@ p_del.set_defaults(func=c_del)
p_install
=
subparsers
.
add_parser
(
"
install
"
,
help
=
c_install
.
__doc__
.
lower
())
p_install
.
add_argument
(
'
-f
'
,
"
--force
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
overwrite existing image
"
)
p_install
.
add_argument
(
"
-c
"
,
"
--cache
"
,
default
=
None
,
help
=
"
Not use persistent db caching
"
)
p_install
.
add_argument
(
"
--no-cache
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
Not use persistent db caching
"
)
p_install
.
add_argument
(
"
-v
"
,
"
--image-version
"
,
type
=
int
,
default
=
None
,
help
=
"
image version
"
)
p_install
.
add_argument
(
"
image
"
,
help
=
"
image to install (path or name)
"
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/repository.py
+
13
−
0
View file @
1a257a8f
...
...
@@ -434,6 +434,19 @@ class RepositoryManager(object):
except
OSError
:
pass
def
__len__
(
self
):
'''
Return the number of repository registered
'''
return
len
(
self
.
repos
)
def
__getitem__
(
self
,
key
):
'''
Return a repostiory by its possition in list
'''
return
self
.
repos
[
key
]
def
register
(
self
,
config
):
'''
Register a repository from its config
...
...
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