When using `AGENT_INIT="yes" ./rootfs.sh centos` to build rootfs, kata-agent will be installed as init process on the build-host machine
liangxianlong opened this issue · 2 comments
liangxianlong commented
Description of problem
When using AGENT_INIT="yes" ./rootfs.sh centos
to build rootfs, kata-agent will be installed as init process on the build-host machine
Expected result
It should install kata-agent
as init process to rootfs-Centos/sbin/init
only:
[root@LIN-9756F85AB47 rootfs-builder]# pwd
/media/A/gopath/src/github.com/kata-containers/osbuilder/rootfs-builder
[root@LIN-9756F85AB47 rootfs-builder]# ll
总用量 72
drwxr-xr-x 2 root 4096 7月 1 17:42 alpine
drwxr-xr-x 2 root 4096 7月 3 20:01 centos
drwxr-xr-x 2 root 4096 7月 1 17:42 clearlinux
drwxr-xr-x 2 root 4096 7月 1 17:42 debian
drwxr-xr-x 2 root 4096 7月 1 17:42 euleros
drwxr-xr-x 2 root 4096 7月 1 17:42 fedora
-rw-r--r-- 1 root root 425 7月 4 10:40 kata-Centos-dnf.conf
-rw-r--r-- 1 root 6913 7月 1 17:42 README.md
dr-xr-xr-x 17 root root 4096 7月 4 10:43 rootfs-Centos
-rwxr-xr-x 1 root 17608 7月 4 10:36 rootfs.sh
drwxr-xr-x 2 root 4096 7月 1 17:42 suse
drwxr-xr-x 2 root 4096 7月 1 17:42 template
drwxr-xr-x 2 root 4096 7月 1 17:42 ubuntu
[root@LIN-9756F85AB47 rootfs-builder]#
[root@LIN-9756F85AB47 rootfs-builder]# AGENT_INIT="yes" ./rootfs.sh centos
[root@LIN-9756F85AB47 rootfs-builder]# ls -al rootfs-Centos/sbin/init
-rwxr-xr-x 1 root root 28589112 7月 4 10:43 rootfs-Centos/sbin/init
[root@LIN-9756F85AB47 rootfs-builder]# ls -al /sbin/init
lrwxrwxrwx 1 root root 22 7月 3 18:50 /sbin/init -> ../lib/systemd/systemd
Actual result
But after AGENT_INIT="yes" ./rootfs.sh centos
, the result is:
[root@LIN-9756F85AB47 rootfs-builder]# AGENT_INIT="yes" ./rootfs.sh centos
[root@LIN-9756F85AB47 rootfs-builder]# ls -al rootfs-Centos/sbin/init
-rwxr-xr-x 1 root root 28589112 7月 4 10:43 rootfs-Centos/sbin/init
[root@LIN-9756F85AB47 rootfs-builder]# ls -al /sbin/init
-rwxr-xr-x 1 root root 28589112 7月 4 10:43 /sbin/init
How to repair
Here is the way to repair,just need to modify rootfs.sh
:
main()
{
parse_arguments $*
check_env_variables
- init="${ROOTFS_DIR}/sbin/init"
if [ -n "$distro" ]; then
build_rootfs_distro
else
#Make sure ROOTFS_DIR is set correctly
[ -d "${ROOTFS_DIR}" ] || die "Invalid rootfs directory: '$ROOTFS_DIR'"
# Set the distro for dracut build method
detect_host_distro
prepare_overlay
fi
+ init="${ROOTFS_DIR}/sbin/init"
setup_rootfs
}
I will submit this revision later
liangxianlong commented
liangxianlong commented