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 May 26, 2023
1 parent 6ec43fa commit c668919
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 37 deletions.
11 changes: 2 additions & 9 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,18 +1176,11 @@ 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 %s for %s, adding them."
log "Missing extra-files field for %s for %s, ignoring them."
(OpamStd.List.concat_map ", "
(fun (_,f) -> OpamFilename.Base.to_string f) ef)
(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/extrafiles-field-checks.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
2 changes: 0 additions & 2 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ license: "ISC"
dev-repo: "hg+https://to@li.nt"
bug-reports: "https://nobug"
extra-files: [ "more-file" "md5=00000000000000000000000000000000" ]
### <pkg:lint.1:more-file>
and there is content!
### opam switch create linting --empty
### # needed for check upstream checks
### <one-more-file>
Expand Down

0 comments on commit c668919

Please # to comment.