diff --git a/scripts/newpisipackage b/scripts/newpisipackage new file mode 100755 index 00000000..e1e28d14 --- /dev/null +++ b/scripts/newpisipackage @@ -0,0 +1,180 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import os +import sys +import time +import string + +data = {"packager_name": "Onur Küçük", + "packager_email": "onur@pardus.org.tr", + "date": time.strftime("%Y-%m-%d"), +} + +temp_pspec = ''' + + + + %(package)s + + + %(packager_name)s + %(packager_email)s + + GPL-2 + app:gui + + + + + + + + + + + + + + + + %(package)s + + + + / + + + %(package)s.desktop + + + System.Package + System.Service + + + + + + %(date)s + + First release + %(packager_name)s + %(packager_email)s + + + +''' + +temp_actions = '''#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright 2006 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;Arcade +''' + +temp_service = '''serviceType = "local" +serviceDesc = "%(package_cap)s" +serviceDefault = "off" + +from comar.service import * + +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) + +# 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 +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) +