forked from Wind-River/meta-wr-sbom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_create_sbom
87 lines (77 loc) · 3.33 KB
/
init_create_sbom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
layer_path=$(dirname $(realpath $BASH_SOURCE))
# WRLinux5 -- WRLinux8
if [ -e Makefile ]
then
p_version=`sed -n 's/^PACKAGE_VERSION\s*=\s*\(.*\)/\1/p' Makefile`
if [ ${p_version:-" "} == "8.0" ] || [ ${p_version:-" "} == "7.0" ] || [ ${p_version:-" "} == "6.0" ]
then
case $p_version in
"6.0")
#patch bitbake
pushd ./bitbake > /dev/null
if [ ! -e bin/bitbake-worker.wrl6lock ]
then
echo 'Backup bin/bitbake-worker to bin/bitbake-worker.wrl6lock'
cp bin/bitbake-worker bin/bitbake-worker.wrl6lock
echo 'Backup lib/bb/runqueue.py to lib/bb/runqueue.py.wrl6lock'
cp lib/bb/runqueue.py lib/bb/runqueue.py.wrl6lock
patch -p1 -i ${layer_path}/patch/enable-taskdepdata.patch
else
echo "bitbake has patched as enable taskdepdata"
fi
popd > /dev/null
;;
"7.0")
;;
"8.0")
;;
esac
grep -q ${layer_path} bitbake_build/conf/bblayers.conf
if [ $? -ne 0 ]
then
echo "BBLAYERS += '${layer_path}'" >> bitbake_build/conf/bblayers.conf
else
echo "${layer_path} had exist in bblayers.conf"
fi
grep -q "^INHERIT.*sls-create-spdx'" bitbake_build/conf/local.conf
[ $? -ne 0 ] && echo "INHERIT += 'sls-create-spdx'" >> bitbake_build/conf/local.conf
[ -e ${layer_path}/classes/sls-create-spdx.bbclass ] && rm ${layer_path}/classes/sls-create-spdx.bbclass
ln -s sls-create-spdx_Py2.bbclass ${layer_path}/classes/sls-create-spdx.bbclass
[ -e ${layer_path}/lib/oe_sbom ] && rm ${layer_path}/lib/oe_sbom
ln -s oe_sbom2 ${layer_path}/lib/oe_sbom
else
echo "ERROR: Not support this Wind River version."
fi
else
grep -q ${layer_path} conf/bblayers.conf
if [ $? -ne 0 ]
then
echo "BBLAYERS += '${layer_path}'" >> conf/bblayers.conf
else
echo "${layer_path} had exist in bblayers.conf"
fi
grep -q "^INHERIT.*sls-create-spdx'" conf/local.conf
[ $? -ne 0 ] && echo "INHERIT += 'sls-create-spdx'" >> conf/local.conf
bb_version=`bitbake --version | awk '{print $NF}'`
eval $(echo $bb_version |awk -F\. '{print "m_ver="$1" s_ver="$2}')
if [ $m_ver -eq 1 ] && [ $s_ver -lt 31 ] #bitbake 1.30 and lower version(yocto2.1 to 1.5)
then
[ -e ${layer_path}/classes/sls-create-spdx.bbclass ] && rm ${layer_path}/classes/sls-create-spdx.bbclass
ln -s sls-create-spdx_Py2.bbclass ${layer_path}/classes/sls-create-spdx.bbclass
[ -e ${layer_path}/lib/oe_sbom ] && rm ${layer_path}/lib/oe_sbom
ln -s oe_sbom2 ${layer_path}/lib/oe_sbom
else #bitbake 1.32 and higher version(yocto2.2 to 4.0)
[ -e ${layer_path}/classes/sls-create-spdx.bbclass ] && rm ${layer_path}/classes/sls-create-spdx.bbclass
ln -s sls-create-spdx_Py3.bbclass ${layer_path}/classes/sls-create-spdx.bbclass
[ -e ${layer_path}/lib/oe_sbom ] && rm ${layer_path}/lib/oe_sbom
ln -s oe_sbom3 ${layer_path}/lib/oe_sbom
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export LANG=en_US.UTF-8
fi
fi