aboutsummaryrefslogtreecommitdiffstats
path: root/create_arm_img_urpmi.sh
diff options
context:
space:
mode:
Diffstat (limited to 'create_arm_img_urpmi.sh')
-rw-r--r--create_arm_img_urpmi.sh102
1 files changed, 45 insertions, 57 deletions
diff --git a/create_arm_img_urpmi.sh b/create_arm_img_urpmi.sh
index 5bc6ebe..330c533 100644
--- a/create_arm_img_urpmi.sh
+++ b/create_arm_img_urpmi.sh
@@ -309,6 +309,7 @@ function createImageWrap()
BOOTFS="ext4"
fi
formatpartitions ${BOOTFS} ext4
+
return 0
}
@@ -343,13 +344,11 @@ function createimage()
info "making partitions"
echo -e "${FDISK_SCRIPT}" | /sbin/fdisk ${DEVICE}
- # Activate loop device
- info "device to detach ${DEVICE}"
- /sbin/losetup -d "${DEVICE}"
- DEVICE=$(/sbin/partx -va "${INSTALL_PATH}/${IMAGE}" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "New attached device ${DEVICE}"
- info "partitions list:"
- info "$(/sbin/partx -v "${INSTALL_PATH}/${IMAGE}")"
+ #Activate 'pY' : /dev/loopXpY
+ partx -vu "${DEVICE}"
+ #Previous function give us a list of partition. It is easy to get it and define prior this list the partition.
+ #But... How to distinguish between the boot p1 and the root p2 if both are empty and ext4 ? ...
+
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
BOOTP="${DEVICE}p1"
ROOTP="${DEVICE}p2"
@@ -368,7 +367,7 @@ function loopingImage()
# -f, --find trouver le premier périphérique inutilisé
# --show afficher le nom du périphérique après configuration (avec -f)
DEVICE=$(/sbin/losetup -f --show "${INSTALL_PATH}/${IMAGE}")
-
+
return 0
}
@@ -446,6 +445,7 @@ function copyingsystem()
copyingcommon
+ sync
warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
return 0
}
@@ -490,25 +490,41 @@ function unmountingPartitions()
# Syncing devices before unmounting
/usr/bin/sync
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- /usr/bin/umount "${BOOT}"
+
+ if [ -z "${BOOTP}" ] && [ -z "${ROOTP}" ] ; then
+ warning "Root partition and Boot partition not defined !"
+
+ for LOOP in $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) ; do
+ IFS=$'\n'
+ for PARTITION in $(mount -l | grep ${LOOP}); do
+ MOUNTPOINT=$(echo "$PARTITION" | cut -d ' ' -f 3)
+ PARTITION=$(echo "$PARTITION" | cut -d ' ' -f 1)
+ info "unmount ${PARTITION} and remove ${MOUNTPOINT}"
+ /usr/bin/umount "${PARTITION}"
+ if [ ${?} -eq 0 ]; then
+ /bin/rmdir "${MOUNTPOINT}"
+ else
+ error "line ${LINENO} error unmounting ${BOOT}..."
+ fi
+ done
+ unset IFS
+ done
+ else
+ if [ ! -z "${BOOTP}" ]; then
+ /usr/bin/umount "${BOOTP}"
+ if [ ${?} -eq 0 ]; then
+ /bin/rmdir "${BOOT}"
+ else
+ error "line ${LINENO} error unmounting ${BOOT}..."
+ fi
+ fi
+ /usr/bin/umount "${ROOTP}"
if [ ${?} -eq 0 ]; then
- /bin/rmdir "${BOOT}"
+ /bin/rmdir "${ROOT}"
else
- error "line ${LINENO} error unmounting ${BOOT}: exiting"
- exit ${ERR_1}
+ error "line ${LINENO} error unmounting ${ROOT}..."
fi
fi
-
- /usr/bin/umount "${ROOT}"
- if [ ${?} -eq 0 ]; then
- /bin/rmdir "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}: exiting"
-# exit ${ERR_1}
- fi
-
return 0
}
@@ -518,32 +534,17 @@ function unloopingImage(){
# Syncing devices before unmounting
/usr/bin/sync
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- /usr/sbin/partx -d "${BOOTP}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} warning : error unmounting ${BOOTP} "
- # exit ${ERR_1}
- fi
- /usr/sbin/partx -d "${ROOTP}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} warning : error unmounting ${ROOTP} "
- # exit ${ERR_1}
- fi
- else
- /usr/sbin/partx -d "${ROOTP}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} warning : error unmounting ${ROOTP} "
- # exit ${ERR_1}
- fi
- fi
-
# [root@jabztop mageia4arm (master)]# losetup -l -O NAME,BACK-FILE -n
# /dev/loop0 /home/jibz/workspaces/mageia4arm/build/Mageia-7-bananaPro1.img (deleted)
info "Looped devices to unmount : $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) "
for LOOP in $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) ; do
info "removing ${LOOP}"
- losetup -d "${LOOP}"
+ for PARTITION in ${LOOP}p* ; do
+ partx -dv "${PARTITION}"
+ done
+# losetup -d "${LOOP}"
+ kpartx -d "${INSTALL_PATH}/${IMAGE}"
done
return 0
@@ -598,20 +599,7 @@ function clean()
else
warning "${IMAGE} does not exists"
fi
-
- # Removing boot and root directory
- if [ -d "${BOOT}" ]; then
- info "Removing ${BOOT}"
- /bin/rm -rf "${BOOT}"
- else
- warning "${BOOT} does not exists"
- fi
- if [ -d "${ROOT}" ]; then
- info "Removing ${ROOT}"
- /bin/rm -rf "${ROOT}"
- else
- warning "${ROOT} does not exists"
- fi
+
return 0
}