With meson, it is possible to pass a string with spaces during configuration, e.g. below usage cases are all valid:
meson -Dfoo="bar1 bar2" ...
meson "-Dfoo=bar1 bar2" ...
meson -Dfoo='bar1 bar2' ...
meson '-Dfoo=bar1 bar2' ...
When building a recipe with Bitbake, EXTRA_OEMESON is used to pass configuration parameters to meson.
I tried below but they all failed:
Surround the string with "" or ''
EXTRA_OEMESON = " -Dfoo=\"bar1 bar2\" "
# Results in
#meson: error: unrecognized arguments: bar2"
Surround the whole -Dxxx with "" or '':
EXTRA_OEMESON = " \"-Dfoo=bar1 bar2\" "
# Results in
# meson: error: unrecognized arguments: "-Dfoo=bar1 bar2"
So the question is, how to pass such a string with space to meson in bitbake?
Just surrounding the value with quotes should work:
EXTRA_OEMESON = "-Dfoo='bar1 bar2'"
Related
I have a requirement where I have to load powershell variables from a powershell script and store the vairable value in a groovy jenkins pipeline variable and use it thereafter to edit the name of an artifact depending on that variable's value.
powershell script: Variables.ps1 (in real scenario this has number of variables but this is just for sample)
$Version = "22.4"
jenkinsfile:
pipeline {
agent any
stages {
stage('TestPowershell') {
steps {
script {
def path = "${env.WORKSPACE}\\Power\\Variables.ps1"
echo path
def versionFromPowershell = powershell(returnStdout: true, script: " . '${path}'; return $Version;")
echo versionFromPowershell
}
}
}
}
}
I get an error when I use this method as below:
groovy.lang.MissingPropertyException: No such property: Version for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:251)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:26)
In the vannila powershell the script works fine and does the job, not sure why the same syntax doesn't work when invoked via jenkins build. Any help is much appreciated!
Thanks
Shobhit
You cannot interpolate Powershell variables in a Groovy interpreter. Therefore, the script argument to the step method must contain escaped variable syntax characters such that the variable Version is interpreted by Powershell and not Groovy:
def versionFromPowershell = powershell(returnStdout: true, script: " . '${path}'; \$Version;")
For one of my requirements, I need to call a specific tasks based on whether a packageconfig variable is defined in another recipes or not.
For example:
We have a recipe called recipes-crypto where, in the .bb file we have:
PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"
BBCLASSEXTEND = "native nativesdk"
Then, in my meta-qti-bsp/classes, I have qimage.class, where I wanted to do like this:
if ${#bb.utils.contains('PACKAGECONFIG', 'veritysetup', 'true', 'false', d)}; then
#Call some function
fi
But it gives errors:
ERROR: ParseError at /local/mnt/workspace/PINTU/WORK/Y2021/NAD-CORE-WORK/NEW_C10_30Nov/poky/meta-qti-bsp/classes/qimage.bbclass:102: unparsed line: 'if ${#bb.utils.contains('PACKAGECONFIG', 'veritysetup', 'true', 'false', d)}; then'
How to make veritysetup variable get recognised in my class file?
I saw some examples and added this on top:
PACKAGECONFIG_append_class-native = " veritysetup"
But with this also it gives the same error.
I am using this veritysetup command only during build time.
So, I wanted to execute this command if and only if this PACKAGECONFIG variable is defined.
What is the best way to do it ?
veritysetup is not a value of PACKAGECONFIG, but it is a flag.
PACKAGECONFIG has many flags and each flag has its value.
For more information about variable flags check this link.
So, here is an example of how to check if that flag is activated:
verity-example.bb
LICENSE = "CLOSED"
PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"
do_check_verity(){
if [ ${#d.getVarFlag('PACKAGECONFIG', 'veritysetup', False)} ]; then
bbwarn "veritysetup is activated with value: ${#d.getVarFlags('PACKAGECONFIG').get('veritysetup')}"
else
bbwarn "veritysetup is not activated."
fi
}
addtask do_check_verity
If you run:
bitbake verity-example -c check_verity
You will get the warning:
WARNING: verity-example-1.0-r0 do_sample: veritysetup is activated
with value: --enable-veritysetup,--disable-veritysetup
Actually, I did it in this way and it worked for me.
The following is already enabled in recipes-crypto like this:
PACKAGECONFIG[veritysetup] = "--enable-veritysetup,--disable-veritysetup"
Now, in our .bbclass I just called like this:
DEPENDS += "cryptsetup-native openssl-native"
PACKAGECONFIG_append = " veritysetup"
**==> This is the main part how we can check, if a packageconfig variable is enabled elsewhere or not**
Then I can check the condition like this:
if not bb.utils.contains('PACKAGECONFIG', 'veritysetup', True, False, d):
//dome something
else:
//done something else
In Below command I want to skip cmdParamString argument since that is not required for one of apps deployment , and its required for other apps deployment so cant change this common deploy command , how can I implement that?
def deployCommand = "\"${msDeploy}\\MSDeploy.exe\" -verb:sync -source:package=\"${packageLocation}\" -dest:${destParamsString} ${cmdParamString}"
Output
C:\bin\jenkins\workspace\Deploy Test>"C:\Program Files\IIS\Microsoft Web Deploy V3\MSDeploy.exe" -verb:sync -source:package="C:/bin/jenkins/ArtifactorySharedDownloads/cabb6d400bb5f176700c6bb21f0a5a6580c6c97f/package.zip" -dest:ContentPath="C:\WWW\Service",ComputerName="http:local.test/MSDeployAgentService",Username="xyz",Password="abc" -setParam:"NLog Database connection string"="server=No DB setting,null;database=null;Integrated Security=SSPI" -setParam:"NLog Log Level"="null" -setParam:"ISL Database connection string"="server=No DB setting,null;database=null;Integrated Security=SSPI"
15:46:00 Error: Unrecognized argument 'NLog Database connection string'.
I tried
if(application.name == "abc") {
cmdParamString = '--%'
}
Error: Unrecognized argument '--'.
solution to this is passing an empty argument like below and it worked:
def cmdParamString = [ all database connection details are filled here]
if (application == 'abc') {
cmdParamString = [:]
}
this has ignored cmdParamString in deployCOmmand for application abc
I am using the Typescript API of pulumi. I noticed that when I invoke console.log("\n\n"), pulumi strips out the newlines. I want to keep these newlines to improve the readability of the deployment log.
Is there a way to instruct pulumi to keep newlines in the output log?
The current behavior of the Pulumi CLI is to break your messages into lines (split by \n), trim every line, drop empty lines, and display the result.
Although ugly, you could force your line breaks with an extra "zero-width space" character:
console.log("Top line");
console.log("\u200B\n\u200B\n\u200B");
console.log("There will be three empty lines before this line");
You could use something more trivial like _ instead of the zero-width space. Obviously, underscores will be visible.
Track this issue for further progress.
Pulumi should not be stripping newlines or otherwise manipulating your console.log() output. I just tested this and my string with newlines was printed as expected with newlines.
Code
import * as aws from "#pulumi/aws";
const bucket = new aws.s3.Bucket("main", {
acl: "private",
})
bucket.onObjectCreated("logger", new aws.lambda.CallbackFunction<aws.s3.BucketEvent, void>("loggerFn", {
memorySize: 128,
callback: (e) => {
for (const rec of e.Records || []) {
const [buck, key] = [rec.s3.bucket.name, rec.s3.object.key];
console.log(`Object created: ${buck}/${key}`);
}
},
}));
console.log(`My
multi-line
string`);
export const bucketName = bucket.bucket;
Output
$ pulumi up -y
Previewing update (dev):
Type Name Plan Info
+ pulumi:pulumi:Stack demo-aws-ts-serverless-dev create 3 ...
+ └─ aws:lambda:Function loggerFn create
Diagnostics:
pulumi:pulumi:Stack (demo-aws-ts-serverless-dev):
My
multi-line
string
Resources:
+ 8 to create
Updating (dev):
Type Name Status Info
+ pulumi:pulumi:Stack demo-aws-ts-serverless-dev created ...
+ └─ aws:lambda:Function loggerFn created
Diagnostics:
pulumi:pulumi:Stack (demo-aws-ts-serverless-dev):
My
multi-line
string
Outputs:
bucketName: "main-b568df3"
Resources:
+ 8 created
...
I am trying to checkout code from SVN repo for which I am accepting the URL as argument. I have quoted the URL as shown below because it contains spaces. I also checked the parameter by redirecting the $svn_url in file (shown below). If I pick the URL from the file and pass it as is on the command line to the given script, it works fine but somehow when invoked from Puppet, it's not working.
Puppet manifests:
repo_checkout.pp:
define infra::svn::repo_checkout ($svn_url_params) {
$svn_url = $svn_url_params[svn_url]
include infra::params
$repo_checkout_ps = $infra::params::repo_checkout_ps
file { $repo_checkout_ps:
ensure => file,
source => 'puppet:///modules/infra/repo_checkout.ps1',
}
util::executeps { 'Checking out repo':
pspath => $repo_checkout_ps,
argument => "\'\"$svn_url\"\'",
}
}
params.pp:
$repo_checkout_ps = 'c:/scripts/infra/repo_checkout.ps1',
site.pp:
$svn_url_ad = {
svn_url => 'https:\\\\some_repo.abc.com\svn\dir with space\util',
}
infra::svn::repo_checkout { "Checking out code in C:\build":
svn_url_params => $svn_url_ad
}
executeps.pp:
define util::executeps ($pspath, $argument) {
$powershell = 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -NoLogo -NonInteractive'
exec { "Executing PS file \"$pspath\" with argument \"$argument\"":
command => "$powershell -file $pspath $argument",
timeout => 900,
}
}
PowerShell code:
$svn_url = $args[0]
Set-Location C:\build
echo "svn co --username user --password xxx --non-interactive '$svn_url'" | Out-File c:\svn_url
svn co --username user --password xxx --non-interactive '$svn_url'
Puppet output on agent node:
Util::Executeps[Checking out repo]/Exec[Executing PS file "c:/scripts/infra/repo_checkout.ps1" with argument "'"https:\\some_repo.abc.com\svn\dir with space\util"'"]/returns: executed successfully
Notice: Applied catalog in 1.83 seconds
Content of c:\svn_url:
'https:\\\\some_repo.abc.com\svn\dir with space\util'
UPDATE: Sorry for the confusion but i was trying out several permutations and combinations and in doing that, i forgot to mention that when the $svn_url contains backslash (\), it does NOT work on the command line too if i copy the SVN URL from the text file where i am redirecting the echo output.
Based on #Ansgar's suggestion, i changed '$svn_url' to "$svn_url" in powershell code but the output in text file then contained ' quote twice around the URL. So i changed the argument parameter from "\'\"$svn_url\"\'" to "\"$svn_url\"". Now the output file had only single quote present around the URL. I copied only the URL (along with single quotes around it) from the output file and tried passing it to the powershell script. I now get the following error:
svn: E020024: Error resolving case of 'https:\\some_repo.abc.com\svn\dir with space\util'
Another thing to note is that if i change the back slashes in URL to forward slashes, it works fine on the command line. Invoking from Puppet still doesn't work.
Posting the final configuration that worked out for me based on #AnsgarWiechers' suggestion.
[tom#pe-server] cat repo_checkout.pp
define infra::svn::repo_checkout ($svn_url_params) {
$svn_url = $svn_url_params[svn_url]
...
...
util::executeps { 'Checking out repo':
pspath => $repo_checkout_ps,
argument => "\"$svn_url\"",
}
}
[tom#pe-server] cat repo_checkout.ps1
$svn_url = $args[0]
Set-Location C:\build
svn co --username user --password xxx --non-interactive "$svn_url"
[tom#pe-server] cat params.pp
$repo_checkout_ps = 'c:/scripts/infra/repo_checkout.ps1',
[tom#pe-server] cat site.pp
$svn_url_ad = {
svn_url => 'https://some_repo.abc.com/svn/dir with space/util',
}
infra::svn::repo_checkout { "Checking out code in C:\build":
svn_url_params => $svn_url_ad
}
Thanks a lot #AnsgarWiechers! :)
Note:
In site.pp: Used forwardslashes (/) when specifying svn_url
In repo_checkout.ps1: Changed '$svn_url' to "$svn_url"
In repo_checkout.pp: Changed double-nested (' and ") quoting in argument to single (") nested i.e., from "\'\"$svn_url\"\'" to "\"$svn_url\""