def create_singlefile_standard (archive, compression, cmd, *args, **kwargs): """Standard routine to create a singlefile archive (like gzip).""" cmdlist = [util.shell_quote(cmd)] if kwargs['verbose']: cmdlist.append('-v') cmdlist.extend(['-c', '--']) cmdlist.extend([util.shell_quote(x) for x in args]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True})
def extract_compress (archive, compression, cmd, **kwargs): """Extract a compressed archive.""" cmdlist = [util.shell_quote(cmd)] if kwargs['verbose']: cmdlist.append('-v') outfile = util.get_single_outfile(kwargs['outdir'], archive) cmdlist.extend(['-c', util.shell_quote(archive), '>', util.shell_quote(outfile)]) return (cmdlist, {'shell': True})
def extract_singlefile_standard (archive, compression, cmd, **kwargs): """Standard routine to extract a singlefile archive (like gzip).""" cmdlist = [util.shell_quote(cmd)] if kwargs['verbose']: cmdlist.append('-v') outfile = util.get_single_outfile(kwargs['outdir'], archive) cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>', util.shell_quote(outfile)]) return (cmdlist, {'shell': True})
def create_bzip2 (archive, compression, cmd, *args, **kwargs): """Create a BZIP2 archive.""" cmdlist = [util.shell_quote(cmd)] if kwargs['verbose']: cmdlist.append('-v') cmdlist.extend(['-c', '-z', '--']) cmdlist.extend([util.shell_quote(x) for x in args]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True})
def extract_cpio (archive, compression, cmd, **kwargs): """Extract a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--extract', '--make-directories', '--preserve-modification-time', '--no-absolute-filenames', '--force-local', '--nonmatching', r'"*\.\.*"'] if kwargs['verbose']: cmdlist.append('-v') cmdlist.extend(['<', util.shell_quote(os.path.abspath(archive))]) return (cmdlist, {'cwd': kwargs['outdir'], 'shell': True})
def create_cpio(archive, compression, cmd, *args, **kwargs): """Create a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--create'] if kwargs['verbose']: cmdlist.append('-v') if len(args) != 0: findcmd = ['find'] findcmd.extend([util.shell_quote(x) for x in args]) findcmd.extend(['-print0', '|']) cmdlist[0:0] = findcmd cmdlist.append('-0') cmdlist.extend([">", util.shell_quote(archive)]) return (cmdlist, {'shell': True})
def extract_rpm (archive, compression, cmd, **kwargs): """Extract a RPM archive.""" # also check cpio cpio = util.find_program("cpio") if not cpio: raise util.PatoolError("cpio(1) is required for rpm2cpio extraction; please install it") path = util.shell_quote(os.path.abspath(archive)) cmdlist = [util.shell_quote(cmd), path, "|", util.shell_quote(cpio), '--extract', '--make-directories', '--preserve-modification-time', '--no-absolute-filenames', '--force-local', '--nonmatching', r'"*\.\.*"'] if kwargs['verbose']: cmdlist.append('-v') return (cmdlist, {'cwd': kwargs['outdir'], 'shell': True})