accessing variables exported in a shell in the recepe file - yocto

I have a yocto recipe file.
However I want to set a value to the variable, by exporting a variable.
For example
I modified I added a variable in oe-init-build-env, (which calls 'svn_util')
export REPO_BRANCH_ROOT=${REPO_BRANCH_ROOT}
The REPO_BRANCH_ROOT variable is set by running a utility 'svn_util', by looking at by current branch.
Now in my recepie.bb file
SRC_URI = "\
svn://${REPO_ROOT_NO_URI}/${REPO_BRANCH_ROOT}/sample module=mymodule;protocol=protocol=http;rev=HEAD \
"
However do_fetch: fails as follows.
Fetcher failure for URL: 'svn://${REPO_ROOT_NO_URI}/${REPO_BRANCH_ROOT}/sample;module=mymodule;protocol=http;rev=HEAD'. Unable to fetch URL from any source.
How do I make .bb file to be aware of my current branch and repository uri? I do not want to hard code it in the .bb file, or local.conf file Because if the .bb file is checked in to a different branch it should work correctly across all branch.
Or to rephrase the question, How a shell exported variable be accessed in the recipe file?

Got my answer, from another post.
https://www.yoctoproject.org/docs/3.1/bitbake-user-manual/bitbake-user-manual.html#var-bb-BB_ENV_EXTRAWHITE
In this case i have to add
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE REPO_SVNREV REPO_ROOT_NO_URI REPO_BRANCH_ROOT"
In the oe-init-build-env

Related

Stale file is located outside of the allowed root path when using Cuckoo

I wanted to mock some of my files, so I used Cuckoo framework. I am using Swift Package Manager, so I did every step that is shown in README of framework.
I tried to use this script
# Define output file. Change "${PROJECT_DIR}/${PROJECT_NAME}Tests" to your test's
root source folder, if it's not the default name.
OUTPUT_FILE="${PROJECT_DIR}/${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory. Change "${PROJECT_DIR}/${PROJECT_NAME}" to your project's root source folder, if it's not the default name.
INPUT_DIR="${PROJECT_DIR}/${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files, include as many input files as you'd like to create mocks for.
"${PROJECT_DIR}/run" --download generate --testable "${PROJECT_NAME}" \
--output "${OUTPUT_FILE}" \
"${INPUT_DIR}/Common/Repository/LatestNewsRepository/LatestNewsRepositoryImpl.swift" \
# ... and so forth, the last line should never end with a backslash
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group.
I also downloaded the latest run script and I had to check For install builds only.
When app is launched I am getting this error -
Stale file '.../LibraryTests/GeneratedMocks.swift' is located outside of the allowed root paths.
Things I tried -
Clean Xcode derived data
Clean build folder
Reset Xcode
Reset Packages Cache
and I am still not getting output file. Is there anything else I should try?

Yocto: add a statement in the default service file within a recipe

I'd need to add a Restart statement within a default .service file, and was looking to an alternate solution to replacing the .service file with a custom one (which works).
The idea would be just adding the following "delta" requirement in a, e.g., ${systemd_system_unitdir}/my_service.d/override.conf file:
[Service]
Restart=always
and then adding that file in a dedicated .bbappend recipe file.
Tests so far were not successful in adding the above statements in the deployed service file (despite the "delta" conf file being correctly deployed). Is this even a possible solution?
You should be able to do that simply by echoing that entry in a do_install:append() section in you .bbappend file. Something like:
do_install:append() {
echo "[Service]\nRestart=always" >> ${D}${sysconfdir}/wpa_supplicant/...
}
You can equally use sed to find and replace that section if there is already a file inplace.
${sysconfdir} will expanded to /etc. Check this file for more defined path variables: https://git.yoctoproject.org/poky/plain/meta/conf/bitbake.conf?h=blinky

how to address files in GitHub action without using environmental parameters

I made a simple python script, that accepts the path text file as input arguments and appends them to each other, and create the single file.
My question is how to address those files in GitHub action without using predefined environmental parameters?
Is there any way the action scripts browse (tree) those files and fed them to the python script?
First, your GitHub Action can define and take a parameter, as see in actions/cat-for-github-actions: that does not use an environment variable.
Second, you can use a path filter in order to trigger your GitHub Action on any txt file change.
But if you want to list files, you need to use the predefined environment variable ${{ github.workspace }}, as in here.
You can then call a python script, which will list/filter files from the checkedout Git repository commit.

AzCopy ignore if source file is older

Is there an option to handle the next situation:
I have a pipeline and Copy Files task implemented in it, it is used to upload some static html file from git to blob. Everything works perfect. But sometimes I need this file to be changed in the blob storage (using hosted application tools). So, the question is: can I "detect" if my git file is older than target blob file and ignore this file for the copy task to leave it untouched. My initial idea was to use Azure file copy and use an "Optional Arguments" textbox. However, I couldn't find required option in the documentation. Does it allow such things? Or should this case be handled some other way?
I think you're looking for the isSourceNewer value for the --overwrite option.
--overwrite string Overwrite the conflicting files and blobs at the destination if this flag is set to true. (default true) Possible values include true, false, prompt, and ifSourceNewer.
More info: azcopy copy - Options
Agree with ickvdbosch. The isSourceNewer value for the --overwrite option could meet your requirements.
error: couldn't parse "ifSourceNewer" into a "OverwriteOption"
Based on my test, I could reproduce this issue in Azure file copy task.
It seems that the isSourceNewer value couldn't be set to Overwrite option in Azure File copy task.
Workaround: you could use PowerShell task to run the azcopy script to upload the files with --overwrite=ifSourceNewer
For example:
azcopy copy "filepath" "BlobURLwithSASToken" --overwrite=ifSourceNewer --recursive
For more detailed info, you could refer to this doc.
For the issue about the Azure File copy task, I suggest that you could submit a feedback ticket in the following link: Report task issues.

Azure DevOps: 'Replace Tokens task' having problem setting variable files from JSON

I'm trying to setup a 'Replace Tokens Task' for my build pipeline from a JSON file that will hold environmental variables as follow:
And then my JSON environment file:
The JavaScript target file to replace the tokens in:
Unfortunately, I'm getting the following error:
What am I missing here?
What am I missing here?
I can reproduce same issue on my side, and I think it only indicates there's something wrong with your Variable files(JSON) input:
Please make sure the variables are successfully loaded from the variable json file.
1.Make sure your env-config.json file has content below:
{
"alambda.endpoint":"ForTest"
}
2.Check carefully about the path of your env-config.json file! (In my opinion, your issue is more like a path issue~) If the task can't find and load the file, it also throws variable not found. For this:
Make sure the relative path is correct.
Try cut the long path, I'm not sure if the issue results from the too long path. Try using **/env-config.json instead of the very long path.
If above tips can't work, I suggest you can move the env-config.json file to root folder $(System.DefaultWorkingDirectory) with Copy Task or what. (About System.DefaultWorkingDirectory see here). Then try it again with **/env-config.json.