Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rebuild
blob: d2a9fb6f75d5965722cc001b68ddc1d54adf227f (plain)
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
#!/usr/bin/env python
# Copyright (C) 2008, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import shutil
import subprocess
import tempfile

target_repo = \
    'shell.sugarlabs.org:/upload/soas/repositories/1'

def fetch(packages):
    for pkg in packages:
        subprocess.check_call(['koji', 'download-build', '--arch=src',
                               '--latestfrom=dist-f11', pkg])

def mockbuild(repo_path):
    rpms = os.listdir('.')
    rpms.sort(lambda x,y: cmp(os.path.getmtime(x), os.path.getmtime(y)))

    for f in rpms:
        print 'Rebuilding %s...' % f
        subprocess.check_call(['mock', '--rebuild', '--resultdir',
                               repo_path, f])

        subprocess.check_call(['createrepo', repo_path])
        subprocess.check_call(['rsync', '-rv', '--delete',
                               repo_path + '/', target_repo])

def rebuild(packages):
    old_cwd = os.getcwd()

    path = tempfile.mkdtemp()
    os.chdir(path)

    repo_path = os.path.join(old_cwd, 'repo')
    if not os.path.exists(repo_path):
        os.mkdir(repo_path)

    try:
        fetch(packages)
        mockbuild(repo_path)
    finally:
        shutil.rmtree(path)
        os.chdir(old_cwd)

rebuild(['sugar-artwork', 'sugar-presence-service', 'sugar', 'sugar-datastore',
         'sugar-base', 'sugar-toolkit', 'dbus-glib', 'telepathy-glib',
         'telepathy-gabble'])