diff --git a/readme.md b/readme.md index 4f4e42f..87ed473 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -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 @@ -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 diff --git a/src/pycpio/main.py b/src/pycpio/main.py index 43767ac..0e0eac5 100755 --- a/src/pycpio/main.py +++ b/src/pycpio/main.py @@ -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"}, @@ -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")