Subversion Repositories SvarDOS

Rev

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

Rev 650 Rev 673
Line 2... Line 2...
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-2022
5
 
5
 
6
  buildidx computes an index tsv file for the SvarDOS repository.
6
  buildidx computes an index tsv file for the SvarDOS repository.
7
  it must be executed pointing to a directory that stores packages (zip)
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
  14 feb 2022: packages are expected to have the *.svp extension
13
  12 feb 2022: skip source packages from being processed (*.src.zip)
14
  12 feb 2022: skip source packages from being processed (*.src.zip)
14
  20 jan 2022: rewritten the code from ANSI C to PHP for easier maintenance
15
  20 jan 2022: rewritten the code from ANSI C to PHP for easier maintenance
15
  13 feb 2021: 'title' LSM field is no longer looked after
16
  13 feb 2021: 'title' LSM field is no longer looked after
16
  11 feb 2021: lsm headers are no longer checked, so it is compatible with the simpler lsm format used by SvarDOS
17
  11 feb 2021: lsm headers are no longer checked, so it is compatible with the simpler lsm format used by SvarDOS
17
  13 jan 2021: removed the identification line, changed CRC32 to bsum, not creating the listing.txt file and stopped compressing index
18
  13 jan 2021: removed the identification line, changed CRC32 to bsum, not creating the listing.txt file and stopped compressing index
Line 26... Line 27...
26
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
27
  10 jul 2013: changed unzip calls to 7za (to handle cases when appinfo is compressed with lzma)
27
  04 feb 2013: added CRC32 support
28
  04 feb 2013: added CRC32 support
28
  22 sep 2012: forked 1st version from FDUPDATE builder
29
  22 sep 2012: forked 1st version from FDUPDATE builder
29
*/
30
*/
30
 
31
 
31
$PVER = "20220120";
32
$PVER = "20220214";
32
 
33
 
33
 
34
 
34
// computes the BSD sum of a file and returns it
35
// computes the BSD sum of a file and returns it
35
function file2bsum($fname) {
36
function file2bsum($fname) {
36
  $result = 0;
37
  $result = 0;
Line 103... Line 104...
103
 
104
 
104
$pkgfiles = scandir($repodir);
105
$pkgfiles = scandir($repodir);
105
$pkglist = '';
106
$pkglist = '';
106
$pkgcount = 0;
107
$pkgcount = 0;
107
 
108
 
108
// iterate over each zip file
109
// iterate over each svp package
109
foreach ($pkgfiles as $zipfile) {
110
foreach ($pkgfiles as $zipfile) {
110
  if (!preg_match('/.zip$/i', $zipfile)) continue; // skip non-zip files
111
  if (!preg_match('/.svp$/i', $zipfile)) continue; // skip non-svp files
111
  if (strchr($zipfile, '-')) {
112
  if (strchr($zipfile, '-')) {
112
    echo "skipping: {$zipfile}\n";
113
    echo "skipping: {$zipfile}\n";
113
    continue; // skip alt vers (like dosmid-0.9.2.zip)
114
    continue; // skip alt vers (like dosmid-0.9.2.svp)
114
  }
115
  }
115
  if (strstr($zipfile, '.src.zip')) {
-
 
116
    echo "skipping source: {$zipfile}\n";
-
 
117
    continue;
-
 
118
  }
-
 
119
 
-
 
120
 
116
 
121
  $path_parts = pathinfo($zipfile);
117
  $path_parts = pathinfo($zipfile);
122
  $pkg = strtolower($path_parts['filename']);
118
  $pkg = strtolower($path_parts['filename']);
123
 
119
 
124
  $zipfile_fullpath = realpath($repodir . '/' . $zipfile);
120
  $zipfile_fullpath = realpath($repodir . '/' . $zipfile);
Line 143... Line 139...
143
  $pkglist .= "{$pkg}\t{$lsmarray['version']}\t{$lsmarray['description']}\t" . file2bsum($zipfile_fullpath) . "\n";
139
  $pkglist .= "{$pkg}\t{$lsmarray['version']}\t{$lsmarray['description']}\t" . file2bsum($zipfile_fullpath) . "\n";
144
  $pkgcount++;
140
  $pkgcount++;
145
 
141
 
146
}
142
}
147
 
143
 
148
echo "DONE - processed " . $pkgcount . " zip files\n";
144
echo "DONE - processed " . $pkgcount . " svp packages\n";
149
 
145
 
150
file_put_contents($repodir . '/index.tsv', $pkglist);
146
file_put_contents($repodir . '/index.tsv', $pkglist);
151
 
147
 
152
exit(0);
148
exit(0);
153
 
149