[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] auto updates
From: |
Brian May |
Subject: |
Re: [Monotone-devel] auto updates |
Date: |
Mon, 30 Oct 2006 16:26:45 +1100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux) |
>>>>> "Brian" == Brian May <address@hidden> writes:
Brian> I will think more about this tomorrow.
Possibly more complicated then I first imagined, but this seems to
work. The note_netsync_end probably would be better if it got its
values from a config file.
launchpad:/etc/monotone# cat hooks.lua
-- This hook reads the 'passphrases' file from the confdir. It expects the
-- file to be formatted as follows:
--
-- address@hidden "passphrase here"
--
-- One entry per line. The quotes are required.
--
-- Note: Because the file contains passphrases it should only be readable by
-- select users.
function get_passphrase (keypair_id)
local permfile = io.open(get_confdir() .. "/passphrases", "r")
if (permfile == nil) then return false end
local line = permfile:read()
while (line ~= nil) do
local _, _, key, passphrase = string.find(line,
"%s*([^%s]*)%s*\"(.*)\"%s*")
if keypair_id == key then return passphrase end
line = permfile:read()
end
io.close(permfile)
return false
end
netsync_branches = {}
function note_netsync_start(nonce)
netsync_branches[nonce] = {}
end
function _note_netsync_cert_received(rev_id,key,name,value,nonce)
if name == "branch" then
if netsync_branches[nonce][value] == nil then
netsync_branches[nonce][value] = 1
else
netsync_branches[nonce][value] = netsync_branches[nonce][value] + 1
end
end
end
function note_netsync_revision_received(new_id,revision,certs,nonce)
for _, item in pairs(certs)
do
_note_netsync_cert_received(new_id,item.key,item.name,item.value,nonce)
end
end
function note_netsync_cert_received(rev_id,key,name,value,nonce)
_note_netsync_cert_received(rev_id,key,name,value,nonce)
end
function note_netsync_end(nonce)
for item, amount in pairs(netsync_branches[nonce])
do
if item == "brian.test" then
io.stderr:write("\nUpdating workspace for ",item,"...\n")
rc=execute("daemon",
"--pidfile=/var/log/monotone/test.pid",
"--output=/var/log/monotone/test.log",
"--",
"/etc/monotone/update",
"launchpad.microcomaustralia.com.au:4691",
"/var/lib/monotone/test.db",
"/home/monotone",
item)
io.stderr:write("...done (",rc,")\n")
end
end
netsync_branches[nonce] = nil
end
launchpad:/etc/monotone# cat update
#!/bin/sh -ex
if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ]
then
echo "Incorrect parameters: " >&2
echo "update <source> <pulldb> <workdir> <branch>" >&2
exit 1
fi
SOURCE="$1"
PULLDB="$2"
WORKDIR="$3"
BRANCH="$4"
mtn pull --db="$PULLDB" "$SOURCE" "$BRANCH"
cd "$WORKDIR"
heads=`mtn --db="$PULLDB" automate heads "$BRANCH" | wc --lines`
if [ "$heads" -gt 1 ]
then
echo "Too many heads" >&2
exit 0
fi
diff=`mtn diff | wc --lines`
if [ "$diff" -gt 3 ]
then
echo "Local changes made" >&2
exit 0
fi
mtn --db="$PULLDB" update --branch="$BRANCH"
--
Brian May <address@hidden>
- Re: [Monotone-devel] auto updates, (continued)
- Re: [Monotone-devel] auto updates, Timothy Brownawell, 2006/10/29
- Re: [Monotone-devel] auto updates, Nathaniel Smith, 2006/10/29
- Re: [Monotone-devel] auto updates, Zack Weinberg, 2006/10/29
- Re: [Monotone-devel] auto updates, Nuno Lucas, 2006/10/29
- Re: [Monotone-devel] auto updates, Nathaniel Smith, 2006/10/29
- Re: [Monotone-devel] auto updates, Zack Weinberg, 2006/10/29
- Re: [Monotone-devel] auto updates, Nuno Lucas, 2006/10/29
- offtopic: POSIX signals (was Re: [Monotone-devel] auto updates), Nathaniel Smith, 2006/10/29
- Re: [Monotone-devel] auto updates, Nathaniel Smith, 2006/10/29
- Re: [Monotone-devel] auto updates, Brian May, 2006/10/29
- Re: [Monotone-devel] auto updates,
Brian May <=