Author: wade
Date: 2006-05-08 19:22:15 -0400 (Mon, 08 May 2006)
New Revision: 60429
Added:
Modified:
Log:
new module: shell_parse
-factored out bash parsing from packaging.py so it can be used elsewhere
defs: since some regexs were fixed, don't need quotes around values anymore
install-deps: ignore exit code of removing rpms
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="5"
+web_index=5
BUILD_HSTS=(
fedora-3-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="6"
+web_index=6
BUILD_HSTS=(
fedora-3-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="7"
+web_index=7
BUILD_HSTS=(
fedora-5-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="10"
+web_index=10
BUILD_HSTS=(
redhat-9-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="4"
+web_index=4
BUILD_HSTS=(
fedora-3-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="8"
+web_index=8
BUILD_HSTS=(
fedora-3-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="0"
+web_index=0
# Possibly use sles-8 as the new base distro?
BUILD_HSTS=(
@@ -314,4 +314,3 @@
make -k check
}
-
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="1"
+web_index=1
BUILD_HSTS=(
redhat-9-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="2"
+web_index=2
BUILD_HSTS=(
redhat-9-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="3"
+web_index=3
BUILD_HSTS=(
redhat-9-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -1,4 +1,4 @@
-web_index="9"
+web_index=9
BUILD_HSTS=(
redhat-9-i386
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -94,11 +94,12 @@
target_env.ssh.execute('/usr/sbin/rcd -r', exec_as_root=1)
print "Waiting for rcd to come alive"
time.sleep(5)
-(code, output) = target_env.ssh.execute('rug rm -y %s' % rpm_names, exec_as_root=1)
+target_env.ssh.execute('rug rm -y %s' % rpm_names, exec_as_root=1)
(code, output) = target_env.ssh.execute('rug in -y -r /tmp/install-packages/*.rpm', exec_as_root=1)
+target_env.ssh.execute('rug shutdown', exec_as_root=1)
else:
target_env.ssh.copy_to('remove-rpms', '/tmp')
-(code, output) = target_env.ssh.execute('/tmp/remove-rpms %s' % rpm_names, exec_as_root=1)
+target_env.ssh.execute('/tmp/remove-rpms %s' % rpm_names, exec_as_root=1)
(code, output) = target_env.ssh.execute('rpm -Uvh /tmp/install-packages/*.rpm', exec_as_root=1)
# Exit with return code
Modified:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -15,6 +15,7 @@
import utils
import sshutils
import packaging
+import shell_parse
class buildenv:
@@ -59,7 +60,7 @@
# Linux distros
redhat_distros = "fedora redhat rhel".split()
-suse_distros = "suse nld sles".split()
+suse_distros = "suse nld sles sled".split()
VERSIN, ARCH
try:
@@ -73,7 +74,7 @@
S, S_TYPE, S_SUBTYPE
# If our os is either suse or redhat
-if (redhat_distros + suse_distros).count(os):
+if (redhat_distros + suse_distros).count(build_os):
info['os'] = 'linux'
info['os_subtype'] = build_os
if build_os in redhat_distros:
@@ -81,7 +82,7 @@
elif build_os in suse_distros:
info['os_type'] = 'suse'
else:
-info['os'] = os
+info['os'] = build_os
DISTRALIASES
if self.name == 'rhel-3-i386':
@@ -92,24 +93,11 @@
# Pull out all vars in the distro conf file
conf_file = os.path.join(config.packaging_dir, "conf", self.name)
-try:fd = open(conf_file, 'r')
-except IError:
-print "Error opening file: %s" % conf_file
-sys.exit(1)
+conf_info = shell_parse.parse(conf_file)
+# Copy info from conf file into structure we've been building
+for k, v in conf_info.iteritems():
+info[k] = v
-for line in fd:
-# Skip comments
-if not re.compile("^#").search(line):
-try:
-# Grab key and value from key=value format
-# Also, ingnore double or single quotes arond the value
-# the .+ is nongreedy before the equals sign (allows for more than one equals)
-(key, value) = re.compile('^(.+?)="?\'?(.*?)"?\'?$').search(line).groups()
-info[key] = value
-#print "Key: %s, value: %s" %( key, value)
-except AttributeError:
-pass
-
# Some required keys
for key in ['target_host']:
if not info.has_key(key):
@@ -122,8 +110,6 @@
if not info.has_key(key):
info[key] = ""
-fd.close()
-
self.info = info
# TD: use fcntl?
@@ -173,33 +159,8 @@
print "File not found: %s" % self.def_file
sys.exit(1)
+self.info = shell_parse.parse(self.def_file)
-# TD: get the rest of the info in the def file
-self.info = {}
-
-# Read in string while removing comments from the file string
-file_string = ""
-def_file = open(self.def_file, 'r')
-for line in def_file:
-if not re.compile('^\s*#').search(line):
-file_string += line
-def_file.close()
-
-# TD: abstract out this bash parsing stuff so it's uniform between conf and def files
-# get vars (var="value")
-for match in re.compile('^(\w*?)=[^\(](.*?)["\']?$', re.S | re.M).finditer(file_string):
-self.info[match.group(1)] = match.group(2)
-
-# get arrays ( var=(value list) )
-for match in re.compile('^(\w*?)=\((.*?)\)', re.S | re.M).finditer(file_string):
-items = match.group(2).split()
-self.info[match.group(1)] = items
-
-# get Functions ( func () { } )
-for match in re.compile('^(\w*?) \(\) {(.*?)}', re.S | re.M).finditer(file_string):
-self.info[match.group(1)] = match.group(2)
-
-
# if we have a build env
if self.package_env:
self.destroot = self.execute_function('get_destroot', 'DEST_RT')
Added:
2006-05-08 23:19:23 UTC (rev 60428)
2006-05-08 23:22:15 UTC (rev 60429)
@@ -0,0 +1,37 @@
+import re
+
+def parse(filename):
+"""Args: shell file. Returns a dictionary with keys as named elements.
+
+Currently supports variables, arrays, and functions."""
+
+file_string = ""
+info = {}
+
+# Read in string while removing comments from the file string
+try: fd = open(filename, 'r')
+except IError:
+print "Could not open " + filename
+sys.exit(1)
+
+for line in fd:
+if not re.compile('^\s*#').search(line):
+file_string += line
+fd.close()
+
+# get vars (var="value")
+# Note: this ingores single and double quotes around the value
+for match in re.compile('^(\w*?)=["\']?([^\(].*?)["\']?$', re.S | re.M).finditer(file_string):
+info[match.group(1)] = match.group(2)
+
+# get arrays ( var=(value list) )
+for match in re.compile('^(\w*?)=\((.*?)\)', re.S | re.M).finditer(file_string):
+items = match.group(2).split()
+info[match.group(1)] = items
+
+# get Functions ( func () { } )
+for match in re.compile('^(\w*?) \(\) {(.*?)}', re.S | re.M).finditer(file_string):
+info[match.group(1)] = match.group(2)
+
+return info
+
Mono-patches maillist - Mono-patches (AT) lists (DOT) ximian.com