from multiprocessing import Pool
from shutil import rmtree
-from subprocess import Popen, PIPE, check_call
from tempfile import mkdtemp
+import daklib.daksubprocess
import os.path
-import signal
class BinaryContentsWriter(object):
'''
'''
Returns the header for the Contents files as a string.
'''
- header_file = None
- try:
- filename = os.path.join(Config()['Dir::Templates'], 'contents')
- header_file = open(filename)
+ filename = os.path.join(Config()['Dir::Templates'], 'contents')
+ with open(filename) as header_file:
return header_file.read()
- finally:
- if header_file:
- header_file.close()
def write_file(self):
'''
if len(component_names) > 0:
component_query = component_query.filter(Component.component_name.in_(component_names))
if not force:
- suite_query = suite_query.filter_by(untouchable = False)
+ suite_query = suite_query.filter(Suite.untouchable == False)
deb_id = get_override_type('deb', session).overridetype_id
udeb_id = get_override_type('udeb', session).overridetype_id
pool = Pool()
+
+ # Lock tables so that nobody can change things underneath us
+ session.execute("LOCK TABLE bin_contents IN SHARE MODE")
+ session.execute("LOCK TABLE src_contents IN SHARE MODE")
+
for suite in suite_query:
suite_id = suite.suite_id
for component in component_query:
scanner = BinaryContentsScanner(binary_id)
scanner.scan()
-
-def subprocess_setup():
- # Python installs a SIGPIPE handler by default. This is usually not what
- # non-Python subprocesses expect.
- signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-
class UnpackedSource(object):
'''
UnpackedSource extracts a source package into a temporary location and
gives you some convinient function for accessing it.
'''
- def __init__(self, dscfilename):
+ def __init__(self, dscfilename, tmpbasedir=None):
'''
The dscfilename is a name of a DSC file that will be extracted.
'''
- temp_directory = mkdtemp(dir = Config()['Dir::TempPath'])
+ basedir = tmpbasedir if tmpbasedir else Config()['Dir::TempPath']
+ temp_directory = mkdtemp(dir = basedir)
self.root_directory = os.path.join(temp_directory, 'root')
command = ('dpkg-source', '--no-copy', '--no-check', '-q', '-x',
dscfilename, self.root_directory)
- check_call(command, preexec_fn = subprocess_setup)
+ daklib.daksubprocess.check_call(command)
def get_root_directory(self):
'''
scanner.scan()
except Exception as e:
print e
-