Skip to content

Commit eeecd1e

Browse files
committed
build: add some commands and make build.sh independent
1. add some command binaries for debug in vm 2. build.sh is for docker/ctr/isula to prepare guest rootfs and build it to image or initrd, thus it should not have any difference with each guest os. Signed-off-by: Zhang Tianyang <[email protected]>
1 parent af4128a commit eeecd1e

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ bin/vmlinux.bin:
2929
@mkdir -p bin && cp vmm/scripts/kernel/${HYPERVISOR}/vmlinux.bin bin/vmlinux.bin && rm vmm/scripts/kernel/${HYPERVISOR}/vmlinux.bin
3030

3131
bin/kuasar.img:
32-
@bash vmm/scripts/image/${GUESTOS_IMAGE}/build.sh image
32+
@bash vmm/scripts/image/build.sh image ${GUESTOS_IMAGE}
3333
@mkdir -p bin && cp /tmp/kuasar.img bin/kuasar.img && rm /tmp/kuasar.img
3434

3535
bin/kuasar.initrd:
36-
@bash vmm/scripts/image/${GUESTOS_IMAGE}/build.sh initrd
36+
@bash vmm/scripts/image/build.sh initrd ${GUESTOS_IMAGE}
3737
@mkdir -p bin && cp /tmp/kuasar.initrd bin/kuasar.initrd && rm /tmp/kuasar.initrd
3838

3939
bin/wasm-sandboxer:

vmm/scripts/image/centos/build.sh vmm/scripts/image/build.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515

1616
exit_flag=0
17+
export GUESTOS_IMAGE=${2:-"centos"}
1718
export IMAGE_NAME=${IMAGE_NAME:-"centos:7"}
1819
export ROOTFS_DIR=${ROOTFS_DIR:-"/tmp/kuasar-rootfs"}
1920
export CONTAINER_RUNTIME=${RUNTIME:-"containerd"}
@@ -40,7 +41,7 @@ echo "build in ${IMAGE_NAME}"
4041

4142
if [ ! -n "${REPO_DIR}" ]; then
4243
current_dir=$(dirname "$(readlink -f "$0")")
43-
pushd ${current_dir}/../../../..
44+
pushd ${current_dir}/../../..
4445
REPO_DIR=$(pwd)
4546
popd
4647
fi
@@ -68,7 +69,7 @@ containerd)
6869
--mount type=bind,src="${ROOTFS_DIR}",dst=/tmp/kuasar-rootfs,options=rbind:rw \
6970
${IMAGE_NAME} \
7071
${container_name} \
71-
bash /kuasar/vmm/scripts/image/centos/build_rootfs.sh
72+
bash /kuasar/vmm/scripts/image/${GUESTOS_IMAGE}/build_rootfs.sh
7273
fn_check_result $? "ctr run ${container_name} return error!"
7374
;;
7475
docker)
@@ -80,7 +81,7 @@ docker)
8081
-v "${REPO_DIR}":/kuasar \
8182
-v "${ROOTFS_DIR}":"/tmp/kuasar-rootfs" \
8283
${IMAGE_NAME} \
83-
bash /kuasar/vmm/scripts/image/centos/build_rootfs.sh
84+
bash /kuasar/vmm/scripts/image/${GUESTOS_IMAGE}/build_rootfs.sh
8485
fn_check_result $? "docker run ${container_name} return error!"
8586
;;
8687
isulad)
@@ -93,7 +94,7 @@ isulad)
9394
-v "${REPO_DIR}":/kuasar \
9495
-v "${ROOTFS_DIR}":"/tmp/kuasar-rootfs" \
9596
${IMAGE_NAME} \
96-
bash /kuasar/vmm/scripts/image/centos/build_rootfs.sh
97+
bash /kuasar/vmm/scripts/image/${GUESTOS_IMAGE}/build_rootfs.sh
9798
fn_check_result $? "isula run ${container_name} return error!"
9899
;;
99100
*)

vmm/scripts/image/centos/binaries.list

+19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
/usr/bin/sh /bin
88
# procps-ng
99
/usr/bin/ps /bin
10+
/usr/bin/kill /bin
11+
/usr/bin/free /bin
12+
/usr/bin/top /bin
1013
# kmod
1114
/usr/sbin/modprobe /sbin
1215
/usr/sbin/depmod /sbin
@@ -23,6 +26,7 @@
2326
/usr/bin/quotasync /bin
2427
# cni
2528
/usr/sbin/arping /sbin
29+
/usr/bin/ping /sbin
2630
/usr/bin/echo /bin
2731
# iptables
2832
/usr/sbin/iptables /sbin
@@ -32,3 +36,18 @@
3236
/usr/bin/ls /bin
3337
/usr/bin/cat /bin
3438
/usr/bin/cp /bin
39+
/usr/bin/mv /bin
40+
/usr/bin/rm /bin
41+
/usr/bin/mkdir /bin
42+
/usr/bin/find /bin
43+
/usr/bin/awk /bin
44+
/usr/bin/grep /bin
45+
/usr/bin/chmod /bin
46+
/usr/bin/chown /bin
47+
/usr/bin/dmesg /bin
48+
/usr/bin/ln /bin
49+
/usr/bin/curl /bin
50+
/usr/sbin/ethtool /sbin
51+
/usr/bin/netstat /bin
52+
/usr/sbin/ip /sbin
53+
# End of file, do not delete

vmm/scripts/image/centos/build_rootfs.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,16 @@ install_and_copy_rpm() {
114114
yum install -y $rpm >/dev/null 2>&1
115115
if [ $? -ne 0 ]; then
116116
echo "Can not install $rpm by yum"
117-
exit 1
117+
continue
118118
fi
119+
rpm -ql $rpm >/dev/null 2>&1 || continue
119120
fi
120121
array=($(rpm -ql $rpm | grep -v "share" | grep -v ".build-id"))
121122
for file in ${array[@]}; do
122123
source=$file
123124
dts_file=${rootfs_dir}$file
124125
dts_folder=${dts_file%/*}
125-
if [ ! -d "$dts_folder" ]; then
126+
if [ ! -d "$dts_folder" ] && [ ! -L "$dts_folder" ]; then
126127
mkdir -p $dts_folder
127128
fi
128129
cp -r -f -d $source $dts_folder

vmm/scripts/image/centos/rpm.list

+5
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ libpcap
2020
iptables
2121
ipvsadm
2222
conntrack-tools
23+
curl
24+
ethtool
25+
net-tools
26+
iproute
27+
# End of file, do not delete

0 commit comments

Comments
 (0)