73
77
post_path = os.path.join(temp_dir, 'post_scripts')
74
78
_copy_script_files(testsuite.post_upgrade_tests.location, post_path)
80
adt_base_path, adt_cmd = _get_adt_path(temp_dir)
76
82
yield TestrunTempFiles(
77
adt_base_path=_grab_git_version_autopkgtest(temp_dir),
83
adt_base_path=adt_base_path,
78
85
run_config_file=run_config_path,
79
86
# Should we create a dir so that it won't interfer?
80
87
unbuilt_dir=temp_dir,
168
def _grab_git_version_autopkgtest(tmp_dir):
169
# Grab the git version of autopkgtest so that we can use the latest
170
# features (i.e. reboot-prepare).
171
# This is needed as 3.14+ is not in vivid.
172
# TODO: Remove this need by grabbing it from backports or universe.
173
git_url = 'git://anonscm.debian.org/autopkgtest/autopkgtest.git'
174
git_trunk_path = os.path.join(tmp_dir, 'local_autopkgtest')
175
git_command = ['git', 'clone', git_url, git_trunk_path]
177
run_command_with_logged_output(git_command)
179
return git_trunk_path
175
def _get_adt_path(tmp_dir):
176
# Check if we need to get a git version of autopkgtest
177
# (If environment variables are set or a local version can't be found)
178
git_url = os.environ.get('AUTOPKGTEST_GIT_REPO', None)
179
git_hash = os.environ.get('AUTOPKGTEST_GIT_HASH', None)
180
local_adt = _get_local_adt()
181
if git_url or git_hash or local_adt is None:
182
git_url = git_url or DEFAULT_GIT_URL
183
logger.info('Fetching autopkgtest from git url: %s', git_url)
184
git_trunk_path = os.path.join(tmp_dir, 'local_autopkgtest')
185
git_command = ['git', 'clone', git_url, git_trunk_path]
186
retval = run_command_with_logged_output(git_command)
188
raise ChildProcessError('{} exited with status {}'.format(
189
git_command, retval))
191
logger.info('Checking out specific git hash: %s', git_hash)
194
'--git-dir', os.path.join(git_trunk_path, '.git'),
195
'--work-tree', git_trunk_path,
196
'checkout', git_hash,
198
run_command_with_logged_output(git_hash_command)
199
adt_path = os.path.join(git_trunk_path, 'tools')
200
adt_cmd = os.path.join(git_trunk_path, 'run-from-checkout')
202
logger.info('Using installed autopkgtest:')
203
run_command_with_logged_output(['dpkg-query', '-W', 'autopkgtest'])
204
adt_path, adt_cmd = local_adt
205
adt_cmd = os.path.join(adt_path, adt_cmd)
206
return (adt_path, adt_cmd)
209
def _get_local_adt():
210
path = find_executable('adt-run')
212
return path.rsplit('/', 1)