4. item
Module providing the Item class for files in the initramfs
Each file type of the initramfs has an Item
subclass. Those classes
provide methods used by Initramfs
generation methods.
- class cmkinitramfs.item.Item[source]
Bases:
ABC
An object within the initramfs
- __contains__(path)[source]
Check if this item is present at the given path in the initramfs
This method should be overriden by subclasses which add files to the initramfs.
- __iter__()[source]
Get the paths of this item within the initramfs
This method should be overriden by subclasses which add files to the initramfs.
- static build_from_cpio_list(data)[source]
Build an Item from a string
This string should respect the format of
gen_init_cpio
.- Parameters
data (str) – String to parse
- Returns
Item corresponding to
data
- Raises
ValueError – Invalid string
- Return type
- abstract build_to_cpio_list()[source]
String representing the item
The string is formatted to be compatible with the
gen_init_cpio
tool from the Linux kernel. This method has to be defined by subclasses.- Return type
- abstract build_to_directory(base_dir)[source]
Add this item to a real filesystem
This will copy or create a file on a real filesystem. This method has to be defined by subclasses.
- Parameters
base_dir (str) – Path to use as root directory (e.g. using
/tmp/initramfs
,/bin/ls
will be copied to/tmp/initramfs/bin/ls
)- Return type
None
- class cmkinitramfs.item.File(mode, user, group, dests, src, data_hash, chunk_size=65536)[source]
Bases:
Item
Normal file within the initramfs
- class cmkinitramfs.item.Directory(mode, user, group, dest)[source]
Bases:
Item
Directory within the initramfs
- class cmkinitramfs.item.Node(mode, user, group, dest, nodetype, major, minor)[source]
Bases:
Item
Special file within the initramfs
- class cmkinitramfs.item.Symlink(mode, user, group, dest, target)[source]
Bases:
Item
Symlinks within the initramfs