Yocto glibc_2.30.bb fatal error: asm/unistd.h: No such file or directory - yocto

I am trying to build Yocto Zeus in Podman and getting the below error. I noticed that sigcontext.h header file .recipe-sysroot/usr/include/ only has 32bit version whereas unistd.h file copied under asm-generic directory.
./recipe-sysroot/usr/include/asm/sigcontext-32.h
./recipe-sysroot/usr/include/asm-generic/unistd.h
| ../sysdeps/unix/sysv/linux/sys/syscall.h:24:10: fatal error: asm/unistd.h: No such file or directory
| 24 | #include <asm/unistd.h>
| | ^~~~~~~~~~~~~~
| compilation terminated.
| Traceback (most recent call last):
| File "../scripts/gen-as-const.py", line 120, in <module>
| main()
| File "../scripts/gen-as-const.py", line 116, in main
| consts = glibcextract.compute_c_consts(sym_data, args.cc)
| File "/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/git/scripts/glibcextract.py", line 62, in compute_c_consts
| subprocess.check_call(cmd, shell=True)
| File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
| raise CalledProcessError(retcode, cmd)
| subprocess.CalledProcessError: Command 'arm-poky-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot -std=gnu11 -fgnu89-inline -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0=/usr/src/debug/glibc/2.30-r0 -fdebug-prefix-map=/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0=/usr/src/debug/glibc/2.30-r0 -fdebug-prefix-map=/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot= -fdebug-prefix-map=/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot-native= -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -ftls-model=initial-exec -I../include -I/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/csu -I/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi -I../sysdeps/unix/sysv/linux/arm -I../sysdeps/arm/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm/armv7/multiarch -I../sysdeps/arm/armv7 -I../sysdeps/arm/armv6t2 -I../sysdeps/arm/armv6 -I../sysdeps/arm/include -I../sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include -isystem /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed -isystem /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/recipe-sysroot/usr/include -D_LIBC_REENTRANT -include /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DTOP_NAMESPACE=glibc -DGEN_AS_CONST_HEADERS -MD -MP -MF /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/tcb-offsets.h.dT -MT '/home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/tcb-offsets.h.d /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/tcb-offsets.h' -S -o /tmp/tmp2wx6srl6/test.s -x c - < /tmp/tmp2wx6srl6/test.c' returned non-zero exit status 1
| make[2]: *** [../Makerules:271: /home/dev/inode_zeus/build/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/glibc/2.30-r0/build-arm-poky-linux-gnueabi/tcb-offsets.h] Error 1
| make[2]: *** Waiting for unfinished jobs....
| In file included from ../signal/signal.h:291,
| from ../include/signal.h:2,
| from ../misc/sys/param.h:28,
| from ../include/sys/param.h:1,
| from ../sysdeps/generic/hp-timing-common.h:39,
| from ../sysdeps/generic/hp-timing.h:25,
| from ../nptl/descr.h:27,
| from ../sysdeps/arm/nptl/tls.h:42,
| from ../sysdeps/unix/sysv/linux/arm/tls.h:23,
| from ../include/link.h:51,
| from ../include/dlfcn.h:4,
| from ../sysdeps/generic/ldsodefs.h:32,
| from ../sysdeps/arm/ldsodefs.h:38,
| from ../sysdeps/gnu/ldsodefs.h:46,
| from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
| from ../sysdeps/unix/sysv/linux/arm/ldsodefs.h:22,
| from <stdin>:2:
| ../sysdeps/unix/sysv/linux/bits/sigcontext.h:30:11: fatal error: asm/sigcontext.h: No such file or directory
| 30 | # include <asm/sigcontext.h>
| | ^~~~~~~~~~~~~~~~~~
| compilation terminated.
|
ERROR: Task (/home/dev/inode_zeus/sources/poky/meta/recipes-core/glibc/glibc_2.30.bb:do_compile) failed with exit code '1'
DEBUG: Teardown for bitbake-worker
NOTE: Tasks Summary: Attempted 437 tasks of which 430 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/dev/inode_zeus/sources/poky/meta/recipes-core/glibc/glibc_2.30.bb:do_compile
Please note that I am able to build Jethro version using the Podman Container which runs Ubuntu16.04.
But, Zeus build is failing. Can someone tell me why these errors are seen?

I am able to resolve the issue by mapping the yocto build directory with host directory.
Yocto build worked liked a charm!
podman --storage-opt overlay.mount_program=/usr/bin/fuse-overlayfs --storage-opt overlay.mountopt=nodev,metacopy=on,noxattrs=1 run -it -v $PWD/my_yocto/build_output:/home/oibdev/yocto/build 4cbcb3842ed5

Related

Using sql query in shell script

