【问题标题】:Opam doesn't download sources when building locallyOpam 在本地构建时不下载源代码
【发布时间】:2021-07-25 21:12:17
【问题描述】:

我正在尝试向llvm Opam 包添加一些补丁,但我在测试它时遇到了问题,因为从包根目录运行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"
}

这是在包根目录上运行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 .

【问题讨论】:

  • 不,这不是已知问题。你能更详细地描述你的问题吗?是什么让您认为文件未下载?我只看到没有应用补丁,因为没有找到相应的文件。此外,常见的错误是:(1)忘记提交,(2)忘记opam update。如果不是这样,请描述您的工作流程。
  • @ivg 关于常见问题:更改已提交到 repo,我事先确实运行了opam update。我认为没有任何内容被下载,因为 opam 几乎立即尝试应用补丁,而我希望必须等待存档下载并首先被提取,它甚至不是一个“小”存档。另外,当使用-vvv 安装上游llvm 包时,我可以看到类似wget/curl 的输出,但我看不到什么,因为文件名被重命名为临时文件名。
  • 更新到先前的评论:事实上,我确实检查了在运行opam install llvm 时,opam 在应用补丁之前首先下载url 部分中指定的文件,使用 curl。当我运行opam install . 时不会发生这种情况
  • 它不会再次下载相同的存档,因为它在缓存中。但存档是正确的,并通过其 md5sum 进行验证。所以我认为你正在寻找错误的方向。我想知道你钉哪个包?再次,请描述您的工作流程。完全不清楚你在哪里运行opam pin . 等等。您也可以考虑在 ocaml/opam 存储库中提出问题。
  • 我添加了一些关于工作流程的注释。关于缓存:我实际上可以看到 opam install llvm (删除 pin 后)always 下载存档。即便如此,我实际上清除了下载缓存目录,opam install . 命令仍然不会下载存档,所以我认为这不是唯一的问题。

标签: url ocaml archive opam


【解决方案1】:

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

  1. 克隆 opam 存储库
git clone git@github.com:ocaml/opam-repository.git
  1. 将本地存储库添加到 opam 存储库列表
opam repo add local ./opam-repository
  1. 复制您想要更改的软件包(使用 llvm 作为工作示例),我们将使用 -&lt;patch&gt;,因为我们只是添加补丁,而不是发布新版本,
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)好吧,至少这是我每天都在使用的工作流程:)

【讨论】:

  • 我假设我需要固定 llvm 包,但是到哪个目录? opam-repository 根目录、llvm 目录或 llvm.11.0.0-1?还是我应该 opam repository add 本地的 opam-repository
  • 哎呀,我忘记了主要成分,是的,您需要将本地克隆的 repo 添加到 opam 存储库列表中。
【解决方案2】:

@ivg 正确提示我使用了错误的工作流程

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

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

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

【讨论】:

    猜你喜欢
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多