diff options
author | Erik Fonnesbeck <efonnes@gmail.com> | 2012-09-17 07:47:01 -0600 |
---|---|---|
committer | Erik Fonnesbeck <efonnes@gmail.com> | 2012-09-17 07:47:01 -0600 |
commit | 147b2be1c255cb892e9de9e05abd2556d072fbce (patch) | |
tree | 6786cd6843f6400a9fab6eb0a883dc34c28f5f00 /etc/phpshellsessions/gitsync | |
parent | c578fb0fc6e768739013df8d7aa19f2616272f18 (diff) | |
download | pfsense-147b2be1c255cb892e9de9e05abd2556d072fbce.zip pfsense-147b2be1c255cb892e9de9e05abd2556d072fbce.tar.gz |
gitsync: Add --minimal parameter that installs only the updated files.
Diffstat (limited to 'etc/phpshellsessions/gitsync')
-rw-r--r-- | etc/phpshellsessions/gitsync | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index 67a671d..d9da7b3 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -255,6 +255,20 @@ foreach($merge_repos as $merge_repo) { } } +// Check if minimal file copy was specified. +// Not recommended if the system has files modified by any method other than gitsync. +if(in_array("--minimal", $argv) || (is_array($command_split) && in_array("--minimal", $command_split))) { + if(file_exists("/etc/version.gitsync")) + $old_revision = trim(file_get_contents("/etc/version.gitsync")); + else if(file_exists("/etc/version.lastcommit")) + $old_revision = trim(file_get_contents("/etc/version.lastcommit")); + $files_to_copy = strtr(shell_exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git diff --name-only " . escapeshellarg($old_revision)), "\n", " "); +} else + $files_to_copy = '--exclude .git .'; + +// Save new commit ID for later minimal file copies +exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git rev-parse -q --verify HEAD > /etc/version.gitsync"); + exec("mkdir -p /tmp/lighttpd/cache/compress/"); // Nuke CVS and pfSense tarballs @@ -283,10 +297,15 @@ exec("rm -f ${CODIR}/pfSenseGITREPO/pfSenseGITREPO/etc/syslog.conf 2>/dev/null") echo "===> Installing new files...\n"; if($g['platform'] == "pfSense") - $command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - --exclude .git . | (cd / ; tar -Uxpf -)"; + $command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -Uxpf -)"; else - $command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - --exclude .git . | (cd / ; tar -xpf -) 2>/dev/null"; -exec($command); + $command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -xpf -) 2>/dev/null"; +if(!empty($files_to_copy)) + exec($command); +else { + echo "Already up-to-date.\n"; + $upgrading = true; +} // Reset the repository to restore the deleted files exec("cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard >/dev/null 2>/dev/null"); |