Subversion Repositories SvarDOS

Rev

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

Rev 804 Rev 909
Line 8... Line 8...
8
  files. buildidx will generate the index file and save it into the package
8
  files. buildidx will generate the index file and save it into the package
9
  repository.
9
  repository.
10
 
10
 
11
  requires php-zip
11
  requires php-zip
12
 
12
 
-
 
13
  21 feb 2022: buildidx collects categories looking at the dir layout of each package
13
  17 feb 2022: checking for non-8+3 filenames in packages and duplicates + devload no longer part of CORE
14
  17 feb 2022: checking for non-8+3 filenames in packages and duplicates + devload no longer part of CORE
14
  16 feb 2022: added warning about overlong version strings and wild files location
15
  16 feb 2022: added warning about overlong version strings and wild files location
15
  15 feb 2022: index is generated as json, contains all filenames and alt versions
16
  15 feb 2022: index is generated as json, contains all filenames and alt versions
16
  14 feb 2022: packages are expected to have the *.svp extension
17
  14 feb 2022: packages are expected to have the *.svp extension
17
  12 feb 2022: skip source packages from being processed (*.src.zip)
18
  12 feb 2022: skip source packages from being processed (*.src.zip)
Line 30... Line 31...
30
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
31
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
31
  04 feb 2013: added CRC32 support
32
  04 feb 2013: added CRC32 support
32
  22 sep 2012: forked 1st version from FDUPDATE builder
33
  22 sep 2012: forked 1st version from FDUPDATE builder
33
*/
34
*/
34
 
35
 
35
$PVER = "20220217";
36
$PVER = "20220221";
36
 
37
 
37
 
38
 
38
// computes the BSD sum of a file and returns it
39
// computes the BSD sum of a file and returns it
39
function file2bsum($fname) {
40
function file2bsum($fname) {
40
  $result = 0;
41
  $result = 0;
Line 189... Line 190...
189
  if ($pkgnam == 'clamdb') $pkgdir = 'clamav'; // data patterns for clamav
190
  if ($pkgnam == 'clamdb') $pkgdir = 'clamav'; // data patterns for clamav
190
 
191
 
191
  // array used to detect duplicated entries after lower-case conversion
192
  // array used to detect duplicated entries after lower-case conversion
192
  $duparr = array();
193
  $duparr = array();
193
 
194
 
-
 
195
  // will hold the list of categories that this package belongs to
-
 
196
  $catlist = array();
-
 
197
 
194
  foreach ($listoffiles as $f) {
198
  foreach ($listoffiles as $f) {
195
    $f = strtolower($f);
199
    $f = strtolower($f);
196
    $path_array = explode('/', $f);
200
    $path_array = explode('/', $f);
197
    // emit a warning when non-8+3 filenames are spotted and find duplicates
201
    // emit a warning when non-8+3 filenames are spotted and find duplicates
198
    foreach ($path_array as $item) {
202
    foreach ($path_array as $item) {
Line 209... Line 213...
209
    }
213
    }
210
    // LSM file is ok
214
    // LSM file is ok
211
    if ($f === "appinfo/{$pkgnam}.lsm") continue;
215
    if ($f === "appinfo/{$pkgnam}.lsm") continue;
212
    if ($f === "appinfo/") continue;
216
    if ($f === "appinfo/") continue;
213
    // CORE and MSDOS_COMPAT packages are premium citizens and can do a little more
217
    // CORE and MSDOS_COMPAT packages are premium citizens and can do a little more
-
 
218
    $core_or_msdoscompat = 0;
214
    if ((array_search($pkgnam, $core_packages_list) !== false)
219
    if (array_search($pkgnam, $core_packages_list) !== false) {
-
 
220
      $catlist[] = 'core';
-
 
221
      $core_or_msdoscompat = 1;
-
 
222
    }
215
       || (array_search($pkgnam, $msdos_compat_list) !== false)) {
223
    if (array_search($pkgnam, $msdos_compat_list) !== false) {
-
 
224
      $catlist[] = 'msdos_compat';
-
 
225
      $core_or_msdoscompat = 1;
-
 
226
    }
-
 
227
    if ($core_or_msdoscompat == 1) {
216
      if (str_head_is($f, 'bin/')) continue;
228
      if (str_head_is($f, 'bin/')) continue;
217
      if (str_head_is($f, 'cpi/')) continue;
229
      if (str_head_is($f, 'cpi/')) continue;
218
      if (str_head_is($f, "doc/{$pkgdir}/")) continue;
230
      if (str_head_is($f, "doc/{$pkgdir}/")) continue;
219
      if ($f === 'doc/') continue;
231
      if ($f === 'doc/') continue;
220
      if (str_head_is($f, "nls/{$pkgdir}.")) continue;
232
      if (str_head_is($f, "nls/{$pkgdir}.")) continue;
221
      if ($f === 'nls/') continue;
233
      if ($f === 'nls/') continue;
222
    }
234
    }
223
    // the help package is allowed to put files in... help
235
    // the help package is allowed to put files in... help
224
    if (($pkgnam == 'help') && (str_head_is($f, 'help/'))) continue;
236
    if (($pkgnam == 'help') && (str_head_is($f, 'help/'))) continue;
-
 
237
    // must be category-prefixed file, add it to the list of categories for this package
-
 
238
    $catlist[] = explode('/', $f)[0];
225
    // well-known "category" dirs are okay
239
    // well-known "category" dirs are okay
226
    if (str_head_is($f, "progs/{$pkgdir}/")) continue;
240
    if (str_head_is($f, "progs/{$pkgdir}/")) continue;
227
    if ($f === 'progs/') continue;
241
    if ($f === 'progs/') continue;
228
    if (str_head_is($f, "devel/{$pkgdir}/")) continue;
242
    if (str_head_is($f, "devel/{$pkgdir}/")) continue;
229
    if ($f === 'devel/') continue;
243
    if ($f === 'devel/') continue;
Line 234... Line 248...
234
    echo "WARNING: {$fname} contains a file in an illegal location: {$f}\n";
248
    echo "WARNING: {$fname} contains a file in an illegal location: {$f}\n";
235
  }
249
  }
236
 
250
 
237
  $meta['fname'] = $fname;
251
  $meta['fname'] = $fname;
238
  $meta['desc'] = $lsmarray['description'];
252
  $meta['desc'] = $lsmarray['description'];
-
 
253
  $meta['cats'] = array_unique($catlist);
239
 
254
 
240
  $pkgdb[$pkgnam][$lsmarray['version']] = $meta;
255
  $pkgdb[$pkgnam][$lsmarray['version']] = $meta;
241
}
256
}
242
 
257
 
243
 
258
 
244
$db = array();
259
$db = array();
-
 
260
$cats = array();
-
 
261
 
-
 
262
// ******** compute the version-sorted list of packages with a single *********
-
 
263
// ******** description and category list for each package ********************
245
 
264
 
246
// iterate over each svp package
265
// iterate over each svp package
247
foreach ($pkgdb as $pkg => $versions) {
266
foreach ($pkgdb as $pkg => $versions) {
248
 
267
 
249
  // sort filenames by version, highest first
268
  // sort filenames by version, highest first
Line 258... Line 277...
258
 
277
 
259
    $meta2['ver'] = strval($ver);
278
    $meta2['ver'] = strval($ver);
260
    $meta2['bsum'] = $bsum;
279
    $meta2['bsum'] = $bsum;
261
 
280
 
262
    if (empty($db[$pkg]['desc'])) $db[$pkg]['desc'] = $desc;
281
    if (empty($db[$pkg]['desc'])) $db[$pkg]['desc'] = $desc;
-
 
282
    if (empty($db[$pkg]['cats'])) {
-
 
283
      $db[$pkg]['cats'] = $meta['cats'];
-
 
284
      $cats = array_unique(array_merge($cats, $meta['cats']));
-
 
285
    }
263
    $db[$pkg]['versions'][$fname] = $meta2;
286
    $db[$pkg]['versions'][$fname] = $meta2;
264
  }
287
  }
265
 
288
 
266
  $pkgcount++;
289
  $pkgcount++;
267
 
290
 
Line 290... Line 313...
290
      break;
313
      break;
291
  }
314
  }
292
  echo "\n";
315
  echo "\n";
293
}
316
}
294
 
317
 
295
file_put_contents($repodir . '/_index.json', json_encode($db));
318
file_put_contents($repodir . '/_index.json', $json_blob);
-
 
319
 
-
 
320
$cats_json = json_encode($cats);
-
 
321
file_put_contents($repodir . '/_cats.json', $cats_json);
296
 
322
 
297
exit(0);
323
exit(0);
298
 
324
 
299
?>
325
?>