aboutsummaryrefslogtreecommitdiff
blob: 3bddf67f8352e3aa49f4444aabbb195586015ffa (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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
    tinderbox.py
    ~~~~~~~~~~~~
    
    a simple script that tries to build all the packages in the package
    database and report possible build errors.
    
    :copyright: (c) 2010 by Rafael Goncalves Martins
    :license: GPL-2, see LICENSE for more details.
"""

import sys
import os

# This block ensures that ^C interrupts are handled quietly.
# Code snippet from Portage
try:
    import signal

    def exithandler(signum,frame):
        signal.signal(signal.SIGINT, signal.SIG_IGN)
        signal.signal(signal.SIGTERM, signal.SIG_IGN)
        sys.exit(1)

    signal.signal(signal.SIGINT, exithandler)
    signal.signal(signal.SIGTERM, exithandler)

except KeyboardInterrupt:
    sys.exit(1)

current_dir = os.path.dirname(os.path.realpath(__file__))
if os.path.exists(os.path.join(current_dir, '..', 'g_octave')):
    sys.path.insert(0, os.path.join(current_dir, '..'))

import subprocess

from g_octave import config, description_tree, ebuild, fetch, overlay

def build_package(pkgatom):
    proc = subprocess.call([
        'emerge',
        '--nodeps',
        '--nospinner',
        '--verbose',
        '--oneshot',
        pkgatom
    ])
    if proc != os.EX_OK:
        bug_report(pkgatom)
        return False
    return True


def remove_packages(pkglist):
    proc = subprocess.call([
        'emerge',
        '--unmerge',
        pkglist
    ])
    return proc == os.EX_OK
    

def bug_report(pkgatom):
    pass


def main(argv):
    fetch.check_db_cache()
    conf = config.Config()
    
    # creating the overlay
    overlay.create_overlay()
    
    desc_tree = description_tree.DescriptionTree()
    
    # creating the ebuilds for all the packages
    for pkgatom in desc_tree.packages():
        e = ebuild.Ebuild(pkgatom)
        try:
            e.create(nodeps=True)
        except:
            pass
    
    installed_packages = []
    
    try:
        for pkgatom in desc_tree.packages():
            if build_package('=g-octave/'+pkgatom):
                installed_packages.append('=g-octave/'+pkgatom)
    except:
        pass
    finally:
        remove_packages(installed_packages)
    

if __name__ == '__main__':
    sys.exit(main(sys.argv))