deb-rust

Crates.iodeb-rust
lib.rsdeb-rust
version0.1.2
sourcesrc
created_at2023-01-25 04:53:20.616715
updated_at2023-02-04 23:01:14.54214
descriptionRust library for building and reading Deb packages
homepage
repositoryhttps://codeberg.org/notsludgebomb/deb-rust
max_upload_size
id767135
size90,045
(NotSludgeBomb)

documentation

README

deb-rust

A pure Rust library for building and reading Deb packages.

deb-rust provides an easy to use, programmatic interface for reading and writing Deb packages. It currently supports only binary deb packages.

You can use deb-rust via crates.io

Examples

Writing

use std::fs::File;
use deb_rust::*;
use deb_rust::binary::*;

fn main() -> std::io::Result<()> {
    let mut package = DebPackage::new("example");
    
    package = package
        .set_version("0.1.0")
        .set_description("deb-rust example")
        .set_architecture(DebArchitecture::Amd64)
        .with_depend("bash")
        .with_file(DebFile::from_path(
            "target/release/example",
            "/usr/bin/example",
        )?);
        
    package.build()?.write(File::create("example.deb")?)?;
    
    Ok(())
}

Reading

use std::fs;
use std::fs::File;
use deb_rust::*;
use deb_rust::binary::*;

fn main() -> std::io::Result<()> {
    let package = DebPackage::from(File::open("example.deb")?)?;
    
    let name = package.name();
    let version = package.version();
    
    for file in package.files() {
        fs::write(file.path(), file.contents())?;
    }
    
    Ok(())
}

Reading and Writing

use std::fs::File;
use deb_rust::*;
use deb_rust::binary::*;

fn main() -> std::io::Result<()> {
    let mut package = DebPackage::from(File::open("example.deb")?)?;

    package = package
        .set_name("rename")
        .set_description("some example idfk");
        
    package.build()?.write(File::create("new.deb")?)?;
    
    Ok(())
}
Commit count: 0

cargo fmt