#!/usr/bin/env python\r
-# -*- coding: utf-8 -*-\r
-\r
-"""\r
-This program is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published\r
-by the Free Software Foundation; version 2 only.\r
-\r
-This program is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-GNU General Public License for more details.\r
-"""\r
\r
import os\r
import sys\r
\r
-import py2deb\r
+try:\r
+ import py2deb\r
+except ImportError:\r
+ import fake_py2deb as py2deb\r
+\r
+import constants\r
+\r
+\r
+__app_name__ = constants.__app_name__\r
+__description__ = """Very simple Audiobook player.\r
+Supports playing, pausing, seeking (sort of) and saving state when changing book/closing.\r
+Plays books arranged as dirs under myDocs/Audiobooks\r
+.\r
+Homepage: http://wiki.maemo.org/Nqaap"""\r
+__author__ = "Soeren 'Pengman' Pedersen"\r
+__email__ = "pengmeister@gmail.com"\r
+__version__ = constants.__version__\r
+__build__ = constants.__build__\r
+__changelog__ = """\r
+""".strip()\r
+\r
+\r
+__postinstall__ = """#!/bin/sh -e\r
+\r
+gtk-update-icon-cache -f /usr/share/icons/hicolor\r
+rm -f ~/.%(name)s/%(name)s.log\r
+""" % {"name": constants.__app_name__}\r
+\r
+\r
+def find_files(prefix, path):\r
+ for root, dirs, files in os.walk(path):\r
+ for file in files:\r
+ if file.startswith(prefix+"-"):\r
+ fileParts = file.split("-")\r
+ unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]\r
+ assert unused == prefix\r
+ relPath = os.sep.join(relPathParts)\r
+ yield relPath, file, newName\r
+\r
+\r
+def unflatten_files(files):\r
+ d = {}\r
+ for relPath, oldName, newName in files:\r
+ if relPath not in d:\r
+ d[relPath] = []\r
+ d[relPath].append((oldName, newName))\r
+ return d\r
\r
\r
def build_package(distribution):\r
- py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]\r
try:\r
os.chdir(os.path.dirname(sys.argv[0]))\r
except:\r
pass\r
\r
- p=py2deb.Py2deb("nqaap")\r
- p.prettyName="NQA Audiobook Player"\r
- p.description="""Very simple Audiobook player.\r
-Supports playing, pausing, seeking (sort of) and saving state when changing book/closing.\r
-Plays books arranged as dirs under myDocs/Audiobooks\r
-.\r
-Homepage: http://wiki.maemo.org/Nqaap"""\r
- p.author="Soeren 'Pengman' Pedersen"\r
- p.mail="pengmeister@gmail.com"\r
+ py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]\r
+ p = py2deb.Py2deb(__app_name__)\r
+ p.prettyName = constants.__pretty_app_name__\r
+ p.description = __description__\r
+ p.bugTracker="https://bugs.maemo.org/enter_bug.cgi?product=nQa%%20Audiobook%%20Player"\r
+ p.author = __author__\r
+ p.mail = __email__\r
p.license = "lgpl"\r
p.depends = ", ".join([\r
"python2.6 | python2.5",\r
"diablo": "user/multimedia",\r
"fremantle": "user/multimedia",\r
}[distribution]\r
+ p.arch="all"\r
+ p.urgency="low"\r
+ p.distribution=distribution\r
+ p.repository="extras"\r
+ p.changelog = __changelog__\r
+ p.postinstall = __postinstall__\r
p.icon = {\r
"debian": "src/usr/share/icons/hicolor/26x26/hildon/nqaap.png",\r
"diablo": "src/usr/share/icons/hicolor/26x26/hildon/nqaap.png",\r
"fremantle": "src/usr/share/icons/hicolor/48x48/hildon/nqaap.png",\r
}[distribution]\r
- p.arch="all"\r
- p.urgency="low"\r
- p.distribution=distribution\r
- p.repository="extras"\r
- p.bugTracker="https://bugs.maemo.org/enter_bug.cgi?product=nQa%%20Audiobook%%20Player"\r
- p.postinstall="""#!/bin/sh\r
-rm -f ~/.nqaap/nqaap.log\r
-"""\r
- version = "0.8.7"\r
- build = "0"\r
- changeloginformation = """\r
-* Fixing a bug with initially configuring the book location\r
-""".strip()\r
- dir_name = "src"\r
- #Thanks to DareTheHair from talk.maemo.org for this snippet that\r
- #recursively builds the file list\r
- for root, dirs, files in os.walk(dir_name):\r
- if any(f.startswith(".") for f in root.split(os.sep)):\r
- continue # avoid hidden folders, esp svn ones\r
-\r
- real_dir = root[len(dir_name):]\r
- fake_file = []\r
- for f in files:\r
- fake_file.append(root + os.sep + f + "|" + f)\r
- if len(fake_file) > 0:\r
- p[real_dir] = fake_file\r
+ p["/opt/%s/bin" % constants.__app_name__] = [ "%s.py" % constants.__app_name__ ]\r
+ for relPath, files in unflatten_files(find_files("src", ".")).iteritems():\r
+ fullPath = "/opt/%s/lib" % constants.__app_name__\r
+ if relPath:\r
+ fullPath += os.sep+relPath\r
+ p[fullPath] = list(\r
+ "|".join((oldName, newName))\r
+ for (oldName, newName) in files\r
+ )\r
+ p["/usr/share/applications/hildon"] = ["%s.desktop" % constants.__app_name__]\r
+ p["/usr/share/icons/hicolor/26x26/hildon"] = ["%s.png" % constants.__app_name__]\r
+ p["/usr/share/icons/hicolor/48x48/hildon"] = ["%s.png" % constants.__app_name__]\r
+ p["/usr/share/icons/hicolor/64x64/hildon"] = ["%s.png" % constants.__app_name__]\r
+ p["/usr/share/icons/hicolor/scalable/hildon"] = ["%s.png" % constants.__app_name__]\r
\r
print p\r
if distribution == "debian":\r
print p.generate(\r
- version="%s-%s" % (version, build),\r
- changelog=changeloginformation,\r
+ version="%s-%s" % (__version__, __build__),\r
+ changelog=__changelog__,\r
build=True,\r
tar=False,\r
changes=False,\r
)\r
else:\r
print p.generate(\r
- version="%s-%s" % (version, build),\r
- changelog=changeloginformation,\r
+ version="%s-%s" % (__version__, __build__),\r
+ changelog=__changelog__,\r
build=False,\r
tar=True,\r
changes=True,\r