OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 else: | 95 else: |
96 target = os.path.join(self.ctx.shell_dir, binary_name) | 96 target = os.path.join(self.ctx.shell_dir, binary_name) |
97 pubkeyfile = "../trusted/%s.pem" % pubkey_fingerprint | 97 pubkeyfile = "../trusted/%s.pem" % pubkey_fingerprint |
98 if not signatures.VerifySignature(target, binary["blob"], | 98 if not signatures.VerifySignature(target, binary["blob"], |
99 binary["sign"], pubkeyfile): | 99 binary["sign"], pubkeyfile): |
100 self._SendResponse("Signature verification failed") | 100 self._SendResponse("Signature verification failed") |
101 return False | 101 return False |
102 os.chmod(target, stat.S_IRWXU) | 102 os.chmod(target, stat.S_IRWXU) |
103 return True | 103 return True |
104 | 104 |
105 def _CheckoutRevision(self, base_revision): | 105 def _CheckoutRevision(self, base_svn_revision): |
| 106 get_hash_cmd = ( |
| 107 "git log -1 --format=%%H --remotes --grep='^git-svn-id:.*@%s'" % |
| 108 base_svn_revision) |
| 109 try: |
| 110 base_revision = subprocess.check_output(get_hash_cmd, shell=True) |
| 111 if not base_revision: raise ValueError |
| 112 except: |
| 113 self._Call("git fetch") |
| 114 try: |
| 115 base_revision = subprocess.check_output(get_hash_cmd, shell=True) |
| 116 if not base_revision: raise ValueError |
| 117 except: |
| 118 self._SendResponse("Base revision not found.") |
| 119 return False |
106 code = self._Call("git checkout -f %s" % base_revision) | 120 code = self._Call("git checkout -f %s" % base_revision) |
107 if code != 0: | 121 if code != 0: |
108 self._Call("git fetch") | |
109 code = self._Call("git checkout -f %s" % base_revision) | |
110 if code != 0: | |
111 self._SendResponse("Error trying to check out base revision.") | 122 self._SendResponse("Error trying to check out base revision.") |
112 return False | 123 return False |
113 code = self._Call("git clean -f -d") | 124 code = self._Call("git clean -f -d") |
114 if code != 0: | 125 if code != 0: |
115 self._SendResponse("Failed to reset checkout") | 126 self._SendResponse("Failed to reset checkout") |
116 return False | 127 return False |
117 return True | 128 return True |
118 | 129 |
119 def _ApplyPatch(self, patch): | 130 def _ApplyPatch(self, patch): |
120 patchfilename = "_dtest_incoming_patch.patch" | 131 patchfilename = "_dtest_incoming_patch.patch" |
121 with open(patchfilename, "w") as f: | 132 with open(patchfilename, "w") as f: |
122 f.write(patch) | 133 f.write(patch) |
123 code = self._Call("git apply %s" % patchfilename) | 134 code = self._Call("git apply %s" % patchfilename) |
124 if code != 0: | 135 if code != 0: |
125 self._SendResponse("Error applying patch.") | 136 self._SendResponse("Error applying patch.") |
126 return False | 137 return False |
127 return True | 138 return True |
128 | 139 |
129 def _Call(self, cmd): | 140 def _Call(self, cmd): |
130 return subprocess.call(cmd, shell=True) | 141 return subprocess.call(cmd, shell=True) |
131 | 142 |
132 | 143 |
133 class WorkSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): | 144 class WorkSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): |
134 def __init__(self, daemon): | 145 def __init__(self, daemon): |
135 address = (daemon.ip, constants.PEER_PORT) | 146 address = (daemon.ip, constants.PEER_PORT) |
136 SocketServer.TCPServer.__init__(self, address, WorkHandler) | 147 SocketServer.TCPServer.__init__(self, address, WorkHandler) |
137 self.job_lock = threading.Lock() | 148 self.job_lock = threading.Lock() |
138 self.daemon = daemon | 149 self.daemon = daemon |
OLD | NEW |