Use to automatically create source package tree with examples and syntax.
Made with "deleting and copying is easier than creating" philosophy example: newpisipackage ../../mynewpackage needs a little bit more cosmetics
This commit is contained in:
Executable
+180
@@ -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 = '''<?xml version="1.0" ?>
|
||||||
|
<!DOCTYPE PISI SYSTEM "http://www.pardus.org.tr/projeler/pisi/pisi-spec.dtd">
|
||||||
|
<PISI>
|
||||||
|
<Source>
|
||||||
|
<Name>%(package)s</Name>
|
||||||
|
<Homepage></Homepage>
|
||||||
|
<Packager>
|
||||||
|
<Name>%(packager_name)s</Name>
|
||||||
|
<Email>%(packager_email)s</Email>
|
||||||
|
</Packager>
|
||||||
|
<License>GPL-2</License>
|
||||||
|
<IsA>app:gui</IsA>
|
||||||
|
<Summary></Summary>
|
||||||
|
<Description></Description>
|
||||||
|
<Summary xml:lang="tr"></Summary>
|
||||||
|
<Description xml:lang="tr"></Description>
|
||||||
|
<Archive sha1sum="" type="targz"></Archive>
|
||||||
|
<BuildDependencies>
|
||||||
|
<Dependency versionFrom=""></Dependency>
|
||||||
|
<Dependency></Dependency>
|
||||||
|
</BuildDependencies>
|
||||||
|
<Patches>
|
||||||
|
<!--
|
||||||
|
<Patch level="1"></Patch>
|
||||||
|
-->
|
||||||
|
</Patches>
|
||||||
|
</Source>
|
||||||
|
|
||||||
|
<Package>
|
||||||
|
<Name>%(package)s</Name>
|
||||||
|
<RuntimeDependencies>
|
||||||
|
</RuntimeDependencies>
|
||||||
|
<Files>
|
||||||
|
<Path fileType="data">/</Path>
|
||||||
|
</Files>
|
||||||
|
<AdditionalFiles>
|
||||||
|
<AdditionalFile owner="root" permission="0644" target="/usr/share/appliactions/%(package)s.desktop">%(package)s.desktop</AdditionalFile>
|
||||||
|
</AdditionalFiles>
|
||||||
|
<Provides>
|
||||||
|
<COMAR script="package.py">System.Package</COMAR>
|
||||||
|
<COMAR script="service.py">System.Service</COMAR>
|
||||||
|
</Provides>
|
||||||
|
</Package>
|
||||||
|
|
||||||
|
<History>
|
||||||
|
<Update release="1">
|
||||||
|
<Date>%(date)s</Date>
|
||||||
|
<Version></Version>
|
||||||
|
<Comment>First release</Comment>
|
||||||
|
<Name>%(packager_name)s</Name>
|
||||||
|
<Email>%(packager_email)s</Email>
|
||||||
|
</Update>
|
||||||
|
</History>
|
||||||
|
</PISI>
|
||||||
|
'''
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
Reference in New Issue
Block a user