/// Generates the copyright file from the license file and adds that to the tar archive.
Generates the copyright file from the license file and adds that to the tar archive.
Generates the copyright file from the license file and adds that to the tar archive .
pub(crate) fn generate_copyright_asset(options: &Config) -> CDResult<Vec<u8>> {
    let mut copyright: Vec<u8> = Vec::new();
    writeln!(&mut copyright, "Upstream Name: {}", options.name)?;
    if let Some(source) = options.repository.as_ref().or(options.homepage.as_ref()) {
        writeln!(&mut copyright, "Source: {}", source)?;
    }
    writeln!(&mut copyright, "Copyright: {}", options.copyright)?;
    if let Some(ref license) = options.license {
        writeln!(&mut copyright, "License: {}", license)?;
    }
    if let Some(ref path) = options.license_file {
        let license_string = fs::read_to_string(options.path_in_workspace(path))
            .map_err(|e| CargoDebError::IoFile("unable to read license file", e, path.to_owned()))?;
        // Skip the first `A` number of lines and then iterate each line after that.
        for line in license_string.lines().skip(options.license_file_skip_lines) {
            // If the line is a space, add a dot, else write the line.
            if line == " " {
                copyright.write_all(b" .\n")?;
            } else {
                copyright.write_all(line.as_bytes())?;
                copyright.write_all(b"\n")?;
            }
        }
    }
    // Write a copy to the disk for the sake of obtaining a md5sum for the control archive.
    Ok(copyright)
}
pub ( crate ) fn generate_copyright_asset ( options : & Config ) -> CDResult < Vec < u8 > > { let mut copyright : Vec < u8 > = Vec :: new ( ) ; writeln ! ( mut copyright " " options name ) ? ; if let Some ( source ) = options . repository . as_ref ( ) . or ( options . homepage . as_ref ( ) ) { writeln ! ( mut copyright " " source ) ? ; } writeln ! ( mut copyright " " options copyright ) ? ; if let Some ( ref license ) = options . license { writeln ! ( mut copyright " " license ) ? ; } if let Some ( ref path ) = options . license_file { let license_string = fs :: read_to_string ( options . path_in_workspace ( path ) ) . map_err ( | e | CargoDebError :: IoFile ( " " , e , path . to_owned ( ) ) ) ? ; // Skip the first `A` number of lines and then iterate each line after that. for line in license_string . lines ( ) . skip ( options . license_file_skip_lines ) { // If the line is a space, add a dot, else write the line. if line == " " { copyright . write_all ( b" \n " ) ? ; } else { copyright . write_all ( line . as_bytes ( ) ) ? ; copyright . write_all ( b" \n " ) ? ; } } } // Write a copy to the disk for the sake of obtaining a md5sum for the control archive. Ok ( copyright ) }
Generates the copyright file from the license file and adds that to the tar archive.
Generates the copyright file from the license file and adds that to the tar archive .
options
&Config