1#!/usr/bin/python
2
3# Little script to grab a patch, compile it, and make it.
4
5# Copyright (C) 2008 Thomas Thurman
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, see <http://www.gnu.org/licenses/>.
19
20
21import os
22import sys
23import posixpath
24
25# FIXME: What would be lovely is an Epiphany extension to call this from Bugzilla pages
26
27# FIXME: Should be possible (but currently isn't) to get this from the patch number
28program = 'metacity'
29
30if len(sys.argv)<2:
31  print 'Specify patch number'
32  sys.exit(255)
33
34patchnum = sys.argv[1]
35
36patchdir = posixpath.expanduser('~/patch/%s/%s' % (program, patchnum))
37
38os.makedirs(patchdir)
39os.chdir(patchdir)
40
41if os.system("svn co svn+ssh://svn.gnome.org/svn/%s/trunk ." % (program))!=0:
42  print "Checkout failed."
43  sys.exit(255)
44
45if os.system("wget http://bugzilla.gnome.org/attachment.cgi?id=%s -O - -q|patch -p 0" % (patchnum))!=0:
46  print "Patch failed."
47  sys.exit(255)
48
49if os.system("./autogen.sh")!=0:
50  print "Autogen failed."
51  sys.exit(255)
52
53if os.system("make")!=0:
54  print "Make failed."
55  sys.exit(255)
56
57print
58print "It all seems to have worked. Don't look so surprised."
59print "Dropping you into a new shell now so you're in the right"
60print "directory; this does mean you'll have to exit twice when"
61print "you're finished."
62print
63
64shell = '/bin/sh'
65if os.environ.has_key('SHELL'):
66  shell = os.environ['SHELL']
67
68if os.system(shell):
69  print "Couldn't launch the shell, though."
70  sys.exit(255)
71