portage.xpak module

portage.xpak.addtolist(mylist, curdir)

(list, dir) — Takes an array(list) and appends all files from dir down the directory tree. Returns nothing. list is modified.


Takes a 4 byte string and converts it into a 4 byte integer. Returns an integer.


Takes a 4 byte integer and converts it into a string of 4 characters. Returns the characters in a string.


(infile) – grabs the index and data segments from the infile. Returns an array [indexSegment, dataSegment]


(infile) – grabs the index segment from the infile and returns it.


Returns the filenames listed in the indexglob passed in.

portage.xpak.getitem(myid, myitem)

Print to the terminal the filenames listed in the indexglob passed in.

portage.xpak.searchindex(myindex, myitem)

(index, item) – Finds the offset and length of the file ‘item’ in the datasegment via the index ‘index’ provided.

class portage.xpak.tbz2(myfile)

Bases: object

compose(datadir, cleanup=0)

Alias for recompose().

decompose(datadir, cleanup=1)

Alias for unpackinfo() — Complement to recompose() but optionally deletes the destination directory. Extracts the xpak from the tbz2 into the directory provided. Raises IOError if scan() fails. Returns result of upackinfo().


Return an array of each file listed in the index.


Returns all the files from the dataSegment as a map object.


Returns an array [indexSegment, dataSegment]


A split/array representation of tbz2.getfile()

getfile(myfile, mydefault=None)

Finds ‘myfile’ in the data segment and returns it.

recompose(datadir, cleanup=0, break_hardlinks=True)

Creates an xpak segment from the datadir provided, truncates the tbz2 to the end of regular data if an xpak segment already exists, and adds the new segment to the file with terminating info.

recompose_mem(xpdata, break_hardlinks=True)

Update the xpak segment. :param xpdata: A new xpak segment to be written, like that returned

from the xpak_mem() function.


break_hardlinks – If hardlinks exist, create a copy in order to break them. This makes it safe to use hardlinks to create cheap snapshots of the repository, which is useful for solving race conditions on binhosts as described here: https://crbug.com/185031 Default is True.


Scans the tbz2 to locate the xpak segment and setup internal values. This function is called by relevant functions already.


Unpacks all the files from the dataSegment into ‘mydest’.

portage.xpak.xpak(rootdir, outfile=None)

(rootdir, outfile) – creates an xpak segment of the directory ‘rootdir’ and under the name ‘outfile’ if it is specified. Otherwise it returns the xpak segment.


Create an xpack segment from a map object.

portage.xpak.xpand(myid, mydest)

(infile) – Splits the infile into two files. ‘infile.index’ contains the index segment. ‘infile.dat’ contails the data segment.