简体   繁体   English

bitbake do_fetch[nostamp] = "1" 无效

[英]bitbake do_fetch[nostamp] = "1" has no effect

I am trying to install the compiled firmware for a microprocessor in my yocto image.我正在尝试在我的 yocto 映像中安装微处理器的已编译固件。 This firmware is sent to a microprocessor on startup.该固件在启动时被发送到微处理器。 The compiler for this firmware only runs on windows, therefore it is not possible to just clone the git repository and compile during build.此固件的编译器仅在 windows 上运行,因此无法仅克隆 git 存储库并在构建期间进行编译。 I get this firmware file from the artifacts of a GitLab CI CD pipeline.我从 GitLab CI CD 管道的工件中获取此固件文件。

For debugging purposes, i would like to download this firmware file from the master branch, everytime that I build the image.出于调试目的,我想在每次构建映像时从 master 分支下载这个固件文件。

I previously worked with a custom do_fetch task and had set do_fetch[nostamp] = "1" .我之前使用自定义do_fetch任务并设置了do_fetch[nostamp] = "1" This worked, but I ran into trouble when curl just put the 404 Error into the file.这行得通,但是当curl将 404 错误放入文件时我遇到了麻烦。 I have now tried to switch to wget and SRC_URI , but even though the nostamp is still set, it generates a .done file.我现在尝试切换到wgetSRC_URI ,但即使nostamp仍然设置,它也会生成一个.done文件。 It now never downloads the file again.它现在不再下载该文件。

Here is the Recipe file I use:这是我使用的食谱文件:

S = "${WORKDIR}/"

PRIVATE_TOKEN = "xxxxxxxxxxx" # redacted
PROJECT_ID = "224"

VERSION = "2.00.01"
TAG = "master"
DOWNLOAD_FILE_PATH = "Production/firmware.bin"
INSTALL_NAME = "my-firmware-file.bin"
VERSION_FILE = "version.txt"

URL = "https://git.mycompany.com/api/v4/projects/${PROJECT_ID}/jobs/artifacts/${TAG}/raw/${DOWNLOAD_FILE_PATH}?job=publish_executable"

FETCHCMD_wget = "/usr/bin/env wget --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}""
BB_STRICT_CHECKSUM = "0"
SRC_URI = "${URL};downloadfilename=${INSTALL_NAME}"

do_fetch[nostamp] = "1"

do_patch(){
    echo ${VERSION} > ${VERSION_FILE}
}

do_install(){
    install -d ${D}${libdir}/test-dir/${PN}
    # Install binary from artifacts
    install -m 644 ${S}${INSTALL_NAME} ${D}${libdir}/test-dir/${PN}/${INSTALL_NAME}
    # Instal version file created from tag
    install -m 644 ${S}${VERSION_FILE} ${D}${libdir}/test-dir/${PN}/${VERSION_FILE}
}

FILES_${PN} += "${libdir}/test-dir/${PN}"

After running the recipe (either bitbake <PN> or bitbake <PN> -c fetch -f ) I can run ls -la build/download | grep my-firmware-file运行食谱后( bitbake <PN>bitbake <PN> -c fetch -f )我可以运行ls -la build/download | grep my-firmware-file ls -la build/download | grep my-firmware-file and it shows two entries: ls -la build/download | grep my-firmware-file ,它显示了两个条目:

-rw-rw-r--  1 root root    613924 Nov 11 11:50 my-firmware-file.bin
-rw-rw-r--  1 root root       463 Nov 14 14:26 my-firmware-file.bin.done

As you see, it generated a .done file, that is newer than the last download of the actual file.如您所见,它生成了一个.done文件,该文件比上次下载的实际文件更新。 Even when changing the TAG variable, no new file is downloaded.即使更改TAG变量,也不会下载新文件。 However for some reason, it always puts the correct version into the version.txt file.但是由于某种原因,它总是将正确的版本放入version.txt文件中。

What am I missing?我错过了什么? I could run a cleanall before every build, but that does not seem like a permanent solution.我可以在每次构建之前运行cleanall ,但这似乎不是一个永久的解决方案。 Also, the endgoal is to version the recipe and use the package version to pull from the correct release, but currently it pulls from master, so this does not make much sense.此外,最终目标是对配方进行版本控制,并使用 package 版本从正确的版本中提取,但目前它是从 master 中提取的,所以这没有多大意义。

Update : I checked the logfiles, and it seems wget is not the problem, as the command is never even executed.更新:我检查了日志文件,似乎 wget 不是问题,因为该命令甚至从未执行过。 The first time after a clean, the log for do_fetch looks like this:第一次清理后, do_fetch的日志如下所示:

DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are []
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: []
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing python function do_fetch
DEBUG: Executing python function base_do_fetch
DEBUG: Trying PREMIRRORS
DEBUG: Trying Upstream
DEBUG: Fetching https://git.mycompany.com/api/v4/projects/224/jobs/artifacts/master/raw/Production/firmware.bin?job=publish_executable;downloadfilename=my-firmware-file.bin using command '/usr/bin/env wget -r --header "PRIVATE-TOKEN: xxxxxxxxxxxxxx" -O /home/.../build/downloads/my-firmware-file.bin.tmp -P /home/.../build/downloads 'https://git.mycompany.com/api/v4/projects/224/jobs/artifacts/master/raw/Production/firmware.bin?job=publish_executable''
DEBUG: Fetcher accessed the network with the command /usr/bin/env wget -r --header "PRIVATE-TOKEN: xxxxxxxxxxxxxx" -O /home/.../build/downloads/my-firmware-file.bin.tmp -P /home/.../build/downloads 'https://git.mycompany.com/api/v4/projects/224/jobs/artifacts/master/raw/Production/firmware.bin?job=publish_executable'
DEBUG: Running export PSEUDO_DISABLED=1; export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1005/bus"; export PATH="..."; export HOME="/home/..."; /usr/bin/env wget -r --header "PRIVATE-TOKEN: xxxxxxxxxxxxxx" -O /home/.../build/downloads/my-firmware-file.bin.tmp -P /home/.../build/downloads 'https://git.mycompany.com/api/v4/projects/224/jobs/artifacts/master/raw/Production/firmware.bin?job=publish_executable' --progress=dot -v
WARNING: combining -O with -r or -p will mean that all downloaded content
will be placed in the single file you specified.

--2022-11-18 07:01:11--  https://git.mycompany.com/api/v4/projects/224/jobs/artifacts/master/raw/Production/firmware.bin?job=publish_executable
Resolving git.mycompany.com (git.mycompany.com)... <IP>
Connecting to git.mycompany.com (git.mycompany.com)|<IP>|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 613924 (600K) [application/octet-stream]
Saving to: ‘/home/.../build/downloads/my-firmware-file.bin.tmp’


2022-11-18 07:01:11 (70.4 MB/s) - ‘/home/.../build/downloads/my-firmware-file.bin.tmp’ saved [613924/613924]

FINISHED --2022-11-18 07:01:11--
Total wall clock time: 0.5s
Downloaded: 1 files, 600K in 0.008s (70.4 MB/s)
WARNING: Missing checksum for '/home/.../build/downloads/my-firmware-file.bin', consider adding at least one to the recipe:
SRC_URI[sha256sum] = "83aa3c373228b48eea58964b4ffec7ad42226014351d18bed12cb9b5eb3d261e"
DEBUG: Python function base_do_fetch finished
DEBUG: Python function do_fetch finished

When I then run do_fetch again (even when changing the TAG variable, so SRC_URI changes), the log looks as follows:当我再次运行do_fetch时(即使更改了TAG变量,因此SRC_URI发生了变化),日志如下所示:

DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are []
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: []
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing python function do_fetch
DEBUG: Executing python function base_do_fetch
WARNING: Missing checksum for '/home/.../build/downloads/my-firmware-file.bin', consider adding at least one to the recipe:
SRC_URI[sha256sum] = "83aa3c373228b48eea58964b4ffec7ad42226014351d18bed12cb9b5eb3d261e"
WARNING: Missing checksum for '/home/.../build/downloads/my-firmware-file.bin', consider adding at least one to the recipe:
SRC_URI[sha256sum] = "83aa3c373228b48eea58964b4ffec7ad42226014351d18bed12cb9b5eb3d261e"
DEBUG: Python function base_do_fetch finished
DEBUG: Python function do_fetch finished

Notice the duplicated missing checksum warning in the second log.请注意第二个日志中重复的缺少校验和警告。 I also tried to delete only the ./downloads/my-firmware-file.bin.done file, but it still is not redownloaded, the log is the same as the second one.我也尝试只删除./downloads/my-firmware-file.bin.done文件,但仍然没有重新下载,日志与第二个相同。

try to add -r flag to force wget to re-download even if the file exists:尝试添加-r标志以强制wget重新下载,即使文件存在:

FETCHCMD_wget = "/usr/bin/env wget -r --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}""

I have tried a lot of things, and by now I feel like it is a bug in bitbake.我已经尝试了很多东西,现在我觉得这是 bitbake 中的一个错误。 For the moment I implemented this workaround, that seems to work fine.目前我实施了这个解决方法,似乎工作正常。 It deletes the downloaded file as well as the .done file before the execution of do_fetch .它会在执行do_fetch之前删除下载的文件以及.done文件。

# Deletes the old, cached version of the firmware file
do_fetch_prepend(){
    import os

    fw_file = f"{d.getVar('DL_DIR')}/{d.getVar('INSTALL_NAME')}"
    done_file = f"{fw_file}.done"

    if os.path.isfile(fw_file):
        os.remove(fw_file)
    if os.path.isfile(done_file):
        os.remove(done_file)
}

I hope to soon be able to correctly version my recipe, so I don't have to rely on such hacks.我希望很快就能正确地修改我的食谱版本,这样我就不必依赖这些技巧了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM