Subversion Repositories SvarDOS

Rev

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

Rev 1037 Rev 1267
Line 1... Line 1...
1
<?php /*
1
<?php /*
2
 
2
 
3
  SvarDOS repo index builder
3
  SvarDOS repo index builder
4
  Copyright (C) Mateusz Viste 2012-2022
4
  Copyright (C) Mateusz Viste 2012-2023
5
 
5
 
6
  buildidx computes an index json file for the SvarDOS repository.
6
  buildidx computes an index json file for the SvarDOS repository.
7
  it must be executed pointing to a directory that stores packages (*.svp)
7
  it must be executed pointing to a directory that stores packages (*.svp)
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
  30 jun 2023: adapted for new CORE packages location (../packages-core)
13
  28 feb 2022: svarcom allowed to have a COMMAND.COM file without subdirectory
14
  28 feb 2022: svarcom allowed to have a COMMAND.COM file without subdirectory
14
  24 feb 2022: added hardcoded hack to translate version 'x.xx' to '0.44' (NESticle)
15
  24 feb 2022: added hardcoded hack to translate version 'x.xx' to '0.44' (NESticle)
15
  23 feb 2022: basic validation of source archives (not empty + matches an existing svp file)
16
  23 feb 2022: basic validation of source archives (not empty + matches an existing svp file)
16
  21 feb 2022: buildidx collects categories looking at the dir layout of each package + improved version string parsing (replaced version_compare call by dos_version_compare)
17
  21 feb 2022: buildidx collects categories looking at the dir layout of each package + improved version string parsing (replaced version_compare call by dos_version_compare)
17
  17 feb 2022: checking for non-8+3 filenames in packages and duplicates + devload no longer part of CORE
18
  17 feb 2022: checking for non-8+3 filenames in packages and duplicates + devload no longer part of CORE
Line 34... Line 35...
34
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
35
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
35
  04 feb 2013: added CRC32 support
36
  04 feb 2013: added CRC32 support
36
  22 sep 2012: forked 1st version from FDUPDATE builder
37
  22 sep 2012: forked 1st version from FDUPDATE builder
37
*/
38
*/
38
 
39
 
39
$PVER = "20220228";
40
$PVER = "20230630";
40
 
41
 
41
 
42
 
42
// computes the BSD sum of a file and returns it
43
// computes the BSD sum of a file and returns it
43
function file2bsum($fname) {
44
function file2bsum($fname) {
44
  $result = 0;
45
  $result = 0;
Line 256... Line 257...
256
  return strpos($haystack, $needle) === 0;
257
  return strpos($haystack, $needle) === 0;
257
}
258
}
258
 
259
 
259
 
260
 
260
// returns an array that contains CORE packages (populated from the core subdirectory in pkgdir)
261
// returns an array that contains CORE packages (populated from the core subdirectory in pkgdir)
261
function load_core_list($repodir) {
262
function load_core_list($repodir_core) {
262
  $res = array();
263
  $res = array();
263
 
264
 
264
  foreach (scandir($repodir . '/core/') as $f) {
265
  foreach (scandir($repodir_core) as $f) {
265
    if (!preg_match('/\.svp$/', $f)) continue;
266
    if (!preg_match('/\.svp$/', $f)) continue;
266
    $res[] = explode('.', $f)[0];
267
    $res[] = explode('.', $f)[0];
267
  }
268
  }
268
  return($res);
269
  return($res);
269
}
270
}
Line 284... Line 285...
284
$pkgcount = 0;
285
$pkgcount = 0;
285
 
286
 
286
 
287
 
287
// load the list of CORE and MSDOS_COMPAT packages
288
// load the list of CORE and MSDOS_COMPAT packages
288
 
289
 
289
$core_packages_list = load_core_list($repodir);
290
$core_packages_list = load_core_list($repodir . '/../packages-core/');
290
$msdos_compat_list = explode(' ', 'append assign attrib callver chkdsk choice comp cpidos debug defrag deltree diskcomp diskcopy display edit edlin exe2bin fc fdapm fdisk find format help himemx kernel keyb label localcfg mem mirror mode more move nlsfunc print replace share shsucdx sort svarcom swsubst tree undelete unformat xcopy');
291
$msdos_compat_list = explode(' ', 'append assign attrib callver chkdsk choice comp cpidos debug defrag deltree diskcomp diskcopy display edit edlin exe2bin fc fdapm fdisk find format help himemx kernel keyb label localcfg mem mirror mode more move nlsfunc print replace share shsucdx sort svarcom swsubst tree undelete unformat xcopy');
291
 
292
 
292
// do a list of all svp packages with their available versions and descriptions
293
// do a list of all svp packages with their available versions and descriptions
293
 
294
 
294
$pkgdb = array();
295
$pkgdb = array();
Line 305... Line 306...
305
    continue;
306
    continue;
306
  }
307
  }
307
 
308
 
308
  // skip (and warn about) non-svp
309
  // skip (and warn about) non-svp
309
  if (!preg_match('/\.svp$/', $fname)) {
310
  if (!preg_match('/\.svp$/', $fname)) {
310
    $okfiles = array('.', '..', '_cats.json', '_index.json', '_buildidx.log', 'core');
311
    $okfiles = array('.', '..', '_cats.json', '_index.json', '_buildidx.log');
311
    if (array_search($fname, $okfiles) !== false) continue;
312
    if (array_search($fname, $okfiles) !== false) continue;
312
    echo "WARNING: wild file '{$fname} (this is either an useless file that should be removed, or a misnamed package or source archive)'\n";
313
    echo "WARNING: wild file '{$fname} (this is either an useless file that should be removed, or a misnamed package or source archive)'\n";
313
    continue;
314
    continue;
314
  }
315
  }
315
 
316