added debian packaging stuff
authorpycage <martin.grimme@gmail.com>
Thu, 7 Jan 2010 21:10:39 +0000 (21:10 +0000)
committerpycage <martin.grimme@gmail.com>
Thu, 7 Jan 2010 21:10:39 +0000 (21:10 +0000)
git-svn-id: file:///svnroot/ussd-widget/trunk@13 d197f4d6-dc93-42ad-8354-0da1f58e353f

ussd-pad/Makefile [new file with mode: 0644]
ussd-pad/debian/changelog [new file with mode: 0644]
ussd-pad/debian/compat [new file with mode: 0644]
ussd-pad/debian/control [new file with mode: 0644]
ussd-pad/debian/copyright [new file with mode: 0644]
ussd-pad/debian/postinst [new file with mode: 0644]
ussd-pad/debian/rules [new file with mode: 0755]
ussd-pad/debian/ussd-pad.links [new file with mode: 0644]
ussd-pad/pycompile/compileall.py [new file with mode: 0644]
ussd-pad/pycompile/py_compile.py [new file with mode: 0644]

diff --git a/ussd-pad/Makefile b/ussd-pad/Makefile
new file mode 100644 (file)
index 0000000..56c0b0e
--- /dev/null
@@ -0,0 +1,31 @@
+# No autotools madness here. Just a simple Makefile to satisfy dpkg-buildpackage
+
+
+NAME=ussd-pad
+PREFIX=/opt
+EXEC_FILE=USSDPad.py
+
+
+clean:
+       find . -name "*.pyc" -exec rm "{}" \;
+       find . -name "*.pyo" -exec rm "{}" \;
+       find . -name "*~" -exec rm "{}" \;
+       @true
+
+all:
+       @true
+
+py-compile:
+       python2.5 -OO pycompile/compileall.py -x ${EXEC_FILE} ${DESTDIR}; true
+       find ${DESTDIR} -name "*.py" | grep -v ${EXEC_FILE} | xargs rm; true
+
+install-files:
+       cp -r src/* ${DESTDIR}
+       chmod a+x ${DESTDIR}${PREFIX}/${NAME}/${EXEC_FILE}
+       
+purge-svn:
+       find ${DESTDIR} -name ".svn" | xargs rm -r; true
+
+install: install-files py-compile purge-svn
+       @true
+
diff --git a/ussd-pad/debian/changelog b/ussd-pad/debian/changelog
new file mode 100644 (file)
index 0000000..11847d6
--- /dev/null
@@ -0,0 +1,12 @@
+ussd-pad (2010.01.07) unstable; urgency=low
+
+  Better support for text encodings
+
+ -- Martin Grimme <martin.grimme@gmail.com>  Thu, 07 Jan 2010 22:45:00 +0100
+
+ussd-pad (2010.01.05) unstable; urgency=low
+
+  Initial release
+
+ -- Martin Grimme <martin.grimme@gmail.com>  Tue, 05 Jan 2010 23:30:00 +0100
+
diff --git a/ussd-pad/debian/compat b/ussd-pad/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/ussd-pad/debian/control b/ussd-pad/debian/control
new file mode 100644 (file)
index 0000000..9aac021
--- /dev/null
@@ -0,0 +1,17 @@
+Source: ussd-pad
+Section: user/utilities
+Priority: optional
+Maintainer: Martin Grimme <martin.grimme@lintegra.de>
+Build-Depends: debhelper (>= 5), python2.5-minimal
+Standards-Version: 3.7.2
+
+Package: ussd-pad
+Architecture: any
+### FREMANTLE
+Depends: python2.5, python-gtk2, python-gobject, python-osso, python-hildon, ussd-common
+Description: Send USSD codes like *135#
+ This is an intermediate solution to send USSD codes with the N900 until the firmware gets native support for it.
+XB-Maemo-Display-Name: USSD Pad
+# TODO: use bigger icon for Fremantle
+XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oBBRQWL9mpz0kAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAACUUlEQVRIx8WVPWgVQRSFvxtiUBD/EAkERKuJ0U6FV6mFgsiolaBNsPInIKiFhYJIjDaCgiAEBOGBUYtIEEbB1/jTRGMVITwmFkoEwxMtlPdAjXFsbmRdd9ZsXiCnubszd/fcO3PmjKBwPgQAa0TIQNa882EPcBLYDCwDPgFPgV5rpJr8voU5wvnQDTwEdgGrgFagHTgIjDgfNs4LEXBR42WgQ4k6taOlwKVkcmsTRGs0DlkjH/TZOx+OAOPAjvkiqgD7gGHnwxBwG3hsjbwB/tnnZpbuGDCqxR4AHgA150O/82F9HlGYxc//5Fgjk6q2QyqKb8By4Cgw5nzYFiP6rmpalKGwNn38kRy3RqatkXvWiAVWa2fPgSXA1RjRR42dGZ2s0/g5QV5zPgTnwwYlbVgjg8BeTdkUE8MwsBa443w4AbwEfgJdwHXNGUnkPwIOA2XnQw/wGlgJnNX5dzGi88BOreRJRld14ELivVdVtxV4lbGX5zKXzhoZ1829BUwAU8AvYBIYALZYI6OJ/LdACbgL1IBp4KsWudsauc9CQFLqmpVJzhhsaqkaQBW4YY2Uo0RqkuVIQXWgZI2MRYjSuGaNnI7Ju5BJzlwZem20qWLPqFJPOR+2x1RXyCRThFPAe+CK82GxKrIHeJZFVMgkczCgRKXY0hUyyRxMaGyPnaNCJlkULXM1yRx0pLzz7z1yPtRUEF3WSNUaaQCDzocK8CVtkjnYr/FFTHWFTDJ10AVYAVigT4dvxogKmeR/Dm6/NVKJiaFZk6zrVdNtjRxnofAbC1T2CPUkSeUAAAAASUVORK5CYII=
+
diff --git a/ussd-pad/debian/copyright b/ussd-pad/debian/copyright
new file mode 100644 (file)
index 0000000..0ebd999
--- /dev/null
@@ -0,0 +1,4 @@
+Copyright (c) 2010 Martin Grimme
+
+USSD Pad is licensed under the terms of the GNU GPL.
+
diff --git a/ussd-pad/debian/postinst b/ussd-pad/debian/postinst
new file mode 100644 (file)
index 0000000..e07a5bd
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+/usr/bin/gtk-update-icon-cache -f /usr/share/icons/hicolor
+
+true
+
diff --git a/ussd-pad/debian/rules b/ussd-pad/debian/rules
new file mode 100755 (executable)
index 0000000..d9af4e6
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+
+       touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+       #docbook-to-man debian/mediabox.sgml > mediabox.1
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) clean
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/ussd-pad.
+       $(MAKE) DESTDIR=$(CURDIR)/debian/ussd-pad install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+#      dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/ussd-pad/debian/ussd-pad.links b/ussd-pad/debian/ussd-pad.links
new file mode 100644 (file)
index 0000000..073900b
--- /dev/null
@@ -0,0 +1,2 @@
+/opt/ussd-pad/USSDPad.py /usr/bin/USSDPad
+
diff --git a/ussd-pad/pycompile/compileall.py b/ussd-pad/pycompile/compileall.py
new file mode 100644 (file)
index 0000000..b21d95f
--- /dev/null
@@ -0,0 +1,157 @@
+"""Module/script to "compile" all .py files to .pyc (or .pyo) file.
+
+When called as a script with arguments, this compiles the directories
+given as arguments recursively; the -l option prevents it from
+recursing into directories.
+
+Without arguments, if compiles all modules on sys.path, without
+recursing into subdirectories.  (Even though it should do so for
+packages -- for now, you'll have to deal with packages separately.)
+
+See module py_compile for details of the actual byte-compilation.
+
+"""
+
+import os
+import sys
+import py_compile
+
+__all__ = ["compile_dir","compile_path"]
+
+def compile_dir(dir, maxlevels=10, ddir=None,
+                force=0, rx=None, quiet=0):
+    """Byte-compile all modules in the given directory tree.
+
+    Arguments (only dir is required):
+
+    dir:       the directory to byte-compile
+    maxlevels: maximum recursion level (default 10)
+    ddir:      if given, purported directory name (this is the
+               directory name that will show up in error messages)
+    force:     if 1, force compilation, even if timestamps are up-to-date
+    quiet:     if 1, be quiet during compilation
+
+    """
+    if not quiet:
+        print 'Listing', dir, '...'
+    try:
+        names = os.listdir(dir)
+    except os.error:
+        print "Can't list", dir
+        names = []
+    names.sort()
+    success = 1
+    for name in names:
+        fullname = os.path.join(dir, name)
+        if ddir is not None:
+            dfile = os.path.join(ddir, name)
+        else:
+            dfile = None
+        if rx is not None:
+            mo = rx.search(fullname)
+            if mo:
+                continue
+        if os.path.isfile(fullname):
+            head, tail = name[:-3], name[-3:]
+            if tail == '.py':
+                cfile = fullname + (__debug__ and 'c' or 'o')
+                ftime = os.stat(fullname).st_mtime
+                try: ctime = os.stat(cfile).st_mtime
+                except os.error: ctime = 0
+                if (ctime > ftime) and not force: continue
+                if not quiet:
+                    print 'Compiling', fullname, '...'
+                try:
+                    ok = py_compile.compile(fullname, None, dfile, True)
+                except KeyboardInterrupt:
+                    raise KeyboardInterrupt
+                except py_compile.PyCompileError,err:
+                    if quiet:
+                        print 'Compiling', fullname, '...'
+                    print err.msg
+                    success = 0
+                except IOError, e:
+                    print "Sorry", e
+                    success = 0
+                else:
+                    if ok == 0:
+                        success = 0
+        elif maxlevels > 0 and \
+             name != os.curdir and name != os.pardir and \
+             os.path.isdir(fullname) and \
+             not os.path.islink(fullname):
+            if not compile_dir(fullname, maxlevels - 1, dfile, force, rx, quiet):
+                success = 0
+    return success
+
+def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
+    """Byte-compile all module on sys.path.
+
+    Arguments (all optional):
+
+    skip_curdir: if true, skip current directory (default true)
+    maxlevels:   max recursion level (default 0)
+    force: as for compile_dir() (default 0)
+    quiet: as for compile_dir() (default 0)
+
+    """
+    success = 1
+    for dir in sys.path:
+        if (not dir or dir == os.curdir) and skip_curdir:
+            print 'Skipping current directory'
+        else:
+            success = success and compile_dir(dir, maxlevels, None,
+                                              force, quiet=quiet)
+    return success
+
+def main():
+    """Script main program."""
+    import getopt
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
+    except getopt.error, msg:
+        print msg
+        print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
+              "[-x regexp] [directory ...]"
+        print "-l: don't recurse down"
+        print "-f: force rebuild even if timestamps are up-to-date"
+        print "-q: quiet operation"
+        print "-d destdir: purported directory name for error messages"
+        print "   if no directory arguments, -l sys.path is assumed"
+        print "-x regexp: skip files matching the regular expression regexp"
+        print "   the regexp is search for in the full path of the file"
+        sys.exit(2)
+    maxlevels = 10
+    ddir = None
+    force = 0
+    quiet = 0
+    rx = None
+    for o, a in opts:
+        if o == '-l': maxlevels = 0
+        if o == '-d': ddir = a
+        if o == '-f': force = 1
+        if o == '-q': quiet = 1
+        if o == '-x':
+            import re
+            rx = re.compile(a)
+    if ddir:
+        if len(args) != 1:
+            print "-d destdir require exactly one directory argument"
+            sys.exit(2)
+    success = 1
+    try:
+        if args:
+            for dir in args:
+                if not compile_dir(dir, maxlevels, ddir,
+                                   force, rx, quiet):
+                    success = 0
+        else:
+            success = compile_path()
+    except KeyboardInterrupt:
+        print "\n[interrupt]"
+        success = 0
+    return success
+
+if __name__ == '__main__':
+    exit_status = int(not main())
+    sys.exit(exit_status)
diff --git a/ussd-pad/pycompile/py_compile.py b/ussd-pad/pycompile/py_compile.py
new file mode 100644 (file)
index 0000000..1cb41f1
--- /dev/null
@@ -0,0 +1,164 @@
+"""Routine to "compile" a .py file to a .pyc (or .pyo) file.
+
+This module has intimate knowledge of the format of .pyc files.
+"""
+
+import __builtin__
+import imp
+import marshal
+import os
+import sys
+import traceback
+
+MAGIC = imp.get_magic()
+
+__all__ = ["compile", "main", "PyCompileError"]
+
+
+class PyCompileError(Exception):
+    """Exception raised when an error occurs while attempting to
+    compile the file.
+
+    To raise this exception, use
+
+        raise PyCompileError(exc_type,exc_value,file[,msg])
+
+    where
+
+        exc_type:   exception type to be used in error message
+                    type name can be accesses as class variable
+                    'exc_type_name'
+
+        exc_value:  exception value to be used in error message
+                    can be accesses as class variable 'exc_value'
+
+        file:       name of file being compiled to be used in error message
+                    can be accesses as class variable 'file'
+
+        msg:        string message to be written as error message
+                    If no value is given, a default exception message will be given,
+                    consistent with 'standard' py_compile output.
+                    message (or default) can be accesses as class variable 'msg'
+
+    """
+
+    def __init__(self, exc_type, exc_value, file, msg=''):
+        exc_type_name = exc_type.__name__
+        if exc_type is SyntaxError:
+            tbtext = ''.join(traceback.format_exception_only(exc_type, exc_value))
+            errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file)
+        else:
+            errmsg = "Sorry: %s: %s" % (exc_type_name,exc_value)
+
+        Exception.__init__(self,msg or errmsg,exc_type_name,exc_value,file)
+
+        self.exc_type_name = exc_type_name
+        self.exc_value = exc_value
+        self.file = file
+        self.msg = msg or errmsg
+
+    def __str__(self):
+        return self.msg
+
+
+# Define an internal helper according to the platform
+if os.name == "mac":
+    import MacOS
+    def set_creator_type(file):
+        MacOS.SetCreatorAndType(file, 'Pyth', 'PYC ')
+else:
+    def set_creator_type(file):
+        pass
+
+def wr_long(f, x):
+    """Internal; write a 32-bit int to a file in little-endian order."""
+    f.write(chr( x        & 0xff))
+    f.write(chr((x >> 8)  & 0xff))
+    f.write(chr((x >> 16) & 0xff))
+    f.write(chr((x >> 24) & 0xff))
+
+def compile(file, cfile=None, dfile=None, doraise=False):
+    """Byte-compile one Python source file to Python bytecode.
+
+    Arguments:
+
+    file:    source filename
+    cfile:   target filename; defaults to source with 'c' or 'o' appended
+             ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo)
+    dfile:   purported filename; defaults to source (this is the filename
+             that will show up in error messages)
+    doraise: flag indicating whether or not an exception should be
+             raised when a compile error is found. If an exception
+             occurs and this flag is set to False, a string
+             indicating the nature of the exception will be printed,
+             and the function will return to the caller. If an
+             exception occurs and this flag is set to True, a
+             PyCompileError exception will be raised.
+
+    Note that it isn't necessary to byte-compile Python modules for
+    execution efficiency -- Python itself byte-compiles a module when
+    it is loaded, and if it can, writes out the bytecode to the
+    corresponding .pyc (or .pyo) file.
+
+    However, if a Python installation is shared between users, it is a
+    good idea to byte-compile all modules upon installation, since
+    other users may not be able to write in the source directories,
+    and thus they won't be able to write the .pyc/.pyo file, and then
+    they would be byte-compiling every module each time it is loaded.
+    This can slow down program start-up considerably.
+
+    See compileall.py for a script/module that uses this module to
+    byte-compile all installed files (or all files in selected
+    directories).
+
+    """
+    f = open(file, 'U')
+    try:
+        timestamp = long(os.fstat(f.fileno()).st_mtime)
+    except AttributeError:
+        timestamp = long(os.stat(file).st_mtime)
+    codestring = f.read()
+    f.close()
+    if codestring and codestring[-1] != '\n':
+        codestring = codestring + '\n'
+    try:
+        codeobject = __builtin__.compile(codestring, dfile or file,'exec')
+    except Exception,err:
+        py_exc = PyCompileError(err.__class__,err.args,dfile or file)
+        if doraise:
+            raise py_exc
+        else:
+            sys.stderr.write(py_exc.msg + '\n')
+            return
+    if cfile is None:
+        cfile = file + (__debug__ and 'c' or 'o')
+    fc = open(cfile, 'wb')
+    fc.write('\0\0\0\0')
+    wr_long(fc, timestamp)
+    marshal.dump(codeobject, fc)
+    fc.flush()
+    fc.seek(0, 0)
+    fc.write(MAGIC)
+    fc.close()
+    set_creator_type(cfile)
+
+def main(args=None):
+    """Compile several source files.
+
+    The files named in 'args' (or on the command line, if 'args' is
+    not specified) are compiled and the resulting bytecode is cached
+    in the normal manner.  This function does not search a directory
+    structure to locate source files; it only compiles files named
+    explicitly.
+
+    """
+    if args is None:
+        args = sys.argv[1:]
+    for filename in args:
+        try:
+            compile(filename, doraise=True)
+        except PyCompileError,err:
+            sys.stderr.write(err.msg)
+
+if __name__ == "__main__":
+    main()