{"id":15051195,"url":"https://github.com/cnstr/apt-parser","last_synced_at":"2026-01-02T10:02:51.321Z","repository":{"id":65830070,"uuid":"600883450","full_name":"cnstr/apt-parser","owner":"cnstr","description":"Parse APT's Key-Value files","archived":false,"fork":false,"pushed_at":"2023-04-24T06:12:22.000Z","size":1942,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-25T21:20:25.934Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnstr.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":"2023-02-12T21:44:33.000Z","updated_at":"2023-02-12T22:20:07.000Z","dependencies_parsed_at":"2024-09-24T21:31:41.475Z","dependency_job_id":"010fa62b-d41c-4564-9ba3-2713453aeb6c","html_url":"https://github.com/cnstr/apt-parser","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":0.368421052631579,"last_synced_commit":"a632e6ae13f0048c32eef7923455606338651eed"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnstr%2Fapt-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnstr","download_url":"https://codeload.github.com/cnstr/apt-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243513322,"owners_count":20302928,"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","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":[],"created_at":"2024-09-24T21:31:36.531Z","updated_at":"2026-01-02T10:02:51.241Z","avatar_url":"https://github.com/cnstr.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APT Parser\n\u003e\n\u003e Looking for the Typescript Version? [It's been moved here...](https://github.com/cnstr/apt-parser-ts)\n\n`apt-parser` is a library for parsing [APT](https://en.wikipedia.org/wiki/APT_(software)) list files.\u003cbr\u003e\nAn APT repository normally consists of a Release file, Packages file, and compressed binary packages.\u003cbr\u003e\nThe library is able to parse these files and return them as [`serde`](https://serde.rs) serialized structs.\u003cbr\u003e\n\n### Installation\n\nMake sure you have a modern version of Rust (1.56+) using `rustup`.\u003cbr\u003e\nThen, add the following to your `Cargo.toml`:\u003cbr\u003e\n\n```toml\n[dependencies]\n# You can also use the latest version\napt-parser = \"1.0.0\"\n```\n\n### Release Parsing\n\nRelease files are the main entry point for an APT repository.\u003cbr\u003e\nThe `Release` struct has strict types for all documented fields in the [`Release` file](https://wiki.debian.org/DebianRepository/Format#A.22Release.22_files).\u003cbr\u003e\nIf you need to access a field that isn't defined, you can use the `get` method.\u003cbr\u003e\nHere's a simple example:\u003cbr\u003e\n\n```rust\nuse apt_parser::Release;\nuse surf::get;\n\nlet data = get(\"http://archive.ubuntu.com/ubuntu/dists/jammy/Release\")\n    .await?\n    .body_string()\n    .await?;\n\nlet release = match Release::from(data) {\n    Ok(release) =\u003e release,\n    Err(err) =\u003e panic!(\"Failed to parse Release file: {}\", err),\n}\n\nassert_eq!(release.origin, \"Ubuntu\");\nassert_eq!(release.version, \"22.04\");\nassert_eq!(release.get(\"InvalidKey\"), None);\n```\n\n```rust\nstruct Release {\n    architectures: Vec\u003cString\u003e, // =\u003e Architectures\n    no_support_for_architecture_all: Option\u003cbool\u003e, // =\u003e No-Support-For-Architecture-All\n    description: Option\u003cString\u003e, // =\u003e Description\n    origin: Option\u003cString\u003e, // =\u003e Origin\n    label: Option\u003cString\u003e, // =\u003e Label\n    suite: Option\u003cString\u003e, // =\u003e Suite\n    version: Option\u003cString\u003e, // =\u003e Version\n    codename: Option\u003cString\u003e, // =\u003e Codename\n    date: Option\u003cString\u003e, // =\u003e Date\n    valid_until: Option\u003cString\u003e, // =\u003e Valid-Until\n    components: Vec\u003cString\u003e, // =\u003e Components\n    md5sum: Option\u003cVec\u003cReleaseHash\u003e\u003e, // =\u003e MD5Sum\n    sha1sum: Option\u003cVec\u003cReleaseHash\u003e\u003e, // =\u003e SHA1\n    sha256sum: Option\u003cVec\u003cReleaseHash\u003e\u003e, // =\u003e SHA256\n    sha512sum: Option\u003cVec\u003cReleaseHash\u003e\u003e, // =\u003e SHA512\n    not_automatic: Option\u003cbool\u003e, // =\u003e NotAutomatic\n    but_automatic_upgrades: Option\u003cbool\u003e, // =\u003e ButAutomaticUpgrades\n    acquire_by_hash: Option\u003cbool\u003e, // =\u003e Acquire-By-Hash\n    signed_by: Option\u003cString\u003e, // =\u003e Signed-By\n    packages_require_authorization: Option\u003cbool\u003e, // =\u003e Packages-Require-Authorization\n\n    fn from(data: \u0026str) -\u003e Result\u003cSelf, APTError\u003e; // =\u003e Parse a Release file\n    fn get(\u0026self, key: \u0026str) -\u003e Option\u003c\u0026str\u003e; // =\u003e Retrieve a raw field value\n}\n\n// A struct for holding the hash information for a Release file\nstruct ReleaseHash {\n    filename: String,\n    hash: String,\n    size: u64,\n}\n```\n\n### Control File Parsing\n\nControl files are used to describe the contents of a binary package.\u003cbr\u003e\nThe `Control` struct has strict types for all documented fields in the [`control` file](https://www.debian.org/doc/debian-policy/ch-controlfields.html).\u003cbr\u003e\nIf you need to access a field that isn't defined, you can use the `get` method.\u003cbr\u003e\nHere's a simple example:\u003cbr\u003e\n\n```rust\nuse apt_parser::Control;\n\nlet data = \"\nPackage: com.amywhile.signalreborn\nArchitecture: iphoneos-arm\nDescription: Visualise your nearby cell towers\nDepends: firmware (\u003e= 12.2) | org.swift.libswift\nMaintainer: Amy While \u003csupport@anamy.gay\u003e\nSection: Applications\nVersion: 2.2.1-2\nInstalled-Size: 1536\nCustom-Key: cool-value\n\";\n\nlet control = match Control::from(data) {\n    Ok(control) =\u003e control,\n    Err(err) =\u003e panic!(\"Failed to parse Control file: {}\", err),\n}\n\nassert_eq!(control.version, \"2.2.1-2\");\nassert_eq!(control.package, \"com.amywhile.signalreborn\");\nassert_eq!(control.get(\"Custom-Key\"), Some(\"cool-value\"));\nassert_eq!(control.get(\"Invalid-Key\"), None);\n```\n\n```rust\nstruct Control {\n    package: String, // =\u003e Package\n    source: Option\u003cString\u003e, // =\u003e Source\n    version: String, // =\u003e Version\n    section: Option\u003cString\u003e, // =\u003e Section\n    priority: Option\u003cString\u003e, // =\u003e Priority\n    architecture: String, // =\u003e Architecture\n    is_essential: Option\u003cbool\u003e, // =\u003e Essential\n    depends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Depends\n    pre_depends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Pre-Depends\n    recommends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Recommends\n    suggests: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Suggests\n    replaces: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Replaces\n    enhances: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Enhances\n    breaks: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Breaks\n    conflicts: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Conflicts\n    installed_size: Option\u003ci64\u003e, // =\u003e Installed-Size\n    maintainer: Option\u003cString\u003e, // =\u003e Maintainer\n    description: Option\u003cString\u003e, // =\u003e Description\n    homepage: Option\u003cString\u003e, // =\u003e Homepage\n    built_using: Option\u003cString\u003e, // =\u003e Built-Using\n    package_type: Option\u003cString\u003e, // =\u003e Package-Type\n    tags: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Tags\n\n    fn from(data: \u0026str) -\u003e Result\u003cSelf, APTError\u003e; // =\u003e Parse a Control file\n    fn get(\u0026self, key: \u0026str) -\u003e Option\u003c\u0026str\u003e; // =\u003e Retrieve a raw field value\n}\n```\n\n### Packages Parsing\n\nPackages files are used to describe the contents of a repository.\u003cbr\u003e\nThe `Packages` struct implements an iterator and has methods for accessing the packages.\u003cbr\u003e\nThe `Package` struct has strict types for all documented fields in the [`Packages` file](https://wiki.debian.org/DebianRepository/Format#A.22Packages.22_Indices).\u003cbr\u003e\nIf you need to access a field that isn't defined, you can use the `get` method.\u003cbr\u003e\nHere's a simple example:\u003cbr\u003e\n\n```rust\nuse apt_parser::Packages;\nuse surf::get;\n\nlet data = get(\"https://repo.chariz.com/Packages\")\n    .await?\n    .body_string()\n    .await?;\n\nlet packages = match Packages::from(\u0026data) {\n    Ok(packages) =\u003e packages,\n    Err(err) =\u003e panic!(\"Failed to parse Packages file: {}\", err),\n}\n\nassert_eq!(packages.len(), 419);\n\nfor package in packages {\n    println!(\"{}: {}\", package.package, package.version);\n}\n```\n\n```rust\nstruct Packages {\n    packages: Vec\u003cPackage\u003e,\n\n    fn from(data: \u0026str) -\u003e Result\u003cSelf, APTError\u003e; // =\u003e Parse a Packages file\n    fn len(\u0026self) -\u003e usize; // =\u003e Get the number of packages\n}\n\nimpl Iterator for Packages;\nimpl Index for Packages;\n\nstruct Package {\n    package: String, // =\u003e Package\n    source: Option\u003cString\u003e, // =\u003e Source\n    version: String, // =\u003e Version\n    section: Option\u003cString\u003e, // =\u003e Section\n    priority: Option\u003cString\u003e, // =\u003e Priority\n    architecture: String, // =\u003e Architecture\n    is_essential: Option\u003cbool\u003e, // =\u003e Essential\n    depends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Depends\n    pre_depends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Pre-Depends\n    recommends: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Recommends\n    suggests: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Suggests\n    replaces: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Replaces\n    enhances: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Enhances\n    breaks: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Breaks\n    conflicts: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Conflicts\n    installed_size: Option\u003ci64\u003e, // =\u003e Installed-Size\n    maintainer: Option\u003cString\u003e, // =\u003e Maintainer\n    description: Option\u003cString\u003e, // =\u003e Description\n    homepage: Option\u003cString\u003e, // =\u003e Homepage\n    built_using: Option\u003cString\u003e, // =\u003e Built-Using\n    package_type: Option\u003cString\u003e, // =\u003e Package-Type\n    tags: Option\u003cVec\u003cString\u003e\u003e, // =\u003e Tags\n    filename: String, // =\u003e Filename\n    size: i64, // =\u003e Size\n    md5sum: Option\u003cString\u003e, // =\u003e MD5sum\n    sha1sum: Option\u003cString\u003e, // =\u003e SHA1\n    sha256sum: Option\u003cString\u003e, // =\u003e SHA256\n    sha512sum: Option\u003cString\u003e, // =\u003e SHA512\n    description_md5sum: Option\u003cString\u003e, // =\u003e Description-md5\n\n    fn get(\u0026self, key: \u0026str) -\u003e Option\u003c\u0026str\u003e; // =\u003e Retrieve a raw field value\n}\n```\n\n\u003e Copyright (c) 2023 Aarnav Tale\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnstr%2Fapt-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnstr%2Fapt-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnstr%2Fapt-parser/lists"}