diff options
Diffstat (limited to 'support/pkgcheck/src/main.rs')
-rw-r--r-- | support/pkgcheck/src/main.rs | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/support/pkgcheck/src/main.rs b/support/pkgcheck/src/main.rs index de0d3b3cb6..cbb678729f 100644 --- a/support/pkgcheck/src/main.rs +++ b/support/pkgcheck/src/main.rs @@ -177,10 +177,8 @@ fn check_readme_inner(fname: &str, f: &std::fs::File) -> bool { result } -fn is_readme(entry: &DirEntry) -> bool { - let r = entry.file_name().to_str().unwrap(); - - match r { +fn is_readme(entry: &str) -> bool { + match entry { "README" | "README.txt" | "README.md" => true, _ => false, } @@ -466,6 +464,7 @@ fn check_generated_files(entry: &str, generated: &mut GeneratedHashMap) { // unwrap() is ok here as we only call this function for files, // specifically .ins or .dtx files let entry_fname = filename(entry).unwrap().to_string(); + // the name of the .ins resp. .dtx without extension let entry_base = &entry_fname[0..entry_fname.len() - 4]; let fhdl = File::open(&entry); @@ -479,32 +478,35 @@ fn check_generated_files(entry: &str, generated: &mut GeneratedHashMap) { gparser::parse_generate(&String::from_utf8_lossy(&buf.clone())) { for fname in found { + // If the filename in the 'file{} statement contains `\jobname` + // we replace jobname with the .dtx resp. .ins filename (without extension) + // before we investigate further + let fname1 = fname.replace("\\jobname", entry_base); + + // If the filename in the generate statement contains a path component + // we ignore it so that a generated file will be reported even if it is + // in a different place in the package directory which sometimes + // happens in uploaded packages + let fname_opt = utils::filename(&fname1); + if fname_opt.is_none() { + continue; + } + let filename = fname_opt.unwrap(); + // As we request a README in the top level directory of // a package we ignore if a README was generated by an // .ins or .dtx file // CAVEAT: If this happens in a subdirectory it could be an error!!!! - if fname == "README" || fname == "README.txt" || fname == "README.md" { + if is_readme(&filename) { continue; } - // If the filename in the 'file{} statement is jobname.<ext> - // we replace jobname with the filename before we investigate further - let fname_x = if fname.starts_with("\\jobname") { - let ext = match get_extension_from_filename(&fname) { - Some(e) => e, - None => "", - }; - format!("{}.{}", entry_base, ext) - } else { - fname.to_string() - }; - - // If the filename in the generate statement contains a path component - // we ignore it so that a generated file will be reported even if it is - // in a different place in the package directory - if let Some(pb) = utils::filename(&fname_x) { - generated.entry(pb.to_string()).or_insert_with(|| entry.to_string()); + // Ignore generated pdf files + if fname.ends_with(".pdf") { + continue; } + + generated.entry(filename.to_string()).or_insert_with(|| entry.to_string()); } }; } @@ -542,7 +544,7 @@ fn check_tds_archive_name(tds_zip: &Option<String>) -> Option<String> { } fn unzip_tds_archive(tds_zip: &str, tmp_dir: &str) { - match run_cmd("/usr/bin/unzip", &["-a", "-q", "-d", tmp_dir, &tds_zip]) { + match run_cmd("unzip", &["-a", "-q", "-d", tmp_dir, &tds_zip]) { CmdReturn { status: true, .. } => (), CmdReturn { status: false, @@ -955,7 +957,7 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<DupHashes> { FileKind::Symlink(pd.clone()), )); } - if is_readme(&dir_entry) { + if is_readme(&file_name) { readme_found = true; file_names.insert( p, @@ -1018,7 +1020,7 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<DupHashes> { .push(PathBuf::from(&dir_entry_str)); } - if is_readme(&dir_entry) { + if is_readme(&file_name) { // We want to deal with README files only if they are // in the root directory of the package. let f = format!( @@ -1302,12 +1304,16 @@ fn print_casefolding(hashes: &HashMap<PathBuf, Vec<(PathBuf, FileKind)>>) { } } -fn print_generated(hashes: &HashMap<PathBuf, Vec<PathBuf>>, generated: &GeneratedHashMap) { +fn print_generated(doublenames: &HashMap<PathBuf, Vec<PathBuf>>, generated: &GeneratedHashMap) { + // `k` is generated by `gen` for (k, gen) in generated.iter() { - let mut path = PathBuf::new(); - path.push(k); - if hashes.contains_key(&path) { - let v = &hashes[&path]; + let path = PathBuf::from(k); + if doublenames.contains_key(&path) { + if k.ends_with(".ins") || k.ends_with(".pdf") { + //println!("key {}, gen {}", k, gen); + continue; + } + let v = &doublenames[&path]; for fname in v { e0019!(fname.to_str().unwrap(), gen.as_str()); } |