From a332d3db796261e5cc5dec457c8ae0997c7257b4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 17 Apr 2013 09:06:52 -0400 Subject: IPC should be IPS. I was tired. --- ipcbuild-setuptree.py | 37 -------------------- ipcbuild.py | 95 --------------------------------------------------- ipsbuild-setuptree.py | 37 ++++++++++++++++++++ ipsbuild.py | 72 ++++++++++++++++++++++++++++++++++++++ test.ipc | 20 ----------- test.ips | 20 +++++++++++ 6 files changed, 129 insertions(+), 152 deletions(-) delete mode 100644 ipcbuild-setuptree.py delete mode 100644 ipcbuild.py create mode 100644 ipsbuild-setuptree.py create mode 100644 ipsbuild.py delete mode 100644 test.ipc create mode 100644 test.ips diff --git a/ipcbuild-setuptree.py b/ipcbuild-setuptree.py deleted file mode 100644 index f3e997a..0000000 --- a/ipcbuild-setuptree.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import sys - -try: - if sys.platform == 'linux' or sys.platform == 'darwin': - home = os.path.normpath(os.environ['HOME']) - elif sys.platform == 'win32': - home = os.path.normpath(os.environ['USERPROFILE']) -except: - Exception("Unsupported platform: {0:s}".format(sys.platform)) - -head = os.path.join(home, 'ipcbuild') -tree = ['BUILDROOT', - 'BUILD', - 'SPECS', - 'SOURCES', - 'PKGS', - 'SPKGS'] - -def create_dir(dirent): - print("Creating directory: {0:s}".format(dirent)) - os.mkdir(dirent) - -def main(): - try: - self.create_dir(head) - except: - print("{0:s} already exists, please remove it.".format(head)) - - try: - for d in tree: - self.create_dir(os.path.join(head, d)) - except: - pass - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/ipcbuild.py b/ipcbuild.py deleted file mode 100644 index ec082e0..0000000 --- a/ipcbuild.py +++ /dev/null @@ -1,95 +0,0 @@ -# Solaris 11 IPC -# Automate package creation - -from pprint import pprint -import shlex -import ConfigParser -import argparse -import string - -class FakeSecHead(object): - """Found on stackoverflow, public domain code""" - def __init__(self, fp): - self.fp = fp - self.sechead = '[IPC]\n' - def readline(self): - if self.sechead: - try: - return self.sechead - finally: - self.sechead = None - else: - return self.fp.readline() -''' -class IPC_Config(object): - def __init__(self, ipcfile): - self._header = 'IPC' - self.config = ConfigParser.SafeConfigParser() - self._config_read(ipcfile) - print("{0:s} parsed".format(ipcfile)) - - def __iter__(self): - for i in self.config.items(self._header): - yield i - - def __getitem__(self, option): - return self.config.get(self._header, option) - - def _config_read(self, ipcfile): - """Wrapper for FakeSecHead""" - self.config.readfp(FakeSecHead(open(ipcfile))) -''' - -class IPC_Config(object): - def __init__(self, ipcfile): - - key_dict = { - 'name': '', - 'version': '', - 'release': '', - 'maintainer': '', - 'upstream_url': '', - 'description': '', - 'arch': '', - 'license': '' - } - - script_dict = { - 'build': [], - 'prep': [], - 'install': [], - 'files': [] - } - - for key in key_dict: - for line in file(ipcfile).readlines(): - parts = shlex.split(line) - if key + ":" in parts: - key_dict[key] = parts[1] - - found_data = False - code_section = ['%build', '%prep', '%install', '%files'] - for section in code_section: - for line in file(ipcfile).readlines(): - parts = shlex.split(line) - if '%end' in parts: - found_data = False - if section in parts: - found_data = True - continue - if found_data: - script_dict[section.strip('%')].append(parts) - - - self.key_dict = key_dict - self.script_dict = script_dict - -class IPC_Build(IPC_Config): - def __init__(self, ipcfile): - super(IPC_Build, self).__init__(ipcfile) - print(self.key_dict['name']) - - -testfile = "test.ipc" -build = IPC_Build(testfile) - diff --git a/ipsbuild-setuptree.py b/ipsbuild-setuptree.py new file mode 100644 index 0000000..135c4e9 --- /dev/null +++ b/ipsbuild-setuptree.py @@ -0,0 +1,37 @@ +import os +import sys + +try: + if sys.platform == 'linux' or sys.platform == 'darwin': + home = os.path.normpath(os.environ['HOME']) + elif sys.platform == 'win32': + home = os.path.normpath(os.environ['USERPROFILE']) +except: + Exception("Unsupported platform: {0:s}".format(sys.platform)) + +head = os.path.join(home, 'ipsbuild') +tree = ['BUILDROOT', + 'BUILD', + 'SPECS', + 'SOURCES', + 'PKGS', + 'SPKGS'] + +def create_dir(dirent): + print("Creating directory: {0:s}".format(dirent)) + os.mkdir(dirent) + +def main(): + try: + self.create_dir(head) + except: + print("{0:s} already exists, please remove it.".format(head)) + + try: + for d in tree: + self.create_dir(os.path.join(head, d)) + except: + pass + +if __name__ == '__main__': + main() diff --git a/ipsbuild.py b/ipsbuild.py new file mode 100644 index 0000000..af53bdb --- /dev/null +++ b/ipsbuild.py @@ -0,0 +1,72 @@ +# Solaris 11 IPS +# Automate package creation + +from pprint import pprint +from collections import deque +import subprocess +import shlex +import ConfigParser +import argparse +import string + +class IPS_Config(object): + def __init__(self, ipsfile): + + key_dict = { + 'name': '', + 'version': '', + 'release': '', + 'maintainer': '', + 'upstream_url': '', + 'description': '', + 'arch': '', + 'license': '' + } + + script_dict = { + 'build': [], + 'prep': [], + 'install': [], + 'files': [] + } + + for key in key_dict: + for line in file(ipsfile).readlines(): + parts = shlex.split(line) + if key + ":" in parts: + key_dict[key] = parts[1] + + found_data = False + code_section = ['%build', '%prep', '%install', '%files'] + for section in code_section: + for line in file(ipsfile).readlines(): + parts = shlex.split(line) + if '%end' in parts: + found_data = False + if section in parts: + found_data = True + continue + if found_data: + script_dict[section.strip('%')].append(parts) + + self.key_dict = key_dict + self.script_dict = script_dict + +class IPS_Task(object): + def __init__(self, task): + if type(task) is not type(list): + TypeError("task must be a list") + +class IPS_Build(IPS_Config): + def __init__(self, ipsfile): + super(IPS_Build, self).__init__(ipsfile) + self.task_queue = deque() + for key in self.script_dict: + for i in self.script_dict[key]: + self.task_queue.append(IPS_Task(i)) + + + +testfile = "test.ips" +build = IPS_Build(testfile) +print build.task_queue diff --git a/test.ipc b/test.ipc deleted file mode 100644 index b13446e..0000000 --- a/test.ipc +++ /dev/null @@ -1,20 +0,0 @@ -name: developer/testpkg -version: 0.1 -release: 1 -maintainer: test person -upstream_url: http://localhost/testpkg.tar.gz -description: a test package -arch: i386 -license: GPL - -%prep -%end - -%build -configure --prefix=/usr -make -%end - -%install -make install -%end \ No newline at end of file diff --git a/test.ips b/test.ips new file mode 100644 index 0000000..b13446e --- /dev/null +++ b/test.ips @@ -0,0 +1,20 @@ +name: developer/testpkg +version: 0.1 +release: 1 +maintainer: test person +upstream_url: http://localhost/testpkg.tar.gz +description: a test package +arch: i386 +license: GPL + +%prep +%end + +%build +configure --prefix=/usr +make +%end + +%install +make install +%end \ No newline at end of file -- cgit