{"id":15394225,"url":"https://github.com/xyproto/metatar","last_synced_at":"2025-07-29T17:12:40.099Z","repository":{"id":48879201,"uuid":"95881332","full_name":"xyproto/metatar","owner":"xyproto","description":"Manipulate tar file metadata, list tar files or convert tar to cpio. For some projects, this can replace fakeroot and cpio, when creating an initrd image that is compatible with the Linux kernel. Used in production in at least one company.","archived":false,"fork":false,"pushed_at":"2025-06-24T08:16:07.000Z","size":6262,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-06-24T09:29:28.229Z","etag":null,"topics":["cpio","distro-tools","fakeroot","genext2fs","makedev","tar","utility","xattr","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xyproto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-30T11:10:44.000Z","updated_at":"2025-06-24T08:16:02.000Z","dependencies_parsed_at":"2024-10-19T02:06:22.691Z","dependency_job_id":"89d97290-8ee4-4dcc-95b4-37a12d64ac54","html_url":"https://github.com/xyproto/metatar","commit_stats":{"total_commits":43,"total_committers":3,"mean_commits":"14.333333333333334","dds":0.2093023255813954,"last_synced_commit":"2cc1938451a918e296baa7511d3bd8a92a6e5390"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/xyproto/metatar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmetatar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmetatar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmetatar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmetatar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyproto","download_url":"https://codeload.github.com/xyproto/metatar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmetatar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267723294,"owners_count":24134103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpio","distro-tools","fakeroot","genext2fs","makedev","tar","utility","xattr","yaml"],"created_at":"2024-10-01T15:22:30.461Z","updated_at":"2025-07-29T17:12:40.089Z","avatar_url":"https://github.com/xyproto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MetaTAR\n\n[![Software License](https://img.shields.io/badge/license-BSD-brightgreen.svg?style=flat-square)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/xyproto/metatar?style=flat-square)](https://goreportcard.com/report/github.com/xyproto/metatar)\n\nMetaTAR can extract metadata from a tar archive and save it as a YAML file.\n\nThe YAML file can then be edited and applied to the original tar archive, in order to produce a new tar archive with changed metadata.\n\n**This can be useful for creating filesystem images with device files without having to use `fakeroot` and `mknod`.**\n\nIt's also useful for checking in data about file owners and permissions into git. It makes it easier to compare changes and see who changed what.\n\nIt can also be used for converting a tar file to a standalone YAML file and back, using base64 encoding for the file data. This produces large, but highly patchable and diffable files. Use `tar --sort=name` to archive files in sorted order.\n\nWhen applying metadata, a cpio (newc format) file can be produced instead.\n\nMetaTAR can list the contents of both tar and cpio (newc) files.\n\nNote that CPIO archives are ordered, and that files/directories must exist before relative symlinks for them appear in the archive.\n\n\u003c!--\n## Simple example\n\n\u003ca href=\"https://asciinema.org/a/bmsk91mof9cl9ccra7jc7pcs9\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/xyproto/metatar/main/img/metatar.gif\" style=\"margin-left: 2em\" alt=\"asciinema screencast\"\u003e\u003c/a\u003e\n--\u003e\n\n## Quick installation\n\nIf you have a recent version of `go` installed:\n\n    go install github.com/xyproto/metatar@latest\n\n## Usage information\n\n\n```\nmetatar\n\nUsage:\n  metatar -s | --save [(-f | --force)] [(-v | --verbose)] [(-d | --data)] [(-e | --expand)] [(-r | --root)] \u003ctarfile\u003e \u003cyamlfile\u003e\n  metatar -a | --apply [(-f | --force)] [(-v | --verbose)] [(-d | --data)] [(-c | --cpio)] \u003ctarfile\u003e \u003cyamlfile\u003e \u003cnewfile\u003e\n  metatar -g | --generate [(-f | --force)] [(-v | --verbose)] \u003cyamlfile\u003e \u003cnewfile\u003e\n  metatar -l | --list \u003ctarfile\u003e\n  metatar -p | --listcpio \u003ccpiofile\u003e\n  metatar -y | --yaml [(-v | --verbose)] [(-d | --data)] [(-e | --expand)] [(-r | --root)] \u003ctarfile\u003e\n  metatar -m | --merge [(-f | --force)] [(-v | --verbose)] \u003cyamlfile1\u003e \u003cyamlfile2\u003e \u003cnewfile\u003e\n  metatar -h | --help\n  metatar -V | --version\n\nOptions:\n  -h --help        Show this screen.\n  -V --version     Show version.\n  -s --save        Save the tar metadata to a YAML file.\n  -a --apply       Apply YAML metadata to tar file.\n  -l --list        List the contents of a tar file.\n  -p --listcpio    List the contents of a cpio/newc file.\n  -y --yaml        Output YAML metadata.\n  -f --force       Overwrite a file if it already exists.\n  -v --verbose     More verbose output.\n  -d --data        Add file data as base64 encoded strings.\n  -e --expand      Expand the metadata to include all possible fields.\n  -g --generate    Generate a new tar file from a given YAML file.\n  -r --root        Set all permissions to root, UID/GID 0\n  -m --merge       Merge two YAML files. Let the second file override the first.\n  -c --cpio        Output a cpio/newc file instead of tar.\n  -n --nouser      Don't output User, Group, UID and GID fields.\n  -o --noskip      Don't skip empty files.\n\nPossible values for the 'type:' field in the YAML file:\n  \"regular file\"\t\t\"regular file (A)\"\t\t\t\"hard link\"\n  \"symlink\"\t\t\t\"character device node\"\t\t\t\"block device node\"\n  \"directory\"\t\t\t\"fifo node\"\t\t\t\t\"reserved\"\n  \"extended header\"\t\t\"global extended header\"\t\t\"sparse file\"\n  \"unknown tar entry\"\t\t\"next file has a long name\"\n  \"next file symlinks to a file with a long name\"\n\nPossible commands for files in the YAML file:\n  \"Skip: true\", for skipping the file when writing the new archive file.\n  \"Rename: newfilename.txt\", for renaming a file.\n  \"Strip: true\", for stripping newlines.\n  \"StripComments: true\", for stripping lines beginning with \"#\" (but not #!).\n```\n\n## Typeflags\n\nWhen files are stored in a tar archive, an unsigned 8-bit int is used to tell which type of file is being stored.\n\nPossible values for the `Type` field in the YAML file:\n\n* `\"regular file\"`\n* `\"regular file (A)\"`\n* `\"hard link\"`\n* `\"symlink\"`\n* `\"character device node\"`\n* `\"block device node\"`\n* `\"directory\"`\n* `\"fifo node\"`\n* `\"reserved\"`\n* `\"extended header\"`\n* `\"global extended header\"`\n* `\"next file has a long name\"`\n* `\"next file symlinks to a file with a long name\"`\n* `\"sparse file\" and \"unknown tar entry\"`\n\n\n## Merging metadata\n\nIf two metadata YAML files are combined to a single file, it's the one at the bottom of the new file that counts.\nPrevious entries for the same filename are disregarded.\n\nSuch a combined file can be applied to a tar file, from which the metadata can be extracted again, to get a merged metadata file.\n\nThis is experimental and may be problematic.\n\n## Omitted fields\n\nSeveral fields in the YAML metadata are omitted, unless an `-e` or `--expand` flag is provided.\n\n### Renaming files\n\n`Rename:` can be used to provide a different filename. Example:\n\n    - Filename: test.txt\n      Rename: test2.txt\n\nWhen applied, `test.txt` from the source archive will be named `test2.txt` in the resulting archive.\n\n### Symbolic links\n\n`Linkname:` can be used to provide a filename that the resulting file will link to. Example:\n\n    - Filename: profile\n      Linkname: /etc/profile\n\nWhen the resulting archive is extracted, the `profile` file will link to `/etc/profile` (soft link).\n\n### Deleting files\n\n`Skip:` can be used to omit a file in the resulting archive. Example:\n\n    - Filename: README.md\n      Skip: true\n\nWhen applied, `README.md` will not be included in the resulting archive.\n\n### Base64 encoded body\n\n`Body:` can be used to provide the contents for a file as a base64 encoded string.\n\n`Size:` is optional, but the number provided must match the length of the decoded data.\n\nExample file:\n\n    Contents:\n    - Filename: hello.txt\n      Body: SGVsbG8sIFdvcmxkIQo=\n\n### Xattrs\n\n`Xattrs:` is optional. Generate metadata with `-e` from a tar file with files that uses Xattrs for an example.\n\n### Device nodes\n\n`Devmajor:` and `Devminor:` can be set to a number if the `Type:` is set to **either** `character device node` **or** `block device node`. The resulting tarball may require root access when being extracted. The file body should be empty.\n\nExample:\n\n    Contents:\n    - Filename: /dev/ttyS0\n      Type: character device node\n      Devmajor: 4\n      Devminor: 64\n      Mode: 0660\n\n## From a tar file to only YAML metadata and back\n\nIt is possible to use standalone YAML, without corresponding tar file. This is experimental and the YAML file will be relatively large.\n\nFrom `.tar` to `.yaml` (including file data):\n\n    metatar -sd input.tar data.yaml\n\nFrom `.yaml` to `.tar`:\n\n    metatar -g data.yaml output.tar\n\n## Known issues\n\n* If __files__ are added to the metadata with a path, like for instance `usr/bin/filename`, then both `usr/` and `usr/bin/` are created automatically. However, if __empty directories__ are added, the parent directories are not created automatically and has to be added manually to the metadata.\n\n## General information\n\n* Version: 1.9.1\n* License: BSD-3\n* Author: Alexander F. Rødseth\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fmetatar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyproto%2Fmetatar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fmetatar/lists"}