Subversion Repositories oidplus

Rev

Rev 1426 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1426 Rev 1427
Line 74... Line 74...
74
// It's no secret, so other users can read it. They must not write to it, though.
74
// It's no secret, so other users can read it. They must not write to it, though.
75
 
75
 
76
foreach (['a','b'] as $ab) {
76
foreach (['a','b'] as $ab) {
77
	$tmpdir = '/tmp/oidplus_git_'.$ab;
77
	$tmpdir = '/tmp/oidplus_git_'.$ab;
78
	if (!is_dir($tmpdir)) {
78
	if (!is_dir($tmpdir)) {
79
		exec('git clone '.escapeshellarg(OIDplus::getEditionInfo()['gitrepo']).' '.escapeshellarg($tmpdir), $out, $ec);
79
		exec('git clone '.escapeshellarg(OIDplus::getEditionInfo()['gitrepo']).' '.escapeshellarg($tmpdir).' --quiet', $out, $ec);
80
		if ($ec != 0) {
80
		if ($ec != 0) {
81
			fwrite(STDERR, "GIT Clone failed\n");
81
			fwrite(STDERR, "GIT Clone failed\n");
82
			exit(1);
82
			exit(1);
83
		}
83
		}
84
	}
84
	}
85
	exec('cd '.escapeshellarg($tmpdir).' && git reset --hard && git checkout master && git pull', $out, $ec);
85
	exec('cd '.escapeshellarg($tmpdir).' && git reset --hard --quiet && git checkout master --quiet && git pull --quiet', $out, $ec);
86
	if ($ec != 0) {
86
	if ($ec != 0) {
87
		fwrite(STDERR, "GIT Pull failed\n");
87
		fwrite(STDERR, "GIT Pull failed\n");
88
		exit(1);
88
		exit(1);
89
	}
89
	}
90
}
90
}
91
 
91
 
92
// Step 1: List all GIT commits and determine its OIDplus versions
92
// Step 1: List all GIT commits and determine its OIDplus versions
93
 
93
 
94
git_version_cache_file = OIDplus::localpath() . 'userdata/cache/git_version_cache.json';
94
$git_version_cache_file = OIDplus::localpath() . 'userdata/cache/git_version_cache.json';
95
$git_version_cache = file_exists($git_version_cache_file) ? json_decode(file_get_contents($git_version_cache_file),true) : ["git-to-ver"=>[],"version-first-commit"=>[]];
95
$git_version_cache = file_exists($git_version_cache_file) ? json_decode(file_get_contents($git_version_cache_file),true) : ["git-to-ver"=>[],"version-first-commit"=>[]];
96
 
96
 
97
$ec = -1;
97
$ec = -1;
98
$out = array();
98
$out = array();
99
exec('cd /tmp/oidplus_git_a && git reset --hard && git checkout master && git log --reverse', $out, $ec);
99
exec('cd /tmp/oidplus_git_a && git reset --hard --quiet && git checkout master --quiet && git log --reverse --quiet', $out, $ec);
100
if ($ec != 0) {
100
if ($ec != 0) {
101
	fwrite(STDERR, "GIT Log failed\n");
101
	fwrite(STDERR, "GIT Log failed\n");
102
	exit(1);
102
	exit(1);
103
} else {
103
} else {
104
	$cont = implode("\n", $out);
104
	$cont = implode("\n", $out);
Line 140... Line 140...
140
// The order of $git_version_cache is very critical here!
140
// The order of $git_version_cache is very critical here!
141
 
141
 
142
$prev_commit = '-';
142
$prev_commit = '-';
143
$prev_version = '2.0.0.0';
143
$prev_version = '2.0.0.0';
144
foreach ($git_version_cache["version-first-commit"] as $version => $version_first_commit) {
144
foreach ($git_version_cache["version-first-commit"] as $version => $version_first_commit) {
145
	$changescript_file = $output_dir.'/output/changescript_'.$version.'.txt';
145
	$changescript_file = $output_dir.'/changescript_'.$version.'.txt';
146
	if ($force || !file_exists($changescript_file) || !file_exists($changescript_file.'.gz')) {
146
	if ($force || !file_exists($changescript_file) || !file_exists($changescript_file.'.gz')) {
147
		#echo "$version = $prev_commit ... $version_first_commit => $changescript_file\n";
147
		echo "Generate changescript for version $version ($version_first_commit)\n";
148
 
148
 
149
		if ($prev_commit == '-') {
149
		if ($prev_commit == '-') {
150
			$old_dir = '/tmp/oidplus_git_empty';
150
			$old_dir = '/tmp/oidplus_git_empty';
151
			if (!is_dir($old_dir)) mkdir($old_dir);
151
			if (!is_dir($old_dir)) mkdir($old_dir);
152
		} else {
152
		} else {
153
			$old_dir = '/tmp/oidplus_git_a';
153
			$old_dir = '/tmp/oidplus_git_a';
154
			exec('cd '.escapeshellarg($old_dir).' && git reset --hard && git checkout '.escapeshellarg($prev_commit).' >/dev/null 2>&1', $out, $ec);
154
			exec('cd '.escapeshellarg($old_dir).' && git reset --hard --quiet && git checkout '.escapeshellarg($prev_commit).' --quiet >/dev/null 2>&1', $out, $ec);
155
			if ($ec != 0) {
155
			if ($ec != 0) {
156
				fwrite(STDERR, "GIT Checkout $prev_commit failed\n");
156
				fwrite(STDERR, "GIT Checkout $prev_commit failed\n");
157
				exit(1);
157
				exit(1);
158
			}
158
			}
159
			hotfix_dir($prev_version, $old_dir);
159
			hotfix_dir($prev_version, $old_dir);
160
		}
160
		}
161
 
161
 
162
		$new_dir = '/tmp/oidplus_git_b';
162
		$new_dir = '/tmp/oidplus_git_b';
163
		exec('cd '.escapeshellarg($new_dir).' && git reset --hard && git checkout '.escapeshellarg($version_first_commit).' >/dev/null 2>&1', $out, $ec);
163
		exec('cd '.escapeshellarg($new_dir).' && git reset --hard --quiet && git checkout '.escapeshellarg($version_first_commit).' --quiet >/dev/null 2>&1', $out, $ec);
164
		if ($ec != 0) {
164
		if ($ec != 0) {
165
			fwrite(STDERR, "GIT Checkout $version_first_commit failed\n");
165
			fwrite(STDERR, "GIT Checkout $version_first_commit failed\n");
166
			exit(1);
166
			exit(1);
167
		}
167
		}
168
		hotfix_dir($version, $new_dir);
168
		hotfix_dir($version, $new_dir);