File: playerconf

package info (click to toggle)
player 3.0.2%2Bdfsg-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 16,968 kB
  • sloc: cpp: 118,349; ansic: 34,116; python: 1,710; ruby: 269; tcl: 265; java: 189; makefile: 113; sh: 30; php: 3
file content (108 lines) | stat: -rwxr-xr-x 3,704 bytes parent folder | download
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
#!/usr/bin/env python

#
#  Player - One Hell of a Robot Server
#  Copyright (C) 2003 Brian Gerkey <gerkey@robotics.stanford.edu>
#                      
#  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# playerconf - a little utility to aid in configuring a player build.  It
#              uses the dialog utility to ask a question regarding each
#              possible --enable/disable and --with/without configure script
#              option
#
# $Id: playerconf 1768 2003-09-05 18:02:18Z inspectorg $
#

import os
import string

os.system('rm -f config.cache')

def inputbox(comment,extras):
  """Pops up an inputbox and returns (0/1,val)"""
  tmpfname='prefix.tmp'
  ret=os.system('dialog ' + extras + ' --inputbox "' + comment + ' (leave empty to use default)." 0 0 2> ' + tmpfname)
  f=os.open(tmpfname,os.O_RDONLY)
  val=os.read(f,256)
  os.unlink(tmpfname)
  return (ret,val)

os.system('dialog --msgbox "Welcome to playerconf.  Please answer the following questions to configure your build of player." 0 0')

configstring = './configure'

(ret,val) = inputbox('Installation prefix', '--nocancel')
if len(val) > 0:
  configstring += ' --prefix=' + val

configout = os.popen('./configure --help')
lines = configout.read().split('\n')

print lines

go = 0
for l in lines:
  if l == '--enable and --with options recognized:':
    go = 1
    continue
  elif not go or len(l) == 0 or string.find(l,'dependency-tracking') >= 0:
    continue
  else:
    # Munge the comment strings so that the ask an intuitive positive question
    # NOTE: this procedure is brittle, making certain assumptions of how
    #       the comment strings are phrased
    tokens = l.split()
    default = tokens[0].split('-')[2]
    tmp = tokens[0].split('-')[3]
    idx = string.find(tmp,'=')
    option = tmp
    val=''
    valname=''
    if idx >= 0:
      option = tmp[:idx]
      valname = tmp[idx+1:]
    comment = string.join(tokens[1:])
    if comment.split()[0] == "Don't":
      comment = string.join(comment.split()[1:])
      comment = string.upper(comment[0]) + comment[1:]
    idx = string.find(comment,'without')
    if idx >= 0:
      comment = comment[:idx] + 'with ' + string.join(comment[idx:].split()[1:])
    dialogstr = 'dialog '
    if default == 'enable' or default == 'with':
      dialogstr += '--defaultno '
    if len(valname) > 0:
      (ret,val) = inputbox(comment,'--ok-label Yes --cancel-label No')
    else:
      dialogstr += '--yesno "' + comment + '?" 0 0'
      ret = os.system(dialogstr)
    if ret == 0:
      if string.find(default,'with') >= 0:
        configstring += ' --with-' + option
      else:
        configstring += ' --enable-' + option
    else:
      if string.find(default,'with') >= 0:
        configstring += ' --without-' + option
      else:
        configstring += ' --disable-' + option
    if len(val) > 0:
      configstring += '=' + val

os.system('''dialog --msgbox "Configuration complete.  Press Enter to run the configure script, then type 'make' to build" 0 0''')

os.system(configstring)