Opam 在本地构建时不下载源

Opam doesn't download sources when building locally

我正在尝试向 llvm Opam 包添加一些补丁,但我在测试它时遇到了问题,因为它似乎来自包根 运行ning opam install .忽略 url 部分并且不下载和解压缩源存档,因此在应用补丁时失败。

这是供参考的opam文件:

opam-version: "2.0"
maintainer: "Kate <kit.ty.kate@disroot.org>"
authors: [
  "whitequark <whitequark@whitequark.org>"
  "The LLVM team"
]
license: "MIT"
doc: "http://llvm.moe/ocaml"
bug-reports: "http://llvm.org/bugs/"
dev-repo: "git+http://llvm.org/git/llvm.git"
homepage: "http://llvm.moe"
install: [
  ["bash" "-ex" "install.sh" "%{conf-llvm:config}%" lib "%{conf-cmake:cmd}%" make]
]
depends: [
  "ocaml" {>= "4.00.0"}
  "ctypes" {>= "0.4"}
  "ounit" {with-test}
  "ocamlfind" {build}
  "conf-llvm" {build & = version}
  "conf-python-2-7" {build}
  "conf-cmake" {build}
]
patches: [
  "fix-shared.patch"
]
synopsis: "The OCaml bindings distributed with LLVM"
description: "Note: LLVM should be installed first."
extra-files: [
  ["link-META.patch" "md5=ef4ebb8706be2ed402f31fc351d7dc75"]
  ["install.sh" "md5=683ec0478ee422a57dcd3716277b3ef3"]
  ["fix-shared.patch" "md5=dce86b1db352332968ceb6d042b408a8"]
  ["META.patch" "md5=1d0af08bab7a0f831f68849b6556e414"]
  ["add-buildfence-llvm.ml.patch" "md5=a3bc667bd2fc937ee51c3b9d33b8ad63"]
  ["add-buildfence-llvm.mli.patch" "md5=99c739d74deeb1b990fe63cf914fc479"]
  ["add-buildfence-llvm_ocaml.c.patch" "md5=a29282f2e1e435abff57cecfd269ccb9"]
]
url {
  src: "https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz"
  checksum: "sha256=ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5"
}

这是 运行ning opam install . -vvv 在包根上的结果:

Processing  1/1: [llvm.11.0.0: rsync]
+ /usr/bin/rsync "-rLptgoDrvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--delete" "--delete-excluded" "/home/frabert/opam-repository/packages/llvm/llvm.11.0.0/" "/home/frabert/.opam/4.11.1/.opam-switch/sources/llvm"
- sending incremental file list
- ./
- out
- 
- sent 828 bytes  received 39 bytes  1,734.00 bytes/sec
- total size is 19,120  speedup is 22.05
[llvm.11.0.0] synchronised from file:///home/frabert/opam-repository/packages/llvm/llvm.11.0.0
+ /usr/bin/lsb_release "-s" "-r"
- 18.04
+ /usr/bin/ocamlc "-vnum"
- 4.05.0
The following actions will be performed:
  ∗ install llvm 11.0.0*
+ /usr/bin/rsync "-rLptgoDrvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--delete" "--delete-excluded" "/home/frabert/opam-repository/packages/llvm/llvm.11.0.0/" "/home/frabert/.opam/4.11.1/.opam-switch/sources/llvm"
- sending incremental file list
- ./
- opam
- out
- files/
- files/META.patch
- files/add-buildfence-llvm.ml.patch
- files/add-buildfence-llvm.mli.patch
- files/add-buildfence-llvm_ocaml.c.patch
- files/fix-shared.patch
- files/install.sh
- files/link-META.patch
- 
- sent 20,648 bytes  received 202 bytes  41,700.00 bytes/sec
- total size is 19,775  speedup is 0.95
[llvm.11.0.0] synchronised from file:///home/frabert/opam-repository/packages/llvm/llvm.11.0.0

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+ /bin/cp "-PRp" "/home/frabert/.opam/4.11.1/.opam-switch/sources/llvm" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/link-META.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/link-META.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/install.sh" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/install.sh"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/fix-shared.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/fix-shared.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/add-buildfence-llvm_ocaml.c.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/add-buildfence-llvm_ocaml.c.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/add-buildfence-llvm.mli.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/add-buildfence-llvm.mli.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/add-buildfence-llvm.ml.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/add-buildfence-llvm.ml.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/overlay/llvm/files/META.patch" "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/META.patch"
+ /bin/cp "/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0/fix-shared.patch" "/home/frabert/.opam/log/processed-patch-13793-c743ac"
Processing  1/2: [llvm: patch]
+ /usr/bin/patch "-p1" "-i" "/home/frabert/.opam/log/processed-patch-13793-c743ac" (CWD=/home/frabert/.opam/4.11.1/.opam-switch/build/llvm.11.0.0)
- can't find file to patch at input line 5
- Perhaps you used the wrong -p or --strip option?
- The text leading up to this was:
- --------------------------
- |diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
- |index 554046b20..b27cbd36c 100644
- |--- a/cmake/modules/AddOCaml.cmake
- |+++ b/cmake/modules/AddOCaml.cmake
- --------------------------
- File to patch: 
- Skip this patch? [y] 
- Skipping patch.
- 1 out of 1 hunk ignored


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build llvm 11.0.0
└─ 
╶─ No changes have been performed

这是一个已知问题吗?

编辑:关于工作流程的说明

我有一个 opam-repository 的本地 git 克隆,我已经编辑并提交了 llvm.11.0.0 包定义。

为了测试编辑,我从包含 opam 文件的 llvm.11.0.0 目录中 运行 opam install .

ocaml/opam-repository 中更改包定义的正确1 工作流程如下。

  1. 克隆 opam-repository
git clone git@github.com:ocaml/opam-repository.git
  1. 将本地存储库添加到 opam 存储库列表
opam repo add local ./opam-repository
  1. 复制你想要更改的包(使用 llvm 作为工作示例),我们将使用 -<patch> 因为我们只是添加补丁,而不是发布新版本,
cd opam-repository/packages/llvm/
cp -r llvm.11.0.0/ llvm.11.0.0-1 
  1. 使用补丁版本...
  2. 提交工作
git add llvm.11.0.0-1
git commit -m 'wip'
  1. 测试一下
opam update
opam install llvm

1) 好吧,至少这是我每天都在使用的工作流程:)

正如@ivg

正确提示的那样,我使用了错误的工作流程

不过,正确的似乎是此处描述的那个:https://github.com/ocaml/opam/issues/4654

基本上,我需要添加一个本地存储库,然后像往常一样安装 llvm 包。

opam repo add local ~/opam-repository
opam install llvm