diff options
author | Norbert Preining <norbert@preining.info> | 2019-10-02 03:01:29 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-10-02 03:01:29 +0000 |
commit | d94b7a8c132734a1bc4046d54a75c7882c4c2619 (patch) | |
tree | 7326afd537da7739f5e5127da75d0766835e3c3e /support/pkgcheck/src/main.rs | |
parent | 31d84cec65917cfc6ef446f1bf6031cff7c6dc7b (diff) |
CTAN sync 201910020301
Diffstat (limited to 'support/pkgcheck/src/main.rs')
-rw-r--r-- | support/pkgcheck/src/main.rs | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/support/pkgcheck/src/main.rs b/support/pkgcheck/src/main.rs index a7be277330..c69423252d 100644 --- a/support/pkgcheck/src/main.rs +++ b/support/pkgcheck/src/main.rs @@ -103,17 +103,17 @@ fn filename_has_bad_chars(entry: &DirEntry) -> Option<(usize, char)> { for (i, c) in s.char_indices() { match c { - '\x00'...'\x1f' => return Some((i, c)), + '\x00'..='\x1f' => return Some((i, c)), ' ' | '!' | '"' | '#' | '$' | '%' | '&' | '\'' => return Some((i, c)), '(' | ')' | '*' => return Some((i, c)), '+' | ',' | '-' | '.' => (), - '0'...'9' => (), + '0'..='9' => (), ':' | ';' | '<' | '=' | '>' | '?' | '@' => return Some((i, c)), - 'A'...'Z' => (), + 'A'..='Z' => (), '[' | '\\' | ']' | '^' => return Some((i, c)), '_' => (), '`' => return Some((i, c)), - 'a'...'z' => (), + 'a'..='z' => (), '{' | '|' | '}' | '~' => return Some((i, c)), '/' => return None, _ => return Some((i, c)), @@ -519,7 +519,6 @@ fn check_generated_files(entry: &str, generated: &mut HashMap<PathBuf, PathBuf>) } Err(e) => println!("Error opening file {}: {:?}", entry, e), } - return; } fn x_bit_set(p: u32) -> bool { @@ -582,6 +581,19 @@ fn check_tds_archive( } }; + // We have a discrepancy between + // TDS zip archive name: babel-base.tds.zip + // and package name: babel + // which yields a false test when checking for the package name + // the path names of the TDS zip archive files. + // Therefore, we correct here. + let real_pkg_name = if pkg_name == "babel-base" { + "babel" + } else { + pkg_name + }; + + let tmp_dir = TempDir::new("pkgcheck")?; let tmp_dir_offset = tmp_dir.path().to_str().unwrap().len() + 1; unzip_tds_archive(tds_zip, tmp_dir.path().to_str().unwrap()); @@ -682,13 +694,16 @@ fn check_tds_archive( if is_temporary_file(&dir_entry_str) { e0008!(dir_entry_display); } + if fsize > 40 * 1024 * 1024 { + w0006!(dir_entry_display, fsize / 1024 / 1024); + } // if the path doesn't contain a man page... if dir_entry_str.find("/man/").is_none() { - let pkg_name_s = format!("/{}/", pkg_name); + let pkg_name_s = format!("/{}/", real_pkg_name); // ...then we want to have the package name in the path if dir_entry_str.find(&pkg_name_s).is_none() { - e0028!(pkg_name, dir_entry_display); + e0028!(real_pkg_name, dir_entry_display); } } @@ -833,8 +848,8 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<Hashes> { i0002!(root); // This hash contains all package file names. - // - // PathBuf: the full path starting at the directory specified at the command line + // + // PathBuf: the full path starting at the directory specified at the command line // Metadata: the meta data of the file // String: the file name without any directory part // ReadmeKind: is it a certain README, file or symlink? @@ -871,7 +886,7 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<Hashes> { continue; } - // this is the file_name without the directory part + // this is the file_name without the directory part // unwrap() is ok here as we covered potential UTF-8 related errors // above in the definition of dir_entry_str let file_name = dir_entry.file_name().to_str().unwrap().to_string(); @@ -992,6 +1007,7 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<Hashes> { .push(PathBuf::from(dir_entry_str)); } + // detecting large files in package directory if is_readme(&dir_entry) { // We want to deal with README files only if they are @@ -1084,6 +1100,10 @@ fn check_package(root: &str, tds_zip: &Option<String>) -> Option<Hashes> { e0005!(dir_entry_str); continue; } + if fsize > 40 * 1024 * 1024 { + w0005!(dir_entry_str, fsize / 1024 / 1024); + continue; + } let p = get_perms(&path); if !owner_has(p, 4) { |