def add(options): if len(argv) != 2: templatetools.print_usage(options['indicator']) sys.exit(4) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_python_dir = os.path.join(abs_template_path, 'store', 'python') # take files from command directory if don't exist python_file = os.path.join(template_python_dir, 'indicator.py') python_name = templatetools.python_name(project_name) target_python_dir = python_name project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) substitutions = (("project_name", project_name), ("python_name", python_name)) templatetools.file_from_template(template_python_dir, "indicator.py", target_python_dir, substitutions)
def add(options): if len(argv) != 2: templatetools.print_usage(options['indicator']) sys.exit(4) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_python_dir = os.path.join(abs_template_path, 'store', 'python') # take files from command directory if don't exist python_file = os.path.join(template_python_dir, 'indicator.py') python_name = templatetools.python_name(project_name) target_python_dir = python_name project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) substitutions = (("project_name",project_name), ( "python_name",python_name)) templatetools.file_from_template(template_python_dir, "indicator.py", target_python_dir, substitutions)
def licensing(license=None): """Add license or update it to the project files Default is GPL-3""" fauthors_name = "AUTHORS" flicense_name = "COPYING" if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) # check if we have a license tag in setup.py otherwise, default to GPL-3 if not license: try: license = quicklyutils.get_setup_value('license') except quicklyutils.cant_deal_with_setup_value: pass if not license: license = guess_license(flicense_name) if license == 'other': msg = _("COPYING contains an unknown license. Please run 'quickly license other' to confirm that you want to use a custom license.") raise LicenceError(msg) if not license: license = 'GPL-3' supported_licenses_list = get_supported_licenses() supported_licenses_list.sort() if license not in supported_licenses_list and license != 'other': cmd = commands.get_command('license', 'ubuntu-application') templatetools.usage_error(_("Unknown licence %s.") % license, cmd=cmd) # get Copyright holders in AUTHORS file license_content = "" try: for line in file(fauthors_name, 'r'): if "<Your Name> <Your E-mail>" in line: # if we have an author in setup.py, grab it try: author = quicklyutils.get_setup_value('author') author_email = quicklyutils.get_setup_value('author_email') line = "Copyright (C) %s %s <%s>\n" % (datetime.datetime.now().year, author, author_email) # update AUTHORS file fout = file('%s.new' % fauthors_name, 'w') fout.write(line) fout.flush() fout.close() os.rename(fout.name, fauthors_name) except quicklyutils.cant_deal_with_setup_value: msg = _('Copyright is not attributed. ' \ 'Edit the AUTHORS file to include your name for the copyright replacing ' \ '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \ 'to fill it automatically') raise LicenceError(msg) license_content += "# %s" % line except (OSError, IOError), e: msg = _("%s file was not found") % fauthors_name raise LicenceError(msg)
def licensing(license=None): """Add license or update it to the project files Default is GPL-3""" fauthors_name = "AUTHORS" flicense_name = "COPYING" if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) # check if we have a license tag in plugin.ini otherwise, default to GPL-3 if license is None: license = get_plugin_ini_value('license') if license is None or license == '': license = 'GPL' if license == 'PLUGIN_LICENSE_GPL': license = 'GPL-2' if license == 'PLUGIN_LICENSE_BSD': license = 'BSD' # get Copyright holders in AUTHORS file license_content = "" try: for line in file(fauthors_name, 'r'): if "<Your Name> <Your E-mail>" in line: # if we have an author in setup.py, grab it try: author = get_plugin_ini_value('author') if author is None: raise quicklyutils.cant_deal_with_setup_value() line = "Copyright (C) %s %s\n" % (datetime.datetime.now().year, author, author_email) # update AUTHORS file fout = file('%s.new' % fauthors_name, 'w') fout.write(line) fout.flush() fout.close() os.rename(fout.name, fauthors_name) except quicklyutils.cant_deal_with_setup_value: msg = _('Copyright is not attributed. ' \ 'Edit the AUTHORS file to include your name for the copyright replacing ' \ '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \ 'to fill it automatically') raise LicenceError(msg) license_content += "%s" % line except (OSError, IOError), e: msg = _("%s file was not found") % fauthors_name raise LicenceError(msg)
filelist = [] for root, dirs, files in os.walk('./'): for name in files: hide_path = root.endswith('_lib') py = name.endswith('.py') if py and not hide_path and name not in ('setup.py'): filelist.append(os.path.join(root, name)) # if config not already loaded if not configurationhandler.project_config: configurationhandler.loadConfig() # add launcher which does not end with .py for older projects (pre-lib split) project_name = configurationhandler.project_config['project'] libdir = os.path.join(templatetools.python_name(project_name) + '_lib') if not os.path.exists(libdir): filelist.append('bin/' + configurationhandler.project_config['project']) # add helpfile sources filelist.extend(glob.glob('help/C/*.page')) editor = quicklyutils.get_quickly_editors() if templatetools.in_verbose_mode(): instance = subprocess.Popen([editor] + filelist) else: nullfile = file("/dev/null") instance = subprocess.Popen([editor] + filelist, stderr=nullfile) if editor != 'gedit': instance.wait()
if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_help_dir = os.path.join(abs_template_path, 'store', 'data', 'mallard') # take files from command directory if don't exist help_page = os.path.join(template_help_dir, 't_o_p_i_c.page') if not os.path.isfile(help_page): template_help_dir = os.path.join(abs_command_path, 'store', 'data', 'mallard') help_page = os.path.join(template_help_dir, 't_o_p_i_c.page') target_help_dir = os.path.join('help', 'C') if not os.path.exists(target_help_dir): os.makedirs(target_help_dir) python_name = templatetools.python_name(topic_name) sentence_name, cc_name = templatetools.conventional_names(topic_name) substitutions = ( ('t_o_p_i_c', topic_name), ('sentence_name', sentence_name), ) templatetools.file_from_template(template_help_dir, 't_o_p_i_c.page', target_help_dir, substitutions)
sys.exit(6) # check that project name follow quickly rules and reformat it. try: project_name = templatetools.quickly_name(project_name) except templatetools.bad_project_name, e: print(e) sys.exit(1) os.chdir(project_name) # get origin path pathname = templatetools.get_template_path_from_project() abs_path_project_root = os.path.join(pathname, 'project_root') python_name = templatetools.python_name(project_name) sentence_name, camel_case_name = templatetools.conventional_names(project_name) # Calculate the SWF's dimensions try: width, height = SWF.dimensions(swf) except SWF.SWFNotASWF: print "File '%s' does not seem to be a SWF. Terminating." sys.exit(7) except SWF.SWFNoDimensions: print "(Could not read size from SWF file; defaulting to 640x480. You should edit bin/%s with the correct size.)" % project_name width, height = (640, 480) substitutions = (("project_name",project_name), ("camel_case_name",camel_case_name),
origin_ui_file_list = [os.path.join(template_ui_dir, 'dialog_camel_case_nameDialog.ui'), os.path.join(template_ui_dir, 'dialog_python_name_dialog.xml')] python_file = os.path.join(template_ui_dir, 'dialog_camel_case_nameDialog.py') if len([file_exist for file_exist in origin_ui_file_list if os.path.isfile(file_exist)]) != len(origin_ui_file_list): template_ui_dir = os.path.join(abs_command_path, 'store', 'data', 'ui') if not os.path.isfile(python_file): template_python_dir = os.path.join(abs_command_path, 'store', 'python') target_ui_dir = os.path.join('data', 'ui') python_name = templatetools.python_name(project_name) target_python_dir = python_name dialog_python_name = templatetools.python_name(dialog_name) dialog_sentence_name, dialog_camel_case_name = \ templatetools.conventional_names(dialog_name) project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) dialog_name = dialog_name.replace('-','_') substitutions = (("project_name",project_name), ("dialog_name",dialog_name), ("dialog_python_name",dialog_python_name), ("dialog_camel_case_name",dialog_camel_case_name), ("project_camel_case_name",project_camel_case_name), ("project_sentence_name",project_sentence_name),
if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_help_dir = os.path.join(abs_template_path, 'store', 'data', 'mallard') # take files from command directory if don't exist help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page') if not os.path.isfile(help_page): template_help_dir = os.path.join(abs_command_path, 'store', 'data', 'mallard') help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page') target_help_dir = os.path.join('help', 'C') if not os.path.exists(target_help_dir): os.makedirs(target_help_dir) python_name = templatetools.python_name(guide_name) sentence_name, cc_name = templatetools.conventional_names(guide_name) substitutions = ( ('g_u_i_d_e', guide_name), ('sentence_name', sentence_name), ) templatetools.file_from_template(template_help_dir, 'g_u_i_d_e.page', target_help_dir, substitutions)
filelist = [] for root, dirs, files in os.walk('./'): for name in files: hide_path = root.endswith('_lib') py = name.endswith('.py') if py and not hide_path and name not in ('setup.py'): filelist.append(os.path.join(root, name)) # if config not already loaded if not configurationhandler.project_config: configurationhandler.loadConfig() # add launcher which does not end with .py for older projects (pre-lib split) project_name = configurationhandler.project_config['project'] libdir = os.path.join(templatetools.python_name(project_name) + '_lib') if not os.path.exists(libdir): filelist.append('bin/' + configurationhandler.project_config['project']) # add helpfile sources filelist.extend(glob.glob('help/C/*.page')) editor = quicklyutils.get_quickly_editors() if templatetools.in_verbose_mode(): instance = subprocess.Popen([editor] + filelist) else: nullfile=file("/dev/null") instance = subprocess.Popen([editor] + filelist, stderr=nullfile) if editor != 'gedit': instance.wait()
project_name = configurationhandler.project_config['project'] template_help_dir = os.path.join(abs_template_path, 'store', 'data', 'mallard') # take files from command directory if don't exist help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page') if not os.path.isfile(help_page): template_help_dir = os.path.join(abs_command_path, 'store', 'data', 'mallard') help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page') target_help_dir = os.path.join('help', 'C') if not os.path.exists(target_help_dir): os.makedirs(target_help_dir) python_name = templatetools.python_name(guide_name) sentence_name, cc_name = templatetools.conventional_names(guide_name) substitutions = ( ('g_u_i_d_e', guide_name), ('sentence_name', sentence_name), ) templatetools.file_from_template(template_help_dir, 'g_u_i_d_e.page', target_help_dir, substitutions)
project_version = arg elif template_version is None: template_version = arg i += 1 (project_version_inspected, template_version_inspected) = templatetools.get_project_and_template_versions("git-python-gtk") if project_version is None: project_version = project_version_inspected if template_version is None: template_version = template_version_inspected if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) substitutions = (("project_name",project_name), ("project_camel_case_name",project_camel_case_name), ("project_sentence_name",project_sentence_name), ("python_name",python_name)) ##### 0.4 update if project_version < '0.4': ## new licensing format if os.path.isfile("LICENSE"): try: os.rename('LICENSE', 'COPYING') except OSError, e:
def licensing(license=None): """Add license or update it to the project files Default is GPL-3""" fauthors_name = "AUTHORS" flicense_name = "COPYING" if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) # check if we have a license tag in setup.py otherwise, default to GPL-3 if not license: try: license = quicklyutils.get_setup_value('license') except quicklyutils.cant_deal_with_setup_value: pass if not license: license = guess_license(flicense_name) if license == 'other': msg = _( "COPYING contains an unknown license. Please run 'quickly license other' to confirm that you want to use a custom license." ) raise LicenceError(msg) if not license: license = 'GPL-3' supported_licenses_list = get_supported_licenses() supported_licenses_list.sort() if license not in supported_licenses_list and license != 'other': cmd = commands.get_command('license', 'ubuntu-application') templatetools.usage_error(_("Unknown licence %s.") % license, cmd=cmd) # get Copyright holders in AUTHORS file license_content = "" try: for line in file(fauthors_name, 'r'): if "<Your Name> <Your E-mail>" in line: # if we have an author in setup.py, grab it try: author = quicklyutils.get_setup_value('author') author_email = quicklyutils.get_setup_value('author_email') line = "Copyright (C) %s %s <%s>\n" % ( datetime.datetime.now().year, author, author_email) # update AUTHORS file fout = file('%s.new' % fauthors_name, 'w') fout.write(line) fout.flush() fout.close() os.rename(fout.name, fauthors_name) except quicklyutils.cant_deal_with_setup_value: msg = _('Copyright is not attributed. ' \ 'Edit the AUTHORS file to include your name for the copyright replacing ' \ '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \ 'to fill it automatically') raise LicenceError(msg) license_content += "# %s" % line except (OSError, IOError), e: msg = _("%s file was not found") % fauthors_name raise LicenceError(msg)
project_name = configurationhandler.project_config['project'] template_help_dir = os.path.join(abs_template_path, 'store', 'data', 'mallard') # take files from command directory if don't exist help_page = os.path.join(template_help_dir, 't_o_p_i_c.page') if not os.path.isfile(help_page): template_help_dir = os.path.join(abs_command_path, 'store', 'data', 'mallard') help_page = os.path.join(template_help_dir, 't_o_p_i_c.page') target_help_dir = os.path.join('help', 'C') if not os.path.exists(target_help_dir): os.makedirs(target_help_dir) python_name = templatetools.python_name(topic_name) sentence_name, cc_name = templatetools.conventional_names(topic_name) substitutions = ( ('t_o_p_i_c', topic_name), ('sentence_name', sentence_name), ) templatetools.file_from_template(template_help_dir, 't_o_p_i_c.page', target_help_dir, substitutions)
def update_rules(): project_name = configurationhandler.project_config["project"] install_rules = """ override_dh_install: dh_install""" opt_root = "/opt/extras.ubuntu.com/" + project_name # Move script to bin/ folder. # There are some complications here. As of this writing, current versions # of python-mkdebian do not correctly install our executable script in a # bin/ subdirectory. Instead, they either install it in the opt-project # root or in the opt-project python library folder (depending on whether # the project name is the same as its python name). So if we find that to # be the case, we move the script accordingly. bin_path = "%(opt_root)s/bin/%(project_name)s" % {"opt_root": opt_root, "project_name": project_name} bad_bin_debpath = "debian/%(project_name)s%(opt_root)s/%(project_name)s" % { "opt_root": opt_root, "project_name": project_name, } python_name = templatetools.python_name(project_name) if project_name == python_name: bad_bin_debpath += "/" + project_name install_rules += """ mkdir -p debian/%(project_name)s%(opt_root)s/bin if [ -x %(bad_bin_debpath)s ]; then mv %(bad_bin_debpath)s debian/%(project_name)s%(opt_root)s/bin; fi""" % { "project_name": project_name, "opt_root": opt_root, "bad_bin_debpath": bad_bin_debpath, } # Move desktop file and update it to point to our /opt locations. # The file starts, as expected, under /opt. But the ARB wants and allows # us to install it in /usr, so we do. old_desktop_debdir = "debian/%(project_name)s%(opt_root)s/share/applications" % { "project_name": project_name, "opt_root": opt_root, } new_desktop_debdir = "debian/%(project_name)s/usr/share/applications" % {"project_name": project_name} new_desktop_debpath = new_desktop_debdir + "/extras-" + project_name + ".desktop" install_rules += """ if [ -f %(old_desktop_debdir)s/%(project_name)s.desktop ]; then \\ mkdir -p %(new_desktop_debdir)s; \\ mv %(old_desktop_debdir)s/%(project_name)s.desktop %(new_desktop_debpath)s; \\ rmdir --ignore-fail-on-non-empty %(old_desktop_debdir)s; \\ sed -i 's|Exec=.*|Exec=%(bin_path)s|' %(new_desktop_debpath)s; \\ sed -i 's|Icon=/usr/|Icon=%(opt_root)s/|' %(new_desktop_debpath)s; \\ fi""" % { "bin_path": bin_path, "old_desktop_debdir": old_desktop_debdir, "new_desktop_debdir": new_desktop_debdir, "project_name": project_name, "opt_root": opt_root, "new_desktop_debpath": new_desktop_debpath, } # Set gettext's bindtextdomain to point to /opt and use the locale # module (gettext's C API) instead of the gettext module (gettext's Python # API), so that translations are loaded from /opt localedir = os.path.join(opt_root, "share/locale") install_rules += """ grep -RlZ 'import gettext' debian/%(project_name)s/* | xargs -0 -r sed -i 's|\(import\) gettext$$|\\1 locale|' grep -RlZ 'from gettext import gettext as _' debian/%(project_name)s/* | xargs -0 -r sed -i 's|from gettext \(import gettext as _\)|from locale \\1|' grep -RlZ "gettext.textdomain('%(project_name)s')" debian/%(project_name)s/* | xargs -0 -r sed -i "s|gettext\(\.textdomain('%(project_name)s')\)|locale\.bindtextdomain('%(project_name)s', '%(localedir)s')\\nlocale\\1|" """ % { "project_name": project_name, "localedir": localedir, } # We install a python_nameconfig.py file that contains a pointer to the # data directory. But that will be determined by setup.py, so it will be # wrong (python-mkdebian's --prefix command only affects where it moves # files during build, but not what it passes to setup.py) config_debpath = "debian/%(project_name)s%(opt_root)s/%(python_name)s*/%(python_name)sconfig.py" % { "project_name": project_name, "opt_root": opt_root, "python_name": python_name, } install_rules += """ sed -i "s|__%(python_name)s_data_directory__ =.*|__%(python_name)s_data_directory__ = '%(opt_root)s/share/%(project_name)s/'|" %(config_debpath)s""" % { "opt_root": opt_root, "project_name": project_name, "python_name": python_name, "config_debpath": config_debpath, } # Adjust XDG_DATA_DIRS so we can find schemas and help files install_rules += """ sed -i 's| sys.path.insert(0, opt_path)|\\0\\n os.putenv("XDG_DATA_DIRS", "%%s:%%s" %% ("%(opt_root)s/share/", os.getenv("XDG_DATA_DIRS", "")))|' debian/%(project_name)s%(bin_path)s""" % { "opt_root": opt_root, "project_name": project_name, "bin_path": bin_path, } # Compile the glib schema, since it is in a weird place that normal glib # triggers won't catch during package install. schema_debdir = "debian/%(project_name)s%(opt_root)s/share/glib-2.0/schemas" % { "opt_root": opt_root, "project_name": project_name, } install_rules += """ if [ -d %(schema_debdir)s ]; then glib-compile-schemas %(schema_debdir)s; fi""" % { "schema_debdir": schema_debdir } # Set rules back to include our changes rules = "" with open("debian/rules", "r") as f: rules = f.read() rules += install_rules templatetools.set_file_contents("debian/rules", rules)
def update_rules(): project_name = configurationhandler.project_config['project'] install_rules = """ override_dh_install: dh_install""" opt_root = "/opt/extras.ubuntu.com/" + project_name # Move script to bin/ folder. # There are some complications here. As of this writing, current versions # of python-mkdebian do not correctly install our executable script in a # bin/ subdirectory. Instead, they either install it in the opt-project # root or in the opt-project python library folder (depending on whether # the project name is the same as its python name). So if we find that to # be the case, we move the script accordingly. bin_path = "%(opt_root)s/bin/%(project_name)s" % { 'opt_root': opt_root, 'project_name': project_name} bad_bin_debpath = "debian/%(project_name)s%(opt_root)s/%(project_name)s" % { 'opt_root': opt_root, 'project_name': project_name} python_name = templatetools.python_name(project_name) if project_name == python_name: bad_bin_debpath += "/" + project_name install_rules += """ mkdir -p debian/%(project_name)s%(opt_root)s/bin if [ -x %(bad_bin_debpath)s ]; then mv %(bad_bin_debpath)s debian/%(project_name)s%(opt_root)s/bin; fi""" % { 'project_name': project_name, 'opt_root': opt_root, 'bad_bin_debpath': bad_bin_debpath} # Move desktop file and update it to point to our /opt locations. # The file starts, as expected, under /opt. But the ARB wants and allows # us to install it in /usr, so we do. old_desktop_debdir = "debian/%(project_name)s%(opt_root)s/share/applications" % { 'project_name': project_name, 'opt_root': opt_root} new_desktop_debdir = "debian/%(project_name)s/usr/share/applications" % {'project_name': project_name} new_desktop_debpath = new_desktop_debdir + "/extras-" + project_name + ".desktop" install_rules += """ if [ -f %(old_desktop_debdir)s/%(project_name)s.desktop ]; then \\ mkdir -p %(new_desktop_debdir)s; \\ mv %(old_desktop_debdir)s/%(project_name)s.desktop %(new_desktop_debpath)s; \\ rmdir --ignore-fail-on-non-empty %(old_desktop_debdir)s; \\ sed -i 's|Exec=.*|Exec=%(bin_path)s|' %(new_desktop_debpath)s; \\ sed -i 's|Icon=/usr/|Icon=%(opt_root)s/|' %(new_desktop_debpath)s; \\ fi""" % { 'bin_path': bin_path, 'old_desktop_debdir': old_desktop_debdir, 'new_desktop_debdir': new_desktop_debdir, 'project_name': project_name, 'opt_root': opt_root, 'new_desktop_debpath': new_desktop_debpath} # Set gettext's bindtextdomain to point to /opt and use the locale # module (gettext's C API) instead of the gettext module (gettext's Python # API), so that translations are loaded from /opt localedir = os.path.join(opt_root, 'share/locale') install_rules += """ grep -RlZ 'import gettext' debian/%(project_name)s/* | xargs -0 -r sed -i 's|\(import\) gettext$$|\\1 locale|' grep -RlZ 'from gettext import gettext as _' debian/%(project_name)s/* | xargs -0 -r sed -i 's|from gettext \(import gettext as _\)|from locale \\1|' grep -RlZ "gettext.textdomain('%(project_name)s')" debian/%(project_name)s/* | xargs -0 -r sed -i "s|gettext\(\.textdomain('%(project_name)s')\)|locale\.bindtextdomain('%(project_name)s', '%(localedir)s')\\nlocale\\1|" """ % { 'project_name': project_name, 'localedir': localedir} # We install a python_nameconfig.py file that contains a pointer to the # data directory. But that will be determined by setup.py, so it will be # wrong (python-mkdebian's --prefix command only affects where it moves # files during build, but not what it passes to setup.py) config_debpath = "debian/%(project_name)s%(opt_root)s/%(python_name)s*/%(python_name)sconfig.py" % { 'project_name': project_name, 'opt_root': opt_root, 'python_name': python_name} install_rules += """ sed -i "s|__%(python_name)s_data_directory__ =.*|__%(python_name)s_data_directory__ = '%(opt_root)s/share/%(project_name)s/'|" %(config_debpath)s""" % { 'opt_root': opt_root, 'project_name': project_name, 'python_name': python_name, 'config_debpath': config_debpath} # Adjust XDG_DATA_DIRS so we can find schemas and help files install_rules += """ sed -i 's| sys.path.insert(0, opt_path)|\\0\\n os.putenv("XDG_DATA_DIRS", "%%s:%%s" %% ("%(opt_root)s/share/", os.getenv("XDG_DATA_DIRS", "")))|' debian/%(project_name)s%(bin_path)s""" % { 'opt_root': opt_root, 'project_name': project_name, 'bin_path': bin_path} # Compile the glib schema, since it is in a weird place that normal glib # triggers won't catch during package install. schema_debdir = "debian/%(project_name)s%(opt_root)s/share/glib-2.0/schemas" % { 'opt_root': opt_root, 'project_name': project_name} install_rules += """ if [ -d %(schema_debdir)s ]; then glib-compile-schemas %(schema_debdir)s; fi""" % { 'schema_debdir': schema_debdir} # Set rules back to include our changes rules = '' with open('debian/rules', 'r') as f: rules = f.read() rules += install_rules templatetools.set_file_contents('debian/rules', rules)