fonctionnalisation - première etape
Première etape de fonctionnalisation des fonctions dépendentes des plateformes
This commit is contained in:
parent
584c02c3c5
commit
ad4968f29d
@ -21,43 +21,24 @@ function title()
|
||||
echo -e "\e[1;32m${1}\e[0m"
|
||||
}
|
||||
|
||||
|
||||
function info()
|
||||
{
|
||||
echo -e "\e[36m${1}\e[0m"
|
||||
}
|
||||
|
||||
|
||||
function warning()
|
||||
{
|
||||
echo -e "\e[1;35m${1}\e[0m"
|
||||
}
|
||||
|
||||
|
||||
function error()
|
||||
{
|
||||
echo -e "\e[1;31m${1}\e[0m"
|
||||
}
|
||||
|
||||
info ${0}
|
||||
|
||||
|
||||
SOURCE_PATH="$(/bin/dirname "$(readlink -f "${0}")")"
|
||||
INSTALL_PATH="${SOURCE_PATH}/arm"
|
||||
FILES_PATH="${SOURCE_PATH}/files"
|
||||
PLATFORMS_PATH="${SOURCE_PATH}/platforms"
|
||||
|
||||
CMDNAME=$(/bin/basename "${0}")
|
||||
|
||||
#while read -r;do
|
||||
# for MAGEIA_VERSION in $REPLY
|
||||
# do
|
||||
# if [ $MAGEIA_VERSION <= 5 ]; then
|
||||
# echo 'Mageia version >= 6 is needed'
|
||||
# exit
|
||||
# fi
|
||||
# break
|
||||
# done
|
||||
#done < /etc/version
|
||||
|
||||
|
||||
|
||||
function help()
|
||||
{
|
||||
@ -95,7 +76,7 @@ function clean()
|
||||
umount "${BUILD_PATH}/dev"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/dev : exiting"
|
||||
#exit 1
|
||||
#exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if ! [ -z "$(mountpoint -qd "${BUILD_PATH}/sys")" ]; then
|
||||
@ -103,7 +84,7 @@ function clean()
|
||||
umount "${BUILD_PATH}/sys"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/sys : exiting"
|
||||
#exit 1
|
||||
#exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if ! [ -z "$(mountpoint -qd "${BUILD_PATH}/proc")" ]; then
|
||||
@ -111,7 +92,7 @@ function clean()
|
||||
umount "${BUILD_PATH}/proc"
|
||||
if ! [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't unmount ${BUILD_PATH}/proc : exiting"
|
||||
#exit 1
|
||||
#exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
# Removing old Build directory
|
||||
@ -152,6 +133,7 @@ function clean()
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# creation of install path and copy of qemu ( installing it if not yet installed )
|
||||
function createchroot()
|
||||
{
|
||||
@ -161,7 +143,7 @@ function createchroot()
|
||||
/sbin/urpmi --auto --no-recommends qemu-user-static
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't install qemu-user-static : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
# Starting qemu service if not started
|
||||
@ -171,13 +153,14 @@ function createchroot()
|
||||
/bin/systemctl start systemd-binfmt.service
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't start qemu-user-static : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# adding Mageia repositories
|
||||
function addmedia()
|
||||
{
|
||||
@ -186,7 +169,7 @@ function addmedia()
|
||||
err=${?}
|
||||
if [ ${err} -ne 0 ]; then
|
||||
error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
if [ ${NONFREE} -eq 1 ]; then
|
||||
title "activating non-free repos"
|
||||
@ -194,7 +177,7 @@ function addmedia()
|
||||
err=${?}
|
||||
if [ ${err} -ne 0 ]; then
|
||||
error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if [ ${TAINTED} -eq 1 ]; then
|
||||
@ -203,21 +186,23 @@ function addmedia()
|
||||
err=${?}
|
||||
if [ ${err} -ne 0 ]; then
|
||||
error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function updatemirror()
|
||||
{
|
||||
title "updating mirror"
|
||||
/sbin/urpmi.update -a --urpmi-root "${BUILD_PATH}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't update mirrors : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function installbasesystem()
|
||||
{
|
||||
# Create Build path
|
||||
@ -229,10 +214,10 @@ function installbasesystem()
|
||||
/bin/mkdir -p "${BUILD_PATH}/usr/bin" "${BUILD_PATH}/usr/lib/binfmt.d"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't create ${BUILD_PATH} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
else
|
||||
info "Build path exists"
|
||||
@ -242,20 +227,21 @@ function installbasesystem()
|
||||
/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 200 shadow-utils basesystem-minimal
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
#/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 200 basesystem-minimal
|
||||
#if [ ${?} -ne 0 ]; then
|
||||
# error "line ${LINENO} error installing basesystem-minimal : exiting"
|
||||
# exit 1
|
||||
# exit ${ERR_1}
|
||||
#fi
|
||||
/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 200 urpmi locales-fr systemd u-boot
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error installing urpmi or locales.fr : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function preparechroot()
|
||||
{
|
||||
title "Preparing chrooting in ${BUILD_PATH}"
|
||||
@ -265,12 +251,12 @@ function preparechroot()
|
||||
/bin/cp /bin/qemu-arm-static "${BUILD_PATH}/usr/bin/"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't copy /bin/qemu-user-static to ${BUILD_PATH}/usr/bin/ : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
/bin/cp /usr/lib/binfmt.d/qemu-arm-static.conf "${BUILD_PATH}/usr/lib/binfmt.d"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} can't copy /usr/lib/binfmt.d/qemu-arm-static.conf to ${BUILD_PATH}/usr/lib/binfmt.d : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
|
||||
@ -282,48 +268,23 @@ function preparechroot()
|
||||
cp --preserve=mode "${CONFIG_PATH}/second_stage_install.sh" "${BUILD_PATH}/second_stage_install.sh"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error copying ${CONFIG_PATH}/second_stage_install.sh : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
info "creation of user account"
|
||||
echo "/bin/passwd << EOF
|
||||
${ROOT_PWD}
|
||||
${ROOT_PWD}
|
||||
EOF
|
||||
/sbin/useradd ${ID_USER}
|
||||
/bin/passwd ${ID_USER} << EOF
|
||||
${PASSWORD}
|
||||
${PASSWORD}
|
||||
EOF" >>"${BUILD_PATH}/second_stage_install.sh"
|
||||
|
||||
|
||||
echo -e "/bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n /sbin/useradd ${ID_USER}\n /bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh"
|
||||
|
||||
info "Copying skel in root directory"
|
||||
/bin/rsync -rlptH /etc/skel/ "${BUILD_PATH}/root/"
|
||||
|
||||
|
||||
case ${TARGET} in
|
||||
"bananaPro")
|
||||
#TODO Complete here for Banana Pro.
|
||||
;;
|
||||
"odroid")
|
||||
#TEMPORARY CODE
|
||||
#copying kernel odroid not existing in mageia repos
|
||||
info "copying kernel-odroid and u-boot rpms in ${BUILD_PATH}/root"
|
||||
#echo "/bin/cp ${CONFIG_PATH}/kernel-odroid-4.14.y-1.armv7hl.rpm ${BUILD_PATH}/root/"
|
||||
/usr/bin/cp --preserve=mode "${CONFIG_PATH}/kernel-odroid-4.14.y-1.armv7hl.rpm" "${BUILD_PATH}/root/"
|
||||
#echo "/bin/cp ${CONFIG_PATH}/u-boot-20180507-3.mga7.armv7hl.rpm ${BUILD_PATH}/root/"
|
||||
/usr/bin/cp --preserve=mode "${CONFIG_PATH}/u-boot-20180507-3.mga7.armv7hl.rpm" "${BUILD_PATH}/root/"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error copying ${CONFIG_PATH}/kernel-odroid-4.14.y-1.armv7hl.rpm : exiting"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
"rpi")
|
||||
;;
|
||||
esac
|
||||
postPrepareChroot
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error in postPrepareChroot function."
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function jumpchroot()
|
||||
{
|
||||
title "chrooting to ${BUILD_PATH}"
|
||||
@ -331,23 +292,23 @@ function jumpchroot()
|
||||
/bin/mount -B /dev "${BUILD_PATH}/dev"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
/bin/mount -B /sys "${BUILD_PATH}/sys"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error mounting ${BUILD_PATH}/sys : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
/bin/mount -B /proc "${BUILD_PATH}/proc"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
info "Copying resolv.conf"
|
||||
/bin/cp -v --preserve=mode /etc/resolv.conf "${BUILD_PATH}/etc/"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error copying ${BUILD_PATH}/etc/resolv.conf : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
if [ "$OPT" = "chroot" ]; then
|
||||
/sbin/chroot "${BUILD_PATH}"
|
||||
@ -377,6 +338,7 @@ function jumpchroot()
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function verify_disk_space()
|
||||
{
|
||||
title "Verifying if there is enough space on disk to make the image"
|
||||
@ -391,63 +353,24 @@ function verify_disk_space()
|
||||
return 0
|
||||
}
|
||||
|
||||
function createxu3image()
|
||||
|
||||
function createImageWrap()
|
||||
{
|
||||
title "Creating Odroid XU3-XU4 image"
|
||||
title "Wrap image creation"
|
||||
preImgCreation
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error in the process ${CONFIG_PATH}/createImage.sh ."
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
createimage
|
||||
if [ -z "${BOOTFS}" ]; then
|
||||
BOOTFS="ext4"
|
||||
fi
|
||||
formatpartitions "${BOOTFS}" ext4
|
||||
copyingsystem
|
||||
}
|
||||
|
||||
function createbproimage()
|
||||
{
|
||||
#TODO
|
||||
# title "Creating Banana Pro image"
|
||||
# createimage
|
||||
# if [ -z "${BOOTFS}" ]; then
|
||||
# BOOTFS="ext4"
|
||||
# fi
|
||||
# formatpartitions "${BOOTFS}" ext4
|
||||
# copyingsystem
|
||||
}
|
||||
|
||||
function createrpiimage()
|
||||
{
|
||||
title "Creating Pi image"
|
||||
|
||||
if ! [ -d "${FIRMWARE_PATH}/${FIRMWARE_DIR}" ]; then # the firmware directory does not exists
|
||||
echo "$(ls *.zip| wc -l)"
|
||||
if [ "$(ls *.zip| wc -l)" -eq 0 ]; then # the firmware archive does not exists
|
||||
warning "The raspberry pi firmware need to be downloaded"
|
||||
info "Downloading FIRMWARE_FILENAME"
|
||||
wget ${FIRMWARE_DOWNLOAD_URL}
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error downloading raspberry firmware at ${FIRMWARE_DOWNLOAD_URL} :exiting"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
info "extracting firmware"
|
||||
unzip -d "${FIRMWARE_PATH}" *.zip
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error unzipping ${FIRMWARE_PATH} : exiting"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
title "Making raspberry pi image"
|
||||
|
||||
createimage
|
||||
if [ -z ${BOOTFS} ]; then
|
||||
BOOTFS="vfat"
|
||||
fi
|
||||
formatpartitions ${BOOTFS} ext4
|
||||
copyingsystem
|
||||
|
||||
}
|
||||
|
||||
|
||||
createimage()
|
||||
{
|
||||
title " in ${IMAGE}"
|
||||
@ -456,7 +379,7 @@ createimage()
|
||||
/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 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -464,7 +387,7 @@ createimage()
|
||||
/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 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
DEVICE=$(/sbin/losetup -f --show "${INSTALL_PATH}/${IMAGE}")
|
||||
if [ ${TARGET} = "odroid" ]; then
|
||||
@ -472,7 +395,7 @@ createimage()
|
||||
pushd "${CONFIG_PATH}/sd_fuse"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error directory ${CONFIG_PATH}/sd_fuse does not exists : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
else
|
||||
./sd_fusing.sh "${DEVICE}"
|
||||
fi
|
||||
@ -480,25 +403,7 @@ createimage()
|
||||
fi
|
||||
|
||||
info "making partitions"
|
||||
/sbin/fdisk "${DEVICE}" << EOF
|
||||
n
|
||||
p
|
||||
1
|
||||
|
||||
+128M
|
||||
t
|
||||
c
|
||||
n
|
||||
p
|
||||
2
|
||||
|
||||
|
||||
a
|
||||
1
|
||||
a
|
||||
2
|
||||
w
|
||||
EOF
|
||||
echo -e "${FDISK_SCRIPT}" | /sbin/fdisk ${DEVICE}
|
||||
|
||||
# Activate loop device
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
@ -510,6 +415,7 @@ EOF
|
||||
ROOTP="${DEVICE}p2"
|
||||
}
|
||||
|
||||
|
||||
formatpartitions()
|
||||
{
|
||||
info "Formatting partitions"
|
||||
@ -518,14 +424,14 @@ formatpartitions()
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error formating ${BOOTP} : exiting"
|
||||
/sbin/losetup -d "${DEVICE}"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
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 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
BOOT_UUID=$(blkid -s UUID -o value UUID "${BOOTP}")
|
||||
info "Boot UUID: ${BOOT_UUID}"
|
||||
@ -533,6 +439,7 @@ formatpartitions()
|
||||
info "Root UUID: ${ROOT_UUID}"
|
||||
}
|
||||
|
||||
|
||||
copyingsystem()
|
||||
{
|
||||
info "mounting partitions, making mountpoint if necessary"
|
||||
@ -540,25 +447,25 @@ copyingsystem()
|
||||
/bin/mkdir "${BOOT}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error making directory ${BOOT} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
if ! [ -d "${ROOT}" ]; then
|
||||
/bin/mkdir "${ROOT}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error making directory ${ROOT} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
/bin/mount "${BOOTP}" "${BOOT}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error mounting ${BOOTP} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
/bin/mount "${ROOTP}" "${ROOT}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error mounting ${ROOTP} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
info "making /etc/fstab"
|
||||
@ -630,7 +537,7 @@ copyingsystem()
|
||||
/bin/cp --preserve=mode "${CONFIG_PATH}/brcmfmac434"* "${ROOT}/usr/lib/firmware/brcm/"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} error copying wifi firmware in ${ROOTP}/usr/lib/firmware/brcm/ : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -680,17 +587,18 @@ copyingsystem()
|
||||
/bin/rmdir "${BOOT}" "${ROOT}"
|
||||
else
|
||||
error "line ${LINENO} error unmounting ${ROOT} or ${BOOT} : exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
|
||||
/usr/sbin/partx -d "${DEVICE}"
|
||||
if [ ${?} -ne 0 ]; then
|
||||
error "line ${LINENO} warning : error unmounting ${DEVICE} "
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
|
||||
}
|
||||
|
||||
|
||||
# Copying files common to all systems
|
||||
copyingcommon()
|
||||
{
|
||||
@ -700,6 +608,56 @@ copyingcommon()
|
||||
chown root:root "${ROOT}/usr/local/bin/"
|
||||
}
|
||||
|
||||
|
||||
function preImgCreation()
|
||||
{
|
||||
error "This function is called if no sourced file about fdisk was lauched."
|
||||
return 1
|
||||
}
|
||||
|
||||
function postPrepareChroot()
|
||||
{
|
||||
error "This function is called if no sourced file contain postPrepareChroot function."
|
||||
return 1
|
||||
}
|
||||
|
||||
ERR_1=1
|
||||
ERR_DEFAULT_CONFIG=2
|
||||
ERR_NO_CONFIG_FILE=3
|
||||
ERR_4=4
|
||||
ERR_5=5
|
||||
ERR_NO_SPACE=6
|
||||
ERR_7=7
|
||||
ERR_8=8
|
||||
ERR_9=9
|
||||
|
||||
|
||||
#######################
|
||||
# PROGRAMM START HERE #
|
||||
#######################
|
||||
|
||||
|
||||
info ${0}
|
||||
|
||||
SOURCE_PATH="$(/bin/dirname "$(readlink -f "${0}")")"
|
||||
INSTALL_PATH="${SOURCE_PATH}/arm"
|
||||
FILES_PATH="${SOURCE_PATH}/files"
|
||||
PLATFORMS_PATH="${SOURCE_PATH}/platforms"
|
||||
|
||||
CMDNAME=$(/bin/basename "${0}")
|
||||
|
||||
#while read -r;do
|
||||
# for MAGEIA_VERSION in $REPLY
|
||||
# do
|
||||
# if [ $MAGEIA_VERSION <= 5 ]; then
|
||||
# echo 'Mageia version >= 6 is needed'
|
||||
# exit
|
||||
# fi
|
||||
# break
|
||||
# done
|
||||
#done < /etc/version
|
||||
|
||||
|
||||
if [ ${#} == 0 ]; then
|
||||
help
|
||||
exit
|
||||
@ -708,13 +666,12 @@ fi
|
||||
|
||||
# parsing commandline
|
||||
TEMP=$(getopt -o h,a --long all,help,clean,create-chroot,addmedia,create-image,,config:,target:,target-version:,chroot,bootfs:,install-basesystem,update-mirror,build-path:,size:,nonfree,tainted -n ${CMDNAME} -- "${@}")
|
||||
if [ ${?} -ne 0 ] ; then error "line ${LINENO} Failed parsing options." >&2 ; exit 1 ; fi
|
||||
if [ ${?} -ne 0 ] ; then error "line ${LINENO} Failed parsing options." >&2 ; exit ${ERR_1} ; fi
|
||||
eval set -- "${TEMP}"
|
||||
|
||||
echo "${TEMP}"
|
||||
# Note the quotes around `$TEMP': they are essential! Or not, $( ) do the same as ` `
|
||||
while true;
|
||||
do
|
||||
# Note the quotes around `$TEMP': they are essential! Or not, $( ) do the same as ` `. But there are the ` ' used ?
|
||||
while true; do
|
||||
case "${1}" in
|
||||
-h|--help)
|
||||
help
|
||||
@ -800,7 +757,7 @@ do
|
||||
break;;
|
||||
*)
|
||||
error "Parameter ${1} does not exists "
|
||||
exit 1;;
|
||||
exit ${ERR_1};;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -809,34 +766,34 @@ done
|
||||
if ! [ -d "${CONFIG_PATH}" ]; then
|
||||
info " Config path does not exists, defaulting to ./platforms/${TARGET}"
|
||||
CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
|
||||
warning "Do you want i make it and copy the template file in? [Y|n] "
|
||||
warning "Do you want to create it and to copy the template file in? [Y|n] "
|
||||
read yn
|
||||
if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
|
||||
/usr/bin/mkdir "${CONFIG_PATH}/"
|
||||
/usr/bin/cp --preserve=mode "${SOURCE_PATH}/config.template" "${CONFIG_PATH}/mageia4arm.cfg"
|
||||
/usr/bin/cp --preserve=mode "${SOURCE_PATH}/mageia4arm.cfg.template" "${CONFIG_PATH}/mageia4arm.cfg"
|
||||
warning "You need now to modify the config file (${CONFIG_PATH}/mageia4arm.cfg) and relaunch the script"
|
||||
exit 2
|
||||
exit ${ERR_DEFAULT_CONFIG}
|
||||
else
|
||||
error( "Error: Can't continue without config file, exiting" )
|
||||
exit 3
|
||||
exit ${ERR_NO_CONFIG_FILE}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "${CONFIG_PATH}/mageia4arm.cfg" ]; then
|
||||
info "using ${CONFIG_PATH}/mageia4arm.cfg as config"
|
||||
source "${CONFIG_PATH}/mageia4arm.cfg" #NOTE1 : Here is sourced a file with variables.
|
||||
else
|
||||
warning "Config file does not exists, do you want i copy template ? [Y|n] "
|
||||
read yn
|
||||
if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
|
||||
/usr/bin/cp --preserve=mode "${SOURCE_PATH}/mageia4arm.cfg.template" "${CONFIG_PATH}/mageia4arm.cfg"
|
||||
warning "You need now to modify the config file (${CONFIG_PATH}/mageia4arm.cfg) and relaunch the script"
|
||||
exit 2
|
||||
fi
|
||||
if [ -e "${CONFIG_PATH}/mageia4arm.cfg" ]; then
|
||||
info "using ${CONFIG_PATH}/mageia4arm.cfg as config"
|
||||
source "${CONFIG_PATH}/mageia4arm.cfg" #NOTE1 : Here is sourced a file with variables.
|
||||
else
|
||||
warning "Config file does not exists, do you want i copy template ? [Y|n] "
|
||||
read yn
|
||||
if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
|
||||
/usr/bin/cp --preserve=mode "${SOURCE_PATH}/mageia4arm.cfg.template" "${CONFIG_PATH}/mageia4arm.cfg"
|
||||
warning "You need now to modify the config file (${CONFIG_PATH}/mageia4arm.cfg) and relaunch the script"
|
||||
exit ${ERR_DEFAULT_CONFIG}
|
||||
fi
|
||||
else # What are this "else fi" related to ?
|
||||
|
||||
fi
|
||||
# else # What are this "else fi" related to ?
|
||||
#
|
||||
# fi
|
||||
|
||||
if ! [ -z "${IMAGE_SIZE_P}" ]; then
|
||||
IMAGE_SIZE=${IMAGE_SIZE_P}
|
||||
@ -869,24 +826,29 @@ BUILD_PATH="${INSTALL_PATH}/build"
|
||||
ARM_VERSION="armv7hl"
|
||||
|
||||
# assign function for building image of TARGET ( rpi, odroid )
|
||||
case ${TARGET} in #NOTE2 : Why isn't it inside the sourced file ? Inside the .cfg ? It will make the code more flexible.
|
||||
"bananaPro")
|
||||
CREATEIMG="createbproimage"
|
||||
;;
|
||||
|
||||
"odroid")
|
||||
CREATEIMG="createxu3image"
|
||||
;;
|
||||
|
||||
"rpi")
|
||||
CREATEIMG="createrpiimage"
|
||||
;;
|
||||
|
||||
*)
|
||||
error "No Target : ${TARGET}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# case ${TARGET} in #NOTE2 : Why isn't it inside the sourced file ? Inside the .cfg ? It will make the code more flexible.
|
||||
# "bananaPro")
|
||||
# CREATEIMG="createbproimage"
|
||||
# ;;
|
||||
#
|
||||
# "odroid")
|
||||
# CREATEIMG="createxu3image"
|
||||
# ;;
|
||||
#
|
||||
# "rpi")
|
||||
# CREATEIMG="createrpiimage"
|
||||
# ;;
|
||||
#
|
||||
# *)
|
||||
# error "No Target : ${TARGET}"
|
||||
# exit ${ERR_1}
|
||||
# ;;
|
||||
# esac
|
||||
|
||||
# Assigne a script for creating a particular target image (rpi, odroid, ...)
|
||||
if [ -e "${CONFIG_PATH}/specialFunctions.sh" ]; then
|
||||
source "${CONFIG_PATH}/specialFunctions.sh"
|
||||
fi
|
||||
|
||||
info "target : ${TARGET}"
|
||||
info "target_version : ${TARGET_VERSION}"
|
||||
@ -909,13 +871,13 @@ if [ "${OPT}" != "clean" ]; then
|
||||
/bin/mkdir -p "${INSTALL_PATH}"
|
||||
if [ -z ${?} ]; then
|
||||
error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
cd "${INSTALL_PATH}"
|
||||
if [ -z ${?} ]; then
|
||||
error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
|
||||
exit 1
|
||||
exit ${ERR_1}
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -936,7 +898,7 @@ case ${OPT} in
|
||||
echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
|
||||
read yn
|
||||
if [ ${yn} = "n" ]; then
|
||||
exit 6
|
||||
exit ${ERR_NO_SPACE}
|
||||
fi
|
||||
fi
|
||||
createchroot
|
||||
@ -945,7 +907,8 @@ case ${OPT} in
|
||||
installbasesystem
|
||||
preparechroot
|
||||
jumpchroot
|
||||
${CREATEIMG}
|
||||
# ${CREATEIMG}
|
||||
createImageWrap
|
||||
;;
|
||||
"createchroot")
|
||||
createchroot
|
||||
@ -963,9 +926,10 @@ case ${OPT} in
|
||||
verify_disk_space
|
||||
if [ ${?} -eq 1 ]; then
|
||||
warning "Not enough space on disk"
|
||||
exit 6
|
||||
exit ${ERR_NO_SPACE}
|
||||
fi
|
||||
${CREATEIMG}
|
||||
# ${CREATEIMG}
|
||||
createImageWrap
|
||||
;;
|
||||
"installbasesystem")
|
||||
installbasesystem
|
||||
@ -976,3 +940,5 @@ esac
|
||||
if ! [ -z ${ERRORN} ]; then
|
||||
warning "Some errors occurs : ${ERRORN} errors"
|
||||
fi
|
||||
|
||||
exit ${ERRORN}
|
||||
|
Reference in New Issue
Block a user