fn generate_control(archive: &mut Archive, options: &Config, listener: &mut dyn Listener) -> CDResult<()> {
    // Create and return the handle to the control file with write access.
    let mut control: Vec<u8> = Vec::with_capacity(1024);

    // Write all of the lines required by the control file.
    writeln!(&mut control, "Package: {}", options.deb_name)?;
    writeln!(&mut control, "Version: {}", options.deb_version)?;
    writeln!(&mut control, "Architecture: {}", options.architecture)?;
    if let Some(ref repo) = options.repository {
        if repo.starts_with("http") {
            writeln!(&mut control, "Vcs-Browser: {}", repo)?;
        }
        if let Some(kind) = options.repository_type() {
            writeln!(&mut control, "Vcs-{}: {}", kind, repo)?;
        }
    }
    if let Some(homepage) = options.homepage.as_ref().or(options.documentation.as_ref()) {
        writeln!(&mut control, "Homepage: {}", homepage)?;
    }
    if let Some(ref section) = options.section {
        writeln!(&mut control, "Section: {}", section)?;
    }
    writeln!(&mut control, "Priority: {}", options.priority)?;
    control.write_all(b"Standards-Version: 3.9.4\n")?;
    writeln!(&mut control, "Maintainer: {}", options.maintainer)?;

    let installed_size = options.assets.resolved
        .iter()
        .filter_map(|m| m.source.len())
        .sum::<u64>() / 1024;

    writeln!(&mut control, "Installed-Size: {}", installed_size)?;

    writeln!(&mut control, "Depends: {}", options.get_dependencies(listener)?)?;

    if let Some(ref build_depends) = options.build_depends {
        writeln!(&mut control, "Build-Depends: {}", build_depends)?;
    }

    if let Some(ref conflicts) = options.conflicts {
        writeln!(&mut control, "Conflicts: {}", conflicts)?;
    }
    if let Some(ref breaks) = options.breaks {
        writeln!(&mut control, "Breaks: {}", breaks)?;
    }
    if let Some(ref replaces) = options.replaces {
        writeln!(&mut control, "Replaces: {}", replaces)?;
    }
    if let Some(ref provides) = options.provides {
        writeln!(&mut control, "Provides: {}", provides)?;
    }

    write!(&mut control, "Description:")?;
    for line in options.description.split_by_chars(79) {
        writeln!(&mut control, " {}", line)?;
    }

    if let Some(ref desc) = options.extended_description {
        for line in desc.split_by_chars(79) {
            writeln!(&mut control, " {}", line)?;
        }
    }
    control.push(10);

    // Add the control file to the tar archive.
    archive.file("./control", &control, 0o644)?;
    Ok(())
}
/// Generates the control file that obtains all the important information about the package.
Generates the control file that obtains all the important information about the package.
Generates the control file that obtains all the important information about the package .
fn generate_control(archive: &mut Archive, options: &Config, listener: &mut dyn Listener) -> CDResult<()> {
    // Create and return the handle to the control file with write access.
    let mut control: Vec<u8> = Vec::with_capacity(1024);
    // Write all of the lines required by the control file.
    writeln!(&mut control, "Package: {}", options.deb_name)?;
    writeln!(&mut control, "Version: {}", options.deb_version)?;
    writeln!(&mut control, "Architecture: {}", options.architecture)?;
    if let Some(ref repo) = options.repository {
        if repo.starts_with("http") {
            writeln!(&mut control, "Vcs-Browser: {}", repo)?;
        }
        if let Some(kind) = options.repository_type() {
            writeln!(&mut control, "Vcs-{}: {}", kind, repo)?;
        }
    }
    if let Some(homepage) = options.homepage.as_ref().or(options.documentation.as_ref()) {
        writeln!(&mut control, "Homepage: {}", homepage)?;
    }
    if let Some(ref section) = options.section {
        writeln!(&mut control, "Section: {}", section)?;
    }
    writeln!(&mut control, "Priority: {}", options.priority)?;
    control.write_all(b"Standards-Version: 3.9.4\n")?;
    writeln!(&mut control, "Maintainer: {}", options.maintainer)?;
    let installed_size = options.assets.resolved
        .iter()
        .filter_map(|m| m.source.len())
        .sum::<u64>() / 1024;
    writeln!(&mut control, "Installed-Size: {}", installed_size)?;
    writeln!(&mut control, "Depends: {}", options.get_dependencies(listener)?)?;
    if let Some(ref build_depends) = options.build_depends {
        writeln!(&mut control, "Build-Depends: {}", build_depends)?;
    }
    if let Some(ref conflicts) = options.conflicts {
        writeln!(&mut control, "Conflicts: {}", conflicts)?;
    }
    if let Some(ref breaks) = options.breaks {
        writeln!(&mut control, "Breaks: {}", breaks)?;
    }
    if let Some(ref replaces) = options.replaces {
        writeln!(&mut control, "Replaces: {}", replaces)?;
    }
    if let Some(ref provides) = options.provides {
        writeln!(&mut control, "Provides: {}", provides)?;
    }
    write!(&mut control, "Description:")?;
    for line in options.description.split_by_chars(79) {
        writeln!(&mut control, " {}", line)?;
    }
    if let Some(ref desc) = options.extended_description {
        for line in desc.split_by_chars(79) {
            writeln!(&mut control, " {}", line)?;
        }
    }
    control.push(10);
    // Add the control file to the tar archive.
    archive.file("./control", &control, 0o644)?;
    Ok(())
}
fn generate_control ( archive : & mut Archive , options : & Config , listener : & mut dyn Listener ) -> CDResult < ( ) > { // Create and return the handle to the control file with write access. let mut control : Vec < u8 > = Vec :: with_capacity ( 1024 ) ; // Write all of the lines required by the control file. writeln ! ( mut control " " options deb_name ) ? ; writeln ! ( mut control " " options deb_version ) ? ; writeln ! ( mut control " " options architecture ) ? ; if let Some ( ref repo ) = options . repository { if repo . starts_with ( " " ) { writeln ! ( mut control " " repo ) ? ; } if let Some ( kind ) = options . repository_type ( ) { writeln ! ( mut control " " kind repo ) ? ; } } if let Some ( homepage ) = options . homepage . as_ref ( ) . or ( options . documentation . as_ref ( ) ) { writeln ! ( mut control " " homepage ) ? ; } if let Some ( ref section ) = options . section { writeln ! ( mut control " " section ) ? ; } writeln ! ( mut control " " options priority ) ? ; control . write_all ( b" \n " ) ? ; writeln ! ( mut control " " options maintainer ) ? ; let installed_size = options . assets . resolved . iter ( ) . filter_map ( | m | m . source . len ( ) ) . sum :: < u64 > ( ) / 1024 ; writeln ! ( mut control " " installed_size ) ? ; writeln ! ( mut control " " options get_dependencies ( listener ) ) ? ; if let Some ( ref build_depends ) = options . build_depends { writeln ! ( mut control " " build_depends ) ? ; } if let Some ( ref conflicts ) = options . conflicts { writeln ! ( mut control " " conflicts ) ? ; } if let Some ( ref breaks ) = options . breaks { writeln ! ( mut control " " breaks ) ? ; } if let Some ( ref replaces ) = options . replaces { writeln ! ( mut control " " replaces ) ? ; } if let Some ( ref provides ) = options . provides { writeln ! ( mut control " " provides ) ? ; } write ! ( mut control " " ) ? ; for line in options . description . split_by_chars ( 79 ) { writeln ! ( mut control " " line ) ? ; } if let Some ( ref desc ) = options . extended_description { for line in desc . split_by_chars ( 79 ) { writeln ! ( mut control " " line ) ? ; } } control . push ( 10 ) ; // Add the control file to the tar archive. archive . file ( " " , & control , 0o644 ) ? ; Ok ( ( ) ) }
Generates the control file that obtains all the important information about the package.
Generates the control file that obtains all the important information about the package .
archive
&mut Archive
options
&Config
listener
&mut dyn Listener
archive
&mut Archive
options
&Config
listener
&mut dyn Listener