255 |
255 |
}
|
256 |
256 |
}
|
257 |
257 |
|
|
258 |
// Check if minimal file copy was specified.
|
|
259 |
// Not recommended if the system has files modified by any method other than gitsync.
|
|
260 |
if(in_array("--minimal", $argv) || (is_array($command_split) && in_array("--minimal", $command_split))) {
|
|
261 |
if(file_exists("/etc/version.gitsync"))
|
|
262 |
$old_revision = trim(file_get_contents("/etc/version.gitsync"));
|
|
263 |
else if(file_exists("/etc/version.lastcommit"))
|
|
264 |
$old_revision = trim(file_get_contents("/etc/version.lastcommit"));
|
|
265 |
$files_to_copy = strtr(shell_exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git diff --name-only " . escapeshellarg($old_revision)), "\n", " ");
|
|
266 |
} else
|
|
267 |
$files_to_copy = '--exclude .git .';
|
|
268 |
|
|
269 |
// Save new commit ID for later minimal file copies
|
|
270 |
exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git rev-parse -q --verify HEAD > /etc/version.gitsync");
|
|
271 |
|
258 |
272 |
exec("mkdir -p /tmp/lighttpd/cache/compress/");
|
259 |
273 |
|
260 |
274 |
// Nuke CVS and pfSense tarballs
|
... | ... | |
283 |
297 |
echo "===> Installing new files...\n";
|
284 |
298 |
|
285 |
299 |
if($g['platform'] == "pfSense")
|
286 |
|
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - --exclude .git . | (cd / ; tar -Uxpf -)";
|
|
300 |
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -Uxpf -)";
|
287 |
301 |
else
|
288 |
|
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - --exclude .git . | (cd / ; tar -xpf -) 2>/dev/null";
|
289 |
|
exec($command);
|
|
302 |
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -xpf -) 2>/dev/null";
|
|
303 |
if(!empty($files_to_copy))
|
|
304 |
exec($command);
|
|
305 |
else {
|
|
306 |
echo "Already up-to-date.\n";
|
|
307 |
$upgrading = true;
|
|
308 |
}
|
290 |
309 |
|
291 |
310 |
// Reset the repository to restore the deleted files
|
292 |
311 |
exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard >/dev/null 2>/dev/null");
|
gitsync: Add --minimal parameter that installs only the updated files.