#!/usr/bin/python # -*- coding: utf-8 -*- # # just put a .pisipackager file in your home and fill it like # # name = Onur Küçük # email = onur@pardus.org.tr # import os import sys import time import string packagerfile = ".pisipackager" data = {"date": time.strftime("%Y-%m-%d"), "year": time.strftime("%Y")} temp_pspec = ''' %(package)s %(packager_name)s %(packager_email)s GPLv2 %(package)s app:gui %(package)s / %(date)s First release %(packager_name)s %(packager_email)s ''' temp_actions = '''#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright %(year)s TUBITAK/UEKAE # Licensed under the GNU General Public License, version 2. # See the file http://www.gnu.org/copyleft/gpl.txt. from pisi.actionsapi import autotools from pisi.actionsapi import pisitools from pisi.actionsapi import shelltools from pisi.actionsapi import get # WorkDir = "" # NoStrip = "/" def setup(): autotools.configure() def build(): autotools.make() def install(): autotools.rawInstall("DESTDIR=%%s" %% get.installDIR()) pisitools.dodoc("AUTHORS", "ChangeLog", "README*", "NEWS") ''' temp_desktop = '''[Desktop Entry] Type=Application Version=1.0 Encoding=UTF-8 Name=%(package_cap)s Name[tr]=%(package_cap)s GenericName=%(package_cap)s GenericName[tr]=%(package_cap)s Icon=%(package)s Exec=%(package)s Terminal=false StartupNotify=false Categories=Application;Game;ArcadeGame; ''' temp_service = '''serviceType = "local" from comar.service import * serviceType = "local" serviceDefault = "off" serviceDesc = _({"en": "%(package_cap)s", "tr": "%(package_cap)s"}) def start(): if 0 == run('/sbin/start-stop-daemon --quiet --start --exec /usr/bin/%(package)s --pidfile /var/run/%(package)s.pid'): notify("System.Service.changed", "started") def stop(): if 0 == run("/sbin/start-stop-daemon --stop --pidfile /var/run/%(package)s.pid"): notify("System.Service.changed", "stopped") def status(): return checkDeamon("/var/run/%(package)s.pid") ''' temp_postscript = '''#/usr/bin/python import os def postInstall(): print "FIXME" ''' def write(filename, data): try: f = file("%s/%s" % (target, filename), "w") f.write(data) f.close() except: print "Could not write file %s/%s" % (target, filename) def create_dirs(): try: os.makedirs("%s/files" % target) os.makedirs("%s/comar" % target) except: print "Could not make directory %s" % target sys.exit(1) def readConfig(): home = os.getenv("HOME", "") cfg = "%s/%s" % (home, packagerfile) d = {"name": "", "email": ""} if home != "" and os.path.exists(cfg): for line in file(cfg): if line != "" and not line.startswith("#") and "=" in line: l, m = line.split("=", 1) k = l.strip() v = m.strip() if k in ["name", "email"]: if v.startswith('"') or v.startswith("'"): v = v[1:-1] d[k.strip()] = v.strip() return d["name"], d["email"] # some checks if len(sys.argv) < 2: print "Usage : %s NewPackageDir" % sys.argv[0] sys.exit(0) else: target = sys.argv[1] data["packagedir"], data["package"] = os.path.split(target) data["package_cap"] = string.capitalize(data["package"]) if os.path.exists(target): print "%s already exists, please remove it first" % target sys.exit(1) elif " " in data["package"]: print "You should not use empty space in package name" sys.exit(1) # here we go data["packager_name"], data["packager_email"] = readConfig() create_dirs() write("pspec.xml", temp_pspec % data) write("actions.py", temp_actions % data) write("files/%s.desktop" % data["package"], temp_desktop % data) write("comar/service.py", temp_service % data) write("comar/package.py", temp_postscript)