I have a shell script that uses output from a sql query and based on the value of one column sends out an alert. However i don't think it's capturing the value. although the value is not greater than 0 yet it still sends out an email.
Any idea where i am going wrong? Thanks.
............................................................................
#!/bin/sh
psql -d postgres -U postgres -c "select pid,application_name,pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn) sending_lag,pg_wal_lsn_diff(sent_lsn,flush_lsn) receiving_lag,pg_wal_lsn_diff(flush_lsn, replay_lsn) replaying_lag,pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) total_lag from pg_stat_replication;"| while read total_lag;
do
echo $total_lag
lag1=$(echo $total_lag)
done
if [[ $lag1 -ge 0 ]]
then echo "Current replication lag is $lag1" |mail -s "WARNING!" abcd#mail.com
else
echo "No issue"
fi
............................................................................
this is the output of above query
pid | application_name | sending_lag | receiving_lag | replaying_lag | total_lag
-------+------------------+-------------+---------------+---------------+-----------
27823 | db123 | 0 | 0 | 0 | 0
27824 | db023 | 0 | 0 | 0 | 0

how to use jq command to create a table from a file content

I already used grep sed command to do something (cat service.yaml | grep -Po '(service_[^:]*|version:.+)'| sed -z 's/\nversion//g'), but now I need to create a "table" of content of this file in the output like this:
Here's a variant of #jq170727's solution that only uses:
a yaml-to-json translator; and
jq
To illustrate an alternative to yq for (1), I'll use npm's yaml2json.
yaml2json service.yaml | jq -r '
keys_unsorted as $keys
| (["service", "version", "replica"] | map("\"\(.)\"")), # quote the headers
($keys[] as $k | .[$k] | [$k, .version, .replica])
| #tsv'
Notice also that keys_unsorted is used, mainly to respect the order of the keys in the original YAML file.
Here is a filter which may help
keys[] as $k | .[$k] | [$k, .version, .replica]
Here is an example using it. For reference this is the yq I have from brew
$ yq --help | grep github
See https://github.com/kislyuk/yq for more information.
and/or https://stedolan.github.io/jq
First convert yaml to json
$ yq . service.yaml
{
"service-1": {
"replica": 2,
"version": "0.6.24"
},
"service-2": {
"replica": 3,
"version": "0.21.14"
}
}
Examine top level object
$ yq . service.yaml \
| jq -r 'keys'
[
"service-1",
"service-2"
]
Flatten into a stream of arrays
$ yq . service.yaml \
| jq -c 'keys[] as $k | .[$k] | [$k, .version, .replica]'
["service-1","0.6.24",2]
["service-2","0.21.14",3]
Convert to csv and format as a table
$ yq . service.yaml \
| jq -cr 'keys[] as $k | .[$k] | [$k, .version, .replica] | #csv' \
| column -s, -t
"service-1" "0.6.24" 2
"service-2" "0.21.14" 3
Add titles
$ yq . service.yaml \
| jq -cr 'keys[] as $k | .[$k] | [$k, .version, .replica] | #csv' \
| (echo '"service","version","replica"'; cat -) \
| column -s, -t
"service" "version" "replica"
"service-1" "0.6.24" 2
"service-2" "0.21.14" 3
If you want no quotes around the strings in the final rows this may be better
$ yq . service.yaml \
| jq -cr 'keys[] as $k | .[$k] | "\($k),\(.version),\(.replica)"' \
| (echo '"service","version","replica"'; cat -) \
| column -s, -t
"service" "version" "replica"
service-1 0.6.24 2
service-2 0.21.14 3

How to preserve new line character while performing psql copy command

