summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfunctions/configuration.sh8
-rwxr-xr-xfunctions/losetup.sh97
-rwxr-xr-xscripts/build/chroot_devpts96
3 files changed, 116 insertions, 85 deletions
diff --git a/functions/configuration.sh b/functions/configuration.sh
index 6f52bdad4..7750a5c54 100755
--- a/functions/configuration.sh
+++ b/functions/configuration.sh
@@ -304,8 +304,12 @@ Prepare_config ()
case "${LB_ARCHITECTURE}" in
amd64|i386)
- LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-syslinux}"
- if ! In_list "${LB_IMAGE_TYPE}" hdd netboot; then
+ if In_list "${LB_IMAGE_TYPE}" hdd; then
+ LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS}"
+ else
+ LB_BOOTLOADER_BIOS="${LB_BOOTLOADER_BIOS:-syslinux}"
+ fi
+ if ! In_list "${LB_IMAGE_TYPE}" netboot; then
LB_BOOTLOADER_EFI="${LB_BOOTLOADER_EFI:-grub-efi}"
fi
;;
diff --git a/functions/losetup.sh b/functions/losetup.sh
index 6774646ff..b221d37a4 100755
--- a/functions/losetup.sh
+++ b/functions/losetup.sh
@@ -32,7 +32,42 @@ Lodetach ()
sync
sleep 1
- losetup -d "${DEVICE}" || Lodetach "${DEVICE}" "$(expr ${ATTEMPT} + 1)"
+ if [ "${LB_IMAGE_TYPE}" = "hdd" ];
+ then
+ case "${LB_BUILD_WITH_CHROOT}" in
+ true)
+ PARTITIONS=$(lsblk --raw --output "MAJ:MIN" --noheadings "${DEVICE}" | tail -n +2 | sort)
+ COUNTER=1
+ for i in $PARTITIONS; do
+ if [ -e "chroot/${DEVICE}p${COUNTER}" ]
+ then
+ Chroot chroot "rm -f ${DEVICE}p${COUNTER}"
+ fi
+ if [ -e "${DEVICE}p${COUNTER}" ]
+ then
+ rm -f ${DEVICE}p${COUNTER}
+ fi
+ COUNTER=$((COUNTER + 1))
+ done
+ ;;
+
+ false)
+ PARTITIONS=$(lsblk --raw --output "MAJ:MIN" --noheadings "${DEVICE}" | tail -n +2 | sort)
+ COUNTER=1
+ for i in $PARTITIONS; do
+ if [ -e "${DEVICE}p${COUNTER}" ]
+ then
+ rm -f ${DEVICE}p${COUNTER}
+ fi
+ COUNTER=$((COUNTER + 1))
+ done
+ ;;
+ esac
+
+
+ fi
+
+ losetup -d "${DEVICE}" || Lodetach "${DEVICE}" "$(expr ${ATTEMPT} + 1)"
}
Losetup ()
@@ -49,21 +84,59 @@ Losetup ()
LOOPDEVICE="$(echo ${DEVICE}p${PARTITION})"
- if [ "${PARTITION}" = "0" ]
- then
+ if [ "${LB_IMAGE_TYPE}" = "hdd" ]
+ then
+ losetup --partscan "${DEVICE}" "${FILE}"
+ case "${LB_BUILD_WITH_CHROOT}" in
+ true)
+ PARTITIONS=$(lsblk --raw --output "MAJ:MIN" --noheadings "${DEVICE}" | tail -n +2 | sort)
+ COUNTER=1
+ for i in $PARTITIONS; do
+ MAJ=$(echo $i | cut -d: -f1)
+ MIN=$(echo $i | cut -d: -f2)
+ if [ ! -e "chroot/${DEVICE}p${COUNTER}" ]
+ then
+ Chroot chroot "mknod ${DEVICE}p${COUNTER} b $MAJ $MIN"
+ fi
+ if [ ! -e "${DEVICE}p${COUNTER}" ]
+ then
+ mknod ${DEVICE}p${COUNTER} b $MAJ $MIN
+ fi
+ COUNTER=$((COUNTER + 1))
+ done
+ ;;
+
+ false)
+ PARTITIONS=$(lsblk --raw --output "MAJ:MIN" --noheadings "${DEVICE}" | tail -n +2 | sort)
+ COUNTER=1
+ for i in $PARTITIONS; do
+ MAJ=$(echo $i | cut -d: -f1)
+ MIN=$(echo $i | cut -d: -f2)
+ if [ ! -e "${DEVICE}p${COUNTER}" ]
+ then
+ mknod ${DEVICE}p${COUNTER} b $MAJ $MIN
+ fi
+ COUNTER=$((COUNTER + 1))
+ done
+ ;;
+ esac
+ else
+ if [ "${PARTITION}" = "0" ]
+ then
Echo_message "Mounting %s with offset 0" "${DEVICE}"
- losetup --partscan "${DEVICE}" "${FILE}"
- else
- local SECTORS
- local OFFSET
- SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")"
- OFFSET="$(expr ${SECTORS} '*' 512)"
+ losetup --partscan "${DEVICE}" "${FILE}"
+ else
+ local SECTORS
+ local OFFSET
+ SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")"
+ OFFSET="$(expr ${SECTORS} '*' 512)"
- Echo_message "Mounting %s with offset %s" "${DEVICE}" "${OFFSET}"
+ Echo_message "Mounting %s with offset %s" "${DEVICE}" "${OFFSET}"
- losetup --partscan -o "${OFFSET}" "${DEVICE}" "${FILE}"
- fi
+ losetup --partscan -o "${OFFSET}" "${DEVICE}" "${FILE}"
+ fi
+ fi
}
# adapted from lib/ext2fs/mkjournal.c, default block size is 4096 bytes (/etc/mke2fs.conf).
diff --git a/scripts/build/chroot_devpts b/scripts/build/chroot_devpts
index f25a3861a..30b42bad8 100755
--- a/scripts/build/chroot_devpts
+++ b/scripts/build/chroot_devpts
@@ -29,89 +29,43 @@ Require_stagefiles config bootstrap
case "${_ACTION}" in
install)
- if [ "${LB_IMAGE_TYPE}" = "hdd" ]; then
- Echo_message "Begin mounting /dev..."
+ Echo_message "Begin mounting /dev/pts..."
- # Checking stage file
- Check_stagefile
+ # Checking stage file
+ Check_stagefile
- # Acquire lock file
- Acquire_lockfile
+ # Acquire lock file
+ Acquire_lockfile
- # Mounting /dev/pts
- mount --bind /dev chroot/dev || true
- mount -t devpts -o gid=5,mode=620,x-gvfs-hide devpts-live chroot/dev/pts || true
+ # Creating mountpoint
+ mkdir -p chroot/dev/pts
- # Creating stage file
- Create_stagefile
- else
- Echo_message "Begin mounting /dev/pts..."
-
- # Checking stage file
- Check_stagefile
-
- # Acquire lock file
- Acquire_lockfile
-
- # Creating mountpoint
- mkdir -p chroot/dev/pts
-
- # Mounting /dev/pts
- mount -t devpts -o gid=5,mode=620,x-gvfs-hide devpts-live chroot/dev/pts || true
+ # Mounting /dev/pts
+ mount -t devpts -o gid=5,mode=620,x-gvfs-hide devpts-live chroot/dev/pts || true
- # Creating stage file
- Create_stagefile
- fi
+ # Creating stage file
+ Create_stagefile
;;
remove)
- if [ "${LB_IMAGE_TYPE}" = "hdd" ]; then
- Echo_message "Begin unmounting /dev..."
-
- # Checking stage file
- Ensure_stagefile_exists
-
- # Acquire lock file
- Acquire_lockfile
-
- # Unmounting /dev/pts
- if grep -qs "$(pwd)/chroot/dev/pts" /proc/mounts || Find_files chroot/dev/pts/*
- then
- umount chroot/dev/pts
- else
- umount -f chroot/dev/pts > /dev/null 2>&1 || true
- fi
-
- # Unmounting /dev
- if grep -qs "$(pwd)/chroot/dev" /proc/mounts || Find_files chroot/dev/*
- then
- umount chroot/dev
- else
- umount -f chroot/dev > /dev/null 2>&1 || true
- fi
-
- # Removing stage file
- Remove_stagefile
- else
- Echo_message "Begin unmounting /dev/pts..."
-
- # Checking stage file
- Ensure_stagefile_exists
+ Echo_message "Begin unmounting /dev/pts..."
- # Acquire lock file
- Acquire_lockfile
+ # Checking stage file
+ Ensure_stagefile_exists
- # Unmounting /dev/pts
- if grep -qs "$(pwd)/chroot/dev/pts" /proc/mounts || Find_files chroot/dev/pts/*
- then
- umount chroot/dev/pts
- else
- umount -f chroot/dev/pts > /dev/null 2>&1 || true
- fi
+ # Acquire lock file
+ Acquire_lockfile
- # Removing stage file
- Remove_stagefile
+ # Unmounting /dev/pts
+ if grep -qs "$(pwd)/chroot/dev/pts" /proc/mounts || Find_files chroot/dev/pts/*
+ then
+ umount chroot/dev/pts
+ else
+ umount -f chroot/dev/pts > /dev/null 2>&1 || true
fi
+
+ # Removing stage file
+ Remove_stagefile
;;
*)