]> git.ipfire.org Git - people/jschlag/ipfire-3.x-image.git/blobdiff - generate_image.sh
Improve how we execute commands in chroot
[people/jschlag/ipfire-3.x-image.git] / generate_image.sh
index 88e4506d02895da7bdf61bef72be4e0f7ee8c11d..674cc2289204dde382f644e8a9b4e61c34440b8d 100755 (executable)
@@ -172,40 +172,29 @@ reset_root_password "${IMAGE_MOUNT_DIR}"
 
 clone_git_repos "${IMAGE_MOUNT_DIR}/build" ${GIT_REPOS}
 
+
 #
 ## Prepare chrooting into the image.
 #
 
-# Check if the network stack should be build.
-if [ "${USE_GIT_NETWORK_STACK}" == "True" ]; then
-       BUILD_NETWORK_CMDS="cd network/ && ./autogen.sh && ./configure && make && make install"
-fi
-
-ENABLE_GETTY="/bin/systemctl enable getty@.service"
+chroot_script_init
 
-# Check if the arch uses grub
 if [ "${HAVE_GRUB}" == "True" ]; then
-       GENERATE_GRUB_CONF="grub-install --boot-directory=${IMAGE_MOUNT_DIR}/boot/ --modules="${FILESYSTEM} part_msdos" ${outlo} && \
-       grub-mkconfig -o /boot/grub/grub.cfg"
+       chroot_script_add_cmd "grub-install --boot-directory=/boot/ ${outlo}" "grub-mkconfig -o /boot/grub/grub.cfg"
 fi
 
 
-# Use systemd-nspawn to spawn a chroot environment and execute
-# commands inside it.
-#
-# The first command enables the terminal on TTY1.
-# The second command generates the configuration file for grub2.
+
+# ENABLE Serial Console
+chroot_script_add_cmd "/bin/systemctl enable getty@.service"
 
 
-systemd-nspawn -D ${IMAGE_MOUNT_DIR} --bind /dev --capability=CAP_SYS_ADMIN,CAP_SYS_RAWIO --bind /proc --bind /sys << END
-       echo "Execute commands inside chroot"
-       ${ENABLE_GETTY}
-       ${GENERATE_GRUB_CONF}
-       cd /build/ && ls
-       ${BUILD_NETWORK_CMDS}
-       echo "All commands executed"
-END
+# Check if the network stack should be build.
+if [ "${USE_GIT_NETWORK_STACK}" == "True" ]; then
+       chroot_script_add_cmd "cd /build/network" "./autogen.sh" "./configure" "make" "make install"
+fi
 
+chroot_script_exec
 
 
 # Insert the UUID because grub-mkconfig often fails to