diff options
-rwxr-xr-x | ipsbuild-setuptree.py | 19 | ||||
-rwxr-xr-x | ipsutils-newspec.py | 18 | ||||
-rw-r--r-- | ipsutils.ips | 17 | ||||
-rw-r--r-- | ipsutils/config.py | 12 | ||||
-rw-r--r-- | ipsutils/env.py | 5 |
5 files changed, 36 insertions, 35 deletions
diff --git a/ipsbuild-setuptree.py b/ipsbuild-setuptree.py index 6b0d0d8..d15de85 100755 --- a/ipsbuild-setuptree.py +++ b/ipsbuild-setuptree.py @@ -37,20 +37,19 @@ tree = ['BUILDROOT', 'SPKGS'] def create_dir(dirent): + if os.path.exists(dirent): + return False print("Creating directory: {0:s}".format(dirent)) os.mkdir(dirent) + return True def main(): -# try: - create_dir(head) -# except: -# print("{0:s} already exists, please remove it.".format(head)) - - try: - for d in tree: - create_dir(os.path.join(head, d)) - except: - pass + if not create_dir(head): + print("ipsbuild tree already exists!") + + for d in tree: + create_dir(os.path.join(head, d)) + if __name__ == '__main__': main() diff --git a/ipsutils-newspec.py b/ipsutils-newspec.py index 62d02c7..8c58332 100755 --- a/ipsutils-newspec.py +++ b/ipsutils-newspec.py @@ -28,21 +28,25 @@ if args.spec: spec_template.key_dict['name'] = os.path.splitext(os.path.basename(spec))[0] spec_template.key_dict['release'] = '1' - print("Generating '{}' spec file".format(spec)) + print("Generating '{}' spec file".format(os.path.basename(spec))) fp = file(spec, 'w+') for key, val in spec_template.key_dict.items(): - if key is 'description' \ - or key is 'classification' \ - or key is 'summary' \ - or key is 'maintainer': - val = '""' + # Write non-essential keywords, commented + if key is 'repackage' \ + or key is 'badpath': + key = '#' + key + # Write initial classification string (user needs to fill it in) + if key is 'classification': + val = 'org.opensolaris.category.2008:' + if key is 'upstream_url': + val = 'http://' fp.write('{}: {}\n'.format(key, val)) fp.write('\n') for key in spec_template.script_dict.keys(): fp.write('\n') fp.write('%{}\n\n'.format(key)) - fp.write('%end\n') + fp.write('%end\n\n') fp.flush() fp.close() else: diff --git a/ipsutils.ips b/ipsutils.ips index 8579e0b..a6d42f5 100644 --- a/ipsutils.ips +++ b/ipsutils.ips @@ -1,21 +1,16 @@ name: ipsutils version: 0.6.0 release: 1 -maintainer: "Joseph Hunkeler <jhunk@stsci.edu>" +maintainer: Joseph Hunkeler <jhunk@stsci.edu> upstream_url: http://localhost/$name-$version.tar.gz source_url: http://localhost/$name-$version.tar.gz -description: "Python IPS library" -summary: "A python based IPS library" +description: Python IPS library +summary: A python based IPS library group: developer -classification: "org.opensolaris.category.2008:Development/Distribution Tools" +classification: org.opensolaris.category.2008:Development/Distribution Tools arch: i386 license: GPL -%setup -%end - -%prep -%end %build python setup.py build @@ -25,7 +20,3 @@ python setup.py build %install python setup.py install --root=$BUILDPROTO --prefix=/opt/ipsutils %end - -%transforms -<transform dir path=opt$ -> edit group bin sys> -%end diff --git a/ipsutils/config.py b/ipsutils/config.py index 756d8fa..eed142c 100644 --- a/ipsutils/config.py +++ b/ipsutils/config.py @@ -38,6 +38,7 @@ class Config(object): key_dict['arch'] = '' key_dict['classification'] = '' key_dict['description'] = '' + key_dict['badpath'] = '' #Define valid build script sections in SPEC file script_dict = collections.OrderedDict() @@ -56,7 +57,7 @@ class Config(object): for line in file(ipsfile).readlines(): parts = shlex.split(line) if key + ":" in parts: - key_dict[key] = parts[1] + key_dict[key] = line[line.find(':')+1:].lstrip(' ').rstrip('\n').rstrip(' ') #Drop using the original file in favor of a StringIO buffer #Because we need room to breathe without rewriting the file @@ -76,8 +77,8 @@ class Config(object): for line in ipsfile_output: parts = shlex.split(line) if key + ":" in parts: - key_dict[key] = parts[1] - + key_dict[key] = line[line.find(':')+1:].lstrip(' ').rstrip('\n').rstrip(' ') + #Parse user defined scripts by section and store them in script_dict found_data = False code_section = ['%build', '%prep', '%install', '%transforms'] @@ -88,7 +89,7 @@ class Config(object): continue if line.startswith('#'): continue - parts = shlex.split(line) + parts = shlex.split(line, posix=False) if '%end' in parts: found_data = False if section in parts: @@ -103,6 +104,9 @@ class Config(object): if not self.check_keywords(): exit(1) + def _quote(self, s): + return "'" + s.replace("'", "'\\''") + "'" + def check_keywords(self): """Validate SPEC file's FMRI section """ diff --git a/ipsutils/env.py b/ipsutils/env.py index ce9dd21..0551b3c 100644 --- a/ipsutils/env.py +++ b/ipsutils/env.py @@ -46,9 +46,12 @@ class Environment(config.Config): 'PKGS': self.pathgen('PKGS'), 'SPKGS': self.pathgen('SPKGS') } + # complete_name is required to build proper path names. - # The use of "self" in this case may be deprecated in the future. self.complete_name = self.key_dict['name'] + '-' + self.key_dict['version'] + if self.key_dict['badpath']: + self.complete_name = self.key_dict['badpath'] + # Dictionary of package-level directories self.env_pkg = { 'BUILDROOT': os.path.join(self.env['BUILDROOT'], self.complete_name), |