Skip to content

Commit

Permalink
lint: don't recover missing extra-files
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Aug 29, 2023
1 parent 7ed5fea commit 63b9546
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 36 deletions.
12 changes: 2 additions & 10 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,20 +1178,12 @@ let add_aux_files ?dir ~files_subdir_hashes opam =
match OpamFile.OPAM.extra_files opam, extra_files with
| None, None -> opam
| None, Some ef ->
log ~level:2
"Missing extra-files field for %a for %a, adding them."
log "Missing extra-files field for %a for %a, ignoring them."
(slog @@ OpamStd.List.concat_map ", "
(fun (_,f) -> OpamFilename.Base.to_string f)) ef
OpamStd.Op.(slog @@ OpamPackage.to_string @* OpamFile.OPAM.package)
opam;
let ef =
List.map
(fun (file, basename) ->
basename,
OpamHash.compute (OpamFilename.to_string file))
ef
in
OpamFile.OPAM.with_extra_files ef opam
opam
| Some ef, None ->
log "Missing expected extra files %s at %s/files"
(OpamStd.List.concat_map ", "
Expand Down
12 changes: 12 additions & 0 deletions tests/reftests/config.test
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ depends: "compiler"
### <pkg:meta-compiler.1:meta-compiler.config>
opam-version: "2.0"
variables { compvar: "something" }
### <hash.sh>
set -ue
file=meta-compiler.config
path=REPO/packages/meta-compiler/meta-compiler.1
MD5=$(openssl md5 $path/files/$file | cut -d' ' -f2)
echo "extra-files: [ \"meta-compiler.config\" \"md5=$MD5\"]" >> $path/opam
### sh hash.sh
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### <pkg:compiler.1>
opam-version: "2.0"
depends: [
Expand Down
20 changes: 20 additions & 0 deletions tests/reftests/dot-install.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ hellow
bonjour
### <pkg:lot-of-files.~dev:dosiero>
saluton
### <hash.sh>
set -ue
for nv in REPO/packages/*/*; do
n=`echo $nv | cut -f3 -d/`
nv=`echo $nv | cut -f4 -d/`
path=REPO/packages/$n/$nv
if [ -d $path/files ]; then
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
fi
done
### sh hash.sh
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### OPAMYES=1
### opam switch create inst --empty
### OPAMPRECISETRACKING=1 OPAMDEBUGSECTIONS="TRACK ACTION" OPAMDEBUG=-1
Expand Down
20 changes: 20 additions & 0 deletions tests/reftests/env.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ flags: compiler
### <pkg:nv.1:nv.config>
opam-version: "2.0"
variables { nv_config: "hej!!" }
### <hash.sh>
set -ue
for nv in REPO/packages/*/*; do
n=`echo $nv | cut -f3 -d/`
nv=`echo $nv | cut -f4 -d/`
path=REPO/packages/$n/$nv
if [ -d $path/files ]; then
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
fi
done
### sh hash.sh
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create conffile nv

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Expand Down
78 changes: 52 additions & 26 deletions tests/reftests/extrafile.test
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ Now run 'opam upgrade' to apply any package updates.
### sh -c "rm OPAM/repo/state-*.cache"
### OPAMDEBUGSECTIONS="opam-file" OPAMDEBUG=-2 opam list good-md5 -s | unordered
opam-file Missing expected extra files ../../../no-checksum/no-checksum.1/files/p.patch at ${BASEDIR}/OPAM/repo/default/packages/escape-good-md5/escape-good-md5.1/files
opam-file Missing extra-files field for p.patch for no-checksum.1, adding them.
opam-file Missing extra-files field for p.patch for not-mentioned.1, adding them.
opam-file Missing extra-files field for p.patch for no-checksum.1, ignoring them.
opam-file Missing extra-files field for p.patch for not-mentioned.1, ignoring them.
opam-file Missing expected extra files p.patch at ${BASEDIR}/OPAM/repo/default/packages/not-present/not-present.1/files
opam-file Mismatching extra-files at ${BASEDIR}/OPAM/repo/default/packages/good-md5-good-sha256/good-md5-good-sha256.1: missing from 'files' directory (1)
opam-file Missing expected extra files /etc/passwdd at ${BASEDIR}/OPAM/repo/default/packages/escape-absolute/escape-absolute.1/files
Expand Down Expand Up @@ -355,20 +355,21 @@ The following actions will be performed:
- install no-checksum 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed no-checksum.1
Done.
[ERROR] The compilation of no-checksum.1 failed at "test -f p.patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build no-checksum 1
+-
- No changes have been performed
# Return code 31 #
### opam remove no-checksum
[ERROR] In the opam file for no-checksum.1:
- At ${BASEDIR}/OPAM/repo/default/packages/no-checksum/no-checksum.1/opam:11:2-11:13::
expected [file checksum]
'extra-files' has been ignored.
The following actions will be performed:
=== remove 1 package
- remove no-checksum 1
[NOTE] no-checksum is not installed.

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed no-checksum.1
Done.
Nothing to do.
### opam install no-checksum --require-checksums
[ERROR] In the opam file for no-checksum.1:
- At ${BASEDIR}/OPAM/repo/default/packages/no-checksum/no-checksum.1/opam:11:2-11:13::
Expand All @@ -379,11 +380,21 @@ The following actions will be performed:
- install no-checksum 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed no-checksum.1
Done.
[ERROR] The compilation of no-checksum.1 failed at "test -f p.patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build no-checksum 1
+-
- No changes have been performed
# Return code 31 #
### opam source no-checksum
Successfully extracted to ${BASEDIR}/no-checksum.1
### test -f no-checksum.1/p.patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :::::::::::::::::
Expand All @@ -400,27 +411,42 @@ The following actions will be performed:
- install not-mentioned 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed not-mentioned.1
Done.
[ERROR] The compilation of not-mentioned.1 failed at "test -f p.patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build not-mentioned 1
+-
- No changes have been performed
# Return code 31 #
### opam remove not-mentioned
The following actions will be performed:
=== remove 1 package
- remove not-mentioned 1
[NOTE] not-mentioned is not installed.

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed not-mentioned.1
Done.
Nothing to do.
### opam install not-mentioned --require-checksums
The following actions will be performed:
=== install 1 package
- install not-mentioned 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed not-mentioned.1
Done.
[ERROR] The compilation of not-mentioned.1 failed at "test -f p.patch".




<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build not-mentioned 1
+-
- No changes have been performed
# Return code 31 #
### opam source not-mentioned
Successfully extracted to ${BASEDIR}/not-mentioned.1
### test -f not-mentioned.1/p.patch
# Return code 1 #
### opam clean --download-cache
Clearing cache of downloaded files
### :II:2: not present
Expand Down
15 changes: 15 additions & 0 deletions tests/reftests/legacy-git.test
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,21 @@ Testing optional dependencies
### cp packages/P5.opam REPO/packages/P5.1/opam
### cp packages/P5/README REPO/packages/P5.1/descr
### sh mkurl.sh P5.1 P5.tar.gz
### <hash.sh>
set -ue
for nv in REPO/packages/*; do
nv=`echo $nv | cut -f3 -d/`
n=`echo $nv | cut -f1 -d.`
path=REPO/packages/$nv
if [ -d $path/files ]; then
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
fi
done
### sh hash.sh
### git -C REPO/packages/ocaml.system add *
### git -C REPO/packages/ocaml.system commit -qm "Adding ocaml.system"
### git -C REPO/packages/ocaml.20 add *
Expand Down
15 changes: 15 additions & 0 deletions tests/reftests/legacy-local.test
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,21 @@ Testing optional dependencies
### cp packages/P5.opam REPO/packages/P5.1/opam
### cp packages/P5/README REPO/packages/P5.1/descr
### sh mkurl.sh P5.1 P5.tar.gz
### <hash.sh>
set -ue
for nv in REPO/packages/*; do
nv=`echo $nv | cut -f3 -d/`
n=`echo $nv | cut -f1 -d.`
path=REPO/packages/$nv
if [ -d $path/files ]; then
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
fi
done
### sh hash.sh
### <REPO/repo>
archive-mirrors: "cache"
### opam update
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ echo "extra-files: [ \"more-file-good-md5\" \"md5=$hsh\" ]" >> REPO/packages/lin

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam lint --package lint.1
<default>/lint.1: Errors.
error 53: Mismatching 'extra-files:' field: "more-file-bad-md5"
Expand Down
20 changes: 20 additions & 0 deletions tests/reftests/parallel.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ install: [ "sh" "shout.sh" name ]
if [ $# -eq 1 ]; then
echo "finally installed $1"
fi
### <hash.sh>
set -ue
for nv in REPO/packages/*/*; do
n=`echo $nv | cut -f3 -d/`
nv=`echo $nv | cut -f4 -d/`
path=REPO/packages/$n/$nv
if [ -d $path/files ]; then
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
fi
done
### sh hash.sh
### opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://${BASEDIR}/REPO
Now run 'opam upgrade' to apply any package updates.
### opam switch create parallel --empty
### opam install foo bar baz qux top -vv | grep -v '^Processing' | sed-cmd sh | unordered
The following actions will be performed:
Expand Down
21 changes: 21 additions & 0 deletions tests/reftests/repository.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
N0REP0
### <hash.sh>
set -ue
repo=$1
nv=$2
n=`echo $nv | cut -f1 -d.`
path=$repo/packages/$n/$nv
echo "extra-files:[" >> $path/opam
for file in `ls $path/files`; do
echo " [\"$file\" \"md5=`openssl md5 $path/files/$file | cut -f2 -d' '`\"]" >> $path/opam
done
echo "]" >> $path/opam
### <REPO/packages/foo/foo.1/opam>
opam-version: "2.0"
build: ["test" "-f" "bar"]
### <REPO/packages/foo/foo.1/files/bar>
some content
### sh hash.sh REPO foo.1
### : Internal repository storage as archive or plain directory :
### opam switch create tarring --empty
### opam update -vv | grep '^\+' | sed-cmd diff | '.*(/|\\)patch(\.exe)?"?.*"' -> 'patch'
Expand All @@ -24,6 +36,7 @@ opam-version: "2.0"
build: ["test" "-f" "baz"]
### <REPO/packages/foo/foo.2/files/baz>
some content
### sh hash.sh REPO foo.2
### opam update default -vv | grep '^\+' | '.*tar(\.exe)?"? "xfz" ".*(/|\\)OPAM(/|\\)repo(/|\\)default\.tar\.gz" "-C" ".*"' -> 'tar xfz OPAM/repo/default.tar.gz -C TMPDIR' | '.*tar(\.exe)?"? "cfz" ".*(/|\\)OPAM(/|\\)repo(/|\\)default\.tar\.gz\.tmp" "-C" ".*" "default"' -> 'tar cfz OPAM/repo/default.tar.gz.tmp -C TMPDIR default' | sed-cmd diff | '.*(/|\\)patch(\.exe)?"?.*"' -> 'patch'
diff "-ruaN" "default" "default.new" (CWD=${BASEDIR}/OPAM/repo)
patch (CWD=${BASEDIR}/OPAM/repo/default)
Expand All @@ -43,6 +56,7 @@ opam-version: "2.0"
build: ["test" "-f" "baz"]
### <REPO/packages/foo/foo.3/files/baz>
some content
### sh hash.sh REPO foo.3
### opam repository add tarred ./REPO --this-switch
[tarred] Initialised
### : New tarred repositories does not change already unchanged existing ones
Expand All @@ -61,6 +75,7 @@ opam-version: "2.0"
build: ["test" "-f" "baz"]
### <REPO/packages/foo/foo.4/files/baz>
some content
### sh hash.sh REPO foo.4
### opam update -vv | grep '^\+' | '.*tar(\.exe)?"? "xfz" ".*(/|\\)OPAM(/|\\)repo(/|\\)tarred\.tar\.gz" "-C" ".*"' -> 'tar xfz OPAM/repo/tarred.tar.gz -C TMPDIR' | '.*tar(\.exe)?"? "cfz" ".*(/|\\)OPAM(/|\\)repo(/|\\)tarred\.tar\.gz\.tmp" "-C" ".*" "tarred"' -> 'tar cfz OPAM/repo/tarred.tar.gz.tmp -C TMPDIR tarred' | sed-cmd diff | '.*(/|\\)patch(\.exe)?"?.*"' -> 'patch'
tar xfz OPAM/repo/tarred.tar.gz -C TMPDIR
diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP})
Expand All @@ -83,6 +98,7 @@ opam-version: "2.0"
build: ["test" "-f" "quux"]
### <REPO/packages/foo/foo.5/files/quux>
some content
### sh hash.sh REPO foo.5
### opam update -vv | grep '^\+' | '.*tar(\.exe)?"? "xfz" ".*(/|\\)OPAM(/|\\)repo(/|\\)tarred\.tar\.gz" "-C" ".*"' -> 'tar xfz OPAM/repo/tarred.tar.gz -C TMPDIR' | sed-cmd diff | '.*(/|\\)patch(\.exe)?"?.*"' -> 'patch'
tar xfz OPAM/repo/tarred.tar.gz -C TMPDIR
diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP})
Expand All @@ -103,6 +119,7 @@ opam-version: "2.0"
build: ["test" "-f" "rab"]
### <REPO/packages/foo/foo.4/files/rab>
some content
### sh hash.sh REPO foo.4
### OPAMDEBUGSECTIONS="FILE(opam) FILE(repo) FILE(repos-config) CACHE(repository)"
### opam update --debug-level=-3 | "state-[0-9A-Z]{8}" -> "state-hash" | unordered
FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s
Expand Down Expand Up @@ -164,6 +181,7 @@ opam-version: "2.0"
build: ["test" "-f" "oof"]
### <REPO2/packages/bar/bar.1/files/oof>
some content
### sh hash.sh REPO2 bar.1
### opam repository add repo2 ./REPO2 --this-switch
[repo2] Initialised
### opam update --debug-level=-3 | "state-[0-9A-Z]{8}" -> "state-hash"
Expand All @@ -188,6 +206,7 @@ opam-version: "2.0"
build: ["test" "-f" "oof"]
### <REPO2/packages/bar/bar.2/files/oof>
some content
### sh hash.sh REPO2 bar.2
### opam update --debug-level=-3 | "state-[0-9A-Z]{8}" -> "state-hash" | unordered
FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s
FILE(repos-config) Read ${BASEDIR}/OPAM/repo/repos-config in 0.000s
Expand Down Expand Up @@ -217,11 +236,13 @@ opam-version: "2.0"
build: ["test" "-f" "rab"]
### <REPO/packages/foo/foo.6/files/rab>
some content
### sh hash.sh REPO foo.6
### <REPO2/packages/bar/bar.3/opam>
opam-version: "2.0"
build: ["test" "-f" "oof"]
### <REPO2/packages/bar/bar.3/files/oof>
some content
### sh hash.sh REPO2 bar.3
### opam update --debug-level=-3 | "state-[0-9A-Z]{8}" -> "state-hash" | unordered
FILE(config) Read ${BASEDIR}/OPAM/config in 0.000s
FILE(repos-config) Read ${BASEDIR}/OPAM/repo/repos-config in 0.000s
Expand Down

0 comments on commit 63b9546

Please # to comment.