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.
27
print "CMD <release> <archs>"
33
print "RELEASES", releases
35
mimetype_pkgweights = { "application/x-shockwave-flash" : { "flashplugin-nonfree" : 9, "flashplugin-installer" : 9 } }
37
class AptPluginDbUpdater:
39
def __init__ (self, apt_con, configroot):
40
self._apt_con = apt_con
41
self._configroot = configroot
43
def redo_arch_rel_data (self, architecture, rel, entries):
44
self._apt_con.execute('delete from package where architecture=? AND distribution=?', (architecture, rel))
47
if e.mimetype in mimetype_pkgweights and e.pkgname in mimetype_pkgweights [ e.mimetype ]:
48
pkgweight = mimetype_pkgweights [ e.mimetype ] [ e.pkgname ]
50
print "insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?,?,?)", \
51
e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight, e.filehint, e.description
54
self._apt_con.execute("insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight, filehint, description) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?,?,?)", \
55
(e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight, e.filehint, e.description))
56
print " ... inserted ... "
68
self._apt_con.execute( \
69
"CREATE TABLE package " + \
70
"( id integer PRIMARY KEY," + \
71
" pkgname string NOT NULL," + \
72
" pkgdesc strong NOT NULL," + \
73
" pkglongdesc string NOT NULL," + \
74
" name string NOT NULL," + \
75
" mimetype string NOT NULL," + \
76
" architecture string NULL," + \
77
" appid string NOT NULL," + \
78
" distribution string NOT NULL," + \
79
" section string NOT NULL," + \
80
" weight integer NOT NULL," + \
81
" filehint integer NOT NULL," + \
82
" description integer NOT NULL," + \
83
" UNIQUE (pkgname, architecture, appid, mimetype, distribution)" + \
87
print "table already exists?"
90
apttmproot=nppapt.setup_tmp_cache_tree(self._configroot)
92
arch_arr = archs.split(" ")
93
rel_arr = releases.split(" ")
94
for architecture in arch_arr:
96
npp_info_entries = nppapt.get_npp_entries_for_arch_and_distribution(apttmproot, architecture, rel)
97
self.redo_arch_rel_data(architecture, rel, npp_info_entries)
99
if not apttmproot is None:
100
nppapt.tear_down_tmp_cache(apttmproot)
107
dbfile="/tmp/apt-plugins.sqlite"
108
apt_con = sqlite3.connect(dbfile)
109
updater = AptPluginDbUpdater(apt_con, "./")