from daklib.dbconn import *
from daklib.config import Config
from daklib.threadpool import ThreadPool
+from multiprocessing import Pool
from sqlalchemy import desc, or_
-from subprocess import Popen, PIPE
+from subprocess import Popen, PIPE, call
import os.path
sure that the new ContentsWriter object can be executed in a different
thread.
'''
- self.suite = suite.clone()
- self.session = self.suite.session()
- self.architecture = architecture.clone(self.session)
- self.overridetype = overridetype.clone(self.session)
- if component is not None:
- self.component = component.clone(self.session)
- else:
- self.component = None
+ self.suite = suite
+ self.architecture = architecture
+ self.overridetype = overridetype
+ self.component = component
+ self.session = suite.session()
def query(self):
'''
}
if self.component is not None:
- params['component'] = component.component_id
+ params['component'] = self.component.component_id
sql = '''
create temp table newest_binaries (
id integer primary key,
last_filename = filename
package_list = []
package_list.append(package)
- yield self.formatline(last_filename, package_list)
+ if last_filename is not None:
+ yield self.formatline(last_filename, package_list)
# end transaction to return connection to pool
self.session.rollback()
'architecture': self.architecture.arch_string
}
if self.component is None:
- return "%(root)s%(suite)s/Contents-%(architecture)s.gz" % values
+ return "%(root)s/dists/%(suite)s/Contents-%(architecture)s.gz" % values
values['component'] = self.component.component_name
- return "%(root)s%(suite)s/%(component)s/Contents-%(architecture)s.gz" % values
+ return "%(root)s/dists/%(suite)s/%(component)s/Contents-%(architecture)s.gz" % values
def get_header(self):
'''
'''
command = ['gzip', '--rsyncable']
output_file = open(self.output_filename(), 'w')
- pipe = Popen(command, stdin = PIPE, stdout = output_file).stdin
- pipe.write(self.get_header())
+ gzip = Popen(command, stdin = PIPE, stdout = output_file)
+ gzip.stdin.write(self.get_header())
for item in self.fetch():
- pipe.write(item)
- pipe.close()
+ gzip.stdin.write(item)
+ gzip.stdin.close()
output_file.close()
+ gzip.wait()
+
+ @classmethod
+ def write_all(class_, suite_names = [], force = False):
+ '''
+ Writes all Contents files for suites in list suite_names which defaults
+ to all 'touchable' suites if not specified explicitely. Untouchable
+ suites will be included if the force argument is set to True.
+ '''
+ session = DBConn().session()
+ suite_query = session.query(Suite)
+ if len(suite_names) > 0:
+ suite_query = suite_query.filter(Suite.suite_name.in_(suite_names))
+ if not force:
+ suite_query = suite_query.filter_by(untouchable = False)
+ pool = Pool()
+ for suite in suite_query:
+ for architecture in suite.get_architectures(skipsrc = True, skipall = True):
+ # handle 'deb' packages
+ command = ['dak', 'contents', '-s', suite.suite_name, \
+ 'generate_helper', architecture.arch_string, 'deb']
+ pool.apply_async(call, (command, ))
+ # handle 'udeb' packages for 'main' and 'non-free'
+ command = ['dak', 'contents', '-s', suite.suite_name, \
+ 'generate_helper', architecture.arch_string, 'udeb', 'main']
+ pool.apply_async(call, (command, ))
+ command = ['dak', 'contents', '-s', suite.suite_name, \
+ 'generate_helper', architecture.arch_string, 'udeb', 'non-free']
+ pool.apply_async(call, (command, ))
+ pool.close()
+ pool.join()
+ session.close()
class ContentsScanner(object):