def write(tempspace, finalpath, pkg, cset=None, platform='', maintainer='', compressor='gz'): # The debian-binary file if cset is None: cset = pkg.contents # The data.tar.gz file data_path = pjoin(tempspace, 'data.tar.gz') tar.write_set(cset, data_path, compressor='gz', absolute_paths=False) # Control data file control = {} control['Package'] = pkg.package #control['Section'] = pkg.category control['Version'] = pkg.fullver control['Architecture'] = platform if maintainer: control['Maintainer'] = maintainer control['Description'] = pkg.description pkgdeps = "%s" % (pkg.rdepends, ) if (pkgdeps is not None and pkgdeps != ""): control.update(parsedeps(pkgdeps)) control_ds = text_data_source("".join("%s: %s\n" % (k, v) for (k, v) in control.iteritems())) control_path = pjoin(tempspace, 'control.tar.gz') tar.write_set(contents.contentsSet([ fs.fsFile('control', {'size': len(control_ds.text_fileobj().getvalue())}, data=control_ds, uid=0, gid=0, mode=0644, mtime=time.time()) ]), control_path, compressor='gz') dbinary_path = pjoin(tempspace, 'debian-binary') with open(dbinary_path, 'w') as f: f.write("2.0\n") ret = spawn(['ar', '-r', finalpath, dbinary_path, data_path, control_path]) if ret != 0: unlink_if_exists(finalpath) raise Exception("failed creating archive: return code %s" % (ret, ))
def write(tempspace, finalpath, pkg, cset=None, platform='', maintainer='', compressor='gz'): # The debian-binary file if cset is None: cset = pkg.contents # The data.tar.gz file data_path = pjoin(tempspace, 'data.tar.gz') tar.write_set(cset, data_path, compressor='gz', absolute_paths=False) # Control data file control = {} control['Package'] = pkg.package #control['Section'] = pkg.category control['Version'] = pkg.fullver control['Architecture'] = platform if maintainer: control['Maintainer'] = maintainer control['Description'] = pkg.description pkgdeps = "%s" % (pkg.rdepends,) if (pkgdeps is not None and pkgdeps != ""): control.update(parsedeps(pkgdeps)) control_ds = text_data_source("".join("%s: %s\n" % (k, v) for (k, v) in control.iteritems())) control_path = pjoin(tempspace, 'control.tar.gz') tar.write_set( contents.contentsSet([ fs.fsFile('control', {'size':len(control_ds.text_fileobj().getvalue())}, data=control_ds, uid=0, gid=0, mode=0644, mtime=time.time()) ]), control_path, compressor='gz') dbinary_path = pjoin(tempspace, 'debian-binary') with open(dbinary_path, 'w') as f: f.write("2.0\n") ret = spawn(['ar', '-r', finalpath, dbinary_path, data_path, control_path]) if ret != 0: unlink_if_exists(finalpath) raise Exception("failed creating archive: return code %s" % (ret,))
# XXX this is more then mildly stupid. st = os.stat(self.env["CCACHE_DIR"]) try: if st.st_gid != portage_gid or (st.st_mode & 02775) != 02775: try: cwd = os.getcwd() except OSError: cwd = "/" try: # crap. os.chmod(self.env["CCACHE_DIR"], 02775) os.chown(self.env["CCACHE_DIR"], -1, portage_gid) os.chdir(cwd) if 0 != spawn([ "chgrp", "-R", str(portage_gid), self.env["CCACHE_DIR"] ]): raise format.FailedDirectory( self.env["CCACHE_DIR"], "failed changing ownership for CCACHE_DIR") if 0 != spawn_bash( "find '%s' -type d -print0 | %s --null chmod 02775" % (self.env["CCACHE_DIR"], xargs)): raise format.FailedDirectory( self.env["CCACHE_DIR"], "failed correcting perms for CCACHE_DIR") if 0 != spawn_bash( "find '%s' -type f -print0 | %s --null chmod 0775" % (self.env["CCACHE_DIR"], xargs)): raise format.FailedDirectory(
if not existent: fp = obj.location else: fp = existent_fp = obj.location + "#new" if fs.isreg(obj): obj.data.transfer_to_path(fp) elif fs.issym(obj): os.symlink(obj.target, fp) elif fs.isfifo(obj): os.mkfifo(fp) elif fs.isdev(obj): dev = os.makedev(obj.major, obj.minor) os.mknod(fp, obj.mode, dev) else: ret = spawn([COPY_BINARY, "-Rp", obj.location, fp]) if ret != 0: raise FailedCopy(obj, "got %i from %s -Rp" % ret) ensure_perms(obj.change_attributes(location=fp)) if existent: os.rename(existent_fp, obj.location) return True def do_link(src, trg): try: os.link(src.location, trg.location) return True except EnvironmentError as e:
if not existent: fp = obj.location else: fp = existent_fp = obj.location + "#new" if fs.isreg(obj): obj.data.transfer_to_path(fp) elif fs.issym(obj): os.symlink(obj.target, fp) elif fs.isfifo(obj): os.mkfifo(fp) elif fs.isdev(obj): dev = os.makedev(obj.major, obj.minor) os.mknod(fp, obj.mode, dev) else: ret = spawn([COPY_BINARY, "-Rp", obj.location, fp]) if ret != 0: raise FailedCopy(obj, "got %i from %s -Rp" % ret) ensure_perms(obj.change_attributes(location=fp)) if existent: os.rename(existent_fp, obj.location) return True def do_link(src, trg): try: os.link(src.location, trg.location) return True except EnvironmentError as e: if e.errno == errno.EXDEV:
def generate_background_pid(self): try: return spawn.spawn(["sleep", "60s"], returnpid=True)[0] except spawn.CommandNotFound: raise SkipTest( "can't complete the test, sleep binary doesn't exist")
"failed creation of ccache dir")) # XXX this is more then mildly stupid. st = os.stat(self.env["CCACHE_DIR"]) try: if st.st_gid != portage_gid or (st.st_mode & 02775) != 02775: try: cwd = os.getcwd() except OSError: cwd = "/" try: # crap. os.chmod(self.env["CCACHE_DIR"], 02775) os.chown(self.env["CCACHE_DIR"], -1, portage_gid) os.chdir(cwd) if 0 != spawn(["chgrp", "-R", str(portage_gid), self.env["CCACHE_DIR"]]): raise format.FailedDirectory( self.env["CCACHE_DIR"], "failed changing ownership for CCACHE_DIR") if 0 != spawn_bash( "find '%s' -type d -print0 | %s --null chmod 02775" % (self.env["CCACHE_DIR"], xargs)): raise format.FailedDirectory( self.env["CCACHE_DIR"], "failed correcting perms for CCACHE_DIR") if 0 != spawn_bash( "find '%s' -type f -print0 | %s --null chmod 0775" % (self.env["CCACHE_DIR"], xargs)): raise format.FailedDirectory( self.env["CCACHE_DIR"],
def generate_background_pid(self): try: return spawn.spawn(["sleep", "60s"], returnpid=True)[0] except process.CommandNotFound: raise SkipTest( "can't complete the test, sleep binary doesn't exist")