'Call repacker in a subprocess.'

def RepackTemplates(self, repack_configs, templates, output_dir, config=None, sign=False, signed_template=False):

    pool = multiprocessing.Pool(processes=10)
    results = []
    for repack_config in repack_configs:
        for template in templates:
            repack_args = ['grr_client_build']
            if config:
                repack_args.extend(['--config', config])
            repack_args.extend(['--secondary_configs', repack_config, 'repack', '--template', template, '--output_dir', self.GetOutputDir(output_dir, repack_config)])
            passwd = None
            bulk_sign_installers = False
            if sign:
                if template.endswith('.exe.zip'):
                    if (platform.system() != 'Windows'):
                        passwd = self.GetWindowsPassphrase()
                        repack_args.append('--sign')
                    else:
                        bulk_sign_installers = True
                    if signed_template:
                        repack_args.append('--signed_template')
                elif template.endswith('.rpm.zip'):
                    passwd = self.GetRPMPassPhrase()
                    repack_args.append('--sign')
            print ('Calling    %s' % '    '.join(repack_args))
            results.append(pool.apply_async(SpawnProcess, (repack_args,), dict(passwd=passwd)))
            if template.endswith('.exe.zip'):
                debug_args = []
                debug_args.extend(repack_args)
                debug_args.append('--debug_build')
                print ('Calling    %s' % '    '.join(debug_args))
                results.append(pool.apply_async(SpawnProcess, (debug_args,), dict(passwd=passwd)))
    try:
        pool.close()
        for result_obj in results:
            result_obj.get(9999)
        pool.join()
    except KeyboardInterrupt:
        print 'parent    received    control-c'
        pool.terminate()
    except ErrorDuringRepacking:
        pool.terminate()
        raise
    if bulk_sign_installers:
        to_sign = []
        for (root, _, files) in os.walk(output_dir):
            for f in files:
                if f.endswith('.exe'):
                    to_sign.append(os.path.join(root, f))
        signer = repacking.TemplateRepacker().GetSigner(['ClientBuilder    Context', 'Target:Windows'])
        signer.SignFiles(to_sign)