I have following content in my csv file(with 3 columns):
141413,"\"'/x=/></script></title><x><x/","Mountain View, CA\"'/x=/></script></title><x><x/"
148443,"CLICK LINK BELOW TO ENTER^^^^^^^^^^^^^^","model\
\
xxx lipsum as it is\
\
100 sometimes unknown\
\
travel evening market\
"
When I import above mentioned csv in mysql using following command, it treats the backslash() as new line; which is the expected behavior.
LOAD DATA INFILE '1.csv' INTO TABLE users FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n';
MYSQL Output
But when I try to import to psql using copy command, it treats \ as a normal character.
copy users from '1.csv' WITH (FORMAT csv, DELIMITER ',', ENCODING 'utf8', NULL "\N", QUOTE E'\"', ESCAPE '\');
postgres Output
Try parsing these \ before importing the CSV file, e.g. using perl -pe or sed and the STDIN from psql:
$ cat 1.csv | perl -pe 's/\\\n/\n/g' | psql testdb -c "COPY users FROM STDIN WITH (FORMAT csv, DELIMITER ',', ENCODING 'utf8', NULL "\N", QUOTE E'\"', ESCAPE '\');"
This is how it looks like after the import:
testdb=# select * from users;
id | company | location
--------+-----------------------------------------+-------------------------------------------------
141413 | "'/x=/></script></title><x><x/ | Mountain View, CA"'/x=/></script></title><x><x/
148443 | CLICK LINK BELOW TO ENTER^^^^^^^^^^^^^^ | model +
| | +
| | xxx lipsum as it is +
| | +
| | 100 sometimes unknown +
| | +
| | travel evening market +
| |
(2 Zeilen)

MissingEndParenthesisInMethodCall - checking if an environment variable is empty

I'm trying to check whether an environment variable is empty or unset in my PowerShell script. The script is running in a Docker container, and intended to pull new code if an environment variable is defined:
CMD if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { \
Write-Host Git pull started; \
PortableGit\bin\git.exe pull; \
}; \
I get a bunch of errors:
web_1 | At line:1 char:110
web_1 | + ... ence = 'SilentlyContinue'; if (-not ([string]::IsNullOrEmpty(env:UPDA ...
web_1 | + ~
web_1 | Missing ')' in method call.
web_1 | At line:1 char:110
web_1 | + ... ue'; if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { Wr ...
web_1 | + ~~~~~~~~~~~~~~~~~~~~~~
web_1 | Unexpected token 'env:UPDATE_FROM_GITHUB' in expression or statement.
web_1 | At line:1 char:110
web_1 | + ... ence = 'SilentlyContinue'; if (-not ([string]::IsNullOrEmpty(env:UPDA ...
web_1 | + ~
web_1 | Missing closing ')' in expression.
web_1 | At line:1 char:110
web_1 | + ... ue'; if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { Wr ...
web_1 | + ~~~~~~~~~~~~~~~~~~~~~~
web_1 | Missing closing ')' after expression in 'if' statement.
web_1 | At line:1 char:132
web_1 | + ... e'; if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { Wri ...
web_1 | + ~
web_1 | Unexpected token ')' in expression or statement.
web_1 | At line:1 char:133
web_1 | + ... '; if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { Writ ...
web_1 | + ~
web_1 | Unexpected token ')' in expression or statement.
web_1 | At line:1 char:134
web_1 | + ... ; if (-not ([string]::IsNullOrEmpty(env:UPDATE_FROM_GITHUB))) { Write ...
I'm not sure how to begin here. The errors seem redundant, but there isn't a clear starting place. Could it have something to do with how Docker parses commands?
PowerShell variables, including environment variables, must always be referred to with sigil $
Therefore, env:UPDATE_FROM_GITHUB must be $env:UPDATE_FROM_GITHUB
To simply test if an environment variable is defined / has a value, you don't strictly need -not [string]::IsNullOrEmpty(...); instead, you can take advantage of PowerShell's implicit Boolean conversion:
$null or the empty string is considered $False
and any nonempty string $True
To put it all together:
CMD if ($env:UPDATE_FROM_GITHUB) { \
Write-Host Git pull started; \
PortableGit\bin\git.exe pull; \
}; \

String manipulation in fish shell

i wish to write a fish shell script to automatically initialize JAVA_HOME to current configured java-alternative.
In bash it would look like this (sorry for the ugly double dirname)
j=`update-alternatives --query javac | grep Value:`
JAVA_HOME=`dirname ${j#Value:}`
JAVA_HOME=`dirname $JAVA_HOME`
export JAVA_HOME
what about fish?
set j (update-alternatives --query javac | grep Value:)
set JAVA_HOME (dirname ${j#Value:}) <-- this won't work!!
set JAVA_HOME (dirname $JAVA_HOME)
set --export JAVA_HOME
The fish shell now has a string builtin command for string manipulation. This was added in version 2.3.0 (May 2016).
E.g. in this case, we could use string replace to remove the Value: substring:
set j (update-alternatives --query javac | grep Value: | string replace 'Value: ' '')
set --export JAVA_HOME (dirname (dirname $j))
There's lots more that string can do. From the string command documentation:
Synopsis
string length [(-q | --quiet)] [STRING...]
string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)]
[STRING...]
string split [(-m | --max) MAX] [(-r | --right)] [(-q | --quiet)] SEP
[STRING...]
string join [(-q | --quiet)] SEP [STRING...]
string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)]
[(-q | --quiet)] [STRING...]
string escape [(-n | --no-quoted)] [STRING...]
string match [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)]
[(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
string replace [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)]
[(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
Bash:
j=$(update-alternatives --query javac | sed -n '/Value: /s///p')
export JAVA_HOME=${j%/*/*}
Fish:
set j (update-alternatives --query javac | sed -n '/Value: /s///p')
set --export JAVA_HOME (dirname (dirname $j))
or
set --export JAVA_HOME (dirname (dirname (update-alternatives --query javac | sed -n '/Value: /s///p')))
Instead of sed, u could make use of expr with a regexp, for example:
$ set a /path/to/some/folder/file.extension
the command:
$ expr "//$a" : '.*/\([^.]*\)\..*$'
file
extract the file basename without extension.
See man expr
Fish shell:
~> set JAVA_HOME (readlink -f /usr/bin/javac | sed "s:/bin/javac::")
~> echo $JAVA_HOME
Output (example):
/usr/lib/jvm/java-8-openjdk-amd64
Also u can add to ~/.config/fish/config.fish this line:
set JAVA_HOME (readlink -f /usr/bin/javac | sed "s:/bin/javac::")
WBR