|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +testRoot="test-root" |
| 4 | +paramCandidateVersion="" |
| 5 | +paramBaselineVersion="" |
| 6 | +baselineRoot="${testRoot}/baselines" |
| 7 | +candidateRoot="${testRoot}/candidates" |
| 8 | +targetRoot="${testRoot}/targets" |
| 9 | +# Check the passed params to avoid disapointment |
| 10 | +checkParams () { |
| 11 | + OPTIND=1 # Reset in case getopts previously used |
| 12 | + |
| 13 | + while getopts "h?b:c:" opt; do # Grab the options |
| 14 | + case "$opt" in |
| 15 | + h|\?) |
| 16 | + showHelp |
| 17 | + exit 0 |
| 18 | + ;; |
| 19 | + b) paramBaselineVersion=$OPTARG |
| 20 | + ;; |
| 21 | + c) paramCandidateVersion=$OPTARG |
| 22 | + ;; |
| 23 | + esac |
| 24 | + done |
| 25 | + |
| 26 | + if [ -z "$paramBaselineVersion" ] || [ -z "$paramCandidateVersion" ] |
| 27 | + then |
| 28 | + showHelp |
| 29 | + exit 0 |
| 30 | + fi |
| 31 | + |
| 32 | + baselineRoot="${baselineRoot}/${paramBaselineVersion}" |
| 33 | + candidateRoot="${candidateRoot}/${paramCandidateVersion}" |
| 34 | + targetRoot="${targetRoot}/${paramCandidateVersion}" |
| 35 | +} |
| 36 | + |
| 37 | +# Show usage message |
| 38 | +showHelp() { |
| 39 | + echo "usage: create-target [-b <baselineVersion>] [-c <candidateVersion>] [-h|?]" |
| 40 | + echo "" |
| 41 | + echo " baselineVersion : The version number id for the baseline data." |
| 42 | + echo " candidateVersion : The version number id for the candidate data." |
| 43 | + echo "" |
| 44 | + echo " -h|? : This message." |
| 45 | +} |
| 46 | + |
| 47 | +# Execution starts here |
| 48 | +checkParams "$@"; |
| 49 | +if [[ -d "${targetRoot}" ]]; then |
| 50 | + echo " - removing existing baseline at ${targetRoot}." |
| 51 | + rm -rf "${targetRoot}" |
| 52 | +fi |
| 53 | + |
| 54 | +echo "TEST BASELINE: Creating baseline" |
| 55 | +# Simply copy baseline for now we're not making any changes |
| 56 | +echo " - copying ${baselineRoot} baseline to ${targetRoot}" |
| 57 | +cp -R "${baselineRoot}" "${targetRoot}" |
| 58 | + |
| 59 | +# Patch release details of the XML reporting module in the audit file |
| 60 | +find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/outputHandler release="1.13">XML/outputHandler release="1.14">XML/' {} \; |
| 61 | + |
| 62 | +# Update release details for HTML module |
| 63 | +find "${targetRoot}" -type f -name "*.html.jhove.xml" -exec sed -i 's/<reportingModule release="1.4.4" date="2024-08-22">HTML-hul<\/reportingModule>/<reportingModule release="1.4.5" date="2025-03-12">HTML-hul<\/reportingModule>/' {} \; |
| 64 | +find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/<module release="1.4.4">HTML-hul<\/module>/<module release="1.4.5">HTML-hul<\/module>/' {} \; |
| 65 | +find "${targetRoot}" -type f -name "audit-HTML-hul.jhove.xml" -exec sed -i 's/<release>1.4.4<\/release>/<release>1.4.5<\/release>/' {} \; |
| 66 | +find "${targetRoot}" -type f -name "audit-HTML-hul.jhove.xml" -exec sed -i 's/2024-08-22/2025-03-12/' {} \; |
| 67 | +find "${targetRoot}" -type f -name "audit-HTML-hul.jhove.xml" -exec sed -i 's/01-08-2002/2002-08-01/' {} \; |
| 68 | +find "${targetRoot}" -type f -name "audit-HTML-hul.jhove.xml" -exec sed -i 's/31-05-2001/2001-05-31/' {} \; |
| 69 | + |
| 70 | +# Update release details for JPEG 2000 module |
| 71 | +find "${targetRoot}" -type f -name "*.jp2.jhove.xml" -exec sed -i 's/<reportingModule release="1.4.4" date="2023-03-16">JPEG2000-hul<\/reportingModule>/<reportingModule release="1.4.5" date="2025-03-12">JPEG2000-hul<\/reportingModule>/' {} \; |
| 72 | +find "${targetRoot}" -type f -name "*.jpx.jhove.xml" -exec sed -i 's/<reportingModule release="1.4.4" date="2023-03-16">JPEG2000-hul<\/reportingModule>/<reportingModule release="1.4.5" date="2025-03-12">JPEG2000-hul<\/reportingModule>/' {} \; |
| 73 | +find "${targetRoot}" -type f -name "*.md.jhove.xml" -exec sed -i 's/<reportingModule release="1.4.4" date="2023-03-16">JPEG2000-hul<\/reportingModule>/<reportingModule release="1.4.5" date="2025-03-12">JPEG2000-hul<\/reportingModule>/' {} \; |
| 74 | +find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/<module release="1.4.4">JPEG2000-hul<\/module>/<module release="1.4.5">JPEG2000-hul<\/module>/' {} \; |
| 75 | +find "${targetRoot}" -type f -name "audit-JPEG2000-hul.jhove.xml" -exec sed -i 's/<release>1.4.4<\/release>/<release>1.4.5<\/release>/' {} \; |
| 76 | +find "${targetRoot}" -type f -name "audit-JPEG2000-hul.jhove.xml" -exec sed -i 's/2023-03-16/2025-03-12/' {} \; |
| 77 | + |
| 78 | +# Copy the files affected by the relative URL output changes to the XML reporting module |
| 79 | +if [[ -f "${candidateRoot}/errors/modules/JPEG2000-hul/ランダム日本語テキスト.jp2.jhove.xml" ]]; then |
| 80 | + cp "${candidateRoot}/errors/modules/JPEG2000-hul/ランダム日本語テキスト.jp2.jhove.xml" "${targetRoot}/errors/modules/JPEG2000-hul/ランダム日本語テキスト.jp2.jhove.xml" |
| 81 | +fi |
| 82 | +if [[ -f "${candidateRoot}/errors/modules/JPEG2000-hul/隨機中國文字.jp2.jhove.xml" ]]; then |
| 83 | + cp "${candidateRoot}/errors/modules/JPEG2000-hul/隨機中國文字.jp2.jhove.xml" "${targetRoot}/errors/modules/JPEG2000-hul/隨機中國文字.jp2.jhove.xml" |
| 84 | +fi |
| 85 | + |
| 86 | +# Copy the files affected by the change to the JPEG-2000 module that prevents empty CompositeListHeader lists from been created |
| 87 | +if [[ -f "${candidateRoot}/errors/modules/JPEG2000-hul/is_jpx.jp2.jhove.xml" ]]; then |
| 88 | + cp "${candidateRoot}/errors/modules/JPEG2000-hul/is_jpx.jp2.jhove.xml" "${targetRoot}/errors/modules/JPEG2000-hul/is_jpx.jp2.jhove.xml" |
| 89 | +fi |
| 90 | +if [[ -f "${candidateRoot}/examples/modules/JPEG2000-hul/ROITest.jpx.jhove.xml" ]]; then |
| 91 | + cp "${candidateRoot}/examples/modules/JPEG2000-hul/ROITest.jpx.jhove.xml" "${targetRoot}/examples/modules/JPEG2000-hul/ROITest.jpx.jhove.xml" |
| 92 | +fi |
| 93 | + |
| 94 | +# Update release details for PDF module |
| 95 | +find "${targetRoot}" -type f -name "*.pdf.jhove.xml" -exec sed -i 's/<reportingModule release="1.12.7" date="2024-08-22">PDF-hul<\/reportingModule>/<reportingModule release="1.12.8" date="2025-03-12">PDF-hul<\/reportingModule>/' {} \; |
| 96 | +find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/<module release="1.12.7">PDF-hul<\/module>/<module release="1.12.8">PDF-hul<\/module>/' {} \; |
| 97 | +find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/<release>1.12.7<\/release>/<release>1.12.8<\/release>/' {} \; |
| 98 | +find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/2024-08-22/2025-03-12/' {} \; |
| 99 | + |
| 100 | +# Fix the results affected by the improvements to date handling in the PDF module |
| 101 | +sed -i 's/<message offset/<message subMessage="For date property: CreationDate, value: Tue Feb 03 16:19:57 2004" offset/' "${targetRoot}/examples/modules/PDF-hul/AA_Banner.pdf.jhove.xml" |
| 102 | +if [[ -f "${candidateRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml" ]]; then |
| 103 | + cp "${candidateRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml" "${targetRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml" |
| 104 | +fi |
| 105 | + |
| 106 | +# Insert new PDF-2.x signature nodes into the PDF audit XML files |
| 107 | +find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/<\/signatures>/ <signature>\n <type>Magic number<\/type>\n <value>%PDF-2.<\/value>\n <offset>0x0<\/offset>\n <use>Mandatory<\/use>\n <\/signature>\n <\/signatures>/' {} \; |
| 108 | + |
| 109 | +# Copy the two new version regression test files, where handling of PDF version declaration has been improved/changed |
| 110 | +declare -a pdf_version_affected=("errors/modules/PDF-hul/pdf-hul-61-CERN-2005-009.pdf.jhove.xml" |
| 111 | + "regression/modules/PDF-hul/PDF-HUL-137.pdf.jhove.xml" |
| 112 | + "regression/modules/PDF-hul/PDF-HUL-137_fixed.pdf.jhove.xml") |
| 113 | +for filename in "${pdf_version_affected[@]}" |
| 114 | +do |
| 115 | + if [[ -f "${candidateRoot}/${filename}" ]]; then |
| 116 | + cp "${candidateRoot}/${filename}" "${targetRoot}/${filename}" |
| 117 | + fi |
| 118 | +done |
| 119 | + |
| 120 | +# Copy the results of the test files fixed by the addition of basic text stream validation |
| 121 | +declare -a pdf_version_affected=("errors/modules/PDF-hul/T02-05-01_009_Missing_open_paranthesis.pdf.jhove.xml" |
| 122 | + "errors/modules/PDF-hul/T02-05-01_010_Missing_closing_paranthesis.pdf.jhove.xml" |
| 123 | + "errors/modules/PDF-hul/T02-05-01_011_paranthesis-substituted-with-brackets.pdf.jhove.xml") |
| 124 | +for filename in "${pdf_version_affected[@]}" |
| 125 | +do |
| 126 | + if [[ -f "${candidateRoot}/${filename}" ]]; then |
| 127 | + cp "${candidateRoot}/${filename}" "${targetRoot}/${filename}" |
| 128 | + fi |
| 129 | +done |
| 130 | + |
| 131 | +# Copy the regression test files affected by the change to object count checking against size |
| 132 | +declare -a xref_size_affected=("errors/modules/PDF-hul/pdf-hul-73-bug-size-int.pdf.jhove.xml" |
| 133 | + "regression/modules/PDF-hul/issue_531.pdf.jhove.xml") |
| 134 | +for filename in "${xref_size_affected[@]}" |
| 135 | +do |
| 136 | + if [[ -f "${candidateRoot}/${filename}" ]]; then |
| 137 | + cp "${candidateRoot}/${filename}" "${targetRoot}/${filename}" |
| 138 | + fi |
| 139 | +done |
| 140 | + |
| 141 | +if [[ -d "${targetRoot}/regression/modules/PDF-hul" ]]; then |
| 142 | + echo " - removing existing regressions for PDF ${targetRoot}/regression/modules/PDF-hul." |
| 143 | + rm -rf "${targetRoot}/regression/modules/PDF-hul" |
| 144 | + cp -r "${candidateRoot}/regression/modules/PDF-hul" "${targetRoot}/regression/modules/PDF-hul" |
| 145 | +fi |
0 commit comments