Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceStage: use expanded archive name by default #11688

Merged
merged 14 commits into from
Jun 20, 2019

Conversation

scheibelp
Copy link
Member

@scheibelp scheibelp commented Jun 13, 2019

For resources, it is desirable to use the expanded archive name of the resource as the name of the directory when adding it to the root staging area.

#11528 established 'spack-src' as the universal directory where source files are placed, which also affected the behavior of resources managed with Stages.

This adds a new property to Stage to remember the name of the expanded source directory, and uses this as the default name when placing a resource directory in the root staging area.

This also:

  • Ensures that downloaded sources are archived using the expanded archive name
  • Updates working_dir context manager to guarantee restoration of original working directory when an exception occurs
  • Adds a "temp_cwd" context manager which creates a temporary directory and sets it as the working directory
  • Tests handling of exploding tarballs (Edit 6/19: this was already handled)

TODOS:

  • Tests should be added to avoid regressions.
  • (New: 6/14) Fix python 2.6 errors

Note: this does not support resources using the go fetch strategy, but go fetching logic is currently in flux anyhow and no packages currently use go-based resources.

Note: this undoes some changes from #11676 and #11667 that accommodated the behavior changes from #11528. Those changes are compatible with this PR but I removed them because they are not strictly required (and in general the purpose of this PR was to reduce the amount of work required to use resources). In terms of staging, this PR would work with the logic for hpcviewer before or after #11676, but the hpcviewer changes are not undone because that PR updated the directory structure for that package build.

@scheibelp scheibelp changed the title [WIP] ResourceStage: use expanded archive name by default ResourceStage: use expanded archive name by default Jun 17, 2019
@@ -520,7 +526,16 @@ def archive(self, destination, **kwargs):
tar.add_default_arg('--exclude=%s' % p)

with working_dir(self.stage.path):
tar('-czf', destination, os.path.basename(self.stage.source_path))
if self.stage.srcdir:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change addressing potential naming conflicts? Or ensuring any surviving archive has a meaningful name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter: srcdir stores whatever meaningful name can be extracted (e.g. the basename of the URL). If one cannot be extracted, then we resort to creating a tarball that expands to spack-src/.

if not spack.config.get('config:debug'):
args.insert(1, '--quiet')
git(*args)
debug = spack.config.get('config:debug')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the git destination option here (as Todd wanted)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm not familiar with that (the option or the context) - is this from a discussion in #11528?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #11528 (comment).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question is "why not check out the repository out directly to the spack-src directory?". The issue with that is that when we do that, we lose the repository name: for example if we do git clone https://github.com/spack then we get a directory called spack; this is useful when choosing a directory name for the archive in two cases:

  • This avoids putting resources named spack-src into a root stage
  • This avoids caching an SCM package into a directory called spack-src (i.e. when placed in var/spack/cache/)

Does that seem reasonable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Thanks for the clarification.

# Yet more efficiency, only download a 1-commit deep tree
if self.git_version >= ver('1.7.1'):
try:
git(*(args + ['--depth', '1', self.url]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above wrt using the git destination option.

@@ -828,8 +853,13 @@ def fetch(self):
args = ['checkout', '--force', '--quiet']
if self.revision:
args += ['-r', self.revision]
args.extend([self.url, self.stage.source_path])
self.svn(*args)
args.extend([self.url])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about using svn path (or destination) option as requested by Todd.

@@ -937,8 +967,13 @@ def fetch(self):
if self.revision:
args.extend(['-r', self.revision])

args.extend([self.url, self.stage.source_path])
self.hg(*args)
args.extend([self.url])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question wrt hg destination option as for git and svn.

@scheibelp scheibelp closed this Jun 19, 2019
@scheibelp scheibelp reopened this Jun 19, 2019
@scheibelp scheibelp merged commit 284ae9d into spack:develop Jun 20, 2019
scheibelp added a commit that referenced this pull request Jun 21, 2019
Fixes #11816

Allow packages to refer to non-expanded downloads (e.g. a single
script) using Stage.archive_file. This addresses a regression from
#11688 and adds a unit test for it.
carsonwoods pushed a commit to carsonwoods/spack that referenced this pull request Jun 27, 2019
For resources, it is desirable to use the expanded archive name of
the resource as the name of the directory when adding it to the root
staging area.

spack#11528 established 'spack-src' as the universal directory where
source files are placed, which also affected the behavior of
resources managed with Stages.

This adds a new property ('srcdir') to Stage to remember the name of
the expanded source directory, and uses this as the default name when
placing a resource directory in the root staging area.

This also:

* Ensures that downloaded sources are archived using the expanded
  archive name (otherwise Spack will not be able to determine the
  original directory name when using a cached archive).
* Updates working_dir context manager to guarantee restoration of
  original working directory when an exception occurs
* Adds a "temp_cwd" context manager which creates a temporary
  directory and sets it as the working directory
carsonwoods pushed a commit to carsonwoods/spack that referenced this pull request Jun 27, 2019
Fixes spack#11816

Allow packages to refer to non-expanded downloads (e.g. a single
script) using Stage.archive_file. This addresses a regression from
spack#11688 and adds a unit test for it.
dev-zero pushed a commit to dev-zero/spack that referenced this pull request Aug 13, 2019
For resources, it is desirable to use the expanded archive name of
the resource as the name of the directory when adding it to the root
staging area.

spack#11528 established 'spack-src' as the universal directory where
source files are placed, which also affected the behavior of
resources managed with Stages.

This adds a new property ('srcdir') to Stage to remember the name of
the expanded source directory, and uses this as the default name when
placing a resource directory in the root staging area.

This also:

* Ensures that downloaded sources are archived using the expanded
  archive name (otherwise Spack will not be able to determine the
  original directory name when using a cached archive).
* Updates working_dir context manager to guarantee restoration of
  original working directory when an exception occurs
* Adds a "temp_cwd" context manager which creates a temporary
  directory and sets it as the working directory
dev-zero pushed a commit to dev-zero/spack that referenced this pull request Aug 13, 2019
Fixes spack#11816

Allow packages to refer to non-expanded downloads (e.g. a single
script) using Stage.archive_file. This addresses a regression from
spack#11688 and adds a unit test for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants