Project:
func
Code Location:
git://git.fedorahosted.org/func.gitmaster
Outline
- > M croak(msg)
pusher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/python """ Michael DeHaan <mdehaan@fedoraproject.org>, 2008 This software may be freely redistributed under the terms of the GNU general public license. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --- This script automates pushes from git checkouts into Fedora CVS. It is expected you already have Fedora CVS set up for a project and have the build system tools installed. After that, usage looks like: python pusher.py --proj=/cg/func --cvs=~/func Work in progress """ # if new releases come out or old ones go away, edit here #PROCESS_RELEASES = [ "devel", "F-9", "F-8", "EL-5", "EL-4" ] PROCESS_RELEASES = [ "devel" ] import optparse import os import sys import glob import subprocess def run(cmd,failok=False): """ Wrapper around subprocess """ print "running: %s" % cmd rc = subprocess.call(cmd, shell=True) print "rc: %s" % rc if not failok and not rc == 0: croak("aborting") def croak(msg): """ Print something and die. """ print msg sys.exit(1) # process options, as described at the top of this file p = optparse.OptionParser(usage="pusher [ARGS]") p.add_option("--cvs", dest="cvs", help="EX: ~/cvs/func") p.add_option("--proj", dest="proj", help="EX: /cg/func") (options,args) = p.parse_args() if options.cvs is None: croak("--cvs is required, PEBKAC") if options.proj is None: croak("--proj is required, PEBKAC") cvsdir = os.path.expanduser(options.cvs) projdir = os.path.expanduser(options.proj) print "----------------------------------------------" print "Running Michael's totally awesome code pusher script" print "----------------------------------------------" print "assuming you first ran something like..." print " ssh-agent bash" print " ssh-agent ~/.ssh/id_dsa" print "if not, expect pain and it's not my fault" print "----------------------------------------------" print " " print "ok, here we go..." print " " # find the RPM build directory rpmbuild = os.path.join(projdir, "rpm-build") if not os.path.exists(rpmbuild): croak("no directory: %s" % rpmbuild) print "found rpm-build directory" # find the tarballs tarsearch = "%s/*.tar.gz" % rpmbuild tars = glob.glob(tarsearch) if len(tars) != 1: croak("expected to find just one tar.gz in %s, no luck") % rpmbuild tarfile = tars[0] print "found tarball: %s" % tarfile # find a version file, if any versionfile = None #versearch = os.path.join(projdir,"version") #if os.path.exists(versearch): # print "found a version file: %s" % versearch # versionfile = versearch #print "found version file: %s" % versionfile # find a specfile specsearch = "%s/*.spec" % projdir specs = glob.glob(specsearch) if len(specs) != 1: croak("need one and only one specfile in %s" % projdir) specfile = specs[0] print "found specfile: %s" % specfile # verify cvsdir exists if not os.path.exists(cvsdir): croak("can't find cvs directory: %s" % cvsdir) # store current directory topdir = os.getcwd() # do cvs update os.chdir(cvsdir) run("cvs update -d") os.chdir(topdir) # copy specfile and version file into CVS # plus upload tarball # and then commit for x in PROCESS_RELEASES: releasedir = os.path.join(cvsdir, x) rc = run("cp %s %s" % (specfile, releasedir)) if versionfile: rc = run("cp %s %s" % (versionfile, releasedir)) print "cd into %s" % releasedir os.chdir(releasedir) rc = run("make upload FILES=%s" % tarfile) os.chdir(cvsdir) run("cvs commit") # go back through each CVS directory and build stuff for x in PROCESS_RELEASES: releasedir = os.path.join(cvsdir, x) print "cd into %s" % releasedir os.chdir(releasedir) rc = run("make tag") rc = run("BUILD_FLAGS=\"--nowait\" make build",failok=True) print "---------------------------------------------" print "all done, assuming you didn't see anything weird" print "don't forget to visit https://admin.fedoraproject.org/updates" print " "
