def install(self): updir = self._unpack() for nm in os.listdir(updir): if nm.endswith(".rpm"): fpath = os.path.join(updir, nm) with open(fpath+".cpio", "w+") as stdout: self.target.do("rpm2cpio", fpath, stdout=stdout) stdout.seek(0) with cd(self.INSTALL_PREFIX): self.target.do("cpio", "-duvi", stdin=stdout) def hackily_define_TIOCSWINSZ(lines): for ln in lines: yield ln if ln.strip().startswith("#define TIOCGWINSZ"): yield "#define TIOCSWINSZ 0x5414\n" ioctl_header = os.path.join(self.INSTALL_PREFIX, "opt/lsb/include/sys/ioctl.h") self._patch_file(ioctl_header, hackily_define_TIOCSWINSZ) # Check if we can actually compile something with tempdir() as workdir: with open(os.path.join(workdir, "test.c"), "w") as f: f.write(""" #include <stdio.h> int main(void) { printf("hello world"); return 0; } """) with cd(workdir): try: self.target.do("lsbcc", "-m32", "-o", "test", "test.c") self.target.do("./test") except Exception, e: msg = "Failed to compile a test executable:\n" msg += " " + str(e) + "\n" msg += "Please make sure you can compile 32-bit " msg += "LSB applications on your system" raise RuntimeError(msg)
def build(self, relpath="", args=[], env={}): super(py_m2crypto, self).build() workdir = self._get_builddir() cmd = [self.target.PYTHON_EXECUTABLE, "setup.py", "build", "build_ext", "--openssl=%s" % self.target.PREFIX] cmd.extend(args) with cd(os.path.join(workdir, relpath)): self.target.do(*cmd, env=env)
def find_new_files(self): # os.walk has a bad habit of choking on unicode errors, so # we do it by hand and get it right. Anything that can't # be decoded properly gets deleted. todo = [self.rootdir] while todo: dirpath = todo.pop(0) try: names = os.listdir(dirpath) except OSError, e: if e.errno not in (errno.ENOENT,): raise continue if not names: if not self._is_oldfile(dirpath + os.sep): yield dirpath + os.sep else: for nm in names: try: fpath = os.path.join(dirpath,nm) except UnicodeDecodeError: with util.cd(dirpath): if util.isrealdir(nm): shutil.rmtree(nm) else: os.unlink(nm) else: if not self._is_tempfile(fpath): if util.isrealdir(fpath): todo.append(fpath) else: if not self._is_oldfile(fpath): yield fpath
def _nway_configure(self, script=None, vars=None, args=None, env={}): """Do a "./configure" for each architecure in a separate dir.""" workdir = self._get_builddir() # Create work dir for each additional arch. archdirs = [] for arch in self.TARGET_ARCHS: if arch == self.LOCAL_ARCH: archdirs.append((arch, workdir)) else: archdir = os.path.join(os.path.dirname(workdir), arch) if os.path.exists(archdir): shutil.rmtree(archdir) shutil.copytree(workdir, archdir) archdirs.append((arch, archdir)) # Now run the appropriate ./configure in each arch dir. for (arch, archdir) in archdirs: if os.path.exists(os.path.join(archdir, "Makefile")): with cd(archdir): try: self.target.do("make", "clean") except subprocess.CalledProcessError: pass self.TARGET_ARCH = arch self.CONFIGURE_DIR = archdir self._generic_configure(script, vars, args, env) self.TARGET_ARCH = None
def _generic_cmake(self,relpath=".",args=[],env={}): """Do a generic "cmake" on the given source tarball.""" archflags = " ".join("-arch "+arch for arch in self.TARGET_ARCHS) workdir = self._get_builddir() cmd = ["cmake"] cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.PREFIX,)) cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON") cmd.append("-DCMAKE_OSX_SYSROOT="+self.MACOSX_SYSROOT) cmd.append("-DCMAKE_OSX_ARCHITECTURES="+";".join(self.TARGET_ARCHS)) cmd.append("-DBUILD_TESTS=False") cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel") for arg in args: cmd.append(arg) libdir = os.path.join(self.PREFIX,"lib") incdir = os.path.join(self.PREFIX,"include") env = env.copy() env.setdefault("LDFLAGS",self.LDFLAGS) env.setdefault("CFLAGS","-Os %s %s -mmacosx-version-min=%s -isysroot %s" % (archflags,self.INCFLAGS,self.MACOSX_DEPLOYMENT_TARGET,self.MACOSX_SYSROOT,)) env.setdefault("CXXFLAGS","-Os %s %s -mmacosx-version-min=%s -isysroot %s" % (archflags,self.INCFLAGS,self.MACOSX_DEPLOYMENT_TARGET,self.MACOSX_SYSROOT,)) # Do an out-of-source build, required by some recipes. builddir = os.path.join(self._get_builddir(), "MYPPY-BUILD") if not os.path.exists(builddir): os.makedirs(builddir) cmd.append("..") with cd(builddir): self.target.do(*cmd,env=env)
def install(self, relpath="", args=[], env={}): workdir = self._get_builddir() # link statically with libmysqlclient_r.so cmd_conf = [ self.target.PYTHON_EXECUTABLE, "setup.py", "setopt", "-c", "options", "-o", "static", "-s", "True", "-f", "site.cfg", ] cmd_conf2 = [ self.target.PYTHON_EXECUTABLE, "setup.py", "setopt", "-c", "options", "-o", "mysql_config", "-s", os.path.join(self.target.PREFIX, "bin", "mysql_config"), "-f", "site.cfg", ] cmd = [self.target.PYTHON_EXECUTABLE, "setup.py", "install_lib"] cmd.extend(args) with cd(os.path.join(workdir, relpath)): self.target.do(*cmd_conf, env=env) self.target.do(*cmd_conf2, env=env) self.target.do(*cmd, env=env)
def _generic_pyinstall(self,relpath="",args=[],env={}): """Do a generic "python setup.py install" for this recipe.""" workdir = self._get_builddir() cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install"] cmd.extend(args) with cd(os.path.join(workdir,relpath)): self.target.do(*cmd,env=env)
def _nway_configure(self,script=None,vars=None,args=None,env={}): """Do a "./configure" for each architecure in a separate dir.""" workdir = self._get_builddir() # Create work dir for each additional arch. archdirs = [] for arch in self.TARGET_ARCHS: if arch == self.LOCAL_ARCH: archdirs.append((arch,workdir)) else: archdir = os.path.join(os.path.dirname(workdir),arch) if os.path.exists(archdir): shutil.rmtree(archdir) shutil.copytree(workdir,archdir) archdirs.append((arch,archdir)) # Now run the appropriate ./configure in each arch dir. for (arch,archdir) in archdirs: if os.path.exists(os.path.join(archdir,"Makefile")): with cd(archdir): try: self.target.do("make","clean") except subprocess.CalledProcessError: pass self.TARGET_ARCH = arch self.CONFIGURE_DIR = archdir self._generic_configure(script,vars,args,env) self.TARGET_ARCH = None
def build(self,relpath="",args=[],env={}): super(py_m2crypto,self).build() workdir = self._get_builddir() cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","build","build_ext", "--openssl=%s" % self.target.PREFIX] cmd.extend(args) with cd(os.path.join(workdir,relpath)): self.target.do(*cmd,env=env)
def install(self): updir = self._unpack() for nm in os.listdir(updir): if nm.endswith(".rpm"): fpath = os.path.join(updir, nm) with open(fpath+".cpio", "w+") as stdout: self.target.do("rpm2cpio", fpath, stdout=stdout) stdout.seek(0) with cd(self.INSTALL_PREFIX): self.target.do("cpio", "-duvi", stdin=stdout)
def install(self,relpath="",args=[],env={}): workdir = self._get_builddir() # link statically with libpg.so cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install_lib"] cmd.extend(args) with cd(os.path.join(workdir,relpath)): f = open('setup.cfg', 'w') f.write(self.SETUP_CFG % self.target.PREFIX) f.close() self.target.do(*cmd,env=env)
def install(self): updir = self._unpack() for nm in os.listdir(updir): if nm.endswith(".rpm"): fpath = os.path.join(updir, nm) with open(fpath + ".cpio", "w+") as stdout: self.target.do("rpm2cpio", fpath, stdout=stdout) stdout.seek(0) with cd(self.INSTALL_PREFIX): self.target.do("cpio", "-duvi", stdin=stdout)
def install(self,relpath="",args=[],env={}): workdir = self._get_builddir() # link statically with libmysqlclient_r.so cmd_conf = [self.target.PYTHON_EXECUTABLE,"setup.py","setopt","-c","options","-o","static","-s","True","-f","site.cfg"] cmd_conf2 = [self.target.PYTHON_EXECUTABLE,"setup.py","setopt","-c","options","-o","mysql_config","-s", os.path.join(self.target.PREFIX,'bin','mysql_config'),"-f","site.cfg"] cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install_lib"] cmd.extend(args) with cd(os.path.join(workdir,relpath)): self.target.do(*cmd_conf,env=env) self.target.do(*cmd_conf2,env=env) self.target.do(*cmd,env=env)
def _generic_cmake(self, relpath=".", args=[], env={}): cmd = ["cmake"] cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.INSTALL_PREFIX,)) cmd.append("-DCMAKE_MODULE_PATH=%s" % (os.path.join(self.PREFIX, "share", "cmake"),)) cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON") cmd.append("-DBUILD_TESTS=False") cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel") for arg in args: cmd.append(arg) with cd(self._get_builddir()): self.target.do(*cmd, env=env)
def _generic_cmake(self, relpath=".", args=[], env={}): cmd = ["cmake"] cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.INSTALL_PREFIX, )) cmd.append("-DCMAKE_MODULE_PATH=%s" % (os.path.join(self.PREFIX, "share", "cmake"), )) cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON") cmd.append("-DBUILD_TESTS=False") cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel") for arg in args: cmd.append(arg) with cd(self._get_builddir()): self.target.do(*cmd, env=env)
def _generic_cmake(self,relpath=".",args=[],env={}): cmd = ["cmake"] cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.INSTALL_PREFIX,)) cmd.append("-DCMAKE_MODULE_PATH=%s" % (os.path.join(self.PREFIX,"share","cmake"),)) cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON") cmd.append("-DBUILD_TESTS=False") cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel") for arg in args: cmd.append(arg) # Do an out-of-source build, required by some recipes. builddir = os.path.join(self._get_builddir(), "MYPPY-BUILD") os.makedirs(builddir) cmd.append("..") with cd(builddir): self.target.do(*cmd,env=env)
def build(self): # fetch and upnpack source src = self.target.fetch(self.SOURCE_URL) self._unpack_tarball(src,self.target.builddir) self.workdir = os.path.join(self.target.builddir, 'p4python-2012.1.442152') # fetch P4API src = self.target.fetch(self.P4API_URL) self._unpack_tarball(src,self.workdir) p4api_dir = os.path.join(self.workdir, 'p4api-2012.1.442152') # Generate the setup.cfg file. with cd(self.workdir): f = open("setup.cfg", "w") f.write("[p4python_config]\n") f.write("p4_api=%s" % p4api_dir) f.close()
def install(self): updir = self._unpack() for nm in os.listdir(updir): if nm.endswith(".rpm"): fpath = os.path.join(updir, nm) with open(fpath+".cpio", "w+") as stdout: self.target.do("rpm2cpio", fpath, stdout=stdout) stdout.seek(0) with cd(self.INSTALL_PREFIX): self.target.do("cpio", "-duvi", stdin=stdout) def hackily_define_TIOCSWINSZ(lines): for ln in lines: yield ln if ln.strip().startswith("#define TIOCGWINSZ"): yield "#define TIOCSWINSZ 0x5414\n" ioctl_header = os.path.join(self.INSTALL_PREFIX, "opt/lsb/include/sys/ioctl.h") self._patch_file(ioctl_header, hackily_define_TIOCSWINSZ)
def _generic_cmake(self,relpath=".",args=[],env={}): """Do a generic "cmake" on the given source tarball.""" archflags = " ".join("-arch "+arch for arch in self.TARGET_ARCHS) workdir = self._get_builddir() cmd = ["cmake"] cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.PREFIX,)) cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON") cmd.append("-DCMAKE_OSX_SYSROOT="+self.ISYSROOT) cmd.append("-DCMAKE_OSX_ARCHITECTURES="+";".join(self.TARGET_ARCHS)) cmd.append("-DBUILD_TESTS=False") cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel") for arg in args: cmd.append(arg) libdir = os.path.join(self.PREFIX,"lib") incdir = os.path.join(self.PREFIX,"include") env = env.copy() env.setdefault("LDFLAGS",self.LDFLAGS) env.setdefault("CFLAGS","-Os %s %s -mmacosx-version-min=10.4 -isysroot %s" % (archflags,self.INCFLAGS,self.ISYSROOT,)) env.setdefault("CXXFLAGS","-Os %s %s -mmacosx-version-min=10.4 -isysroot %s" % (archflags,self.INCFLAGS,self.ISYSROOT,)) with cd(workdir): self.target.do(*cmd,env=env)
def _generic_configure(self,script=None,vars=None,args=None,env={}): """Do a generic "./configure" for this recipe.""" if script is None: script = self.CONFIGURE_SCRIPT if vars is None: vars = self.CONFIGURE_VARS if args is None: args = self.CONFIGURE_ARGS if isinstance(script,basestring): cmd = [script] else: cmd = list(script) cmd.append("--prefix=%s" % (self.INSTALL_PREFIX,)) for arg in args: cmd.append(arg) if vars is not None: for var in vars: cmd.append(var) workdir = self._get_builddir() workdir = os.path.join(workdir,self.CONFIGURE_DIR) with cd(workdir): self.target.do(*cmd,env=env)
def install(self): self._generic_make(target='install') # create symlinks in lib folder with cd(os.path.join(self.target.PREFIX,'lib')): os.system('ln -s mysql/libmysqlclient.a') os.system('ln -s mysql/libmysqlclient_r.a')
def _patch(self): workdir = self._get_builddir() patchfile = os.path.join(os.path.dirname(__file__),"_py2app.patch") with open(patchfile,"rb") as fin: with cd(os.path.join(workdir,"py2app")): self.target.do("patch",stdin=fin)
def install(self): self._generic_make(target="install") # create symlinks in lib folder with cd(os.path.join(self.target.PREFIX, "lib")): os.system("ln -s mysql/libmysqlclient.a") os.system("ln -s mysql/libmysqlclient_r.a")
def _patch(self): workdir = self._get_builddir() patchfile = os.path.join(os.path.dirname(__file__), "_py2app.patch") with open(patchfile, "rb") as fin: with cd(os.path.join(workdir, "py2app")): self.target.do("patch", stdin=fin)
def install(self): cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install"] with cd(self.workdir): self.target.do(*cmd)
def install(self,relpath="",args=[],env={}): workdir = self._get_builddir() cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install_lib"] cmd.extend(args) with cd(os.path.join(workdir,relpath)): self.target.do(*cmd,env=env)