summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErik Fonnesbeck <efonnes@gmail.com>2012-09-17 07:47:01 -0600
committerErik Fonnesbeck <efonnes@gmail.com>2012-09-17 07:47:01 -0600
commit147b2be1c255cb892e9de9e05abd2556d072fbce (patch)
tree6786cd6843f6400a9fab6eb0a883dc34c28f5f00 /etc
parentc578fb0fc6e768739013df8d7aa19f2616272f18 (diff)
downloadpfsense-147b2be1c255cb892e9de9e05abd2556d072fbce.zip
pfsense-147b2be1c255cb892e9de9e05abd2556d072fbce.tar.gz
gitsync: Add --minimal parameter that installs only the updated files.
Diffstat (limited to 'etc')
-rw-r--r--etc/phpshellsessions/gitsync25
-rwxr-xr-xetc/rc.firmware3
2 files changed, 25 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");
diff --git a/etc/rc.firmware b/etc/rc.firmware
index 54a115c..7af6b6a 100755
--- a/etc/rc.firmware
+++ b/etc/rc.firmware
@@ -467,6 +467,9 @@ pfSenseupgrade)
sh /etc/init_bootloader.sh >> /conf/upgrade_log.txt 2>&1
fi
+ # Remove saved commit ID for gitsync
+ rm -f /etc/version.gitsync
+
# If /tmp/post_upgrade_command exists after update
# then execute the command.
if [ -f /tmp/post_upgrade_command ]; then
OpenPOWER on IntegriCloud