Example #1
0
def makedeb(config, iface, icon):
	pkg_name = iface.get_name().lower().replace(' ', '-')

	desc_paras = ('Description: ' + iface.description).split('\n\n')
	wrapped = [textwrap.wrap(para) for para in desc_paras]
	desc_lines = []
	for para in wrapped:
		desc_lines += [' ' + (line or '.') for line in para]
	description = '\n'.join(desc_lines)[1:]

	sig, = config.iface_cache.get_cached_signatures(iface.uri)[:1]
	key = gpg.load_key(sig.fingerprint)
	bytes = 0

	d = tempfile.mkdtemp(prefix = 'bootstrap-')
	try:
		bin_dir = d + '/usr/bin'
		apps_dir = d + '/usr/share/applications'
		icons_dir = d + '/usr/share/pixmaps'
		deb_dir = d + '/DEBIAN'
		os.makedirs(bin_dir)
		os.makedirs(apps_dir)
		os.makedirs(icons_dir)
		os.makedirs(deb_dir)

		icon_name = None
		if icon:
			icon_name = pkg_name + '.png'
			shutil.copyfile(icon, icons_dir + '/' + icon_name)
			bytes += os.path.getsize(icon)

		s = open(apps_dir + '/' + pkg_name + '.desktop', 'w')
		s.write(support.make_desktop_file(iface, icon_name))
		bytes += s.tell()
		s.close()

		control = _control_template.format(deb_name = pkg_name,
			   author = key.name,
			   description = description,
			   installed_size = (bytes + 1023) / 1024)

		s = open(deb_dir + '/control', 'w')
		s.write(control)
		s.close()

		subprocess.check_call(['fakeroot', 'dpkg-deb', '--build', '--', d, pkg_name + '.deb'])
	finally:
		shutil.rmtree(d)
Example #2
0
def makerpm(config, iface, icon):
    pkg_name = iface.get_name().lower().replace(" ", "-")

    sig, = config.iface_cache.get_cached_signatures(iface.uri)[:1]
    key = gpg.load_key(sig.fingerprint)

    d = tempfile.mkdtemp(prefix="0bootstrap-")
    try:
        os.environ["HOME"] = d
        bin_dir = d + "/usr/bin"
        apps_dir = d + "/usr/share/applications"
        icons_dir = d + "/usr/share/pixmaps"
        top_dir = d + "/rpmbuild"
        rpm_sources = top_dir + "/SOURCES"
        os.makedirs(bin_dir)
        os.makedirs(apps_dir)
        os.makedirs(icons_dir)
        os.makedirs(rpm_sources)
        os.makedirs(top_dir + "/BUILD")

        icon_name = None
        if icon:
            icon_name = pkg_name + ".png"
            shutil.copyfile(icon, icons_dir + "/" + icon_name)

        s = open(apps_dir + "/" + pkg_name + ".desktop", "w")
        s.write(support.make_desktop_file(iface, icon_name))
        s.close()

        spec = _spec_template.format(
            rpm_name=pkg_name, author=key.name, summary=iface.summary, description=iface.description
        )

        s = open(d + "/" + pkg_name + ".spec", "w")
        s.write(spec)
        s.close()

        t = tarfile.open(rpm_sources + "/" + pkg_name + ".tar.gz", "w:gz")
        t.add(d + "/usr", "usr", recursive=True)
        t.close()

        subprocess.check_call(["rpmbuild", "--define", "%_topdir " + top_dir, "-bb", d + "/" + pkg_name + ".spec"])

        rpms_dir = top_dir + "/RPMS/noarch"
        rpm, = os.listdir(rpms_dir)
        shutil.copyfile(rpms_dir + "/" + rpm, pkg_name + ".rpm")
    finally:
        shutil.rmtree(d)
Example #3
0
def makerpm(config, iface):
	rpm_name = iface.get_name().lower().replace(' ', '-')

	sig, = config.iface_cache.get_cached_signatures(iface.uri)[:1]
	key = gpg.load_key(sig.fingerprint)

	d = tempfile.mkdtemp(prefix = '0bootstrap-')
	try:
		os.environ['HOME'] = d
		bin_dir = d + '/usr/bin'
		apps_dir = d + '/usr/share/applications'
		top_dir = d + '/rpmbuild'
		rpm_sources = top_dir + '/SOURCES'
		os.makedirs(bin_dir)
		os.makedirs(apps_dir)
		os.makedirs(rpm_sources)
		os.makedirs(top_dir + '/BUILD')

		s = open(apps_dir + '/' + rpm_name + '.desktop', 'w')
		s.write(support.make_desktop_file(iface))
		s.close()

		spec = _spec_template.format(rpm_name = rpm_name,
			   author = key.name,
			   summary = iface.summary,
			   description = iface.description,
			   TOPDIR = top_dir)

		s = open(d + '/' + rpm_name + '.spec', 'w')
		s.write(spec)
		s.close()

		t = tarfile.open(rpm_sources + '/' + rpm_name + '.tar.gz', 'w:gz')
		t.add(d + '/usr', 'usr', recursive=True)
		t.close()

		subprocess.check_call(['rpmbuild', '-ba', d + '/' + rpm_name + '.spec'])

		rpms_dir = top_dir + '/RPMS/noarch'
		rpm, = os.listdir(rpms_dir)
		shutil.copyfile(rpms_dir + '/' + rpm, './' + rpm)
	finally:
		shutil.rmtree(d)