File: sf-cf.py

package info (click to toggle)
allegro4.4 2:4.4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 20,744 kB
  • sloc: ansic: 164,458; asm: 17,620; cpp: 3,848; objc: 1,687; sh: 1,107; python: 676; pascal: 179; makefile: 55; perl: 29; lisp: 1
file content (110 lines) | stat: -rwxr-xr-x 3,919 bytes parent folder | download | duplicates (9)
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
#!/usr/bin/env python
import os, sys, optparse, threading, time

# Put here any hosts you want to compile on.
hosts = [

    "x86-linux2", #: Fedora Linux FC2 running Linux 2.6 kernel
    "x86-openbsd1", #: OpenBSD 3.4
    "x86-solaris1", #: Sun Solaris 9
    "x86-linux1", #: Debian GNU/Linux 3.0 running Linux 2.4 kernel
    "x86-freebsd1", #: FreeBSD 4.8
    "x86-netbsd1", #: NetBSD 1.6.1

    "amd64-linux1", #: Fedora Core release 3 running Linux 2.6 kernel
    "amd64-linux2", #: Fedora Core release 3 running Linux 2.6 kernel

    "alpha-linux1", #: Debian GNU/Linux 3.0 running Linux 2.2 kernel

    "ppc-osx1", #: Apple Mac OS X 10.1 Server with Fink running on an Apple Mac G4
    "ppc-osx2", #: Apple Mac OS X 10.2 Server with Fink running on an Apple Mac G4
    "ppc-osx3",

    "sparc-solaris1",
    "sparc-solaris2", #: Sun Solaris 9, running on two Sun Enterprise 220R systems

    "openpower-linux1", #: SuSE Enterprise Linux 9, running on an IBM OpenPower 720 (e-Series) host.
]

# The name of a directory containing the sources to be compiled.
source_folder = "allegro"

def exe(c):
    print ">>>" + c + "\n"
    r = os.popen(c).read()
    print r

parser = optparse.OptionParser()

parser.set_usage(
"""
python %s [options]

To use this script, you must have ssh access to the SourceForge compile farm,
and your home directory must contain a directory called "allegro". The existence
of .txt files with the name of the various hosts controls which systems are
tested - by default all for which no .txt file exists yet.
""".strip() % sys.argv[0])

hostname = os.popen("hostname").read().strip()
parser.add_option("-s", "--ssh", action = "store_true", dest = "ssh",
    help = "Connect to all hosts for which no .txt files exists and " +
    "try to compile there, pasting the results back to a .txt file.")
parser.add_option("-c", "--compile", action = "store", dest = "compile",
    help = "Internal command to directly compile on the current host. Do not use.")
parser.add_option("-o", "--one", action = "store", dest = "one",
    help = "Compile only on the given host, and overwrite the .txt " +
    "file for it if it exists already.")
parser.add_option("-u", "--user",
    help = "The SourceForge compile farm username to use.")
options, args = parser.parse_args()

user = options.user

def compile(host):
    print ">>>Running on %s [%s].\n" % (host, time.asctime())
    make = "make"
    if host.find("bsd") >= 0: make = "gmake"
    name = user[:1] + "/" + user[:2] + "/" + user + "/" + host
    configure = "./configure --prefix=/home/users/%s/local" % name
    if host.find("osx") >= 0:
        configure = "./fix.sh macosx"

    commands = " ".join([
        "rm -r %s ;" % host,
        "mkdir %s ; mkdir %s/local ; " % (host, host),
        "cd %s &&" % host,
        #"gunzip -c ../allegro-4.2.1.tar.gz | tar xf - && cd allegro-4.2.1 && ",
        "cp -r ../%s . && cd %s && " % (source_folder, source_folder),
        "%s && " % configure,
        "%s &&" % make,
        "%s install" % make])
    connect_command = r'''ssh %s  "'%s'"''' % (host, commands)
    sshcommand = "ssh cf-shell.sf.net %s" % connect_command
    print sshcommand
    stdin, stdout = os.popen4(sshcommand, bufsize=1)
    print stdout.read()

def run(host):
    print "Connecting to %s..\n" % host
    print os.popen(
        "python -u compile.py --compile %s 2>&1 | tee %s.txt" %
         (host, host)).read()

if options.ssh:
    threads = []
    for host in hosts:
        # Delete previous result .txt to try again!
        if not os.path.exists("%s.txt" % host):
            threads.append(threading.Thread(None, run, None, (host, )))
    for t in threads: t.start()
    for t in threads: t.join()

elif options.compile:
    compile(options.compile)
elif options.one:
    run(options.one)
else:
    print "Need either --ssh or --compile argument. -h or --help for help."
    print
    parser.print_help()