]> git.ipfire.org Git - people/jschlag/ipfire-3.x-image.git/blobdiff - functions.sh
Improve how we execute commands in chroot
[people/jschlag/ipfire-3.x-image.git] / functions.sh
index f666c30234de85b33fcf4a944d1b14dbc52aad88..ad46a30ffd3e5295473d7c0a1aea6b85e66b6e80 100644 (file)
@@ -20,6 +20,7 @@ FALSE=1
 
 IMAGE_RELEASE=${FALSE}
 
+CHROOT_SCRIPT="/build/chroot.sh"
 
 
 # Functions
@@ -356,3 +357,22 @@ chroot_wrapper() {
        umount "${chroot_dir}/run"
        umount "${chroot_dir}/tmp"
 }
+
+chroot_script_init(){
+       echo "#!/bin/bash" > "${IMAGE_MOUNT_DIR}${CHROOT_SCRIPT}"
+}
+
+chroot_script_add_cmd(){
+       local command
+       for command in "$@"
+       do
+       echo "${command}" >>  "${IMAGE_MOUNT_DIR}${CHROOT_SCRIPT}"
+       done
+}
+
+
+chroot_script_exec() {
+       chmod +x  "${IMAGE_MOUNT_DIR}${CHROOT_SCRIPT}"
+
+       chroot_wrapper ${IMAGE_MOUNT_DIR}  "${CHROOT_SCRIPT}"
+}