Subversion Repositories SvarDOS

Rev

Rev 798 | Rev 802 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 798 Rev 801
Line 147... Line 147...
147
 
147
 
148
// do a list of all svp packages with their available versions and descriptions
148
// do a list of all svp packages with their available versions and descriptions
149
 
149
 
150
$pkgdb = array();
150
$pkgdb = array();
151
foreach ($pkgfiles as $fname) {
151
foreach ($pkgfiles as $fname) {
152
  if (!preg_match('/.svp$/i', $fname)) continue; // skip non-svp files
152
  if (!preg_match('/\.svp$/i', $fname)) continue; // skip non-svp files
-
 
153
 
-
 
154
  if (!preg_match('/^[a-zA-Z0-9+. _-]*\.svp$/', $fname)) {
-
 
155
    echo "ERROR: {$fname} has a very weird name\n";
-
 
156
    continue;
-
 
157
  }
153
 
158
 
154
  $path_parts = pathinfo($fname);
159
  $path_parts = pathinfo($fname);
155
  $pkgnam = explode('-', $path_parts['filename'])[0];
160
  $pkgnam = explode('-', $path_parts['filename'])[0];
156
  $pkgfullpath = realpath($repodir . '/' . $fname);
161
  $pkgfullpath = realpath($repodir . '/' . $fname);
157
 
162
 
Line 232... Line 237...
232
  $meta['desc'] = $lsmarray['description'];
237
  $meta['desc'] = $lsmarray['description'];
233
 
238
 
234
  $pkgdb[$pkgnam][$lsmarray['version']] = $meta;
239
  $pkgdb[$pkgnam][$lsmarray['version']] = $meta;
235
}
240
}
236
 
241
 
-
 
242
 
237
$db = array();
243
$db = array();
238
 
244
 
239
// iterate over each svp package
245
// iterate over each svp package
240
foreach ($pkgdb as $pkg => $versions) {
246
foreach ($pkgdb as $pkg => $versions) {
241
 
247
 
Line 260... Line 266...
260
 
266
 
261
}
267
}
262
 
268
 
263
if ($pkgcount < 100) echo "WARNING: an unexpectedly low number of packages has been found in the repo ({$pkgcount})\n";
269
if ($pkgcount < 100) echo "WARNING: an unexpectedly low number of packages has been found in the repo ({$pkgcount})\n";
264
 
270
 
-
 
271
$json_blob = json_encode($db);
-
 
272
if ($json_blob === false) {
-
 
273
  echo "ERROR: JSON convertion failed! -> ";
-
 
274
  switch (json_last_error()) {
-
 
275
    case JSON_ERROR_DEPTH:
-
 
276
      echo 'maximum stack depth exceeded';
-
 
277
      break;
-
 
278
    case JSON_ERROR_STATE_MISMATCH:
-
 
279
      echo 'underflow of the modes mismatch';
-
 
280
      break;
-
 
281
    case JSON_ERROR_CTRL_CHAR:
-
 
282
      echo 'unexpected control character found';
-
 
283
      break;
-
 
284
    case JSON_ERROR_UTF8:
-
 
285
      echo 'malformed utf-8 characters';
-
 
286
      break;
-
 
287
    default:
-
 
288
      echo "unknown error";
-
 
289
      break;
-
 
290
  }
-
 
291
  echo "\n";
-
 
292
}
-
 
293
 
265
file_put_contents($repodir . '/_index.json', json_encode($db));
294
file_put_contents($repodir . '/_index.json', json_encode($db));
266
 
295
 
267
exit(0);
296
exit(0);
268
 
297
 
269
?>
298
?>