https://github.com/xbzzzz/cpio_newc_dumper
a tool to dump and pack newc cpio ("file" calls it "ASCII cpio archive (SVR4 with no CRC)") archives written in deno javascript
https://github.com/xbzzzz/cpio_newc_dumper
cpio cpio-archives deno
Last synced: 8 months ago
JSON representation
a tool to dump and pack newc cpio ("file" calls it "ASCII cpio archive (SVR4 with no CRC)") archives written in deno javascript
- Host: GitHub
- URL: https://github.com/xbzzzz/cpio_newc_dumper
- Owner: xBZZZZ
- License: gpl-3.0
- Created: 2023-02-24T18:49:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-20T11:18:25.000Z (over 1 year ago)
- Last Synced: 2024-01-20T12:25:19.626Z (over 1 year ago)
- Topics: cpio, cpio-archives, deno
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cpio_newc_dumper.js
Use it to dump (not properly extract directory tree with permissions!) an ASCII cpio archive (SVR4 with no CRC).Search New ASCII Format [here](https://manpages.ubuntu.com/manpages/jammy/en/man5/cpio.5.html) for explanation of archive format.
It is intended for editing ASCII cpio archives (SVR4 with no CRC) with minimal changes.It almost perfectly replicates original achive from dump:Archive is ungzipped `ramdisk.img` from [`primeOS-mainline_0.6.1-20211206.iso`](https://sourceforge.net/projects/primeos/files/Mainline/primeOS-mainline_0.6.1-20211206.iso/download).
The zeros in the `diff`erence are garbage data after the `TRAILER!!!` file in original ungzipped archive (`ramdisk`).bash-5.1$ zcat ramdisk.img > ramdisk
bash-5.1$ mkdir dumpdir
bash-5.1$ deno run --allow-read --allow-write cpio_newc_dumper.js dump ramdisk dumpdir
bash-5.1$ deno run --allow-read --allow-write cpio_newc_dumper.js pack ramdisk2 dumpdir
bash-5.1$ diff <(xxd ramdisk) <(xxd ramdisk2)
271681,271696c271681
< 00425400: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425410: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425420: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425430: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425440: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425450: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425460: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425470: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425480: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 00425490: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
< 004254f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
---
> 00425400: 0000 0000 ....
What it doesn't replicate:
* data after `TRAILER!!!` file
* case of hex letters (`ABCDEF` or `abcdef`) in headers
* It understands both uppercase (`0123456789ABCDEF`) and lowercase (`0123456789abcdef`) hex digits but writes lowercase hex digits.
---
```
usage: deno run --allow-read --allow-write THIS_SCRIPT MODE ARCHIVE DUMP_DIRMODE is case-insensitive and means what to do:
"dump" dump ARCHIVE into DUMP_DIR
ARCHIVE is "-" means stdin
"dumpgz" ungzip and dump ARCHIVE into DUMP_DIR
ARCHIVE is "-" means stdin
"pack" pack DUMP_DIR into ARCHIVE
ARCHIVE is "-" means stdout
"packgz" pack and gzip DUMP_DIR into ARCHIVE
ARCHIVE is "-" means stdoutDUMP_DIR contains non-empty files (symlinks is dumped as files with link target as content) and "table.txt".
"table.txt" contains file names from ARCHIVE and names of corresponding files in DUMP_DIR and numbers from cpio_newc_header struct.I am not a cpio extractor that keeps file names and directory structure!
I am a tool to dump and pack newc cpio ("file" calls it "ASCII cpio archive (SVR4 with no CRC)") archives.
See https://manpages.ubuntu.com/manpages/jammy/en/man5/cpio.5.html "New ASCII Format".some ARCHIVE and DUMP_DIR names won't work, example (bash):
deno run --allow-read --allow-write cpio_newc_dumper.js dump $'\xee.cpio' asd
```