[Piuparts-commits] [piuparts] 01/01: drop code to support adt-backend providers
Holger Levsen
holger at layer-acht.org
Mon Sep 18 10:18:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit 2a138d97404383fa09da805fcd68988df46b8d39
Author: Holger Levsen <holger at layer-acht.org>
Date: Mon Sep 18 12:16:12 2017 +0200
drop code to support adt-backend providers
Drop code to support using autopkgtest as a test backend. This code was
merged in 2008 from Ubuntu, but it's unclear (and unlikely) that it still
works. Also it never has really been supported. (See #815084)
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
debian/changelog | 3 +
piuparts.py | 299 -------------------------------------------------------
2 files changed, 3 insertions(+), 299 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 09cb581..ea71a4e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,9 @@ piuparts (0.81) UNRELEASED; urgency=medium
* Fix syntax errors in git snapshot running on piuparts.debian.org, thanks
to Boud Roukema and Philipp Huebner for the reports.
(Closes: #875605, #875664)
+ * Drop code to support using autopkgtest as a test backend. This code was
+ merged in 2008 from Ubuntu, but it's unclear (and unlikely) that it still
+ works. Also it never has really been supported. (See #815084)
-- Holger Levsen <holger at debian.org> Thu, 31 Aug 2017 17:41:08 +0200
diff --git a/piuparts.py b/piuparts.py
index 803a046..c4efcd7 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -183,7 +183,6 @@ class Settings:
self.savetgz = None
self.lvm_volume = None
self.lvm_snapshot_size = "1G"
- self.adt_virt = None
self.existing_chroot = None
self.hard_link = False
self.schroot = None
@@ -1883,289 +1882,6 @@ class Chroot:
return errorcodes
-class VirtServ(Chroot):
- # Provides a thing that looks to the rest of piuparts much like
- # a chroot but is actually provided by an adt virtualisation server.
- # See /usr/share/doc/autopkgtest/README.virtualisation-server.
-
- def __init__(self, cmdline):
- self._cmdline = cmdline
- self.name = '/ADT-VIRT'
- self._vs = None
-
- def _awaitok(self, cmd):
- r = self._vs.stdout.readline().rstrip('\n')
- l = r.split(' ')
- if l[0] != 'ok':
- self._fail('virtserver response to %s: %s' % (cmd, r))
- logging.debug('adt-virt << %s', r)
- return l[1:]
-
- def _vs_send(self, cmd):
- if isinstance(cmd, type([])):
- def maybe_quote(a):
- if not isinstance(a, type(())):
- return a
- (a,) = a
- return urllib.quote(a)
- cmd = ' '.join(map(maybe_quote, cmd))
- logging.debug('adt-virt >> %s', cmd)
- print >>self._vs.stdin, cmd
- return cmd.split(' ')[0]
-
- def _command(self, cmd):
- # argument forms: complete-command-string
- # [arg, ...] where arg may be (arg,) to quote it
- cmdp = self._vs_send(cmd)
- self._vs.stdin.flush()
- return self._awaitok(cmdp)
-
- def _getfilecontents(self, filename):
- try:
- (_, tf) = create_temp_file()
- self._command(['copyup', (filename,), (tf,)])
- with open(tf, 'r') as f:
- d = f.read()
- finally:
- os.remove(tf)
- return d
-
- def create_temp_dir(self):
- if self._vs is None:
- logging.debug('adt-virt || %s' % self._cmdline)
- self._vs = subprocess.Popen(self._cmdline, shell=True,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None)
- self._awaitok('banner')
- self._caps = self._command('capabilities')
-
- def shutdown(self):
- if self._vs is None:
- return
- self._vs_send('quit')
- self._vs.stdin.close()
- self._vs.stdout.close()
- self._vs.wait()
- self._vs = None
-
- def remove(self):
- self._command('close')
- dont_do_on_panic(self.panic_handler_id)
-
- def _fail(self, m):
- logging.error("adt-virt-* error: " + m)
- panic()
-
- def _open(self):
- self._scratch = self._command('open')[0]
-
- # this is a hack to make install_and_upgrade_between distros
- # work; we pretend to save the chroot to a tarball but in
- # fact we do nothing and then we can `restore' the `tarball' with
- # adt-virt revert
- def create_temp_tgz_file(self):
- return self
-
- def remove_temp_tgz_file(self, tgz):
- if tgz is not self:
- self._fail('removing a tgz not supported')
- # FIXME: anything else to do here?
-
- def pack_into_tgz(self, tgz):
- if tgz is not self:
- self._fail('packing into tgz not supported')
- if not 'revert' in self._caps:
- self._fail('testbed cannot revert')
-
- def unpack_from_tgz(self, tgz):
- if tgz is not self:
- self._fail('unpacking from tgz not supported')
- self._open()
-
- def _execute(self, cmdl, tolerate_errors=False):
- assert isinstance(cmdl, type([]))
- prefix = ['sh', '-ec', '''
- LC_ALL=C
- unset LANGUAGES
- export LC_ALL
- exec 2>&1
- exec "$@"
- ''', '<command>']
- ca = ','.join(map(urllib.quote, prefix + cmdl))
- stdout = '%s/cmd-stdout' % self._scratch
- stderr = '%s/cmd-stderr-base' % self._scratch
- cmd = ['execute', ca,
- '/dev/null', (stdout,), (stderr,),
- '/root', 'timeout=600']
- es = int(self._command(cmd)[0])
- if es and not tolerate_errors:
- stderr_data = self._getfilecontents(stderr)
- logging.error("Execution failed (status=%d): %s\n%s" %
- (es, repr(cmdl), indent_string(stderr_data)))
- panic()
- return (es, stdout, stderr)
-
- def _execute_getoutput(self, cmdl):
- (es, stdout, stderr) = self._execute(cmdl)
- stderr_data = self._getfilecontents(stderr)
- if es or stderr_data:
- logging.error('Internal command failed (status=%d): %s\n%s' %
- (es, repr(cmdl), indent_string(stderr_data)))
- panic()
- (_, tf) = create_temp_file()
- try:
- self._command(['copyup', (stdout,), (tf,)])
- except:
- os.remove(tf)
- raise
- return tf
-
- def run(self, command, ignore_errors=False):
- cmdl = ['sh', '-ec', 'cd /\n' + ' '.join(command)]
- (es, stdout, stderr) = self._execute(cmdl, tolerate_errors=True)
- stdout_data = self._getfilecontents(stdout)
- print >>sys.stderr, "VirtServ run", repr(command), repr(cmdl), '==>', repr(es), repr(stdout), repr(stderr), '|', stdout_data
- if es == 0 or ignore_errors:
- return (es, stdout_data)
- stderr_data = self._getfilecontents(stderr)
- logging.error('Command failed (status=%d): %s\n%s' %
- (es, repr(command), indent_string(stdout_data + stderr_data)))
- panic()
-
- def setup_minimal_chroot(self):
- self._open()
-
- def _tbpath(self, with_junk):
- if not with_junk.startswith(self.name):
- logging.error("Un-mangling testbed path `%s' but it does not"
- "start with expected manglement `%s'" %
- (with_junk, self.name))
- panic()
- return with_junk[len(self.name):]
-
- def chmod(self, path, mode):
- self._execute(['chmod', ('0%o' % mode), self._tbpath(path)])
-
- def remove_files(self, paths):
- self._execute(['rm', '--'] + map(self._tbpath, paths))
-
- def copy_file(self, our_src, tb_dest):
- self._command(['copydown', (our_src,),
- (self._tbpath(tb_dest) + '/' + os.path.basename(our_src),)])
-
- def create_file(self, path, data):
- path = self._tbpath(path)
- try:
- (_, tf) = create_temp_file()
- with open(tf, 'w') as f:
- f.write(data)
- self._command(['copydown', (tf,), (path,)])
- finally:
- os.remove(tf)
-
- class DummyStat:
- pass
-
- def get_tree_meta_data(self):
- mode_map = {
- 's': stat.S_IFSOCK,
- 'l': stat.S_IFLNK,
- 'f': stat.S_IFREG,
- 'b': stat.S_IFBLK,
- 'd': stat.S_IFDIR,
- 'c': stat.S_IFCHR,
- 'p': stat.S_IFIFO,
- }
-
- vdict = {}
-
- tf = self._execute_getoutput(['find', '/', '-xdev', '-printf',
- "%y %m %U %G %s %p %l \\n".replace(' ', '\\0')])
- try:
- f = file(tf)
-
- while True:
- line = ''
- while True:
- splut = line.split('\0')
- if len(splut) == 8 and splut[7] == '\n':
- break
- if len(splut) >= 8:
- self._fail('aaargh wrong output from find: %s' %
- urllib.quote(line), repr(splut))
- l = f.readline()
- if not l:
- if not line:
- break
- self._fail('aargh missing final newline from find'
- ': %s, %s' % (repr(l)[0:200], repr(splut)[0:200]))
- line += l
- if not line:
- break
-
- st = VirtServ.DummyStat()
- st.st_mode = mode_map[splut[0]] | int(splut[1], 8)
- (st.st_uid, st.st_gid, st.st_size) = map(int, splut[2:5])
-
- vdict[splut[5]] = (st, splut[6])
-
- f.close()
- finally:
- os.remove(tf)
-
- return vdict
-
- def get_files_owned_by_packages(self):
- tf = self._execute_getoutput(['bash', '-ec', '''
- cd /var/lib/dpkg/info
- find . -name "*.list" -type f -print0 | \\
- xargs -r0 egrep . /dev/null
- test "${PIPESTATUS[*]}" = "0 0"
- '''])
- vdict = {}
- try:
- f = file(tf)
- for l in f:
- (lf, pathname) = l.rstrip('\n').split(':', 1)
- assert lf.endswith('.list')
- pkg = lf[:-5]
- if pathname in vdict:
- vdict[pathname].append(pkg)
- else:
- vdict[pathname] = [pkg]
-
- f.close()
- finally:
- os.remove(tf)
- return vdict
-
- def check_for_broken_symlinks(self):
- if not settings.check_broken_symlinks:
- return
- tf = self._execute_getoutput(['bash', '-ec', '''
- find / -xdev -type l -print0 | \\
- xargs -r0 -i'{}' \\
- find '{}' -maxdepth 0 -follow -type l -ls
- test "${PIPESTATUS[*]}" = "0 0"
- '''])
- try:
- f = file(tf)
- broken = False
- for l in f:
- logging.error("FAIL: Broken symlink: " + l)
- broken = True
- if broken:
- panic()
- logging.debug("No broken symlinks found.")
- finally:
- os.remove(tf)
-
- def check_for_no_processes(self):
- pass # ?!
-
- def mount_proc(self):
- pass
-
-
def selinux_enabled(enabled_test="/usr/sbin/selinuxenabled"):
if os.access(enabled_test, os.X_OK):
retval, output = run([enabled_test], ignore_errors=True)
@@ -2889,11 +2605,6 @@ def parse_command_line():
parser.add_option("--arch", metavar="ARCH", action="store",
help="Create chroot and run tests for (non-default) architecture ARCH.")
- parser.add_option("--adt-virt",
- metavar='CMDLINE', default=None,
- help="Use CMDLINE via autopkgtest (adt-virt-*)"
- " protocol instead of managing a chroot.")
-
parser.add_option("-b", "--basetgz", metavar="TARBALL",
help="Use TARBALL as the contents of the initial " +
"chroot, instead of building a new one with " +
@@ -3263,11 +2974,6 @@ def parse_command_line():
if not settings.pedantic_purge_test:
settings.ignored_patterns += settings.non_pedantic_ignore_patterns
- if opts.adt_virt is None:
- settings.adt_virt = None
- else:
- settings.adt_virt = VirtServ(opts.adt_virt)
-
log_file_name = opts.log_file
if opts.log_level == "error":
@@ -3329,9 +3035,7 @@ def parse_command_line():
def get_chroot():
- if settings.adt_virt is None:
return Chroot()
- return settings.adt_virt
# Process the packages given in a list
@@ -3399,9 +3103,6 @@ def process_packages(package_list):
logging.error("FAIL: Upgrading between Debian distributions.")
panic()
- if settings.adt_virt is not None:
- settings.adt_virt.shutdown()
-
def main():
"""Main program. But you knew that."""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git
More information about the Piuparts-commits
mailing list