1
0

can choose between urpmi or dnf

This commit is contained in:
Daniel Tartavel 2020-08-06 15:26:15 +02:00
parent a27de93bfe
commit 5b4c77e853

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/bash
# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com> # Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
# Jean-Baptiste Biernacki <j.biernacki@free.fr> # Jean-Baptiste Biernacki <j.biernacki@free.fr>
@ -6,7 +6,7 @@
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License,dnf or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
@ -87,33 +87,35 @@ function createchroot()
title "Making chroot" title "Making chroot"
if ! [ -f /usr/share/distribution-gpg-keys/mageia/RPM-GPG-KEY-Mageia ]; then if ! [ -f /usr/share/distribution-gpg-keys/mageia/RPM-GPG-KEY-Mageia ]; then
title "distribution-gpg-keys package not present : installing distribution-gpg-keys" title "distribution-gpg-keys package not present : installing distribution-gpg-keys"
/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install distribution-gpg-keys #/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install distribution-gpg-keys
installpkg "distribution-gpg-keys" "--setopt=install_weak_deps=False"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't install distribution-gpg-keys : exiting" error "line ${LINENO} can't install distribution-gpg-keys : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
fi fi
if ! [ -f /bin/qemu-arm-static ]; then if ! [ -f /usr/bin/qemu-arm-static ]; then
title "Qemu package not present : installing qemu packages" title "Qemu package not present : installing qemu packages"
/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install qemu-user-static #/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install qemu-user-static
if [ ${?} -ne 0 ]; then installpkg "qemu-user-static" "--setopt=install_weak_deps=False"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't install qemu-user-static : exiting" error "line ${LINENO} can't install qemu-user-static : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
fi fi
# Starting qemu service if not started # Starting qemu service if not started
/bin/systemctl is-active systemd-binfmt.service /usr/bin/systemctl is-active systemd-binfmt.service
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
title "Starting systemd-binfmt.service" title "Starting systemd-binfmt.service"
/bin/systemctl start systemd-binfmt.service /usr/bin/systemctl start systemd-binfmt.service
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't start qemu-user-static : exiting" error "line ${LINENO} can't start qemu-user-static : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
else else
title "Restarting systemd-binfmt.service" title "Restarting systemd-binfmt.service"
/bin/systemctl restart systemd-binfmt.service /usr/bin/systemctl restart systemd-binfmt.service
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't start qemu-user-static : exiting" error "line ${LINENO} can't start qemu-user-static : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -166,7 +168,7 @@ function enableextrarepos()
if [ "${MAGEIA_VERSION}" != "cauldron" ]; then if [ "${MAGEIA_VERSION}" != "cauldron" ]; then
DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-nonfree" DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-nonfree"
fi fi
/usr/bin/dnf $DNFPARAM; /usr/bin/dnf $DNFPARAM
err=${?} err=${?}
if [ ${err} -ne 0 ]; then if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate nonfree repositories : exiting" error "line ${LINENO} error ${err} - can't activate nonfree repositories : exiting"
@ -179,7 +181,7 @@ function enableextrarepos()
if [ "${MAGEIA_VERSION}" != "cauldron" ]; then if [ "${MAGEIA_VERSION}" != "cauldron" ]; then
DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-tainted" DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-tainted"
fi fi
/usr/bin/dnf $DNFPARAM² /usr/bin/dnf $DNFPARAM
err=${?} err=${?}
if [ ${err} -ne 0 ]; then if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate tainted repositories : exiting" error "line ${LINENO} error ${err} - can't activate tainted repositories : exiting"
@ -240,7 +242,7 @@ function installbasesystem()
read yn read yn
if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then if [ -z ${yn} ] || [ ${yn} = "Y" ] || [ ${yn} = "y" ]; then
title "Creating ${BUILD_PATH}" title "Creating ${BUILD_PATH}"
/bin/mkdir -p "${BUILD_PATH}/usr/bin" "${BUILD_PATH}/usr/lib/binfmt.d" /usr/bin/mkdir -p "${BUILD_PATH}/usr/bin" "${BUILD_PATH}/usr/lib/binfmt.d"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't create ${BUILD_PATH} : exiting" error "line ${LINENO} can't create ${BUILD_PATH} : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -266,7 +268,8 @@ function installbasesystem()
fi fi
title "installing basesystem" title "installing basesystem"
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install shadow-utils basesystem-minimal #/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install shadow-utils basesystem-minimal
installpkg "shadow-utils basesystem-minimal"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting" error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -276,27 +279,43 @@ function installbasesystem()
# error "line ${LINENO} error installing basesystem-minimal : exiting" # error "line ${LINENO} error installing basesystem-minimal : exiting"
# exit ${ERR_1} # exit ${ERR_1}
#fi #fi
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install dnf dnf-plugins-core locales if [ ${INSTALL_METHOD} = "urpmi" ]; then
if [ ${?} -ne 0 ]; then installpkg "urpmi locales"
error "line ${LINENO} error installing dnf or locales : exiting" else
exit ${ERR_1} installpkg "dnf dnf-plugins-core locales"
fi fi
if [ "${ARM_VERSION}" = "armv7hl" ]; then #/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install dnf dnf-plugins-core locales
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install u-boot
if [ ${?} -ne 0 ]; then #if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing u-boot : exiting" # error "line ${LINENO} error installing dnf or locales : exiting"
exit ${ERR_1} # exit ${ERR_1}
fi #fi
fi #if [ "${ARM_VERSION}" = "aarch64" ]; then
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install urpmi #/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install u-boot
if [ ${?} -ne 0 ]; then # installpkg "/u-boot*"
error "line ${LINENO} error installing urpmi : exiting" # if [ ${?} -ne 0 ]; then
exit ${ERR_1} # error "line ${LINENO} error installing u-boot : exiting"
fi # exit ${ERR_1}
# fi
#fi
#/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install urpmi
#installpkg "urpmi"
#if [ ${?} -ne 0 ]; then
# error "line ${LINENO} error installing urpmi : exiting"
# exit ${ERR_1}
#fi
return 0 return 0
} }
function installpkg()
{
if [ ${INSTALL_METHOD} = "urpmi" ]; then
/usr/sbin/urpmi --urpmi-root "$BUILD_PATH" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 200 $3 $1;
else
/usr/bin/dnf $2 --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install $1;
fi
}
function preparechroot() function preparechroot()
{ {
title "Preparing chrooting in ${BUILD_PATH}" title "Preparing chrooting in ${BUILD_PATH}"
@ -305,27 +324,33 @@ function preparechroot()
echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname" echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname"
info "copying second stage script in ${BUILD_PATH}" info "copying second stage script in ${BUILD_PATH}"
#echo "/bin/cp ${CONFIG_PATH}/second_stage_install.sh ${BUILD_PATH}/" #echo "/usr/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" cp --preserve=mode "${CONFIG_PATH}/second_stage_install.sh" "${BUILD_PATH}/second_stage_install.sh"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying ${CONFIG_PATH}/second_stage_install.sh : exiting" error "line ${LINENO} error copying ${CONFIG_PATH}/second_stage_install.sh : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
info "configuring second_install_install.sh for ${INSTALL_METHOD}"
if [ ${INSTALL_METHOD} = "urpmi" ]; then
sed -i -e "s/<INSTALL_EXEC>/sbin\/urpmi --no-verify-rpm --auto/g" "${BUILD_PATH}/second_stage_install.sh"
else
sed -i -e "s/<INSTALL_EXEC>/bin\/dnf --nogpgcheck --assumeyes install/g" "${BUILD_PATH}/second_stage_install.sh"
fi
info "Preparation for setting root and user account" info "Preparation for setting root and user account"
if [ -n "${ROOT_PWD}" ]; then #If root password defined, it will be setted at the end of the chroot of the second_stage_install.sh script if [ -n "${ROOT_PWD}" ]; then #If root password defined, it will be setted at the end of the chroot of the second_stage_install.sh script
echo -e "/bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n" >>"${BUILD_PATH}/second_stage_install.sh" echo -e "/usr/bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n" >>"${BUILD_PATH}/second_stage_install.sh"
else else
info "No root password... One password will be set at the first login." info "No root password... One password will be set at the first login."
echo -e "/bin/passwd -d root\n/bin/passwd -e root\n" >>"${BUILD_PATH}/second_stage_install.sh" echo -e "/usr/bin/passwd -d root\n/usr/bin/passwd -e root\n" >>"${BUILD_PATH}/second_stage_install.sh"
fi fi
if [ -n "${ID_USER}" ]; then #If user ID defined, it will be setted at the end of the chroot of the second_stage_install.sh script if [ -n "${ID_USER}" ]; then #If user ID defined, it will be setted at the end of the chroot of the second_stage_install.sh script
echo -e " /sbin/useradd ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh" echo -e " /sbin/useradd ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh"
if [ -n "${PASSWORD}" ]; then if [ -n "${PASSWORD}" ]; then
echo -e "/bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh" echo -e "/usr/bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh"
else else
echo -e "/bin/passwd -d ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh" echo -e "/usr/bin/passwd -d ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh"
fi fi
else else
info "No user defined, no user account created." info "No user defined, no user account created."
@ -334,7 +359,7 @@ function preparechroot()
# BUG: This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs). # BUG: This line break the default .bashrc file from the package "rootfiles" and the values as PATH (and /usr/sbin programs).
# info "Copying skel in root directory" # info "Copying skel in root directory"
# /bin/rsync -rlptH "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/" # /usr/bin/rsync -rlptH "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/"
postPrepareChroot postPrepareChroot
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
@ -349,49 +374,58 @@ function jumpchroot()
{ {
title "chrooting to ${BUILD_PATH}" title "chrooting to ${BUILD_PATH}"
info "mounting dev, sys, proc directories in chroot" info "mounting dev, sys, proc directories in chroot"
/bin/mount -B /dev "${BUILD_PATH}/dev" /usr/bin/mount -B /dev "${BUILD_PATH}/dev"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting" error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
/bin/mount -B /sys "${BUILD_PATH}/sys" /usr/bin/mount -B /sys "${BUILD_PATH}/sys"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/sys : exiting" error "line ${LINENO} error mounting ${BUILD_PATH}/sys : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
/bin/mount -B /proc "${BUILD_PATH}/proc" /usr/bin/mount -B /proc "${BUILD_PATH}/proc"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting" error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
info "Copying resolv.conf" info "Copying resolv.conf"
/bin/cp -v --preserve=mode /etc/resolv.conf "${BUILD_PATH}/etc/" /usr/bin/cp -v --preserve=mode /etc/resolv.conf "${BUILD_PATH}/etc/"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying ${BUILD_PATH}/etc/resolv.conf : exiting" error "line ${LINENO} error copying ${BUILD_PATH}/etc/resolv.conf : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
info "chrooting to ${BUILD_PATH}"
if [ "$OPT" = "chroot" ]; then if [ "$OPT" = "chroot" ]; then
info "/sbin/chroot ${BUILD_PATH}"
/sbin/chroot "${BUILD_PATH}" /sbin/chroot "${BUILD_PATH}"
RET=${?}
if [ ${RET} -ne 0 ]; then
error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
ERRORN=$((${ERRORN}+1))
fi
else else
/sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'bash /second_stage_install.sh 2>&1' info "/sbin/chroot --userspec root:root ${BUILD_PATH} /usr/bin/bash -v -c 'bash /second_stage_install.sh 2>&1'"
fi /sbin/chroot --userspec root:root "${BUILD_PATH}" /usr/bin/bash -v -c 'bash /second_stage_install.sh 2>&1'
RET=${?} RET=${?}
if [ ${RET} -ne 0 ]; then if [ ${RET} -ne 0 ]; then
error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}" error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
ERRORN=$((${ERRORN}+1)) ERRORN=$((${ERRORN}+1))
fi
fi fi
info "unmounting dev, sys, proc" info "unmounting dev, sys, proc"
/bin/umount -lf "${BUILD_PATH}/dev" /usr/bin/umount -lf "${BUILD_PATH}/dev"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway" warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/dev, continuing anyway"
ERRORN=$((${ERRORN}+1)) ERRORN=$((${ERRORN}+1))
fi fi
/bin/umount -lf "${BUILD_PATH}/sys" /usr/bin/umount -lf "${BUILD_PATH}/sys"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway" warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/sys, continuing anyway"
ERRORN=$((${ERRORN}+1)) ERRORN=$((${ERRORN}+1))
fi fi
/bin/umount -lf "${BUILD_PATH}/proc" /usr/bin/umount -lf "${BUILD_PATH}/proc"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway" warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
ERRORN=$((${ERRORN}+1)) ERRORN=$((${ERRORN}+1))
@ -423,7 +457,7 @@ function createimage()
title " in ${IMAGE}" title " in ${IMAGE}"
if [ -f "${INSTALL_PATH}/${IMAGE}" ]; then if [ -f "${INSTALL_PATH}/${IMAGE}" ]; then
warning "Deleting previous image" warning "Deleting previous image"
/bin/rm -f "${INSTALL_PATH}/${IMAGE}" /usr/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error can't remove previous image at ${INSTALL_PATH}/${IMAGE} : exiting" error "line ${LINENO} error can't remove previous image at ${INSTALL_PATH}/${IMAGE} : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -431,7 +465,7 @@ function createimage()
fi fi
warning "please wait until end of image creation" warning "please wait until end of image creation"
/bin/dd if=/dev/zero of="${INSTALL_PATH}/${IMAGE}" bs=1MB count=$(( ${IMAGE_SIZE} * 1024 )) /usr/bin/dd if=/dev/zero of="${INSTALL_PATH}/${IMAGE}" bs=1MB count=$(( ${IMAGE_SIZE} * 1024 )) status=progress
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting" error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -511,7 +545,7 @@ function generateExtlinux()
info "\tFound extlinux.conf" info "\tFound extlinux.conf"
if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
info "making /boot/extlinux/extlinux.conf" info "making /boot/extlinux/extlinux.conf"
/bin/rm -rf "${BUILD_PATH}/boot/extlinux" /usr/bin/rm -rf "${BUILD_PATH}/boot/extlinux"
mkdir -p "${BUILD_PATH}/boot/extlinux" mkdir -p "${BUILD_PATH}/boot/extlinux"
fi fi
if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
@ -531,7 +565,7 @@ function copyingsystem()
generateExtlinux generateExtlinux
info "Remove second_stage_install.sh" info "Remove second_stage_install.sh"
/bin/rm -f "${BUILD_PATH}/second_stage_install.sh" /usr/bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
ARM_BOOT="${BUILD_PATH}/mnt/arm_boot" ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
@ -540,12 +574,12 @@ function copyingsystem()
mkdir -p "${ARM_BOOT}" mkdir -p "${ARM_BOOT}"
fi fi
info "copying Mageia image to root partition" info "copying Mageia image to root partition"
/bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/" /usr/bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
/bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/" /usr/bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
/bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/" #/usr/bin/rsync -rlptogDH "${BUILD_PATH}/boot/" "${BOOT}/"
else else
info "copying Mageia image to root partition" info "copying Mageia image to root partition"
/bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/" /usr/bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
fi fi
copyingCustomSystem copyingCustomSystem
@ -567,13 +601,13 @@ function mountPartitions(){
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
if ! [ -d "${BOOT}" ]; then if ! [ -d "${BOOT}" ]; then
/bin/mkdir "${BOOT}" /usr/bin/mkdir "${BOOT}"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error making directory ${BOOT} : exiting" error "line ${LINENO} error making directory ${BOOT} : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
fi fi
/bin/mount "${BOOTP}" "${BOOT}" /usr/bin/mount "${BOOTP}" "${BOOT}"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BOOTP} : exiting" error "line ${LINENO} error mounting ${BOOTP} : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -581,13 +615,13 @@ function mountPartitions(){
fi fi
if ! [ -d "${ROOT}" ]; then if ! [ -d "${ROOT}" ]; then
/bin/mkdir "${ROOT}" /usr/bin/mkdir "${ROOT}"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error making directory ${ROOT} : exiting" error "line ${LINENO} error making directory ${ROOT} : exiting"
exit ${ERR_1} exit ${ERR_1}
fi fi
fi fi
/bin/mount "${ROOTP}" "${ROOT}" /usr/bin/mount "${ROOTP}" "${ROOT}"
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${ROOTP} : exiting" error "line ${LINENO} error mounting ${ROOTP} : exiting"
exit ${ERR_1} exit ${ERR_1}
@ -613,7 +647,7 @@ function unmountingPartitions()
info "unmount ${PARTITION} and remove ${MOUNTPOINT}" info "unmount ${PARTITION} and remove ${MOUNTPOINT}"
/usr/bin/umount "${PARTITION}" /usr/bin/umount "${PARTITION}"
if [ ${?} -eq 0 ]; then if [ ${?} -eq 0 ]; then
/bin/rmdir "${MOUNTPOINT}" /usr/bin/rmdir "${MOUNTPOINT}"
else else
error "line ${LINENO} error unmounting ${BOOT}..." error "line ${LINENO} error unmounting ${BOOT}..."
fi fi
@ -624,14 +658,14 @@ function unmountingPartitions()
if [ ! -z "${BOOTP}" ]; then if [ ! -z "${BOOTP}" ]; then
/usr/bin/umount "${BOOTP}" /usr/bin/umount "${BOOTP}"
if [ ${?} -eq 0 ]; then if [ ${?} -eq 0 ]; then
/bin/rmdir "${BOOT}" /usr/bin/rmdir "${BOOT}"
else else
error "line ${LINENO} error unmounting ${BOOT}..." error "line ${LINENO} error unmounting ${BOOT}..."
fi fi
fi fi
/usr/bin/umount "${ROOTP}" /usr/bin/umount "${ROOTP}"
if [ ${?} -eq 0 ]; then if [ ${?} -eq 0 ]; then
/bin/rmdir "${ROOT}" /usr/bin/rmdir "${ROOT}"
else else
error "line ${LINENO} error unmounting ${ROOT}..." error "line ${LINENO} error unmounting ${ROOT}..."
fi fi
@ -667,8 +701,8 @@ function copyingcommon()
{ {
title "Copying common files and configuration" title "Copying common files and configuration"
rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/" rsync -rlptDH "${SOURCE_PATH}/common/" "${ROOT}/"
rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/bin/" rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/usr/bin/"
chown root:root "${ROOT}/usr/local/bin/" chown root:root "${ROOT}/usr/local/usr/bin/"
return 0 return 0
} }
@ -699,14 +733,14 @@ function clean()
# Removing old Build directory # Removing old Build directory
if [ -d "${BUILD_PATH}" ]; then if [ -d "${BUILD_PATH}" ]; then
info "Removing ${BUILD_PATH}" info "Removing ${BUILD_PATH}"
/bin/rm -Rf "${BUILD_PATH}" /usr/bin/rm -Rf "${BUILD_PATH}"
else else
warning "${BUILD_PATH} does not exists" warning "${BUILD_PATH} does not exists"
fi fi
# removing old image # removing old image
if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then if [ -e "${INSTALL_PATH}/${IMAGE}" ]; then
info "Removing ${IMAGE}" info "Removing ${IMAGE}"
/bin/rm -f "${INSTALL_PATH}/${IMAGE}" /usr/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
else else
warning "${IMAGE} does not exists" warning "${IMAGE} does not exists"
fi fi
@ -771,12 +805,12 @@ if [ 0 -ne $(id -u) ]; then
exit ${ERR_NOT_ROOT} exit ${ERR_NOT_ROOT}
fi fi
SOURCE_PATH="$(/bin/dirname "$(readlink -f "${0}")")" SOURCE_PATH="$(/usr/bin/dirname "$(readlink -f "${0}")")"
INSTALL_PATH="$(pwd)/build" INSTALL_PATH="$(pwd)/build"
# FILES_PATH="${SOURCE_PATH}/files" # FILES_PATH="${SOURCE_PATH}/files"
PLATFORMS_PATH="${SOURCE_PATH}/platforms" PLATFORMS_PATH="${SOURCE_PATH}/platforms"
CMDNAME=$(/bin/basename "${0}") CMDNAME=$(/usr/bin/basename "${0}")
if [ ${#} == 0 ]; then if [ ${#} == 0 ]; then
@ -786,7 +820,7 @@ fi
# parsing commandline # parsing commandline
TEMP=$(getopt -o h,a --long all,help,clean,create-chroot,add-urpmimedia,create-image,,config:,target:,target-version:,chroot,bootfs:,install-basesystem,update-mirror,build-path:,size:,nonfree,tainted -n ${CMDNAME} -- "${@}") TEMP=$(getopt -o h,a --long all,help,clean,create-chroot,prepare-chroot,jump-chroot,add-urpmimedia,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 if [ ${?} -ne 0 ] ; then error "line ${LINENO} Failed parsing options." >&2 ; exit ${ERR_1} ; fi
eval set -- "${TEMP}" eval set -- "${TEMP}"
@ -826,6 +860,18 @@ while true; do
fi fi
shift shift
;; ;;
--prepare-chroot)
if [ -z ${OPT} ]; then
OPT="preparechroot"
fi
shift
;;
--jump-chroot)
if [ -z ${OPT} ]; then
OPT="jumpchroot"
fi
shift
;;
--add-urpmimedia) --add-urpmimedia)
if [ -z ${OPT} ]; then if [ -z ${OPT} ]; then
OPT="addurpmimedia" OPT="addurpmimedia"
@ -962,6 +1008,7 @@ info "Build path: ${BUILD_PATH}"
info "Commande : ${CMDNAME}" info "Commande : ${CMDNAME}"
info "Firmware path : ${FIRMWARE_PATH}" info "Firmware path : ${FIRMWARE_PATH}"
info "Firmware dir : ${FIRMWARE_DIR}" info "Firmware dir : ${FIRMWARE_DIR}"
info "Installation method : ${INSTALL_METHOD}"
# Defining default image size to 7 go # Defining default image size to 7 go
if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then if [[ "${IMAGE_SIZE}" -lt 2 ]] || [[ "${IMAGE_SIZE}" -gt 128 ]]; then
@ -972,7 +1019,7 @@ fi
if [ "${OPT}" != "clean" ]; then if [ "${OPT}" != "clean" ]; then
info "cd ${INSTALL_PATH}" info "cd ${INSTALL_PATH}"
if ! [ -e "${INSTALL_PATH}" ]; then if ! [ -e "${INSTALL_PATH}" ]; then
/bin/mkdir -p "${INSTALL_PATH}" /usr/bin/mkdir -p "${INSTALL_PATH}"
if [ -z ${?} ]; then if [ -z ${?} ]; then
error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting" error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
exit ${ERR_1} exit ${ERR_1}
@ -1007,19 +1054,16 @@ case ${OPT} in
fi fi
createImageWrap #Create the empty .img createImageWrap #Create the empty .img
createchroot #Check qemu and activate it createchroot #Check qemu and activate it
genusemirroroptions #Generate mirror options, if needed if [ ${INSTALL_METHOD} = "urpmi" ]; then
installbasesystem #Generate the rootfs, rootfiles, ... addurpmimedia
enableextrarepos else
# addurpmimedia genusemirroroptions #Generate mirror options, if needed
enableextrarepos
fi
installbasesystem #Generate the rootfs, rootfiles, ...
mkfstab mkfstab
preparechroot preparechroot
jumpchroot jumpchroot
#Check before is useless (with $MIRROR
info "Use mirrorlist to light one server."
MIRROR=
genusemirroroptions
enableextrarepos
# addurpmimedia
mountPartitions mountPartitions
copyingsystem copyingsystem
unmountingPartitions unmountingPartitions
@ -1028,6 +1072,12 @@ case ${OPT} in
"createchroot") "createchroot")
createchroot createchroot
;; ;;
"preparechroot")
preparechroot
;;
"jumpchroot")
jumpchroot
;;
"chroot") "chroot")
jumpchroot jumpchroot
;; ;;