réagencement du processus, fonctionnalisation nouvelle.
La création de l'image est effectuée avant l'installation des logiciels. De nouvelles fonctions ont été divisées de fonctions existantes. Il y a un bout de code qui ne me plaît pas : 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}")" if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then BOOTP="${DEVICE}p1" ROOTP="${DEVICE}p2" else ROOTP="${DEVICE}p1" fi
This commit is contained in:
parent
013c1e174f
commit
3122435982
@ -309,17 +309,101 @@ function createImageWrap()
|
||||
BOOTFS="ext4"
|
||||
fi
|
||||
formatpartitions ${BOOTFS} ext4
|
||||
copyingsystem
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function createimage()
|
||||
{
|
||||
title " in ${IMAGE}"
|
||||
if [ -f "${INSTALL_PATH}/${IMAGE}" ]; then
|
||||
warning "Deleting previous image"
|
||||
/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error can't remove previous image at ${INSTALL_PATH}/${IMAGE} : exiting"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
warning "please wait until end of image creation"
|
||||
/bin/dd if=/dev/zero of="${INSTALL_PATH}/${IMAGE}" bs=1MB count=$(( ${IMAGE_SIZE} * 1024 ))
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
loopingImage
|
||||
|
||||
bunrningBootloader
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
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}")"
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
BOOTP="${DEVICE}p1"
|
||||
ROOTP="${DEVICE}p2"
|
||||
else
|
||||
ROOTP="${DEVICE}p1"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function loopingImage()
|
||||
{
|
||||
title "Looping image ..."
|
||||
|
||||
# Mettre en place et contrôler des périphériques boucle.
|
||||
# -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
|
||||
}
|
||||
|
||||
|
||||
function formatpartitions()
|
||||
{
|
||||
info "Formatting partitions"
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
info "Boot : ${BOOTP} as ${1}"
|
||||
"/sbin/mkfs.${1}" "${BOOTP}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error formating ${BOOTP} : exiting"
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
BOOT_UUID=$(blkid -s UUID -o value UUID "${BOOTP}")
|
||||
info "Boot UUID: ${BOOT_UUID}"
|
||||
fi
|
||||
|
||||
info "Root : ${ROOTP} as ${2}"
|
||||
"/sbin/mkfs.${2}" "${ROOTP}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error formating ${ROOTP} : exiting"
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
ROOT_UUID=$(blkid -s UUID -o value UUID "${ROOTP}")
|
||||
info "Root UUID: ${ROOT_UUID}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function copyingsystem()
|
||||
{
|
||||
mountImage
|
||||
|
||||
mkfstab
|
||||
|
||||
info "Generate extlinux if extlinux.conf exists."
|
||||
if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
|
||||
info "\tFound extlinux.conf"
|
||||
@ -361,38 +445,13 @@ function copyingsystem()
|
||||
fi
|
||||
|
||||
copyingcommon
|
||||
# Syncing devices before unmounting
|
||||
/usr/bin/sync
|
||||
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
/usr/bin/umount "${BOOT}"
|
||||
if [ ${?} -eq 0 ]; then
|
||||
/bin/rmdir "${BOOT}"
|
||||
else
|
||||
error "line ${LINENO} error unmounting ${BOOT}: exiting"
|
||||
exit ${ERR_1}
|
||||
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
|
||||
|
||||
/usr/sbin/partx -d "${DEVICE}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} warning : error unmounting ${DEVICE} "
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function mountImage(){
|
||||
function mountPartitions(){
|
||||
info "mounting partitions, making mountpoint if necessary"
|
||||
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
@ -425,6 +484,72 @@ function mountImage(){
|
||||
}
|
||||
|
||||
|
||||
function unmountingPartitions()
|
||||
{
|
||||
title "Unmounting partitions..."
|
||||
|
||||
# Syncing devices before unmounting
|
||||
/usr/bin/sync
|
||||
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
/usr/bin/umount "${BOOT}"
|
||||
if [ ${?} -eq 0 ]; then
|
||||
/bin/rmdir "${BOOT}"
|
||||
else
|
||||
error "line ${LINENO} error unmounting ${BOOT}: exiting"
|
||||
exit ${ERR_1}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
function unloopingImage(){
|
||||
title "Unlooping image..."
|
||||
# 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}"
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# Copying files common to all systems
|
||||
function copyingcommon()
|
||||
{
|
||||
@ -436,35 +561,6 @@ function copyingcommon()
|
||||
}
|
||||
|
||||
|
||||
function formatpartitions()
|
||||
{
|
||||
info "Formatting partitions"
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
info "Boot : ${BOOTP} as ${1}"
|
||||
"/sbin/mkfs.${1}" "${BOOTP}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error formating ${BOOTP} : exiting"
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
BOOT_UUID=$(blkid -s UUID -o value UUID "${BOOTP}")
|
||||
info "Boot UUID: ${BOOT_UUID}"
|
||||
fi
|
||||
|
||||
info "Root : ${ROOTP} as ${2}"
|
||||
"/sbin/mkfs.${2}" "${ROOTP}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error formating ${ROOTP} : exiting"
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
ROOT_UUID=$(blkid -s UUID -o value UUID "${ROOTP}")
|
||||
info "Root UUID: ${ROOT_UUID}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function mkfstab()
|
||||
{
|
||||
title "making /etc/fstab"
|
||||
@ -480,101 +576,13 @@ function mkfstab()
|
||||
}
|
||||
|
||||
|
||||
function createimage()
|
||||
{
|
||||
title " in ${IMAGE}"
|
||||
if [ -f "${INSTALL_PATH}/${IMAGE}" ]; then
|
||||
warning "Deleting previous image"
|
||||
/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error can't remove previous image at ${INSTALL_PATH}/${IMAGE} : exiting"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
warning "please wait until end of image creation"
|
||||
/bin/dd if=/dev/zero of="${INSTALL_PATH}/${IMAGE}" bs=1MB count=$(( ${IMAGE_SIZE} * 1024 ))
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting"
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
DEVICE=$(/sbin/losetup -f --show "${INSTALL_PATH}/${IMAGE}")
|
||||
|
||||
bunrningBootloader
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
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}")"
|
||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||
BOOTP="${DEVICE}p1"
|
||||
ROOTP="${DEVICE}p2"
|
||||
else
|
||||
ROOTP="${DEVICE}p1"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
function unmounting()
|
||||
{
|
||||
title "Unmounting..."
|
||||
|
||||
# Unmounting /dev /proc /sys in chroot
|
||||
if ! [ -z "$(mountpoint -qd "${BUILD_PATH}/dev")" ]; then # mountpoint - see if a directory or file is a mountpoint ; -d Show the major/minor numbers of the device that is mounted on the given directory.
|
||||
info "Unmounting ${BUILD_PATH}/dev"
|
||||
umount "${BUILD_PATH}/dev"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/dev : exiting"
|
||||
#exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if ! [ -z "$(mountpoint -qd "${BUILD_PATH}/sys")" ]; then
|
||||
info "Unmounting ${BUILD_PATH}/sys"
|
||||
umount "${BUILD_PATH}/sys"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/sys : exiting"
|
||||
#exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if ! [ -z "$(mountpoint -qd "${BUILD_PATH}/proc")" ]; then
|
||||
info "Unmounting ${BUILD_PATH}/proc"
|
||||
umount "${BUILD_PATH}/proc"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/proc : exiting"
|
||||
#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}"
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# cleaning build space
|
||||
function clean()
|
||||
{
|
||||
title "Cleaning"
|
||||
|
||||
unmounting
|
||||
unmountingPartitions
|
||||
unloopingImage
|
||||
|
||||
# Removing old Build directory
|
||||
if [ -d "${BUILD_PATH}" ]; then
|
||||
@ -898,15 +906,18 @@ case ${OPT} in
|
||||
exit ${ERR_NO_SPACE}
|
||||
fi
|
||||
fi
|
||||
createchroot
|
||||
createImageWrap #Create the empty .img
|
||||
createchroot #Check qemu and activate it
|
||||
addmedia
|
||||
updatemirror
|
||||
installbasesystem
|
||||
mkfstab
|
||||
installbasesystem #Generate the rootfs, rootfiles, ...
|
||||
mkfstab
|
||||
preparechroot
|
||||
jumpchroot
|
||||
createImageWrap
|
||||
unmounting
|
||||
mountPartitions
|
||||
copyingsystem
|
||||
unmountingPartitions
|
||||
unloopingImage
|
||||
;;
|
||||
"createchroot")
|
||||
createchroot
|
||||
|
Reference in New Issue
Block a user