aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJybz <j.biernacki@free.fr>2022-04-20 20:01:17 +0200
committerJybz <j.biernacki@free.fr>2022-04-20 20:01:17 +0200
commit4346bf0552e6d129d3aca4768bd9babebfcaf5aa (patch)
tree971d1c6b6149d1ce9992bbc93858725ecca2d03b
parent08f711f798b9f0f4be66cd2e63b83b2bcc9e1cae (diff)
downloadmageia4arm-4346bf0552e6d129d3aca4768bd9babebfcaf5aa.tar
mageia4arm-4346bf0552e6d129d3aca4768bd9babebfcaf5aa.tar.gz
mageia4arm-4346bf0552e6d129d3aca4768bd9babebfcaf5aa.tar.bz2
mageia4arm-4346bf0552e6d129d3aca4768bd9babebfcaf5aa.tar.xz
mageia4arm-4346bf0552e6d129d3aca4768bd9babebfcaf5aa.zip
WIP: Improve sfdisk script, swap formating and looping steps, reimplements functions for freebox-delta
-rwxr-xr-xfunctions.sh7
-rw-r--r--platforms/freebox-delta/second_stage_install.sh8
-rwxr-xr-xplatforms/freebox-delta/specialFunctions.sh160
3 files changed, 164 insertions, 11 deletions
diff --git a/functions.sh b/functions.sh
index 7df8d67..1b70c0e 100755
--- a/functions.sh
+++ b/functions.sh
@@ -69,7 +69,7 @@ function check_environment() {
error "dnf is missing."
fi
fi
- list_of_tools="/usr/bin/qemu-arm-static /usr/bin/qemu-img"
+ list_of_tools="/usr/bin/qemu-arm-static /usr/bin/qemu-img /usr/bin/udisksctl"
### TODO add other environmnet things, like : from function createchroot()
for tool in ${list_of_tools} ; do
hash ${tool}
@@ -547,11 +547,6 @@ function partitionningimage() {
function loopingImage() {
title "Looping image ..."
- if ! [ -x /usr/bin/udisksctl ]; then
- error "Error, udisks2 is missing."
- cleanExit ${ERR_1}
- fi
-
# 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)
diff --git a/platforms/freebox-delta/second_stage_install.sh b/platforms/freebox-delta/second_stage_install.sh
index 00ca822..bc06649 100644
--- a/platforms/freebox-delta/second_stage_install.sh
+++ b/platforms/freebox-delta/second_stage_install.sh
@@ -29,10 +29,10 @@ export ARCH=arm64
# #Set the list space separated of added modules and omitted modules :
# DRIVER_ADD_LIST="sunxi-mmc mmcblk"
# DRIVER_OMI_LIST="drm"
-# #Create a configuration file inside the FS, it will be used by dracut for all kernel update
-# mkdir -p /etc/dracut.conf.d/
-# echo -e "# Omiting drm as it failed for arm :\nomit_dracutmodules+=\" ${DRIVER_OMI_LIST} \"" >> /etc/dracut.conf.d/30-bananapro.conf
-# echo -e "\n\n# Driver to add :\nadd_drivers+=\" ${DRIVER_ADD_LIST} \"\n" > /etc/dracut.conf.d/30-bananapro.conf
+MODULE_ADD_LIST=" fs-lib"
+#Create a configuration file inside the FS, it will be used by dracut for all kernel update
+mkdir -p /etc/dracut.conf.d/
+echo -e "# Module to add :\nadd_dracutmodules+=\" ${MODULE_ADD_LIST} \"\n" > /etc/dracut.conf.d/30-kvm.conf
#Install all packages you need
diff --git a/platforms/freebox-delta/specialFunctions.sh b/platforms/freebox-delta/specialFunctions.sh
index 2cd8725..4386a54 100755
--- a/platforms/freebox-delta/specialFunctions.sh
+++ b/platforms/freebox-delta/specialFunctions.sh
@@ -42,9 +42,167 @@ PART_BOOTandROOT_SIZE="${DEFAULT}"
# FDISK_SCRIPT="${NEW_PART}\n${PRIMARY}\n${PART_BOOTandROOT}\n${PART_BOOTandROOT_FIRST_SECTOR}\n${PART_BOOTandROOT_SIZE}\n${CHANGE_BOOTFLAG}\n${APPLY}\n"
-SFDISK_SCRIPT=",128M,U,*\n,,L,\nwrite\n"
+p1_Start_sector="${DEFAULT}"
+p1_Size="128M"
+p1_Size=$((2*1024*128))
+p1_Type="uefi"
+#p1_Bootable="*"
+p1_Bootable="${DEFAULT}"
+p2_Start_sector="${DEFAULT}"
+p2_Size="${DEFAULT}"
+p2_Type="linux"
+p2_Bootable="${DEFAULT}"
+#SFDISK_SCRIPT=",128M,U,*\n,,L,\nwrite\n"
+SFDISK_SCRIPT="label: gpt
+${p1_Start_sector}, ${p1_Size}, ${p1_Type}, ${p1_Bootable}
+${p2_Start_sector}, ${p2_Size}, ${p2_Type}, ${p2_Bootable}
+write
+"
+function createImageWrap() {
+ title "Wrap image creation"
+ preImgCreation
+ if [ ${?} -ne 0 ]; then
+ error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
+ cleanExit ${ERR_1}
+ fi
+ createimage
+
+ partitionningimage
+
+ loopingImage
+
+ BOOTFS=${BOOTFS:="ext4"}
+ formatpartitions ${BOOTFS} ext4
+ unloopingImage
+ loopingImage
+
+ 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=$(/usr/sbin/losetup -f --show "${INSTALL_PATH}/${IMAGE}")
+ DEVICE=$(/usr/bin/udisksctl loop-setup -f ${INSTALL_PATH}/${IMAGE} | sed -e 's|^.*\/dev\/|\/dev\/|' -e 's|\.$||')
+ if [ -z "${DEVICE}" ]; then
+ error "Error, device missing from udisksctl loop-setup output."
+ cleanExit ${ERR_1}
+ fi
+
+ print_info "Image looped on ${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"
+
+# BOOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${BOOTP}")
+ BOOT_UUID=$(/usr/bin/lsblk -n -o UUID "${BOOTP}")
+ print_info "Boot UUID: ${BOOT_UUID}"
+ else
+ ROOTP="${DEVICE}p1"
+ fi
+
+# ROOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${ROOTP}")
+ ROOT_UUID=$(/usr/bin/lsblk -n -o UUID "${ROOTP}")
+ print_info "Root UUID: ${ROOT_UUID}"
+
+ return 0
+}
+
+
+function out_partitionningimage() {
+ title "Partitionning image"
+ warning "JE SUIS ICI DEDANS!"
+
+ if [ "x" != "${SFDISK_SCRIPT:="x"}" ]; then
+ HDD_INFO="$(echo -e "${SFDISK_SCRIPT}" | /usr/sbin/sfdisk "${INSTALL_PATH}/${IMAGE}")"
+ warning "JE check"
+ /usr/sbin/sfdisk -V "${INSTALL_PATH}/${IMAGE}"
+ warning "DONE"
+ echo "${HDD_INFO}"
+ SECTOR_SIZE="$(echo "${HDD_INFO}" | grep -m1 "Units: sectors" | sed -e 's/^.* \([[:digit:]]\+\) bytes[[:space:]]*$/\1/')"
+ if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
+ BOOT_P_INFO=$(echo "${HDD_INFO}" | grep -m1 -A3 "^Device" | grep "${IMAGE}1" | tr '*' ' ' | sed -e 's/[[:space:]]\+/ /g')
+ ROOT_P_INFO=$(echo "${HDD_INFO}" | grep -m1 -A3 "^Device" | grep "${IMAGE}2" | tr '*' ' ' | sed -e 's/[[:space:]]\+/ /g')
+ BOOT_OFFSET_S="$(echo "${BOOT_P_INFO}" | sed -e "s/^.*${IMAGE}[[:digit:]][[:space:]\*]\+//g" | cut -d ' ' -f 1)"
+ BOOT_NB_SECTORS=$(echo "${BOOT_P_INFO}" | sed -e "s/^.*${IMAGE}[[:digit:]][[:space:]\*]\+//g" | cut -d ' ' -f 3)
+ BOOT_SIZE_KB="$((${SECTOR_SIZE}*${BOOT_NB_SECTORS}/1024))"
+ BOOT_SIZE_B="$((${SECTOR_SIZE}*${BOOT_NB_SECTORS}))"
+ BOOT_OFFSET_KB="$((${SECTOR_SIZE}*${BOOT_OFFSET_S}/1024))"
+ print_info "Boot offset : ${BOOT_OFFSET_S}"
+ print_info "Boot offset (kB) : ${BOOT_OFFSET_KB}"
+ print_info "Boot sectors : ${BOOT_NB_SECTORS}"
+ print_info "Boot size (kB) : ${BOOT_SIZE_KB}"
+ print_info "Boot size (B) : ${BOOT_SIZE_B}"
+ else
+ ROOT_P_INFO=$(echo "${HDD_INFO}" | grep -m1 -A3 "^Device" | grep "${IMAGE}1")
+ fi
+ ROOT_OFFSET_S=$(echo "${ROOT_P_INFO}" | sed -e "s/^.*${IMAGE}[[:digit:]][[:space:]\*]\+//g" | cut -d ' ' -f 1)
+ ROOT_NB_SECTORS=$(echo "${ROOT_P_INFO}" | sed -e "s/^.*${IMAGE}[[:digit:]][[:space:]\*]\+//g" | cut -d ' ' -f 3)
+ ROOT_SIZE_KB="$((${SECTOR_SIZE}*${ROOT_NB_SECTORS}/1024))"
+ ROOT_OFFSET_B="$((${SECTOR_SIZE}*${ROOT_OFFSET_S}))"
+
+ print_info "Root offset : ${ROOT_OFFSET_S}"
+ print_info "Root offset (B) : ${ROOT_OFFSET_B}"
+ print_info "Root sectors : ${ROOT_NB_SECTORS}"
+ print_info "Root size kB : ${ROOT_SIZE_KB}"
+ else
+ error "Error, no partitionning script found."
+ cleanExit ${ERR_1}
+ fi
+
+ return 0
+}
+
+function formatpartitions() {
+ print_info "Formatting partitions"
+ if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
+ print_info "Boot : ${BOOTP} as ${1}"
+ if [ "vfat" = ${1} ]; then
+ FSINFO=$(/usr/sbin/mkfs.vfat ${BOOTP} )
+ BOOT_UUID=$(echo "${FSINFO}" | grep 'Volume ID is' | sed 's/Volume ID is \([[:alnum:]]*\),.*$/\1/')
+ print_info "Boot UUID = ${BOOT_UUID}"
+ rm -f ${temporary}
+ else
+ FSINFO=$(yes | /usr/sbin/mkfs.ext4 -E offset=${BOOT_OFFSET_B} ${INSTALL_PATH}/${IMAGE} $((${BOOT_SIZE_KB}))k)
+ BOOT_UUID=$(echo "${FSINFO}" | grep 'Filesystem UUID' | sed 's/Filesystem UUID: //')
+ fi
+# "/sbin/mkfs.${1}" "${BOOTP}"
+ if [ ${?} -ne 0 ]; then
+ error "line ${LINENO} error formating ${BOOTP} : exiting"
+# /usr/sbin/losetup -d "${DEVICE}"
+ udisksctl unmount -b ${BOOTP}
+ cleanExit ${ERR_1}
+ fi
+# BOOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${BOOTP}")
+# print_info "Boot UUID: ${BOOT_UUID}"
+ fi
+
+ print_info "Root : ${ROOTP} as ${2}"
+ FSINFO=$(yes | /sbin/mkfs.${2} "${ROOTP}" )
+ if [ ${?} -ne 0 ]; then
+ error "line ${LINENO} error formating ${ROOTP} : exiting"
+ cleanExit ${ERR_1}
+ fi
+ ROOT_UUID=$(echo "${FSINFO}" | grep 'Filesystem UUID' | sed 's/Filesystem UUID: //')
+# ROOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${ROOTP}")
+ print_info "Root UUID: ${ROOT_UUID}"
+
+ /usr/bin/sync
+
+ return 0
+}
+
function imageConversion()
{
title "Converting image into a qcow2 file"