diff options
author | Norbert Preining <norbert@preining.info> | 2022-01-16 03:01:19 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-01-16 03:01:19 +0000 |
commit | a574e957682cad50981ddb567c2a106213dc8672 (patch) | |
tree | cd02ecf7773fd7bad8e7b6cdb07cf2ff437ba59f /support | |
parent | 0cb730e5737ffa35f797eaf75c2613e5ac88617c (diff) |
CTAN sync 202201160301
Diffstat (limited to 'support')
-rw-r--r-- | support/pkgcheck/CHANGES.md | 11 | ||||
-rw-r--r-- | support/pkgcheck/Cargo.toml | 39 | ||||
-rwxr-xr-x | support/pkgcheck/bin/pkgcheck | bin | 6057000 -> 6966792 bytes | |||
-rw-r--r-- | support/pkgcheck/docs/pkgcheck.pdf | bin | 77953 -> 77966 bytes | |||
-rw-r--r-- | support/pkgcheck/docs/title.tex | 2 | ||||
-rw-r--r-- | support/pkgcheck/src/linkcheck.rs | 20 | ||||
-rw-r--r-- | support/pkgcheck/src/main.rs | 55 | ||||
-rw-r--r-- | support/pkgcheck/src/messages/errorsd.rs | 1 | ||||
-rw-r--r-- | support/pkgcheck/src/messages/mod.rs | 263 | ||||
-rw-r--r-- | support/pkgcheck/src/utils.rs | 12 |
10 files changed, 240 insertions, 163 deletions
diff --git a/support/pkgcheck/CHANGES.md b/support/pkgcheck/CHANGES.md index 98c911348a..fc9e145fd2 100644 --- a/support/pkgcheck/CHANGES.md +++ b/support/pkgcheck/CHANGES.md @@ -147,7 +147,7 @@ - unpack TDS zip without -a flag which was introduced in 2.0.1. According to Petra this creates more problems than it solves - revive e0020 which checks for unwanted directories in the top level directory of a TDS zip - archive. + archive. - new error message e0039: no doc/ top level directory in tds zip archive - new error message e0040: too few top level directories in tds zip archive - new error message e0041: map file found in path not starting with `fonts/map/dvips` @@ -161,3 +161,12 @@ - ignore if generated files with ending .html or .css exist (merge request from Vít Novotný). Reason is that documentation could also exist as html. - some code simplifications most of them by clippy recommendations +2022-01-02 + - switch to Rust edition 2021 + - switch from blake2 to blake3 library for checksumming + - add .xray to temporary file endings + - (experimental) when URL checking decode some html entities if they appear in URLs + - unzipping now done internally. /usr/bin/unzip no longer required +2022-01-15 (2.4.0) + - for latex-lab and latex-lab-dev use the real directory name 'latex' resp. + 'latex-dev' when checking path names in the TDS zip archive diff --git a/support/pkgcheck/Cargo.toml b/support/pkgcheck/Cargo.toml index fa6fcc58ae..29048feda9 100644 --- a/support/pkgcheck/Cargo.toml +++ b/support/pkgcheck/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "pkgcheck" -version = "2.3.0" +version = "2.4.0" authors = ["Manfred Lotz <manfred@ctan.org>"] description = "Command-line tool to check packages uploaded to CTAN." license = "MIT/Apache-2.0" -edition = "2018" +readme = "README.md" +edition = "2021" # with this option binaries are smaller # https://doc.rust-lang.org/edition-guide/rust-2018/error-handling-and-panics/aborting-on-panic.html @@ -17,13 +18,13 @@ structopt = "0.3" walkdir = "2.3" scoped_threadpool = "0.1" num_cpus = "1" -blake2 = "0.9" +blake3 = "1.2.0" rustc-hash = "1.1" unbytify = "0.2" regex = "1" glob = "0.3" colored = "2" -linkify = "0.7" +linkify = "0.8" reqwest = { version = "0.11", features = ["blocking", "gzip"] } tokio = { version = "1", features = ["full"] } @@ -42,3 +43,33 @@ unicode-bom = "1" url = "2.1" +zip = { version = "0.5", default-features = false } +zip-extensions = "0.6" + +[package.metadata.deb] +section = "utility" +depends = "" +priority = "optional" +assets = [ + ["target/x86_64-unknown-linux-musl/release/pkgcheck", "usr/bin/", "755"], + ["LICENSE-MIT", "usr/share/doc/pkgcheck/", "644"], + ["LICENSE-APACHE", "usr/share/doc/pkgcheck/", "644"], + ["README.md", "usr/share/doc/pkgcheck/README", "644"], + ["docs/pkgcheck.pdf", "usr/share/doc/pkgcheck/pkgcheck.pdf", "644"], +] +extended-description = """\ +A checker for uploaded packages to CTAN +""" + +changelog = "CHANGES.md" + + + +[package.metadata.rpm] +package = "pkgcheck" + +[package.metadata.rpm.cargo] +buildflags = ["--release"] + +[package.metadata.rpm.targets] +pkgcheck = { path = "/usr/bin/pkgcheck" } diff --git a/support/pkgcheck/bin/pkgcheck b/support/pkgcheck/bin/pkgcheck Binary files differindex dbe8182c07..5f7df9aaa2 100755 --- a/support/pkgcheck/bin/pkgcheck +++ b/support/pkgcheck/bin/pkgcheck diff --git a/support/pkgcheck/docs/pkgcheck.pdf b/support/pkgcheck/docs/pkgcheck.pdf Binary files differindex ede6f9fd41..a1f12200dc 100644 --- a/support/pkgcheck/docs/pkgcheck.pdf +++ b/support/pkgcheck/docs/pkgcheck.pdf diff --git a/support/pkgcheck/docs/title.tex b/support/pkgcheck/docs/title.tex index 86ff2b23cc..5a37d84767 100644 --- a/support/pkgcheck/docs/title.tex +++ b/support/pkgcheck/docs/title.tex @@ -1 +1 @@ -\title{pkgcheck Utility, v2.3.0} +\title{pkgcheck Utility, v2.4.0} diff --git a/support/pkgcheck/src/linkcheck.rs b/support/pkgcheck/src/linkcheck.rs index cc7aa36e31..b0b33fb3b2 100644 --- a/support/pkgcheck/src/linkcheck.rs +++ b/support/pkgcheck/src/linkcheck.rs @@ -161,6 +161,22 @@ fn get_links(fname: &str) -> Option<Vec<String>> { None } +fn resolve_entities(url: &str) -> String { + if !url.contains('&') { + return String::from(url); + } + + let v = vec![ + ("ö", "ö"), + ("ü", "ü"), + ]; + let mut url_new = String::from(url); + for (e,r) in v { + url_new = url_new.replace(e, r); + } + url_new +} + // retrieves links in a string and then checks those links fn get_links_inner(s: &str) -> Option<Vec<String>> { let mut finder = LinkFinder::new(); @@ -177,9 +193,9 @@ fn get_links_inner(s: &str) -> Option<Vec<String>> { } // This is a workaround to prevent URLs ending with certain characters - let url = r.trim_end_matches(|c| c == '。' || c == '`'); + let url = resolve_entities(r.trim_end_matches(|c| c == '。' || c == '`')); - links.push(String::from(url)); + links.push(url); } if !links.is_empty() { Some(links) diff --git a/support/pkgcheck/src/main.rs b/support/pkgcheck/src/main.rs index bb8e90b76e..b18fd8793b 100644 --- a/support/pkgcheck/src/main.rs +++ b/support/pkgcheck/src/main.rs @@ -49,7 +49,6 @@ use std::path::Path; use std::path::PathBuf; use std::sync::atomic::{AtomicBool, Ordering}; -use blake2::{Blake2b, Digest}; use rustc_hash::{FxHashMap, FxHashSet}; use std::sync::mpsc::{channel, Sender}; @@ -80,14 +79,14 @@ const BLOCKSIZE: usize = 4096; fn hash_file_inner(path: &Path) -> io::Result<Vec<u8>> { let mut buf = [0u8; BLOCKSIZE]; let mut fp = File::open(&path)?; - let mut digest = Blake2b::default(); + let mut digest = blake3::Hasher::new(); loop { match fp.read(&mut buf)? { 0 => break, - n => digest.update(&buf[..n]), + n => { digest.update(&buf[..n]); }, } } - Ok(digest.finalize().to_vec()) + Ok(digest.finalize().as_bytes().to_vec()) } fn hash_file(fsize: u64, path: PathBuf, tx: &HashSender) { @@ -576,22 +575,22 @@ fn check_tds_archive_name(tds_zip: &Option<String>) -> Option<String> { } } -fn unzip_tds_archive(tds_zip: &str, tmp_dir: &str) { - match run_cmd("unzip", &["-q", "-d", tmp_dir, tds_zip]) { - CmdReturn { status: true, .. } => (), - CmdReturn { - status: false, - output: out, - } => { - if let Some(o) = out { - e0033!(&tds_zip, o); - } else { - e0033!(&tds_zip, "<no error given"); - } - process::exit(1); - } - } -} +// fn unzip_tds_archive(tds_zip: &str, tmp_dir: &str) { +// match run_cmd("unzip", &["-q", "-d", tmp_dir, tds_zip]) { +// CmdReturn { status: true, .. } => (), +// CmdReturn { +// status: false, +// output: out, +// } => { +// if let Some(o) = out { +// e0033!(&tds_zip, o); +// } else { +// e0033!(&tds_zip, "<no error given"); +// } +// process::exit(1); +// } +// } +// } fn check_tds_archive(pkg_name: &str, tds_zip: &str, hashes: &DupHashes) { i0003!(tds_zip); @@ -619,11 +618,13 @@ fn check_tds_archive(pkg_name: &str, tds_zip: &str, hashes: &DupHashes) { let mut pkg_replacements: FxHashMap<&str, &str> = FxHashMap::default(); pkg_replacements.insert("babel-base", "babel"); pkg_replacements.insert("latex-base", "latex"); + pkg_replacements.insert("latex-lab", "latex"); pkg_replacements.insert("latex-tools", "latex"); pkg_replacements.insert("latex-graphics", "latex"); pkg_replacements.insert("latex-amsmath", "latex"); pkg_replacements.insert("latex-firstaid", "latex/firstaid"); pkg_replacements.insert("latex-base-dev", "latex-dev"); + pkg_replacements.insert("latex-lab-dev", "latex-dev"); pkg_replacements.insert("latex-tools-dev", "latex-dev"); pkg_replacements.insert("latex-graphics-dev", "latex-dev"); pkg_replacements.insert("latex-amsmath-dev", "latex-dev"); @@ -643,7 +644,17 @@ fn check_tds_archive(pkg_name: &str, tds_zip: &str, hashes: &DupHashes) { }; let tmp_dir_offset = tmp_dir.path().to_str().unwrap().len() + 1; - unzip_tds_archive(tds_zip, tmp_dir.path().to_str().unwrap()); + let tmp_dir_str = tmp_dir.path().to_str().unwrap(); + // unzip the TDS zip archive into a temporary directory + match ut.unzip(tds_zip, tmp_dir_str) { + Ok(_) => {}, + Err(e) => { + println!("Could not unpack `{}` into directory `{}`", tds_zip, tmp_dir_str); + println!("Error from unzip: {}", e); + e0033!(&tds_zip, e); + process::exit(1) + } + } // in order to compare the package files with the content of the // tds zip archive we need to checksum the files in the tds zip @@ -896,7 +907,7 @@ fn fix_perms(entry: &str) { } i0005!(entry); - let rc = run_cmd("/bin/chmod", &["-v", "ug=rwX,o=rX", entry]); + let rc = run_cmd("chmod", &["-v", "ug=rwX,o=rX", entry]); if rc.status { if let Some(op) = rc.output { diff --git a/support/pkgcheck/src/messages/errorsd.rs b/support/pkgcheck/src/messages/errorsd.rs index 6ef9eed62e..0ea42eb23f 100644 --- a/support/pkgcheck/src/messages/errorsd.rs +++ b/support/pkgcheck/src/messages/errorsd.rs @@ -486,4 +486,3 @@ fonts/map/dvips. "# ) } - diff --git a/support/pkgcheck/src/messages/mod.rs b/support/pkgcheck/src/messages/mod.rs index e3ec350143..f6819f1120 100644 --- a/support/pkgcheck/src/messages/mod.rs +++ b/support/pkgcheck/src/messages/mod.rs @@ -53,57 +53,57 @@ macro_rules! msgid { } macro_rules! f0001 { - () => { + () => {{ error_occured!(); print!( "{} Specify a directory to check (use option -d)\n", msgid!("F0001") ); - }; + }}; } macro_rules! f0002 { - ($fmt1:expr) => { + ($fmt1:expr) => {{ error_occured!(); print!( "{} Specified directory {} does not exist. Exiting...\n", msgid!("F0002"), $fmt1 ); - }; + }}; } macro_rules! f0003 { - ($fmt1:expr) => { + ($fmt1:expr) => {{ error_occured!(); print!( "{} Specified TDS archive {} does not exist or is no file. Exiting...\n", msgid!("F0003"), $fmt1 ); - }; + }}; } macro_rules! f0004 { - ($fmt1:expr) => { + ($fmt1:expr) => {{ error_occured!(); print!( "{} File {} specified as TDS archive is no zip archive. Exiting...\n", msgid!("F0004"), $fmt1 ); - }; + }}; } macro_rules! f0005 { - ($fmt1:expr) => { + ($fmt1:expr) => {{ error_occured!(); print!( "{} Bad filename {} for the tds.zip archive. Exiting...\n", msgid!("F0005"), $fmt1 ); - }; + }}; } // macro_rules! f0006 { @@ -118,18 +118,18 @@ macro_rules! f0005 { // } macro_rules! f0007 { - ($fmt1:expr) => { + ($fmt1:expr) => {{ error_occured!(); print!( "{} Unable to create temporary directory for unzipping the TDS zip archive: {}. Exiting...\n", msgid!("F0007"), $fmt1 ); - }; + }}; } macro_rules! e0001 { - ($fmt1:expr, $fmt2:expr, $fmt3:expr) => { + ($fmt1:expr, $fmt2:expr, $fmt3:expr) => {{ error_occured!(); print!( "{} Bad character {} ({:#02x}) found in file name {} at offset {}\n", @@ -139,11 +139,11 @@ macro_rules! e0001 { $fmt2, $fmt3 ); - }; + }}; } macro_rules! e0002 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} File {} has bad permissions: {}\n", @@ -151,102 +151,102 @@ macro_rules! e0002 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0003 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {} is no text file\n", msgid!("E0003"), $fmt); - }; + }}; } macro_rules! e0004 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} Empty directory {} detected\n", msgid!("E0004"), $fmt); - }; + }}; } macro_rules! e0005 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} Empty file {} detected\n", msgid!("E0005"), $fmt); - }; + }}; } macro_rules! e0006 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} Hidden directory {} detected\n", msgid!("E0006"), $fmt); - }; + }}; } macro_rules! e0006t { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Hidden directory {} detected in TDS zip archive\n", msgid!("E0006"), $fmt ); - }; + }}; } macro_rules! e0007 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} Hidden file {} detected\n", msgid!("E0007"), $fmt); - }; + }}; } macro_rules! e0007t { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Hidden file {} detected in TDS zip archive\n", msgid!("E0007"), $fmt ); - }; + }}; } macro_rules! e0008 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} Temporary file {} detected\n", msgid!("E0008"), $fmt); - }; + }}; } macro_rules! e0008t { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Temporary file {} detected in TDS zip archive\n", msgid!("E0008"), $fmt ); - }; + }}; } macro_rules! e0009 { - () => { + () => {{ error_occured!(); print!( "{} One of README/README.md/README.txt must exist\n", msgid!("E0009") ); - }; + }}; } macro_rules! e0010 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {} is a broken symlink\n", msgid!("E0010"), $fmt); - }; + }}; } macro_rules! e0011 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} Directory {} has bad permissions: {}\n", @@ -254,72 +254,72 @@ macro_rules! e0011 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0012 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} File {} has CRLF line endings\n", msgid!("E0012"), $fmt ); - }; + }}; } macro_rules! e0013 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {} is a socket special file\n", msgid!("E0013"), $fmt); - }; + }}; } macro_rules! e0014 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {} is a fifo file\n", msgid!("E0014"), $fmt); - }; + }}; } macro_rules! e0015 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {} is a block device file\n", msgid!("E0015"), $fmt); - }; + }}; } macro_rules! e0016 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} {} is a character device file\n", msgid!("E0016"), $fmt ); - }; + }}; } macro_rules! e0017 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} PDF error detected in {}\n", msgid!("E0017"), $fmt); - }; + }}; } macro_rules! e0018 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Unwanted directory {} detected\n", msgid!("E0018"), $fmt ); - }; + }}; } macro_rules! e0019 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} {} generated by {} exists\n", @@ -327,22 +327,22 @@ macro_rules! e0019 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0020 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Unwanted directory `{}` detected in the top level directory of a TDS archive\n", msgid!("E0020"), $fmt ); - }; + }}; } macro_rules! e0021 { - ($fmt1:expr, $fmt2:expr, $fmt3:expr) => { + ($fmt1:expr, $fmt2:expr, $fmt3:expr) => {{ error_occured!(); print!( "{} File {} : Error reading in line {}: {}\n", @@ -351,25 +351,24 @@ macro_rules! e0021 { $fmt2, $fmt3 ); - }; + }}; } macro_rules! e0022 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!("{} {}: `{}`\n", msgid!("E0022"), $fmt1, $fmt2); - }; + }}; } - macro_rules! e0023 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} {}\n", msgid!("E0023"), $fmt); - }; + }}; } macro_rules! e0024 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} The TDS zip archive {} has bad permissions: {}\n", @@ -377,33 +376,33 @@ macro_rules! e0024 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0025 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Duplicate names when ignoring letter case for: {}\n", msgid!("E0025"), $fmt ); - }; + }}; } macro_rules! e0026 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} {} : file not in TDS or different in TDS and non-install tree\n", msgid!("E0026"), $fmt ); - }; + }}; } macro_rules! e0027 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} {}: An I/O error occured -> {}\n", @@ -411,11 +410,11 @@ macro_rules! e0027 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0028 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} No directory {} (= package name) found in path {}\n", @@ -423,11 +422,11 @@ macro_rules! e0028 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0029 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} {}: {} encoding with BOM detected\n", @@ -435,11 +434,11 @@ macro_rules! e0029 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0030 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} Symlink {} points to {} which is outside of the package directory tree\n", @@ -447,22 +446,22 @@ macro_rules! e0030 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! e0031 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} File name {} contains invalid UTF-8 character(s)\n", msgid!("E0031"), $fmt ); - }; + }}; } macro_rules! e0033 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} Error `{}` when unpacking tds archive {}. Exiting...\n", @@ -470,51 +469,51 @@ macro_rules! e0033 { $fmt2, $fmt1 ); - }; + }}; } macro_rules! e0034 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Unwanted file `{}` detected in the top level directory of a TDS archive\n", msgid!("E0034"), $fmt ); - }; + }}; } macro_rules! e0035 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Unwanted TDS archive `{}` detected in package directory tree\n", msgid!("E0035"), $fmt ); - }; + }}; } macro_rules! e0036 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} File `{}` not below `source/` or `doc/` top level directory in TDS zip archive\n", msgid!("E0036"), $fmt ); - }; + }}; } macro_rules! e0037 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!("{} File {} has CR line endings\n", msgid!("E0037"), $fmt); - }; + }}; } macro_rules! e0038 { - ($fmt1:expr, $fmt2:expr, $fmt3:expr, $fmt4:expr) => { + ($fmt1:expr, $fmt2:expr, $fmt3:expr, $fmt4:expr) => {{ error_occured!(); print!( "{} File {} has inconsistent line endings: CR={}, LF={}, CRLF={}\n", @@ -524,60 +523,62 @@ macro_rules! e0038 { $fmt3, $fmt4 ); - }; + }}; } macro_rules! e0039 { - () => { + () => {{ error_occured!(); print!("{} No doc/ directory found\n", msgid!("E0039")); - }; + }}; } macro_rules! e0040 { - () => { + () => {{ error_occured!(); - print!("{} Too few top level directories in the TDS zip archive\n", msgid!("E0040")); - }; + print!( + "{} Too few top level directories in the TDS zip archive\n", + msgid!("E0040") + ); + }}; } macro_rules! e0041 { - () => { + () => {{ error_occured!(); print!("{} One or more map file found for the package but none of them is in a path starting with fonts/map/dvips\n", msgid!("E0041")); - }; + }}; } - macro_rules! w0001 { - ($fmt:expr) => { + ($fmt:expr) => {{ print!( "{} Archive as package file detected: {}\n", msgid!("W0001"), $fmt ); - }; + }}; } macro_rules! w0002 { - () => { + () => {{ print!("{} Duplicate files detected\n", msgid!("W0002"),); - }; + }}; } macro_rules! w0003 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Same named files detected in the package directory tree: {}\n", msgid!("W0003"), $fmt ); - }; + }}; } macro_rules! w0004 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} {}: {} encoding with BOM detected\n", @@ -585,115 +586,115 @@ macro_rules! w0004 { $fmt1, $fmt2 ); - }; + }}; } macro_rules! w0005 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} Very large file {} with size {}MiB detected\n", msgid!("W0005"), $fmt1, $fmt2 - ); - }; + ) + }}; } macro_rules! w0006 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ error_occured!(); print!( "{} Very large file {} with size {}MiB detected in TDS zip archive\n", msgid!("W0006"), $fmt1, $fmt2 - ); - }; + ) + }}; } macro_rules! w0007 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Empty directory {} detected in TDS zip archive\n", msgid!("W0007"), $fmt ); - }; + }}; } macro_rules! w0008 { - ($fmt:expr) => { + ($fmt:expr) => {{ error_occured!(); print!( "{} Windows file {} has Unix line endings\n", msgid!("W0008"), $fmt ); - }; + }}; } macro_rules! i0002 { - ($fmt:expr) => { + ($fmt:expr) => {{ print!( "{} {} {}\n", msgid!("I0002"), "Checking package files in directory", $fmt ); - }; + }}; } macro_rules! i0003 { - ($fmt:expr) => { + ($fmt:expr) => {{ print!( "{} {} {}\n", msgid!("I0003"), "Checking TDS zip archive", $fmt ); - }; + }}; } macro_rules! i0004 { - ($fmt:expr) => { + ($fmt:expr) => {{ print!( "{} Correcting line endings for file {}\n", msgid!("I0004"), $fmt ); - }; + }}; } macro_rules! i0005 { - ($fmt:expr) => { + ($fmt:expr) => {{ print!( "{} Correcting permissions for {}\n", msgid!("I0005"), $fmt ); - }; + }}; } macro_rules! i0006 { - () => { + () => {{ print!( "{} Files having one of the following file name endings are regarded as temporary\n", msgid!("I0006") ); - }; + }}; } macro_rules! i0007 { - ($fmt1:expr, $fmt2:expr) => { + ($fmt1:expr, $fmt2:expr) => {{ print!( "{} {}: Successfully corrected wrong line endings to {}\n", msgid!("I0007"), $fmt1, $fmt2 ); - }; + }}; } pub fn explains(err: &str) { diff --git a/support/pkgcheck/src/utils.rs b/support/pkgcheck/src/utils.rs index a8f2d56c0f..860b8c223b 100644 --- a/support/pkgcheck/src/utils.rs +++ b/support/pkgcheck/src/utils.rs @@ -15,6 +15,8 @@ use std::sync::atomic::Ordering; use std::fs; +use zip_extensions::*; + #[derive(Debug, Clone, PartialEq, Eq)] pub enum CheckType { Tds, @@ -174,6 +176,13 @@ impl Utils { } } } + + pub fn unzip(&self, zip_archive: &str, out_dir: &str) -> zip::result::ZipResult<()> { + let archive_file = PathBuf::from(zip_archive); + let target_dir = PathBuf::from(out_dir); + + zip_extract(&archive_file, &target_dir) + } } pub fn temp_file_endings() -> Vec<(String, String)> { @@ -267,6 +276,7 @@ pub fn temp_file_endings() -> Vec<(String, String)> { (".w18", "temporary file for the ifplatform package"), (".xdv", "intermediate document"), (".xref", "htlatex related"), + (".xray", "dump of \\show output"), ("~", "a file name ending with ~ (tilde) is temporary anyway"), // ( ".lyx~", "LyX related backup file" ), ]; @@ -414,7 +424,7 @@ pub fn run_cmd(cmd: &str, argument: &[&str]) -> CmdReturn { let output = Command::new(cmd) .args(argument.iter()) .output() - .expect("Failed to execute process"); + .unwrap_or_else(|_| panic!("Failed to execute process `{}`", cmd)); if output.status.success() { CmdReturn { |