Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Currently, the library only supports the New ASCII format.

xz and zstd compression types are currently suppored.

This library is primary designed for use in [ugrd](https://github.com/desultory/ugrd) to create CPIO archives for use in initramfs.
This library is primary designed for use in [ugrd](https://github.com/desultory/ugrd) to create initramfs CPIO archives

## Usage

Expand All @@ -33,6 +33,7 @@ This library is primary designed for use in [ugrd](https://github.com/desultory/
--relative RELATIVE append to archive relative to this path
--absolute allow absolute paths
--reproducible Set mtime to 0, start inodes at 0
--deduplicate Make hardlinks for files with identical content
--rm RM, --delete RM delete from archive
-n NAME, --name NAME Name/path override for append
-s SYMLINK, --symlink SYMLINK
Expand Down Expand Up @@ -69,4 +70,5 @@ This library is primary designed for use in [ugrd](https://github.com/desultory/
- `chardev` : A character device
* CPIO objects are collected in a `pycpio.cpio.archive` object
- The archive handles duplication, inode generation, name normalization, and other collection related tasks

* All CPIO object types can be initialized from args, bytes, or a file path
16 changes: 16 additions & 0 deletions src/pycpio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def main():
{"flags": ["--recursive"], "action": "store", "help": "append to archive recursively"},
{"flags": ["--relative"], "action": "store", "help": "append to archive relative to this path"},
{"flags": ["--absolute"], "action": "store_true", "help": "allow absolute paths"},
{
"flags": ["--deduplicate"],
"action": "store_true",
"help": "deduplicate files (make hardlinks) when file contents match",
},
{"flags": ["--reproducible"], "action": "store_true", "help": "Set mtime to 0, start inodes at 0"},
{"flags": ["--rm", "--delete"], "action": "store", "help": "delete from archive"},
{"flags": ["-n", "--name"], "action": "store", "help": "Name/path override for append"},
Expand Down Expand Up @@ -61,6 +66,17 @@ def main():
raise ValueError("Character device requires minor number")
c.add_chardev(chardev_path, major, minor)

if append_file := kwargs.get("append"):
cmdargs = {
"relative": kwargs.get("relative"),
"path": Path(append_file),
"name": kwargs.get("name"),
"absolute": kwargs.get("absolute"),
}
c.append_cpio(**cmdargs)
if recursive_path := kwargs.get("recursive"):
cmdargs = {"relative": kwargs.get("relative"), "path": Path(recursive_path)}
c.append_recursive(**cmdargs)

if output_file := kwargs.get("output"):
compression = kwargs.get("compress")
Expand Down