aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--clean1
-rw-r--r--copy1
-rw-r--r--create1
-rw-r--r--create_arm_img_urpmi.sh.orig1084
-rw-r--r--create_arm_img_urpmi_BACKUP_5131.sh1084
-rw-r--r--create_arm_img_urpmi_BACKUP_8288.sh1084
-rw-r--r--create_arm_img_urpmi_BACKUP_8385.sh1084
-rw-r--r--create_arm_img_urpmi_BACKUP_8481.sh1084
-rw-r--r--create_arm_img_urpmi_BACKUP_9579.sh1084
-rw-r--r--create_arm_img_urpmi_BASE_5131.sh961
-rw-r--r--create_arm_img_urpmi_BASE_8288.sh961
-rw-r--r--create_arm_img_urpmi_BASE_8385.sh961
-rw-r--r--create_arm_img_urpmi_BASE_8481.sh961
-rw-r--r--create_arm_img_urpmi_BASE_9579.sh961
-rw-r--r--create_arm_img_urpmi_LOCAL_5131.sh948
-rw-r--r--create_arm_img_urpmi_LOCAL_8288.sh948
-rw-r--r--create_arm_img_urpmi_LOCAL_8385.sh948
-rw-r--r--create_arm_img_urpmi_LOCAL_8481.sh948
-rw-r--r--create_arm_img_urpmi_LOCAL_9579.sh948
-rw-r--r--create_arm_img_urpmi_REMOTE_5131.sh960
-rw-r--r--create_arm_img_urpmi_REMOTE_8288.sh960
-rw-r--r--create_arm_img_urpmi_REMOTE_8385.sh960
-rw-r--r--create_arm_img_urpmi_REMOTE_8481.sh960
-rw-r--r--create_arm_img_urpmi_REMOTE_9579.sh960
-rw-r--r--platforms/bananaPro.tar.gzbin31444384 -> 0 bytes
-rw-r--r--platforms/bananaPro/README.md5
27 files changed, 6 insertions, 20852 deletions
diff --git a/.gitignore b/.gitignore
index 796b96d..048b651 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/build
+/platforms/*/INFO/
diff --git a/clean b/clean
deleted file mode 100644
index d3fca78..0000000
--- a/clean
+++ /dev/null
@@ -1 +0,0 @@
-./create_arm_img_urpmi.sh --clean --config bananaPro --build-path ./build
diff --git a/copy b/copy
deleted file mode 100644
index a434b1d..0000000
--- a/copy
+++ /dev/null
@@ -1 +0,0 @@
-dd if=./build/Mageia-7-bananaPro1.img | pv | dd of=/dev/mmcblk0 ; sync
diff --git a/create b/create
deleted file mode 100644
index fe641aa..0000000
--- a/create
+++ /dev/null
@@ -1 +0,0 @@
-./create_arm_img_urpmi.sh --all --target bananaPro --size 2 --tainted --nonfree --build-path ./build --config bananaPro 2>&1 | tee -a ./log/creation.log
diff --git a/create_arm_img_urpmi.sh.orig b/create_arm_img_urpmi.sh.orig
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi.sh.orig
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BACKUP_5131.sh b/create_arm_img_urpmi_BACKUP_5131.sh
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi_BACKUP_5131.sh
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BACKUP_8288.sh b/create_arm_img_urpmi_BACKUP_8288.sh
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi_BACKUP_8288.sh
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BACKUP_8385.sh b/create_arm_img_urpmi_BACKUP_8385.sh
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi_BACKUP_8385.sh
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BACKUP_8481.sh b/create_arm_img_urpmi_BACKUP_8481.sh
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi_BACKUP_8481.sh
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BACKUP_9579.sh b/create_arm_img_urpmi_BACKUP_9579.sh
deleted file mode 100644
index c7dbe83..0000000
--- a/create_arm_img_urpmi_BACKUP_9579.sh
+++ /dev/null
@@ -1,1084 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
-<<<<<<< HEAD
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-=======
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
->>>>>>> upstream/master
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-fi
-
-
-# parsing commandline
-<<<<<<< HEAD
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
-=======
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
->>>>>>> upstream/master
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
-<<<<<<< HEAD
- 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 to 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
-=======
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
->>>>>>> upstream/master
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_BASE_5131.sh b/create_arm_img_urpmi_BASE_5131.sh
deleted file mode 100644
index eb4aa37..0000000
--- a/create_arm_img_urpmi_BASE_5131.sh
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- ;;
- --tainted)
- TAINTED_P=1
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error( "Error: Can't continue without config file, exiting" )
- exit 3
- fi
-fi
-
- if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
- 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
- fi
-else
-
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_BASE_8288.sh b/create_arm_img_urpmi_BASE_8288.sh
deleted file mode 100644
index eb4aa37..0000000
--- a/create_arm_img_urpmi_BASE_8288.sh
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- ;;
- --tainted)
- TAINTED_P=1
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error( "Error: Can't continue without config file, exiting" )
- exit 3
- fi
-fi
-
- if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
- 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
- fi
-else
-
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_BASE_8385.sh b/create_arm_img_urpmi_BASE_8385.sh
deleted file mode 100644
index eb4aa37..0000000
--- a/create_arm_img_urpmi_BASE_8385.sh
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- ;;
- --tainted)
- TAINTED_P=1
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error( "Error: Can't continue without config file, exiting" )
- exit 3
- fi
-fi
-
- if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
- 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
- fi
-else
-
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_BASE_8481.sh b/create_arm_img_urpmi_BASE_8481.sh
deleted file mode 100644
index eb4aa37..0000000
--- a/create_arm_img_urpmi_BASE_8481.sh
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- ;;
- --tainted)
- TAINTED_P=1
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error( "Error: Can't continue without config file, exiting" )
- exit 3
- fi
-fi
-
- if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
- 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
- fi
-else
-
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_BASE_9579.sh b/create_arm_img_urpmi_BASE_9579.sh
deleted file mode 100644
index eb4aa37..0000000
--- a/create_arm_img_urpmi_BASE_9579.sh
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- ;;
- --tainted)
- TAINTED_P=1
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error( "Error: Can't continue without config file, exiting" )
- exit 3
- fi
-fi
-
- if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
- 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
- fi
-else
-
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_LOCAL_5131.sh b/create_arm_img_urpmi_LOCAL_5131.sh
deleted file mode 100644
index 0bd7cc3..0000000
--- a/create_arm_img_urpmi_LOCAL_5131.sh
+++ /dev/null
@@ -1,948 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
- 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 to 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
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_LOCAL_8288.sh b/create_arm_img_urpmi_LOCAL_8288.sh
deleted file mode 100644
index 0bd7cc3..0000000
--- a/create_arm_img_urpmi_LOCAL_8288.sh
+++ /dev/null
@@ -1,948 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
- 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 to 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
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_LOCAL_8385.sh b/create_arm_img_urpmi_LOCAL_8385.sh
deleted file mode 100644
index 0bd7cc3..0000000
--- a/create_arm_img_urpmi_LOCAL_8385.sh
+++ /dev/null
@@ -1,948 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
- 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 to 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
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_LOCAL_8481.sh b/create_arm_img_urpmi_LOCAL_8481.sh
deleted file mode 100644
index 0bd7cc3..0000000
--- a/create_arm_img_urpmi_LOCAL_8481.sh
+++ /dev/null
@@ -1,948 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
- 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 to 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
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_LOCAL_9579.sh b/create_arm_img_urpmi_LOCAL_9579.sh
deleted file mode 100644
index 0bd7cc3..0000000
--- a/create_arm_img_urpmi_LOCAL_9579.sh
+++ /dev/null
@@ -1,948 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#Change the local to the most global
-export LC_ALL=C
-
-function WaitToContinue() {
- read -p "Break... Press [ENTER] to continue." GARBAGE
-}
-
-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"
-}
-
-function help() {
- echo -e "${CMDNAME} [option] [size of image in Go]"
- echo -e "Options:"
- echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}"
- echo -e "--clean Clean all (suppress all) to make a new image"
- echo -e "--size size of image default: 7Go"
- echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}"
- echo -e "--target target system (for now rpi, odroid)"
- echo -e "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo -e "--config Path to config files"
- echo -e "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo -e "--nonfree activate nonfree repos"
- echo -e "--tainted activate tainted repos"
-
- echo -e "\nBuild levels:"
- echo -e "--create-chroot Create the chroot directory"
- echo -e "--addmedia add mirrors"
- echo -e "--update-mirror update urpmi database"
- echo -e "--install-basesystem install base system"
- echo -e "--chroot chroot to arm directory and launch packages installation"
- echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "${INSTALL_PATH}" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ ${DISK_SPACE} -lt ${IMAGE_SIZE} ]; then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "${0} --size ${IMAGE_SIZE} --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media ${MIRROR}"
-
- info "Removing old media"
- /sbin/urpmi.removemedia --urpmi-root "${BUILD_PATH}" -a
-
- info "Adding media"
- if [ ! -z "${MIRROR}" ] ; then
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib "${MIRROR}"
- else
- info "MIRROR variable not set, using mirrorlist."
- /sbin/urpmi.addmedia --urpmi-root "${BUILD_PATH}" --distrib --mirrorlist "http://mirrors.mageia.org/api/mageia.${MAGEIA_VERSION}.${ARM_VERSION}.list"
- fi
-
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
- fi
- if [ ${NONFREE} -eq 1 ]; then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
- fi
- fi
- if [ ${TAINTED} -eq 1 ]; then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "${BUILD_PATH}" --no-ignore Tainted\ Release Tainted\ Updates
- err=${?}
- if [ ${err} -ne 0 ]; then
- error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
- fi
- fi
- return 0
-}
-
-
-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 ${ERR_1}
- fi
- return 0
-}
-
-
-function installbasesystem()
-{
- # Create Build path
- if ! [ -d "${BUILD_PATH}" ]; then
- warning "Build path ( ${BUILD_PATH} ) does not exist, do you want to create it ? [Y|n] "
- read yn
- if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
- title "Creating ${BUILD_PATH}"
- /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 ${ERR_1}
- fi
- else
- exit ${ERR_1}
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 shadow-utils basesystem-minimal
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
- fi
- #/sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 basesystem-minimal
- #if [ ${?} -ne 0 ]; then
- # error "line ${LINENO} error installing basesystem-minimal : exiting"
- # exit ${ERR_1}
- #fi
- /sbin/urpmi --urpmi-root "${BUILD_PATH}" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 0 urpmi locales u-boot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error installing urpmi or locales.fr : exiting"
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function preparechroot()
-{
- title "Preparing chrooting in ${BUILD_PATH}"
-
- #Copying qemu
-
- /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 ${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 ${ERR_1}
- fi
-
-
- info "making /etc/hostname"
- echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
-
- info "copying second stage script in ${BUILD_PATH}"
- #echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/"
- 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 ${ERR_1}
- fi
-
- info "creation of user account"
- 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 "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
-#This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
-
- postPrepareChroot
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
- fi
- return 0
-}
-
-
-function jumpchroot()
-{
- title "chrooting to ${BUILD_PATH}"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- 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 ${ERR_1}
- fi
- /bin/mount -B /proc "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- 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 ${ERR_1}
- fi
- if [ "$OPT" = "chroot" ]; then
- /sbin/chroot "${BUILD_PATH}"
- else
- /sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'sh /second_stage_install.sh 2>&1'
- fi
- RET=${?}
- if [ ${RET} -ne 0 ]; then
- error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
- ERRORN=$((${ERRORN}+1))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "${BUILD_PATH}/dev"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/sys"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- /bin/umount -lf "${BUILD_PATH}/proc"
- if [ ${?} -ne 0 ]; then
- warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
- ERRORN=$((${ERRORN}+1))
- fi
- return 0
-}
-
-
-function createImageWrap()
-{
- title "Wrap image creation"
- preImgCreation
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
- createimage
- if [ -z "${BOOTFS}" ]; then
- BOOTFS="ext4"
- fi
- formatpartitions ${BOOTFS} ext4
-
- 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 '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"
- 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()
-{
- info "Generate extlinux if extlinux.conf exists."
- if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
- info "\tFound extlinux.conf"
- if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
- info "making /boot/extlinux/extlinux.conf"
- /bin/rm -rf "${BUILD_PATH}/boot/extlinux"
- mkdir -p "${BUILD_PATH}/boot/extlinux"
- fi
- if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
- info "\tTuning extlinux.conf"
- sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/extlinux.conf"
- KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
- sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
- fi
- fi
-
- info "Remove second_stage_install.sh"
- /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
- if ! [ -d "${ARM_BOOT}" ]; then
- rm -rf "${ARM_BOOT}"
- mkdir -p "${ARM_BOOT}"
- fi
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- /bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
- /bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
- else
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
- fi
-
- copyingCustomSystem
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
- fi
-
- copyingcommon
-
- sync
- warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
- return 0
-}
-
-
-function mountPartitions(){
- info "mounting partitions, making mountpoint if necessary"
-
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- if ! [ -d "${BOOT}" ]; then
- /bin/mkdir "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error making directory ${BOOT} : exiting"
- exit ${ERR_1}
- fi
- fi
- /bin/mount "${BOOTP}" "${BOOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${BOOTP} : exiting"
- 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 ${ERR_1}
- fi
- fi
- /bin/mount "${ROOTP}" "${ROOT}"
- if [ ${?} -ne 0 ]; then
- error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
- fi
-}
-
-
-function unmountingPartitions()
-{
- title "Unmounting partitions..."
-
- # Syncing devices before unmounting
- /usr/bin/sync
-
- 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 "${ROOT}"
- else
- error "line ${LINENO} error unmounting ${ROOT}..."
- fi
- fi
- return 0
-}
-
-
-function unloopingImage(){
- title "Unlooping image..."
- # Syncing devices before unmounting
- /usr/bin/sync
-
- # [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}"
- for PARTITION in ${LOOP}p* ; do
- partx -dv "${PARTITION}"
- done
-# losetup -d "${LOOP}"
- kpartx -d "${INSTALL_PATH}/${IMAGE}"
- done
-
- return 0
-}
-
-
-# Copying files common to all systems
-function copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
- rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/"
- chown root:root "${ROOT}/usr/local/bin/"
- return 0
-}
-
-
-function mkfstab()
-{
- title "making /etc/fstab"
- ### BUG : /mnt/arm_boot is set to vfat for all plateforms, odroid configuration says ext4.
- #echo -e "proc /proc proc defaults 0 0\nUUID=${BOOT_UUID} /mnt/arm_boot vfat defaults 0 0\nUUID=${ROOT_UUID} / ext4 defaults 0 0" > "${BUILD_PATH}/etc/fstab"
- #echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${BOOT_UUID}\t/mnt/arm_boot\t${BOOTFS}\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- else
- echo -e "proc\t/proc\tproc\tdefaults\t0\t0\nUUID=${ROOT_UUID}\t/\text4\tdefaults\t0\t0" > "${BUILD_PATH}/etc/fstab"
- fi
- return 0
-}
-
-
-# cleaning build space
-function clean()
-{
- title "Cleaning"
-
- unmountingPartitions
- unloopingImage
-
- # Removing old Build directory
- if [ -d "${BUILD_PATH}" ]; then
- info "Removing ${BUILD_PATH}"
- /bin/rm -Rf "${BUILD_PATH}"
- else
- warning "${BUILD_PATH} does not exists"
- fi
- # removing old image
- if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
- info "Removing ${IMAGE}"
- /bin/rm -f "${INSTALL_PATH}/${IMAGE}"
- else
- warning "${IMAGE} does not exists"
- fi
-
- return 0
-}
-
-
-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 is containing postPrepareChroot function."
- return 1
-}
-
-function bunrningBootloader()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-function copyingCustomSystem()
-{
- error "This function is called if no sourced file is containing bunrningBootloader function."
- return 1
-}
-
-
-
-ERRORN=0
-ERR_1=1
-ERR_DEFAULT_CONFIG=2
-ERR_NO_CONFIG_FILE=3
-ERR_NOT_ROOT=4
-ERR_DEPENDENCY_MISSING=5
-ERR_NO_SPACE=6
-ERR_7=7
-ERR_8=8
-ERR_9=9
-
-SEPARATE_BOOT_PARTITION=1
-
-#######################
-# PROGRAMM START HERE #
-#######################
-
-
-info ${0}
-
-#Check dependencies :
-#if [ -e /usr/bin/qemu-arm-static ]; then
-# error "qemu-user-static package is needed."
-# exit ${ERR_DEPENDENCY_MISSING}
-#fi
-#if [ 0 -ne $(id -u) ]; then
-# error "Script need to be run as root."
-# exit ${ERR_NOT_ROOT}
-#fi
-
-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}")
-
-
-if [ ${#} == 0 ]; then
- help
- exit
-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 ${ERR_1} ; fi
-eval set -- "${TEMP}"
-
-echo "${TEMP}"
-# 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
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=${2}
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P=$(readlink -f "${2}")
- shift 2
- ;;
- --chroot)
- if [ -z ${OPT} ]; then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z ${OPT} ]; then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z ${OPT} ]; then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z ${OPT} ]; then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z ${OPT} ]; then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z ${OPT} ]; then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=${2}
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=${2}
- shift 2
- ;;
- --config)
- CONFIG_PATH="${PLATFORMS_PATH}/${2}"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=${2}
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter ${1} does not exists "
- exit ${ERR_1};;
- esac
-done
-
-
-# path of config file
-if ! [ -d "${CONFIG_PATH}" ]; then
- info " Config path does not exists, defaulting to ./platforms/${TARGET}"
- CONFIG_PATH="${PLATFORMS_PATH}/${TARGET}"
- 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}/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}
- else
- error "Error: Can't continue without config file, exiting"
- 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 to 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
-fi
-
-if ! [ -z "${IMAGE_SIZE_P}" ]; then
- IMAGE_SIZE=${IMAGE_SIZE_P}
-fi
-if ! [ -z "${INSTALL_PATH_P}" ]; then
- INSTALL_PATH=${INSTALL_PATH_P}
-fi
-if ! [ -z "${TARGET_P}" ]; then
- TARGET=${TARGET_P}
-fi
-if ! [ -z "${TARGET_VERSION_P}" ]; then
- TARGET_VERSION=${TARGET_VERSION_P}
-fi
-if ! [ -z "${BOOTFS_P}" ]; then
- BOOTFS=${BOOTFS_P}
-fi
-if ! [ -z "${NONFREE_P}" ]; then
- NONFREE=${NONFREE_P}
-else
- NONFREE=0
-fi
-if ! [ -z "${TAINTED_P}" ]; then
- TAINTED=${TAINTED_P}
-else
- TAINTED=0
-fi
-
-info "Option: "${OPT}
-
-IMAGE="Mageia-${MAGEIA_VERSION}-${TARGET}${TARGET_VERSION}.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="${INSTALL_PATH}/build-${TARGET}${TARGET_VERSION}"
-ARM_VERSION="armv7hl"
-
-# 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}"
-info "source path: ${SOURCE_PATH}"
-info "Install path: ${INSTALL_PATH}"
-info "Build path: ${BUILD_PATH}"
-info "Commande : ${CMDNAME}"
-info "Firmware path : ${FIRMWARE_PATH}"
-info "Firmware dir : ${FIRMWARE_DIR}"
-
-# Defining default image size to 7 go
-if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "${OPT}" != "clean" ]; then
- info "cd ${INSTALL_PATH}"
- if ! [ -e "${INSTALL_PATH}" ]; then
- /bin/mkdir -p "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
- fi
- cd "${INSTALL_PATH}"
- if [ -z ${?} ]; then
- error "line ${LINENO} can't change to directory ${INSTALL_PATH} , exiting"
- exit ${ERR_1}
- fi
-fi
-
-#if no parameters then display help message
-if [ -z ${OPT} ]; then
- OPT="--help"
-fi
-
-info "Image size is: ${IMAGE_SIZE} GB"
-
-case ${OPT} in
- "clean")
- clean
- ;;
- "all")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ ${yn} = "n" ]; then
- exit ${ERR_NO_SPACE}
- fi
- fi
- createImageWrap #Create the empty .img
- createchroot #Check qemu and activate it
- addmedia
- updatemirror
- installbasesystem #Generate the rootfs, rootfiles, ...
- mkfstab
- preparechroot
- jumpchroot
- #Check before is useless (with $MIRROR
- info "Use mirrorlist to light one server."
- MIRROR=
- addmedia
- mountPartitions
- copyingsystem
- unmountingPartitions
- unloopingImage
- ;;
- "createchroot")
- createchroot
- ;;
- "chroot")
- jumpchroot
- ;;
- "addmedia")
- addmedia
- ;;
- "updatemirror")
- updatemirror
- ;;
- "createimage")
- verify_disk_space
- if [ ${?} -ne 0 ]; then
- warning "Not enough space on disk"
- exit ${ERR_NO_SPACE}
- fi
- createImageWrap
- ;;
- "installbasesystem")
- installbasesystem
- ;;
-esac
-
-
-if [ ${ERRORN} -ne 0 ]; then
- warning "Some errors occurs : ${ERRORN} errors"
-fi
-
-exit ${ERRORN}
diff --git a/create_arm_img_urpmi_REMOTE_5131.sh b/create_arm_img_urpmi_REMOTE_5131.sh
deleted file mode 100644
index 37ab33a..0000000
--- a/create_arm_img_urpmi_REMOTE_5131.sh
+++ /dev/null
@@ -1,960 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error "Error: Can't continue without config file, exiting"
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_REMOTE_8288.sh b/create_arm_img_urpmi_REMOTE_8288.sh
deleted file mode 100644
index 37ab33a..0000000
--- a/create_arm_img_urpmi_REMOTE_8288.sh
+++ /dev/null
@@ -1,960 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error "Error: Can't continue without config file, exiting"
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_REMOTE_8385.sh b/create_arm_img_urpmi_REMOTE_8385.sh
deleted file mode 100644
index 37ab33a..0000000
--- a/create_arm_img_urpmi_REMOTE_8385.sh
+++ /dev/null
@@ -1,960 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error "Error: Can't continue without config file, exiting"
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_REMOTE_8481.sh b/create_arm_img_urpmi_REMOTE_8481.sh
deleted file mode 100644
index 37ab33a..0000000
--- a/create_arm_img_urpmi_REMOTE_8481.sh
+++ /dev/null
@@ -1,960 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error "Error: Can't continue without config file, exiting"
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/create_arm_img_urpmi_REMOTE_9579.sh b/create_arm_img_urpmi_REMOTE_9579.sh
deleted file mode 100644
index 37ab33a..0000000
--- a/create_arm_img_urpmi_REMOTE_9579.sh
+++ /dev/null
@@ -1,960 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-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()
-{
- echo "$CMDNAME [option] [size of image in Go]"
- echo "Options:"
- echo "--all create ready to burn image of Mageia $MAGEIA_VERSION"
- echo "--clean Clean all (suppress all) to make a new image"
- echo "--size size of image default: 7Go"
- echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
- echo "--target target system (for now rpi, odroid)"
- echo "--target-version version of the target (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
- echo "--config Path to config files (rpi1 rpi2 rpi3 rpi3+ xu4)"
- echo "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4"
- echo "--nonfree activate nonfree repos"
- echo "--tainted activate tainted repos"
- echo "\nBuild levels:"
- echo "--create-chroot Create the chroot directory"
- echo "--addmedia add mirrors"
- echo "--update-mirror update urpmi database"
- echo "--install-basesystem install base system"
- echo "--chroot chroot to arm directory and launch packages installation"
- echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
-
- echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
-}
-
-
-# cleaning build space
-function clean()
-{
- # Unmounting /dev /proc /sys in chroot
- title "Cleaning"
- if ! [ -z "$(mountpoint -qd "$BUILD_PATH/dev")" ];then
- info "Unmounting $BUILD_PATH/dev"
- umount "$BUILD_PATH/dev"
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't unmount $BUILD_PATH/dev : exiting"
- #exit 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 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 1
- fi
- fi
- # Removing old Build directory
- if [ -d "$BUILD_PATH" ];then
- info "Removing $BUILD_PATH"
- /bin/rm -Rf "$BUILD_PATH"
- else
- warning "$BUILD_PATH does not exists"
- fi
- # removing old image
- if [ -e "$IMAGE" ];then
- info "Removing $IMAGE"
- /bin/rm -f "$INSTALL_PATH/$IMAGE"
- else
- warning "$IMAGE does not exists"
- fi
- # removing loop devices
- for LOOP in $(ls /dev/loop*[0-9]p1)
- do
- X=${LOOP:0:10}
- if [ -e "$X" ];then
- info "removing $X"
- partx -d "$X"
- fi
- done
- # Removing boot and root directory
- if [ -d "$BOOT" ];then
- info "Removing $BOOT"
- /bin/rmdir "$BOOT"
- else
- warning "$BOOT does not exists"
- fi
- if [ -d "$ROOT" ];then
- info "Removing $ROOT"
- /bin/rmdir "$ROOT"
- else
- warning "$ROOT does not exists"
- fi
- exit 0
-}
-
-# creation of install path and copy of qemu ( installing it if not yet installed )
-
-function createchroot()
-{
- title "Making chroot"
- if ! [ -f /bin/qemu-arm-static ]; then
- title "Qemu package not present : installing qemu packages"
- /sbin/urpmi --auto --no-recommends qemu-user-static
- if ! [ $? -eq 0 ];then
- error "line $LINENO can't install qemu-user-static : exiting"
- exit 1
- fi
- fi
- # Starting qemu service if not started
- /bin/systemctl is-active systemd-binfmt.service
- if [ $? -ne 0 ]; then
- title "Starting systemd-binfmt.service"
- /bin/systemctl start systemd-binfmt.service
- if ! [ $? -ne 0 ];then
- error "line $LINENO can't start qemu-user-static : exiting"
- exit 1
- fi
- fi
-
-
-}
-
-# adding Mageia repositories
-function addmedia()
-{
- title "Creating media $MIRROR"
- /sbin/urpmi.addmedia --urpmi-root "$BUILD_PATH" --distrib "$MIRROR"
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't add medias from $MIRROR : exiting"
- exit 1
- fi
- if [ $NONFREE -eq 1 ];then
- title "activating non-free repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Nonfree\ Release Nonfree\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias nonfree : exiting"
- exit 1
- fi
- fi
- if [ $TAINTED -eq 1 ];then
- title "activating tainted repos"
- /sbin/urpmi.update --urpmi-root "$BUILD_PATH" --no-ignore Tainted\ Release Tainted\ Updates
- err=$?
- if [ $err -ne 0 ];then
- error "line $LINENO error $err - can't activate medias tainted : exiting"
- exit 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
- fi
-}
-
-function installbasesystem()
-{
-
-# Create Build path
- if ! [ -d "$BUILD_PATH" ];then
- warning "Build path ( $BUILD_PATH ) does not exists, do you want i create it ? [Y|n] "
- read yn
- if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
- title "Creating $BUILD_PATH"
- /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
- fi
- else
- exit 1
- fi
- else
- info "Build path exists"
- fi
-
- title "installing basesystem"
- /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
- 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
- #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
- fi
-}
-
-function preparechroot()
-{
- title "Preparing chrooting in $BUILD_PATH"
-
- #Copying qemu
-
- /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
- 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
- fi
-
-
- info "making /etc/hostname"
- echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
-
- info "copying second stage script in $BUILD_PATH"
- echo "/bin/cp $CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
- 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
- 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"
-
-
-
- info "Copying skel in root directory"
- /bin/rsync -rlptH /etc/skel/ "$BUILD_PATH/root/"
-
-
- case $TARGET in
- 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
-}
-
-function jumpchroot()
-{
- title "chrooting to $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 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
- fi
- if [ "$OPT" = "chroot" ];then
- /sbin/chroot "$BUILD_PATH"
- else
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
- fi
- RET=$?
- if [ $RET -ne 0 ];then
- error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
- ERRORN=$((ERRORN++))
- fi
- info "unmounting dev, sys, proc"
- /bin/umount -lf "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
- /bin/umount -lf "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
- ERRORN=$((ERRORN++))
- fi
-}
-
-function verify_disk_space()
-{
- title "Verifying if there is enough space on disk to make the image"
- DISK_SPACE=$(/usr/bin/df -BG --output=avail "$INSTALL_PATH" | sed '1d;s/[^0-9]//g')
- info "Free disk space: ${DISK_SPACE}G"
- if [ $DISK_SPACE -lt $IMAGE_SIZE ];then
- warning "image size is greater than disk space"
- info "correct the problem and relaunch the script with parameter --create-rpi-image"
- info "$0 --size $IMAGE_SIZE --create-rpi-image"
- return 1
- fi
- return 0
-}
-
-function createxu3image()
-{
- title "Creating Odroid XU3-XU4 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"
- 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 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 1
- fi
- DEVICE=$(/sbin/losetup -f --show "$INSTALL_PATH/$IMAGE")
- if [ $TARGET = "odroid" ];then
- info "installing blobs"
- pushd "$CONFIG_PATH/sd_fuse"
- if [ $? -ne 0 ];then
- error "line $LINENO error directory $CONFIG_PATH/sd_fuse does not exists : exiting"
- exit 1
- else
- ./sd_fusing.sh "$DEVICE"
- fi
- pushd
- fi
-
- info "making partitions"
- /sbin/fdisk "$DEVICE" << EOF
-n
-p
-1
-
-+128M
-t
-c
-n
-p
-2
-
-
-a
-1
-a
-2
-w
-EOF
-
- # Activate loop device
- /sbin/losetup -d "$DEVICE"
- DEVICE=$(/sbin/partx -va "$INSTALL_PATH/$IMAGE" | /bin/grep -m 1 -E -o '/dev/loop.?')
- info "device $DEVICE"
- info "partitions list:"
- info "$(/sbin/partx -v "$INSTALL_PATH/$IMAGE")"
- BOOTP="${DEVICE}p1"
- ROOTP="${DEVICE}p2"
-}
-
-formatpartitions()
-{
- info "Formatting partitions"
- 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 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
- fi
- BOOT_UUID=$(blkid -s UUID -o value UUID "$BOOTP")
- info "Boot UUID: $BOOT_UUID"
- ROOT_UUID=$(blkid -s UUID -o value UUID "$ROOTP")
- info "Root UUID: $ROOT_UUID"
-}
-
-copyingsystem()
-{
- info "mounting partitions, making mountpoint if necessary"
- if ! [ -d "$BOOT" ];then
- /bin/mkdir "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $BOOT : exiting"
- exit 1
- fi
- fi
- if ! [ -d "$ROOT" ];then
- /bin/mkdir "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error making directory $ROOT : exiting"
- exit 1
- fi
- fi
- /bin/mount "$BOOTP" "$BOOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BOOTP : exiting"
- exit 1
- fi
- /bin/mount "$ROOTP" "$ROOT"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $ROOTP : exiting"
- exit 1
- fi
-
- info "making /etc/fstab"
- echo "proc /proc proc defaults 0 0
-UUID=$BOOT_UUID /mnt/arm_boot vfat defaults 0 0
-UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PATH"/etc/fstab
-
- if [ ! -d "$BUILD_PATH/boot/extlinux" ];then
- info "making /boot/extlinux/extlinux.conf"
- mkdir -p "$BUILD_PATH/boot/extlinux"
- fi
- if [ ! -f "$BUILD_PATH/boot/extlinux/extlinux.conf" ];then
- sed -e s/\<UUID\>/$ROOT_UUID/g $CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
- KERNEL_ID=`basename $BUILD_PATH/usr/lib/linux-*`
- sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
- fi
- case $TARGET in
- rpi)
-
- info "copying 10-vchiq-permissions.rules"
- cp --preserve=mode "$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
- info "Making /etc/modules"
- echo "vchiq
-snd_bcm2835
-vc4
-brcmfmac" >> "$BUILD_PATH"/etc/modules
-
- ARM_BOOT="$BUILD_PATH/mnt/arm_boot"
- if ! [ -d "$ARM_BOOT" ];then
- mkdir -p "$ARM_BOOT"
- fi
- info "copying modprobe.conf"
- /usr/bin/cp -v --preserve=mode "$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
- chown root:root "$BUILD_PATH/etc/modprobe.conf"
-
- info "copying firmware, overlays in rpi boot partition"
-# cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
- cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
- cp -vR --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
-
- info "copying u-boot binary to $ARM_BOOT"
- case $TARGET_VERSION in
- 2)
- info "copying u-boot for $TARGET 2"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 0)
- info "copying u-boot for $TARGET 0"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 1)
- info "copying u-boot for $TARGET 1"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3_32)
- info "copying u-boot for $TARGET 3 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- 3+)
- info "copying u-boot for $TARGET 3b+ 32 bits"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
- ;;
- esac
-
-# info "copying raspberry optionals files in opt"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
-
- info "copying wifi firmware file missing in kernel-firmware-nonfree"
- if ! [ -d "$ROOT/usr/lib/firmware/brcm/" ];then
- /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
- fi
- if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
- /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
- fi
- fi
-
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ARM_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ARM_BOOT/" "$BOOT/"
- ;;
- odroid)
- ODROID_BOOT="$BUILD_PATH/mnt/odroid_boot"
- if ! [ -d "$ODROID_BOOT" ];then
- mkdir -p "$ODROID_BOOT"
- fi
- case $TARGET_VERSION in
- xu4)
- info "copying u-boot for $TARGET $TARGET_VERSION"
- cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
- ;;
- esac
- # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
-
- info "Copying extlinux.conf on $ODROID_BOOT"
- cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
- info "copying Mageia image to root partition"
- /bin/rsync -rlptogDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
- /bin/rsync -rlptogDH "$ODROID_BOOT/" "$BOOT/"
- ;;
- esac
-
-# info "copying tools in /usr/local/bin/"
-# /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
-# if ! [ $? -eq 0 ];then
-# error "line $LINENO error copying tools"
-# ERRORN=$((ERRORN++))
-# fi
-# /bin/mkdir "$ROOT/boot"
-
- copyingcommon
- # Syncing devices before unmounting
- /usr/bin/sync
- /usr/bin/umount "$BOOT" "$ROOT"
- if [ $? -eq 0 ];then
- /bin/rmdir "$BOOT" "$ROOT"
- else
- error "line $LINENO error unmounting $ROOT or $BOOT : exiting"
- exit 1
- fi
-
- /usr/sbin/partx -d "$DEVICE"
- if [ $? -ne 0 ];then
- error "line $LINENO warning : error unmounting $DEVICE "
- exit 1
- fi
- warning "You can now burn the image ( $INSTALL_PATH/$IMAGE ) on SD card"
-}
-
-# Copying files common to all systems
-copyingcommon()
-{
- title "Copying common files and configuration"
- rsync -rlptDH "$SOURCE_PATH/common/" "$ROOT/"
- rsync -rlptDH "$SOURCE_PATH/tools/"*.sh "$ROOT/usr/local/bin/"
- chown root:root "$ROOT/usr/local/bin/"
-}
-
-if [ $# == 0 ];then
- help
- exit
-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
-eval set -- "$TEMP"
-
-echo "$TEMP"
-# Note the quotes around `$TEMP': they are essential!
-while true;
-do
- case "$1" in
- -h|--help)
- help
- exit 0
- ;;
- -a|--all)
- OPT="all"
- shift 1
- ;;
- --clean)
- OPT="clean"
- shift
- ;;
- --size)
- IMAGE_SIZE_P=$2
- shift 2
- ;;
- --build-path)
- INSTALL_PATH_P="$2"
- shift 2
- ;;
- --chroot)
- if [ -z $OPT ];then
- OPT="chroot"
- fi
- shift
- ;;
- --create-chroot)
- if [ -z $OPT ];then
- OPT="createchroot"
- fi
- shift
- ;;
- --addmedia)
- if [ -z $OPT ];then
- OPT="addmedia"
- fi
- shift
- ;;
- --update-mirror)
- if [ -z $OPT ];then
- OPT="updatemirror"
- fi
- shift
- ;;
- --install-basesystem)
- if [ -z $OPT ];then
- OPT="installbasesystem"
- fi
- shift
- ;;
- --create-image)
- if [ -z $OPT ];then
- CREATEIMAGE=true
- OPT="createimage"
- fi
- shift
- ;;
- --target)
- TARGET_P=$2
- shift 2
- ;;
- --target-version)
- TARGET_VERSION_P=$2
- shift 2
- ;;
- --config)
- CONFIG_PATH="$PLATFORMS_PATH/$2"
- shift 2
- ;;
- --bootfs)
- BOOTFS_P=$2
- shift 2
- ;;
- --nonfree)
- NONFREE_P=1
- shift
- ;;
- --tainted)
- TAINTED_P=1
- shift
- ;;
- --)
- shift
- break;;
- *)
- error "Parameter $1 does not exists "
- exit 1;;
- esac
-done
-
-
-# path of config file
-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] "
- 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"
- warning "You need now to modify the config file ($CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
- exit 2
- else
- error "Error: Can't continue without config file, exiting"
- exit 3
- fi
-fi
-
-if [ -e "$CONFIG_PATH/mageia4arm.cfg" ];then
- info "using $CONFIG_PATH/mageia4arm.cfg as config"
- . "$CONFIG_PATH/mageia4arm.cfg"
-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
-fi
-
-if ! [ -z "$IMAGE_SIZE_P" ];then
- IMAGE_SIZE=$IMAGE_SIZE_P
-fi
-if ! [ -z "$INSTALL_PATH_P" ];then
- INSTALL_PATH=$INSTALL_PATH_P
-fi
-if ! [ -z "$TARGET_P" ];then
- TARGET=$TARGET_P
-fi
-if ! [ -z "$TARGET_VERSION_P" ];then
- TARGET_VERSION=$TARGET_VERSION_P
-fi
-if ! [ -z "$BOOTFS_P" ];then
- BOOTFS=$BOOTFS_P
-fi
-if ! [ -z "$NONFREE_P" ];then
- NONFREE=$NONFREE_P
-fi
-if ! [ -z "$TAINTED_P" ];then
- TAINTED=$TAINTED_P
-fi
-
-info "Option: "$OPT
-
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
-BOOT="/mnt/boot"
-ROOT="/mnt/root"
-BUILD_PATH="$INSTALL_PATH/build"
-ARM_VERSION="armv7hl"
-
-# assign function for building image of TARGET ( rpi, odroid )
-case $TARGET in
-odroid)
- CREATEIMG="createxu3image"
- ;;
-rpi)
- CREATEIMG="createrpiimage"
- ;;
-*)
- error "No Target : $TARGET"
- exit 1
- ;;
-esac
-
-info "target : $TARGET"
-info "target_version : $TARGET_VERSION"
-info "source path: $SOURCE_PATH"
-info "Install path: $INSTALL_PATH"
-info "Build path: $BUILD_PATH"
-info "Commande : $CMDNAME"
-info "Firmware path : $FIRMWARE_PATH"
-info "Firmware dir : $FIRMWARE_DIR"
-
-# Defining default image size to 7 go
-if [[ "$IMAGE_SIZE" -lt 7 ]] || [[ "$IMAGE_SIZE" -gt 128 ]];then
- IMAGE_SIZE=7
-fi
-
-# change dir to install path and create it if not existing
-if [ "$OPT" != "clean" ];then
- info "cd $INSTALL_PATH"
- if ! [ -e "$INSTALL_PATH" ];then
- /bin/mkdir -p "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't make directory $INSTALL_PATH , exiting"
- exit 1
- fi
- fi
- cd "$INSTALL_PATH"
- if [ -z $? ];then
- error "line $LINENO can't change to directory $INSTALL_PATH , exiting"
- exit 1
- fi
-fi
-
-#if no parameters then display help message
-if [ -z $OPT ];then
- OPT="--help"
-fi
-
-info "Image size is: $IMAGE_SIZE Go"
-
-case $OPT in
- clean)
- clean
- ;;
- all)
- verify_disk_space
- if [ $? -eq 1 ];then
- echo -e "Not enough space on disk\nDo you want to continue anyway ? [Y,n]"
- read yn
- if [ $yn = "n" ];then
- exit 6
- fi
- fi
- createchroot
- addmedia
- updatemirror
- installbasesystem
- preparechroot
- jumpchroot
- $CREATEIMG
- ;;
- createchroot)
- createchroot
- ;;
- chroot)
- jumpchroot
- ;;
- addmedia)
- addmedia
- ;;
- updatemirror)
- updatemirror
- ;;
- createimage)
- verify_disk_space
- if [ $? -eq 1 ];then
- warning "Not enough space on disk"
- exit 6
- fi
- $CREATEIMG
- ;;
- installbasesystem)
- installbasesystem
- ;;
-esac
-
-
-if ! [ -z $ERRORN ];then
- warning "Some errors occurs : $ERRORN errors"
-fi
diff --git a/platforms/bananaPro.tar.gz b/platforms/bananaPro.tar.gz
deleted file mode 100644
index 78431cb..0000000
--- a/platforms/bananaPro.tar.gz
+++ /dev/null
Binary files differ
diff --git a/platforms/bananaPro/README.md b/platforms/bananaPro/README.md
index 5643069..8b68d53 100644
--- a/platforms/bananaPro/README.md
+++ b/platforms/bananaPro/README.md
@@ -113,3 +113,8 @@ Not Written.
ln -r -s ./vmlinuz-5.2.13-desktop-2.mga7 ./vmlinuz
rm -f ./vmlinuz && ln -r -s ./vmlinuz-5.3.1-desktop-2.mga7 ./vmlinuz
```
+
+## Commands used :
+./create_arm_img_urpmi.sh --clean --config bananaPro --build-path ./build
+./create_arm_img_urpmi.sh --all --target bananaPro --size 2 --tainted --nonfree --build-path ./build --config bananaPro 2>&1 | tee -a ./log/creation.log
+dd if=./build/Mageia-7-bananaPro1.img | pv | dd of=/dev/mmcblk0 ; sync