1
0

Rectification skel, clean, rm ${BOOT}&${ROOT}

Skel supprime les fichiers par défaut du paquet rootfiles dont le .bashrc et la variable PATH contenant /usr/sbin.
Clean démontait les partitions avec une regex dans la commande ls, qui ne gère pas les regex. Méthode changée.
Modification de rmdir -rf /mnt/boot à rm -rf car rmdir ne prends aucun de des arguments r/f et bloque si le dossier n'est pas vide.
This commit is contained in:
Jybz 2019-10-27 15:08:49 +00:00
parent ef464c1ed0
commit 4057597197

View File

@ -15,6 +15,10 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
function WaitToContinue()
{
read -p "Break... Press [ENTER] to continue." GARBAGE
}
function title() function title()
{ {
@ -109,24 +113,42 @@ function clean()
else else
warning "${IMAGE} does not exists" warning "${IMAGE} does not exists"
fi fi
# [root@jabztop mageia4arm (master)]# losetup -l -O NAME,BACK-FILE -n
# /dev/loop0 /home/jibz/workspaces/mageia4arm/build/Mageia-7-bananaPro1.img (deleted)
# # 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}" # Tell the kernel about the presence and numbering of partitions.
# fi
# done
info "Supposed image name : ${IMAGE}"
info "Looped devices : $(losetup -l -O NAME -n)"
info "Looped devices with this image : $(losetup -l -O NAME -n | grep ${IMAGE})"
# removing loop devices # removing loop devices
for LOOP in $(ls /dev/loop*[0-9]p1); do for LOOP in $(losetup -l -O NAME -n); do
X=${LOOP:0:10} info "removing ${LOOP}"
if [ -e "${X}" ]; then losetup -d "${LOOP}" # Tell the kernel about the presence and numbering of partitions.
info "removing ${X}"
partx -d "${X}" # Tell the kernel about the presence and numbering of partitions.
fi
done done
# Removing boot and root directory # Removing boot and root directory
if [ -d "${BOOT}" ]; then if [ -d "${BOOT}" ]; then
info "Removing ${BOOT}" info "Removing ${BOOT}"
/bin/rmdir "${BOOT}" /bin/rm -rf "${BOOT}"
else else
warning "${BOOT} does not exists" warning "${BOOT} does not exists"
fi fi
if [ -d "${ROOT}" ]; then if [ -d "${ROOT}" ]; then
info "Removing ${ROOT}" info "Removing ${ROOT}"
/bin/rmdir "${ROOT}" /bin/rm -rf "${ROOT}"
else else
warning "${ROOT} does not exists" warning "${ROOT} does not exists"
fi fi
@ -276,8 +298,9 @@ function preparechroot()
info "creation of user account" 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" 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" # info "Copying skel in root directory"
/bin/rsync -rlptH /etc/skel/ "${BUILD_PATH}/root/" # /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 postPrepareChroot
if [ ${?} -ne 0 ]; then if [ ${?} -ne 0 ]; then
@ -494,19 +517,21 @@ copyingsystem()
fi fi
if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then if [ -e "${CONFIG_PATH}/extlinux.conf" ]; then
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" /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
info "\tTuning extlinux.conf"
sed -e s/\<UUID\>/${ROOT_UUID}/g ${CONFIG_PATH}/extlinux.conf >"${BUILD_PATH}/boot/extlinux/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-*) KERNEL_ID=$(basename ${BUILD_PATH}/usr/lib/linux-*)
sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf" sed -i -e s/\<FDTDIR\>/${KERNEL_ID}/g "${BUILD_PATH}/boot/extlinux/extlinux.conf"
fi fi
fi fi
info "Remove second_stage_install.sh"
/bin/rm -f "${BUILD_PATH}/second_stage_install.sh" /bin/rm -f "${BUILD_PATH}/second_stage_install.sh"
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then