diff options
Diffstat (limited to 'create_arm_image.sh')
-rwxr-xr-x | create_arm_image.sh | 108 |
1 files changed, 74 insertions, 34 deletions
diff --git a/create_arm_image.sh b/create_arm_image.sh index 2649bc0..e56f2aa 100755 --- a/create_arm_image.sh +++ b/create_arm_image.sh @@ -23,31 +23,57 @@ export LC_ALL=C source "$(dirname $(realpath "$0"))/functions.sh" function help() { - echo -e "${CMDNAME} [option] [size of image in Go]" + echo -e "${CMDNAME} [option]" 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 "--install-basesystem install base system" - echo -e "--add-urpmimedia add mirrors for urpmi" - echo -e "--chroot chroot to arm directory and launch packages installation" - echo -e "--create-image Create the image of Mageia ${MAGEIA_VERSION}" - echo -e "--config Path to config files (rpi2 rpi3 rpi3+ xu4 bananaPro)" + echo -e "--all create ready to burn image of Mageia ${MAGEIA_VERSION}" + echo -e "--build-path Path to the build directory of the image of Mageia ${MAGEIA_VERSION}" + echo -e "--clean Clean all (suppress all) to make a new image" + echo -e "--log [file] logs the output into mga4arm-YYYY-MM-DD-HH-MM-\${config}.log or specific file." + echo -e "--config [name | path] A name of a default config or a path to a config files" + 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 "--bootfs filesystem of boot partition (ext4 or vfat) default: ext4" + echo -e "--nonfree activate nonfree repos" + echo -e "--size size of image default: 7Go" + echo -e "--tainted activate tainted repos" + echo -e "--desktop [xfce|...] add a desktop environment task" + echo -e "--package \"pkg1 pkg2\" One space separated list of package to install" + + echo -e "\nBuild levels:" + echo -e "--create-chroot Create the chroot directory" + echo -e "--install-basesystem install base system" + echo -e "--add-urpmimedia add mirrors for urpmi" + 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)" } +CMD_LINE="${@}" +if [ 0 -ne $(echo "${CMD_LINE}" | grep -c '\-\-log') ]; then + if [ 0 -ne $(echo "${CMD_LINE}" | grep -c '\-\-config') ]; then + CONFIG_NAME="$(echo "${CMD_LINE}" | sed -e 's/^.*--config //' | sed -e 's/[[:space:]]*--.*$//' | sed -e 's/.*\/\([-_+[:alnum:]]*\)$/\1/' | tr ' ' '_')" + if [ "x" = "${CONFIG_NAME}x" ]; then + CONFIG_NAME="noconf" + fi + else + CONFIG_NAME="noconf" + fi + LOGFILE="$(echo "${CMD_LINE}" | sed -e 's/^.*--log //' | sed -e 's/[[:space:]]*--.*$//' )" + if [ "x" = "${LOGFILE}x" ]; then + LOGFILE="./mga4arm-$(date "+%Y-%m-%d-%H:%M:%S")-${CONFIG_NAME}.log" + LOGCMD="--log " + else + LOGCMD="--log ${lOGFILE}" + fi + CMD_LINE="$(echo ${CMD_LINE} | sed -e "s/${LOGCMD}//" )" + touch ${LOGFILE} + /usr/bin/chown ${USER}:${USER} ${LOGFILE} + exec ${0} ${CMD_LINE} 2>&1 | tee ${LOGFILE} + exit +fi + info ${0} #Check dependencies : @@ -55,10 +81,10 @@ info ${0} # 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 +if [ 0 -ne $(id -u) ]; then + error "Script need to be run as root." + exit ${ERR_NOT_ROOT} +fi SOURCE_PATH="$(/usr/bin/dirname "$(readlink -f "${0}")")" INSTALL_PATH="$(pwd)/build" @@ -120,7 +146,7 @@ while true; do ;; --config) PATH_NOT_NAME=$(echo "${2}" | grep '/' 2>&1 1>/dev/null && echo "true" || echo "false" ) - if [ $PATH_NOT_NAME == true ] ; then + if [ ${PATH_NOT_NAME} == true ] ; then CONFIG_PATH="${2}" else CONFIG_PATH="${PLATFORMS_PATH}/${2}" @@ -139,6 +165,10 @@ while true; do fi shift ;; + --desktop) + DESKTOP="task-${2}" + shift 2 + ;; -h|--help) help exit 0 @@ -159,6 +189,10 @@ while true; do NONFREE_P=1 shift ;; + --package) + PACKAGE="${2}" + shift + ;; --prepare-chroot) if [ -z ${OPT} ]; then OPT="preparechroot" @@ -232,13 +266,13 @@ else fi # VARIABLE_A=${VARIABLE_B_IF_EXISTS:=${VARIABLE_C_IF_B_DOESNT_EXISTS}} -IMAGE_SIZE=${IMAGE_SIZE_P:=${IMAGE_SIZE}} -INSTALL_PATH=${INSTALL_PATH_P:=${INSTALL_PATH}} -TARGET=${TARGET_P:=${TARGET}} -TARGET_VERSION=${TARGET_VERSION_P:=${TARGET_VERSION}} -BOOTFS=${BOOTFS_P:=${BOOTFS}} -NONFREE=${NONFREE_P:=0} -TAINTED=${TAINTED_P:=0} +IMAGE_SIZE="${IMAGE_SIZE_P:=${IMAGE_SIZE}}" +INSTALL_PATH="${INSTALL_PATH_P:=${INSTALL_PATH}}" +TARGET="${TARGET_P:=${TARGET}}" +TARGET_VERSION="${TARGET_VERSION_P:=${TARGET_VERSION}}" +BOOTFS="${BOOTFS_P:=${BOOTFS}}" +NONFREE="${NONFREE_P:=0}" +TAINTED="${TAINTED_P:=0}" info "Option: "${OPT} @@ -263,9 +297,9 @@ info "Firmware dir : ${FIRMWARE_DIR}" info "Installation method : ${INSTALL_METHOD}" # Defining default image size to 7 go -if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then - IMAGE_SIZE=7 -fi +# 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 @@ -302,6 +336,7 @@ case ${OPT} in exit ${ERR_NO_SPACE} fi fi + ckeck_extrapackage createImageWrap #Create the empty .img mountPartitions createchroot #Check qemu and activate it @@ -318,6 +353,10 @@ case ${OPT} in bunrningBootloader unmountingPartitions unloopingImage + + warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card" + info "pv \"${INSTALL_PATH}/${IMAGE}\" | dd of=/dev/mmcblk#" + generateExtra ;; "createchroot") createchroot @@ -352,4 +391,5 @@ if [ ${ERRORN} -ne 0 ]; then warning "Some errors occurs : ${ERRORN} errors" fi +unset exit exit ${ERRORN} |