-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_docker.sh
More file actions
executable file
·109 lines (104 loc) · 4.83 KB
/
create_docker.sh
File metadata and controls
executable file
·109 lines (104 loc) · 4.83 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#------------------SCRIPT VARIABLES---------------#
compiler_ver="rhel8"
input_version=""
init_path="/tmp/output/"
#repo_path assigned the default repo
repo_path="/swgwork/valentinef/OFED_REBASE_AREA/rebase_5_5/backports_stage/mlnx-ofa_kernel-4.0"
script_name="create_docker"
container_name="$(whoami)"
external_headers=""
kernel_list="
'linux-5.13-rc4'\n'linux-5.12'\n'linux-5.11'\n'linux-5.10-rc2'\n'linux-5.9-rc2'\n'linux-5.8'\n'linux-5.7'\n'linux-5.6'\n'linux-5.5'\n'linux-5.4'\n'linux-5.3'\n'linux-5.2'\n'linux-5.0'\n'linux-4.20'\n'linux-4.19'\n'linux-4.18.0-235.el8.x86_64'\n'linux-4.18'\n'linux-4.17-rc1'\n'linux-4.16'\n'linux-4.15'\n'linux-4.14.3'\n'linux-4.13'\n'linux-4.12-rc6'\n'linux-4.11'\n'linux-4.10-Without-VXLAN'\n'linux-4.10-IRQ_POLL-OFF'\n'linux-4.10'\n'linux-4.9'\n'linux-4.8-rc4'\n'linux-4.7-rc7'\n'linux-4.6.3'\n'linux-4.5.5-300.fc24.x86_64'\n'linux-4.5.1'\n'linux-4.4.73-5-default'\n'linux-4.4.21-69-default'\n'linux-4.4.0-22-generic'\n'linux-4.4'\n'linux-4.3-rc6'\n'linux-4.2.3-300.fc23.x86_64'\n'linux-4.2-rc8'\n'linux-4.1.12-37.5.1.el6uek.x86_64'\n'linux-4.1'\n'linux-4.0.4-301.fc22.x86_64'\n'linux-4.0.1'\n'linux-3.19.0'\n'linux-3.18'\n'linux-3.17.4-301.fc21.x86_64'\n'linux-3.17.1'\n'linux-3.16-rc7'\n'linux-3.15.7-200.fc20.x86_64'\n'linux-3.15'\n'linux-3.14'\n'linux-3.13.1'\n'linux-3.12'\n'linux-3.12.49-11-xen'\n'linux-3.12.49-11-default'\n'linux-3.10'\n'linux-3.12.28-4-default'\n'linux-3.10.0-327.el7.x86_64'\n'linux-3.10.0-514.el7.x86_64-ok'\n'linux-3.10.0-229.el7.x86_64'\n'linux-3.10.0-123.el7.x86_64'\n'linux-3.10.0-693.el7.x86_64'\n'linux-3.10.0-862.el7.x86_64'\n'linux-3.10.0-957.el7.x86_64'
"
#----------------------MAIN------------------------#
while [ ! -z "$1" ]
do
if [[ $1 == "linux"* ]]; then
input_version=$1
shift
continue
fi
case "$1" in
-l | --list)
echo " supported kernels:"
echo "-------------------"
echo -e $kernel_list
exit 1
;;
-r | --repositoty)
repo_path="$2"
shift
;;
-n | --name)
container_name="$2"
shift
;;
-e | --external-headers)
external_headers="$2"
shift
;;
-c | --compiler)
compiler_ver="$2"
shift
;;
-h | --help)
echo "Usage: ${script_name} [options] linux-KERNEL_VERSION
use this script to create docker.
-h, --help display this help message and exit
-l, --list display list of supported kernel and exit
-r, --repository full path for your git repositoy
-n, --name create container with specific name [Default: user's name]
-c, --compiler Choose compiler version [Default rhel8]
-e, --external-headers Use Specific headers in path
"
exit 1
;;
*)
echo "-E- Unsupported option: $1" >&2
echo "use -h flag to display help menu"
exit 1
;;
esac
shift
done
if [ -z "$repo_path" ]
then
echo "-E- 'create_docker.sh' must have full path to repository [use {-r | --repository} flag]"
exit 1
fi
if [ -z "$input_version" ]
then
echo "-E- 'create_docker.sh' must have version [use: 'create_docker.sh -l' to see supported kernels]"
exit 1
else
echo "inside docker for kernel ${input_version}"
echo ""
echo "---------------------------------------------------------------------------------------------"
echo " use: 'source /output/init_docker.sh' ['source output/init_docker.sh -h' for help]"
echo "---------------------------------------------------------------------------------------------"
echo "Usage: init_docker [options]
use this script to config docker environment.
important: need to source this script for full functionality.
-h, --help display this help message and exit
--without-odp ignore odp feature at configure
--without-xdp ignore XDP feature at configure
-m, --module config environment for specific module [default module is ib_core]
-l, --module-list display available MODULEs and exit
"
major=$(echo $input_version | sed -e 's/linux-//g' | cut -d"." -f1)
minor=$(echo $input_version | sed -e 's/linux-//g' | sed -e 's/-.*//g' |cut -d"." -f2)
#if [ $major -ge 5 ]; then
# if [ $minor -ge 8 ] || [ $major -gt 5 ]; then
# compiler_ver="rhel8"
#should open when resolved, for now not working
#compiler_ver="rhel8"
# fi
#fi
sudo cp -f /swgwork/royno/OFED/my_scripts/init_docker.sh /tmp/output/
if [ "X$external_headers" == "X" ];then
sudo docker run -it --rm --entrypoint=/bin/bash --tmpfs /build:rw,exec,nosuid,mode=755,size=20G --name=${container_name} --mount type=tmpfs,target=/tmp/ -v ${repo_path}/.git:/git-repo/:ro -v /tmp/output:/output -v /.autodirect/mswg2/work/kernel.org/x86_64/${input_version}/:/tmp/${input_version}/ harbor.mellanox.com/sw-linux-devops/cross_compile:${compiler_ver}
else
sudo docker run -it --rm --entrypoint=/bin/bash --tmpfs /build:rw,exec,nosuid,mode=755,size=20G --name=${container_name} --mount type=tmpfs,target=/tmp/ -v ${repo_path}/.git:/git-repo/:ro -v /tmp/output:/output -v ${external_headers}:/tmp/${input_version}/ harbor.mellanox.com/sw-linux-devops/cross_compile:${compiler_ver}
fi
fi