~gary-lasker/software-center/misc-fixes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env python

import distutils
import fnmatch
import glob
import os
import re
from subprocess import Popen, PIPE, call
import sys

from distutils.core import setup
from DistUtilsExtra.command import (build_extra, build_i18n, build_help,
                                    build_icons)


class PocketLint(distutils.cmd.Command):
    """ command class that runs pocketlint """
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def binary_in_path(self, binary):
        return any([os.path.exists(os.path.join(p, binary))
                    for p in os.environ["PATH"].split(":")])

    def run(self):
        if not self.binary_in_path("pocketlint"):
            sys.stderr.write("No pocketlint found in path\n"
                             "Use python-pocket-lint in natty or from "
                             "ppa:sinzui\n")
            return
        py_files = []
        for root, dirs, files in os.walk("."):
            pyl = fnmatch.filter(files, "*.py")
            py_files.extend([os.path.join(root, f) for f in pyl
                             if os.path.exists(os.path.join(root, f))])
        call(["pocketlint"]+py_files)


def merge_authors_into_about_dialog():
    fname="./data/ui/gtk/SoftwareCenter.ui"
    authors = open("AUTHORS").read()
    gtkbuilder = open(fname).read()
    gtkbuilder = re.sub(r'<property name="authors">.*</property>',
                        r'<property name="authors">%s</property>' % authors,
                        gtkbuilder)
    open(fname, "w").write(gtkbuilder)
    


# update version.py
line = open("debian/changelog").readline()
m = re.match("^[\w-]+ \(([\w\.~]+)\) ([\w-]+);", line)
VERSION = m.group(1)
CODENAME = m.group(2)
DISTRO = Popen(
    ["lsb_release", "-s", "-i"], stdout=PIPE).communicate()[0].strip()
RELEASE = Popen(
    ["lsb_release", "-s", "-r"], stdout=PIPE).communicate()[0].strip()
open("softwarecenter/version.py", "w").write("""
VERSION='%s'
CODENAME='%s'
DISTRO='%s'
RELEASE='%s'
""" % (VERSION, CODENAME, DISTRO, RELEASE))

# update po4a
if sys.argv[1] == "build":
    merge_authors_into_about_dialog()
    call(["po4a", "po/help/po4a.conf"])

# real setup
setup(name="software-center", version=VERSION,
      scripts=["software-center",
               "software-center-gtk3",
               # gtk
               "utils/submit_review.py",
               "utils/report_review.py",
               "utils/submit_usefulness.py",
               "utils/delete_review.py",
               "utils/modify_review.py",
               # gtk3
               "utils/submit_review_gtk3.py",
               "utils/report_review_gtk3.py",
               "utils/submit_usefulness_gtk3.py",
               "utils/delete_review_gtk3.py",
               "utils/modify_review_gtk3.py",
               # db helpers
               "utils/update-software-center",
               "utils/update-software-center-agent",
               ]+glob.glob("utils/piston-helpers/*.py"),
      packages = ['softwarecenter',
                  'softwarecenter.backend',
                  'softwarecenter.backend.piston',
                  'softwarecenter.db',
                  'softwarecenter.db.pkginfo_impl',
                  'softwarecenter.db.history_impl',
                  'softwarecenter.distro',
                  'softwarecenter.ui',
                  'softwarecenter.ui.gtk',
                  'softwarecenter.ui.gtk.models',
                  'softwarecenter.ui.gtk.widgets',
                  'softwarecenter.ui.gtk3',
                  'softwarecenter.ui.gtk3.dialogs',
                  'softwarecenter.ui.gtk3.models',
                  'softwarecenter.ui.gtk3.panes',
                  'softwarecenter.ui.gtk3.session',
                  'softwarecenter.ui.gtk3.views',
                  'softwarecenter.ui.gtk3.widgets',
                  'softwarecenter.ui.qml',
                 ],
      data_files=[
                  # gtk2
                  ('share/software-center/ui/gtk/',
                   glob.glob("data/ui/gtk/*.ui")),
                  # gtk3
                  ('share/software-center/ui/gtk3/',
                   glob.glob("data/ui/gtk3/*.ui")),
                  ('share/software-center/ui/gtk3/css/',
                   glob.glob("data/ui/gtk3/css/*.css")),
                  ('share/software-center/ui/gtk3/art/',
                   glob.glob("data/ui/gtk3/art/*.png")),
                  ('share/software-center/ui/gtk3/art/icons',
                   glob.glob("data/ui/gtk3/art/icons/*.png")),
                  ('share/software-center/default_banner',
                   glob.glob("data/default_banner/*")),
                  # html
                  ('share/software-center/templates/',
                   glob.glob("data/templates/*.html")),
                  # dbus
                  ('../etc/dbus-1/system.d/',
                   ["data/com.ubuntu.SoftwareCenter.conf"]),
                  # images
                  ('share/software-center/images/',
                   glob.glob("data/images/*.png")+
                   glob.glob("data/images/*.gif")),
                  ('share/software-center/icons/',
                   glob.glob("data/emblems/*.png")),
                  # xpian
                  ('share/apt-xapian-index/plugins',
                   glob.glob("apt-xapian-index-plugin/*.py")),
                  # apport
                  ('share/apport/package-hooks/',
                   ['debian/source_software-center.py']),
                  ],
      cmdclass = {"build": build_extra.build_extra,
                  "build_i18n": build_i18n.build_i18n,
                  "build_help": build_help.build_help,
                  "build_icons": build_icons.build_icons,
                  "lint": PocketLint,
                 },
      )