'Generates the files needed by dpkg-buildpackage.'

def GenerateDPKGFiles(self, template_path):

    template_binary_dir = os.path.join(template_path, 'dist/debian/grr-client')
    package_name = config.CONFIG.Get('ClientBuilder.package_name', context=self.context)
    target_binary_dir = os.path.join(template_path, ('dist/debian/%s%s' % (package_name, config.CONFIG.Get('ClientBuilder.target_dir', context=self.context))))
    if (package_name == 'grr-client'):
        shutil.move(template_binary_dir, ('%s-template' % template_binary_dir))
        template_binary_dir = ('%s-template' % template_binary_dir)
    utils.EnsureDirExists(os.path.dirname(target_binary_dir))
    shutil.move(template_binary_dir, target_binary_dir)
    shutil.move(os.path.join(target_binary_dir, 'grr-client'), os.path.join(target_binary_dir, config.CONFIG.Get('Client.binary_name', context=self.context)))
    deb_in_dir = os.path.join(template_path, 'dist/debian/debian.in/')
    self.GenerateDirectory(deb_in_dir, os.path.join(template_path, 'dist/debian'), [('grr-client', package_name)])
    utils.EnsureDirExists(os.path.join(template_path, ('dist/debian/%s/usr/sbin' % package_name)))
    if (config.CONFIG['Template.version_numeric'] >= 3125):
        self.GenerateFile(os.path.join(target_binary_dir, 'nanny.sh.in'), os.path.join(target_binary_dir, 'nanny.sh'))
    self.GenerateFile(os.path.join(template_path, 'dist/debian/upstart.in/grr-client.conf'), os.path.join(template_path, ('dist/debian/%s.upstart' % package_name)))
    self.GenerateFile(os.path.join(template_path, 'dist/debian/initd.in/grr-client'), os.path.join(template_path, ('dist/debian/%s.init' % package_name)))
    self.GenerateFile(os.path.join(template_path, 'dist/debian/systemd.in/grr-client.service'), os.path.join(template_path, ('dist/debian/%s.service' % package_name)))
    shutil.rmtree(deb_in_dir)
    shutil.rmtree(os.path.join(template_path, 'dist/debian/upstart.in'))
    shutil.rmtree(os.path.join(template_path, 'dist/debian/initd.in'))
    shutil.rmtree(os.path.join(template_path, 'dist/debian/systemd.in'))
