3
# Copyright (C) 2007-2008 Canonical Ltd.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
print "CMD <release> <archs>"
34
print "RELEASES", releases
36
mimetype_pkgweights = { "application/x-shockwave-flash" : { "flashplugin-nonfree" : 9, "flashplugin-installer" : 9 } }
38
class AptPluginDbUpdater:
40
def __init__ (self, apt_con, configroot):
41
self._apt_con = apt_con
42
self._configroot = configroot
44
def redo_arch_rel_data (self, architecture, rel, entries):
45
self._apt_con.execute('delete from package where architecture=? AND distribution=?', (architecture, rel))
48
if e.mimetype in mimetype_pkgweights and e.pkgname in mimetype_pkgweights [ e.mimetype ]:
49
pkgweight = mimetype_pkgweights [ e.mimetype ] [ e.pkgname ]
51
print "insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description, manualInstallURL) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?,?,?,\"\")", \
52
e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight, e.filehint, e.description
55
self._apt_con.execute("insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description, manualInstallURL) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?,?,?,\"\")", \
56
(e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight, e.filehint, e.description))
57
print " ... inserted ... "
61
def add_extra_data (self, arch, dist):
62
fd = open('extra.json', 'r')
63
extras = json.load(fd)
66
for mimetype in extras['mimetypes']:
67
entry = extras['mimetypes'][mimetype]
68
for appid in extras[entry]['appids']:
69
print "insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description, manualInstallURL) values (\"\",\"\",\"\",?,?,?,\"{"+appid+"}\",?,\"\",\"\",\"\",?,?)", extras[entry]['name'], mimetype, arch, dist, extras[entry]['description'], extras[entry]['manualInstallURL']
72
self._apt_con.execute("insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description, manualInstallURL) values (\"\",\"\",\"\",?,?,?,\"{"+appid+"}\",?,\"\",-1,\"\",?,?)", (extras[entry]['name'], mimetype, arch, dist, extras[entry]['description'], extras[entry]['manualInstallURL']))
73
print " ... inserted ... "
84
self._apt_con.execute( \
85
"CREATE TABLE package " + \
86
"( id integer PRIMARY KEY," + \
87
" pkgname string NOT NULL," + \
88
" pkgdesc strong NOT NULL," + \
89
" pkglongdesc string NOT NULL," + \
90
" name string NOT NULL," + \
91
" mimetype string NOT NULL," + \
92
" architecture string NULL," + \
93
" appid string NOT NULL," + \
94
" distribution string NOT NULL," + \
95
" section string NOT NULL," + \
96
" weight integer NOT NULL," + \
97
" filehint integer NOT NULL," + \
98
" description integer NOT NULL," + \
99
" manualInstallURL string NOT NULL," + \
100
" UNIQUE (pkgname, architecture, appid, mimetype, distribution, manualInstallURL)" + \
104
print "table already exists?"
107
apttmproot=nppapt.setup_tmp_cache_tree(self._configroot)
109
arch_arr = archs.split(" ")
110
rel_arr = releases.split(" ")
111
for architecture in arch_arr:
113
npp_info_entries = nppapt.get_npp_entries_for_arch_and_distribution(apttmproot, architecture, rel)
114
self.redo_arch_rel_data(architecture, rel, npp_info_entries)
115
self.add_extra_data(architecture, rel)
118
if not apttmproot is None:
119
nppapt.tear_down_tmp_cache(apttmproot)
126
dbfile="/tmp/apt-plugins.sqlite"
127
apt_con = sqlite3.connect(dbfile)
128
updater = AptPluginDbUpdater(apt_con, "./")