Rev 535 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
557 | daniel-mar | 1 | #!/usr/bin/env php |
533 | daniel-mar | 2 | <?php |
3 | |||
4 | /* |
||
5 | * OIDplus 2.0 |
||
6 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
||
7 | * |
||
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
9 | * you may not use this file except in compliance with the License. |
||
10 | * You may obtain a copy of the License at |
||
11 | * |
||
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
13 | * |
||
14 | * Unless required by applicable law or agreed to in writing, software |
||
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
17 | * See the License for the specific language governing permissions and |
||
18 | * limitations under the License. |
||
19 | */ |
||
20 | |||
21 | // This script will be called at the ViaThinkSoft server side |
||
22 | |||
23 | $argc = $_SERVER['argc']; // to please Eclipse for PHP |
||
24 | $argv = $_SERVER['argv']; // to please Eclipse for PHP |
||
25 | |||
535 | daniel-mar | 26 | if (PHP_SAPI != 'cli') { |
27 | die("This file can only be invoked in CLI mode.\n"); |
||
28 | } |
||
29 | |||
533 | daniel-mar | 30 | if ($argc != 2) { |
31 | echo "Usage: ".$argv[0]." <targetpath>\n"; |
||
32 | exit(2); |
||
33 | } |
||
34 | |||
35 | $output_dir = $argv[1]; |
||
36 | |||
37 | if (!is_dir($output_dir)) { |
||
38 | echo "Path $output_dir does not exist!\n"; |
||
39 | exit(1); |
||
40 | } |
||
41 | |||
42 | function getDirContents($dir, $basepath = null, &$results = array()) { |
||
43 | if (is_null($basepath)) $basepath = $dir; |
||
44 | $basepath = realpath($basepath) . DIRECTORY_SEPARATOR; |
||
45 | $dir = realpath($dir) . DIRECTORY_SEPARATOR; |
||
46 | $files = scandir($dir); |
||
47 | foreach ($files as $file) { |
||
48 | $path = realpath($dir . DIRECTORY_SEPARATOR . $file); |
||
49 | if (!is_dir($path)) { |
||
50 | $xpath = substr($path, strlen($basepath)); |
||
51 | $xpath = str_replace('\\', '/', $xpath); |
||
52 | $results[] = hash_file('sha256', $path)."\t".$xpath; |
||
53 | } else if ($file != "." && $file != ".." && $file != ".svn" && $file != ".git") { |
||
54 | getDirContents($path, $basepath, $results); |
||
55 | $xpath = substr($path, strlen($basepath)); |
||
56 | $xpath = str_replace('\\', '/', $xpath); |
||
57 | $results[] = hash('sha256', '')."\t".$xpath; |
||
58 | } |
||
59 | } |
||
60 | return $results; |
||
61 | } |
||
62 | |||
63 | $out = array(); |
||
64 | $ec = -1; |
||
65 | exec('svn info https://svn.viathinksoft.com/svn/oidplus/ | grep "Revision:" | cut -d " " -f 2', $out, $ec); |
||
66 | $max_svn = implode("", $out); |
||
67 | |||
68 | for ($i=1; $i<=$max_svn; $i++) { |
||
69 | echo "SVN revision $i / $max_svn\r"; |
||
70 | $outdir = "/tmp/oidplus_svntmp_$i/"; |
||
71 | $outfile = "$output_dir/svn-rev$i.txt"; |
||
72 | if (is_dir($outdir)) { |
||
73 | exec("rm -rf $outdir", $out, $ec); |
||
74 | } |
||
75 | if (!file_exists($outfile)) { |
||
76 | exec("svn co https://svn.viathinksoft.com/svn/oidplus/@$i $outdir", $out, $ec); |
||
77 | if ($ec != 0) continue; |
||
78 | $ary = getDirContents($outdir, $outdir); |
||
79 | exec("rm -rf $outdir", $out, $ec); |
||
80 | if ($ec != 0) continue; |
||
81 | $ary = implode("\n", $ary)."\n"; |
||
82 | file_put_contents($outfile, $ary); |
||
83 | } |
||
84 | } |
||
85 | echo "\n"; |