3 * (c) Koen Kooi 2006, 2007
4 * (c) Marcin Juszkiewicz 2006, 2007
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License along
15 * with this library; see the file COPYING.LIB. If not, write to the Free
16 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 require_once 'includes/config.inc';
22 require_once 'includes/functions.inc';
25 A package entry looks like this:
28 Depends: libc6 (>= 2.4)
29 Provides: libfontconfig-utils
30 Replaces: libfontconfig-utils
31 Conflicts: libfontconfig-utils
34 Maintainer: Angstrom Developers <angstrom-dev@handhelds.org>
36 MD5Sum: b8bd197224e24759d2162091a0fa727f
38 Filename: zeroconf_0.9-r0_armv5te.ipk
39 Source: http://www.progsoc.org/~wildfire/zeroconf/download/zeroconf-0.9.tar.gz file://zeroconf-default file://debian-zeroconf
40 Description: IPv4 link-local address allocator
45 die("Database not found and cannot be created.");
48 $feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds");
52 $feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds WHERE f_uri = '${argv[1]}'");
53 } else if ($argc == 3 && $argv[1] == "--type") {
54 $feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds WHERE f_type = '${argv[2]}'");
58 die("Cannot find feed(s) in the DB\n");
64 foreach($feeds as $feed)
66 print("Updating {$feed['f_name']}: ");
67 db_query_n("DELETE FROM packages WHERE p_feed = '{$feed['f_id']}'");
71 $packagesgz_h = fopen("compress.zlib://{$feed['f_uri']}/Packages.gz", "r");
75 $package_info = array(
76 'name'=>'', 'version'=>'', 'arch'=>'', 'depends'=>'',
77 'maintainer'=>'', 'homepage'=>'', 'section'=>'', 'replaces'=>'',
78 'provides'=>'', 'recommends'=>'', 'conflicts'=>'', 'size'=>'',
79 'md5sum'=>'', 'source'=>'', 'feed'=>$feed['f_id'], 'file'=>'', 'desc'=>''
82 while (!feof($packagesgz_h))
84 $buffer = fscanf($packagesgz_h, "%[^:]: %[ -~]");
85 list ($field, $value) = $buffer;
87 if($field == 'Package' && $count > 0)
89 insert_ipkgs($package_info);
91 $package_info = array(
92 'name'=>'', 'version'=>'', 'arch'=>'', 'depends'=>'',
93 'maintainer'=>'', 'homepage'=>'', 'section'=>'', 'replaces'=>'',
94 'provides'=>'', 'recommends'=>'', 'conflicts'=>'', 'size'=>'',
95 'md5sum'=>'', 'source'=>'', 'feed'=>$feed['f_id'], 'file'=>'', 'desc'=>''
102 $package_info['name'] = $value;
106 $package_info['version'] = $value;
109 $package_info['depends'] = $value;
112 $package_info['provides'] = $value;
115 $package_info['recommends'] = $value;
118 $package_info['replaces'] = $value;
121 $package_info['conflicts'] = $value;
124 $package_info['section'] = strtolower($value);
127 $package_info['arch'] = $value;
130 $package_info['maintainer'] = str_replace("'","\"", $value);
133 $package_info['md5sum'] = $value;
136 $package_info['size'] = $value;
139 $package_info['file'] = $value;
142 $package_info['source'] = $value;
145 $package_info['desc'] = str_replace("'","\"", $value);
151 insert_ipkgs($package_info);
154 $p_count = $count +
$p_count;
155 print("$count packages\n");
156 gzclose($packagesgz_h);
161 $difference = $end - $start;
163 $days = floor($difference/86400);
164 $difference = $difference - ($days*86400);
166 $hours = floor($difference/3600);
167 $difference = $difference - ($hours*3600);
169 $minutes = floor($difference/60);
170 $difference = $difference - ($minutes*60);
172 $seconds = $difference;
174 print "Added $p_count packages in $days days, $hours hours, $minutes minutes and $seconds seconds \n";
177 function insert_ipkgs(&$package_info)
179 db_query_n("INSERT INTO packages VALUES (
180 '{$package_info['name']}', '{$package_info['version']}',
181 '{$package_info['arch']}', '{$package_info['depends']}',
182 '{$package_info['maintainer']}', '{$package_info['homepage']}',
183 '{$package_info['section']}', '{$package_info['replaces']}',
184 '{$package_info['provides']}', '{$package_info['recommends']}',
185 '{$package_info['conflicts']}', '{$package_info['size']}',
186 '{$package_info['md5sum']}', '{$package_info['source']}',
187 '{$package_info['feed']}', '{$package_info['file']}',
188 '{$package_info['desc']}'