Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
eic_tools
Spack
Commits
e58ee88a
Commit
e58ee88a
authored
10 years ago
by
Matthew LeGendre
Committed by
Todd Gamblin
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add 'spack packagerepo create' command
parent
7ea32865
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
lib/spack/spack/cmd/packagerepo.py
+45
-6
45 additions, 6 deletions
lib/spack/spack/cmd/packagerepo.py
lib/spack/spack/packages.py
+2
-2
2 additions, 2 deletions
lib/spack/spack/packages.py
with
47 additions
and
8 deletions
lib/spack/spack/cmd/packagerepo.py
+
45
−
6
View file @
e58ee88a
...
...
@@ -23,15 +23,20 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from
external
import
argparse
import
llnl.util.tty
as
tty
from
llnl.util.tty.color
import
colorize
from
llnl.util.tty.colify
import
colify
from
llnl.util.lang
import
index_by
from
llnl.util.filesystem
import
join_path
,
mkdirp
import
spack.spec
import
spack.config
from
spack.util.environment
import
get_path
from
spack.packages
import
packagerepo_filename
import
os
import
exceptions
from
contextlib
import
closing
description
=
"
Manage package sources
"
...
...
@@ -41,6 +46,10 @@ def setup_parser(subparser):
add_parser
=
sp
.
add_parser
(
'
add
'
,
help
=
packagerepo_add
.
__doc__
)
add_parser
.
add_argument
(
'
directory
'
,
help
=
"
Directory containing the packages.
"
)
create_parser
=
sp
.
add_parser
(
'
create
'
,
help
=
packagerepo_create
.
__doc__
)
create_parser
.
add_argument
(
'
directory
'
,
help
=
"
Directory containing the packages.
"
)
create_parser
.
add_argument
(
'
name
'
,
help
=
"
Name of new package repository.
"
)
remove_parser
=
sp
.
add_parser
(
'
remove
'
,
help
=
packagerepo_remove
.
__doc__
)
remove_parser
.
add_argument
(
'
name
'
)
...
...
@@ -48,19 +57,48 @@ def setup_parser(subparser):
list_parser
=
sp
.
add_parser
(
'
list
'
,
help
=
packagerepo_list
.
__doc__
)
def
packagerepo_add
(
args
):
"""
Add package sources to the Spack configuration.
"""
def
add_to_config
(
dir
):
config
=
spack
.
config
.
get_config
()
user_config
=
spack
.
config
.
get_config
(
'
user
'
)
orig
=
None
if
config
.
has_value
(
'
packagerepo
'
,
''
,
'
directories
'
):
orig
=
config
.
get_value
(
'
packagerepo
'
,
''
,
'
directories
'
)
if
orig
and
args
.
directory
in
orig
.
split
(
'
:
'
):
tty
.
die
(
'
Repo directory %s already exists in the repo list
'
%
args
.
directory
)
if
orig
and
dir
in
orig
.
split
(
'
:
'
):
return
False
newsetting
=
orig
+
'
:
'
+
args
.
directory
if
orig
else
args
.
directory
newsetting
=
orig
+
'
:
'
+
dir
if
orig
else
dir
user_config
.
set_value
(
'
packagerepo
'
,
''
,
'
directories
'
,
newsetting
)
user_config
.
write
()
return
True
def
packagerepo_add
(
args
):
"""
Add package sources to the Spack configuration.
"""
if
not
add_to_config
(
args
.
directory
):
tty
.
die
(
'
Repo directory %s already exists in the repo list
'
%
dir
)
def
packagerepo_create
(
args
):
"""
Create a new package repo at a directory and name
"""
dir
=
args
.
directory
name
=
args
.
name
if
os
.
path
.
exists
(
dir
)
and
not
os
.
path
.
isdir
(
dir
):
tty
.
die
(
'
File %s already exists and is not a directory
'
%
dir
)
if
not
os
.
path
.
exists
(
dir
):
try
:
mkdirp
(
dir
)
except
exceptions
.
OSError
,
e
:
tty
.
die
(
'
Failed to create new directory %s
'
%
dir
)
path
=
os
.
path
.
join
(
dir
,
packagerepo_filename
)
try
:
with
closing
(
open
(
path
,
'
w
'
))
as
repofile
:
repofile
.
write
(
name
+
'
\n
'
)
except
exceptions
.
IOError
,
e
:
tty
.
die
(
'
Could not create new file %s
'
%
path
)
if
not
add_to_config
(
args
.
directory
):
tty
.
warn
(
'
Repo directory %s already exists in the repo list
'
%
dir
)
def
packagerepo_remove
(
args
):
...
...
@@ -80,6 +118,7 @@ def packagerepo_list(args):
def
packagerepo
(
parser
,
args
):
action
=
{
'
add
'
:
packagerepo_add
,
'
create
'
:
packagerepo_create
,
'
remove
'
:
packagerepo_remove
,
'
list
'
:
packagerepo_list
}
action
[
args
.
packagerepo_command
](
args
)
This diff is collapsed.
Click to expand it.
lib/spack/spack/packages.py
+
2
−
2
View file @
e58ee88a
...
...
@@ -44,7 +44,7 @@
from
spack.repo_loader
import
RepoLoader
,
imported_packages_module
,
package_file_name
# Filename for package repo names
_
packagerepo_filename
=
'
reponame
'
packagerepo_filename
=
'
reponame
'
def
_autospec
(
function
):
"""
Decorator that automatically converts the argument of a single-arg
...
...
@@ -85,7 +85,7 @@ def __init__(self, default_root):
def
_read_reponame_from_directory
(
self
,
dir
):
"""
For a packagerepo directory, read the repo name from the dir/reponame file
"""
path
=
os
.
path
.
join
(
dir
,
'
repo
name
'
)
path
=
os
.
path
.
join
(
dir
,
packagerepo_file
name
)
try
:
with
closing
(
open
(
path
,
'
r
'
))
as
reponame_file
:
...
...
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