1
0

Compare commits

...

5 Commits

Author SHA1 Message Date
DTux
5e7efc71ae Mettre à jour 'README.md' 2020-08-06 14:28:03 +00:00
DTux
e17b42b9b1 Mettre à jour 'README.md' 2020-08-06 14:26:35 +00:00
Daniel Tartavel
e0b6e8600f Readme 2020-08-06 16:21:38 +02:00
Daniel Tartavel
a7ca8ac2c9 migration sur le git de Mageia 2020-08-06 16:17:38 +02:00
Daniel Tartavel
5b4c77e853 can choose between urpmi or dnf 2020-08-06 15:42:24 +02:00
2 changed files with 187 additions and 131 deletions

104
README.md
View File

@ -1,3 +1,9 @@
## **ATTENTION: Le projet a migré sur le git de Mageia.**
## **WARNING: project has migrated on Mageia's git.**
## [http://gitweb.mageia.org/software/mageia4arm/](http://)
mageia4arm
==========
@ -42,31 +48,31 @@ Avoir une copie de ce dépot :
```
git clone https://git.labolyon.fr/DTux/mageia4arm
```
Choisissez le dossier de configuration adapté à votre besoin (rpi ou xu4), sinon créez un nouveau dossier de configuration, copiez le fichier "mageia4arm.cfg.template" à l'interieur et modifiez le selon vos besoins.
Par défaut l'utilisateur est "pi" avec le mot de passe "raspberry", et l'administrateur "root" avec le mot de passe "piroot".
Choisissez le dossier de configuration adapté à votre besoin (rpi ou xu4), sinon créez un nouveau dossier de configuration, copiez le fichier "mageia4arm.cfg.template" à l'interieur et modifiez le selon vos besoins.
Par défaut l'utilisateur est "pi" avec le mot de passe "raspberry", et l'administrateur "root" avec le mot de passe "piroot".
<a id="fr_creatimg"/>
### Créer l'image :
create_arm_image.sh --all --config \<dossier de configuration\>
Par exemple :
create_arm_image.sh --all --config \<dossier de configuration\>
Par exemple :
```
su -
<mot de passe root>
cd /home/user/workspace/mageia4arm/
su -
<mot de passe root>
cd /home/user/workspace/mageia4arm/
./create_arm_image.sh --all --target bananaPro --size 4 --tainted --nonfree --build-path ./build --config bananaPro 2>&1 | tee -a ./build.log
```
Avec cette commande, toutes les étapes (--all) du processus de création pour (--target) la bananaPro sont exécuter. L'image final tiendra sur une carte de (--size) 4Go. Les dépots tainted et nonfree seront activé. Le chemin de construction (--build-path) sera ./build. Finalement, la configuration (--config) sera bananaPro. La suite de la commande, 2>&1 redirige la sortie d'erreur dans la sortie standart et le tout est dupliqué (| tee -a) dans le fichier build.log pour le déboguage.
<a id="fr_help"/>
### Aide :
create_arm_image.sh -h|--help
create_arm_image.sh -h|--help
Vous pouvez adapter le script "second_stage_install.sh" afin de compléter l'installation.
Des scripts sont disponibles dans le dossier "tools", ils sont copié dans /usr/local/bin/ dans l'image.
Vous pouvez adapter le script "second_stage_install.sh" afin de compléter l'installation.
Des scripts sont disponibles dans le dossier "tools", ils sont copié dans /usr/local/bin/ dans l'image.
<a id="fr_1stStart"/>
### Premier lancement de l'image sur le raspberry pi :
- lancer drakkeyboard afin de configurer le clavier
- lancer drakkeyboard afin de configurer le clavier
- si vous avez besoin d'un gestionnaire graphique, lancer le script :<br/>install_graphical.sh \<gestionnaire-graphique\>( xfce, lxqt, plasma, ...) voir les métapaquetages disponibles dans "Environnement graphique" dans le gestionnaire de logiciels.
@ -84,31 +90,31 @@ Ce script est lancé avec chroot, ainsi nous pouvons exécuter des opérations p
<a id="fr_file-spe"/>
#### specialFunctions.sh
Ce script complémente le processus d'installation pour des éléments spécifiques à la plateformes, comme le partitionnement, la manière de mettre en place le chargeur de démarrage, le téléchargements de fichiers externe, etc.
Le script doit implémenter ces quatres fonctions :
Ce script complémente le processus d'installation pour des éléments spécifiques à la plateformes, comme le partitionnement, la manière de mettre en place le chargeur de démarrage, le téléchargements de fichiers externe, etc.
Le script doit implémenter ces quatres fonctions :
```
function preImgCreation() {
#Possibilité de télécharger des éléments supplémentaires ici.
return 0
}
function postPrepareChroot() {
#Possibilité de copier des fichiers spécifique à la plateforme avant de lancer le script second_stage_install.sh.
return 0
}
function burningBootloader() {
#Plusieurs méthodes sont possibles pour flasher le chargeur de démarrage, et dépendent de la plateforme.
return 0
}
function copyingCustomSystem() {
#Possibilité de copier des fichiers dans le système monté.
return 0
}
function preImgCreation() {
#Possibilité de télécharger des éléments supplémentaires ici.
return 0
}
function postPrepareChroot() {
#Possibilité de copier des fichiers spécifique à la plateforme avant de lancer le script second_stage_install.sh.
return 0
}
function burningBootloader() {
#Plusieurs méthodes sont possibles pour flasher le chargeur de démarrage, et dépendent de la plateforme.
return 0
}
function copyingCustomSystem() {
#Possibilité de copier des fichiers dans le système monté.
return 0
}
```
Si l'une de ces fonctions ne retourne pas 0, la création de l'image échoue.
<a id="fr_file-extlinux"/>
#### extlinux.conf
Extlinux.conf est un script utilisé par le chargeur de démarrage (s'il est capable de le gérer, uboot le peut), pour spécifier la version du noyau à démarrer. Le script est normalement généré automatiquement par les outils de Mageia à chaque installation/mise à jour d'un noyau. Malheureusement, lors de la création d'une image de Mageia en chroot, l'outil refuse de générer ce fichier, de plus si le fichier est manquant, lors de la mise à jour du noyau, l'outil de Mageia génère un fichier erroné avec des entrées vides que u-boot refuse.
Extlinux.conf est un script utilisé par le chargeur de démarrage (s'il est capable de le gérer, uboot le peut), pour spécifier la version du noyau à démarrer. Le script est normalement généré automatiquement par les outils de Mageia à chaque installation/mise à jour d'un noyau. Malheureusement, lors de la création d'une image de Mageia en chroot, l'outil refuse de générer ce fichier, de plus si le fichier est manquant, lors de la mise à jour du noyau, l'outil de Mageia génère un fichier erroné avec des entrées vides que u-boot refuse.
Il vaut mieux créer ce fichier, même s'il n'est pas primordiale. D'autant plus que lors de la mise à jour d'un noyau, l'outil de Mageia reprends les arguments de la commande de démarrage pour les nouvelles versions.
La structure basique du fichier est :
@ -141,30 +147,30 @@ Diverses informations complémentaires.
<a id="fr_burn"/>
#### Graver une image
Il est possible de graver l'image avec dd, souvent les cartes SD sont disponibles sous le nom mmcblkX avec X leurs numéros.
Il est possible de graver l'image avec dd, souvent les cartes SD sont disponibles sous le nom mmcblkX avec X leurs numéros.
```
dd if=./build/Mageia-7-bananaPro1.img of=/dev/mmcblkX
```
On peut ajouter une barre de progression :
On peut ajouter une barre de progression :
```
pv ./build/Mageia-7-bananaPro1.img | dd of=/dev/mmcblkX
```
<a id="fr_compress"/>
#### Compresser une image
Pour compresser l'image, de plusieurs Go en quelques centaines de Mo pour la mettre en ligne par exemple, il est possible d'exécuter la commande suivante :
Pour compresser l'image, de plusieurs Go en quelques centaines de Mo pour la mettre en ligne par exemple, il est possible d'exécuter la commande suivante :
```
dd if=./build/Mageia-7-bananaPro1.img | gzip -9 | dd of=./build/Mageia-7-bananaPro1.img.gz
```
Avec une barre d'avancement :
```
Avec une barre d'avancement :
```
pv ./build/Mageia-7-bananaPro1.img | gzip -9 | dd of=./build/Mageia-7-bananaPro1.img.gz
```
Il est possible d'utiliser d'autre logiciel de compression comme xz par exemple.
```
Il est possible d'utiliser d'autre logiciel de compression comme xz par exemple.
<a id="fr_gen_chksum"/>
#### Calculer les sommes de contrôles
Pour s'assurer qu'un fichier a été bien téléchargé, pour vérifier son intégrité, il est d'usage de comparer la somme de contrôle. On peut la calculer avec l'algorithme MD5, SHA1, SHA256, SHA512. Par exemple :
Pour s'assurer qu'un fichier a été bien téléchargé, pour vérifier son intégrité, il est d'usage de comparer la somme de contrôle. On peut la calculer avec l'algorithme MD5, SHA1, SHA256, SHA512. Par exemple :
```
cd /home/user/workspace/mageia4arm/build
md5sum Mageia-7-bananaPro1.img > Mageia-7-bananaPro1.img.md5
@ -233,16 +239,16 @@ English
<a id="en_desc"/>
### Description:
This repository contains script to make image for arm based systems from Mageia repositories.
This repository contains script to make image for arm based systems from Mageia repositories.
<a id="en_quick"/>
<a id="en_creatimg"/>
### Quick start:
Choose the config dir you need (rpi or xu4), else create a new config directory with "mageia4arm.cfg.template" in and modify it as you need.
By default username is "pi" with password "raspberry" and root password is "piroot".
Choose the config dir you need (rpi or xu4), else create a new config directory with "mageia4arm.cfg.template" in and modify it as you need.
By default username is "pi" with password "raspberry" and root password is "piroot".
create_arm_image.sh --all --config <your config dir\>
create_arm_image.sh --all --config <your config dir\>
Example given :
```
su -
@ -254,14 +260,14 @@ With such command, all steps of the build process for the bananaPro will be exec
<a id="en_help"/>
### Help:
create_arm_image.sh -h|--help
create_arm_image.sh -h|--help
you can adapt the script "second_stage_install.sh" to complete the installation.
Some scripts are available in directory "tools". they are copied in /usr/local/bin/ in the image.
you can adapt the script "second_stage_install.sh" to complete the installation.
Some scripts are available in directory "tools". they are copied in /usr/local/bin/ in the image.
<a id="en_1stStart"/>
### First launch of the image on raspberry pi:
- launch drakkeyboard to configure keyboard layout.
- launch drakkeyboard to configure keyboard layout.
- if you need a graphical environment, launch the script :<br/>install_graphical.sh \<graphical environment\> ( xfce, lxqt, plasma, ...), see "Graphical environment" in the Mageia application manager meta packages.
@ -279,8 +285,8 @@ This script is launched with chroot, then we can execute custom operation as ins
<a id="en_file-spe"/>
#### specialFunctions.sh
This script add into the installation process some elements specific to the platform, as the partitionning, the fashon to set the bootloader, downloading external files, etc.
It must implement the four next functons :
This script add into the installation process some elements specific to the platform, as the partitionning, the fashon to set the bootloader, downloading external files, etc.
It must implement the four next functons :
```
function preImgCreation() {
#Here it is possible to download external file.
@ -303,7 +309,7 @@ If one of this functions does not return 0, the process is stoped.
<a id="en_file-extlinux"/>
#### extlinux.conf
extlinux.conf is a script used by the bootloader (if it is able to manage it, uboot does) in order to select specific kernel version to start with boot arguments. This script is normaly automatically generated by Mageia's tools at each kernel installation/update. Unfortunately, when creating the image of Mageia in chroot, the tool refuses to generate the file, moreover, if the file is missing, at the first kernel update, the tool will create it with empty entries which makes uboot failing to parse it.
extlinux.conf is a script used by the bootloader (if it is able to manage it, uboot does) in order to select specific kernel version to start with boot arguments. This script is normaly automatically generated by Mageia's tools at each kernel installation/update. Unfortunately, when creating the image of Mageia in chroot, the tool refuses to generate the file, moreover, if the file is missing, at the first kernel update, the tool will create it with empty entries which makes uboot failing to parse it.
It is better to generate this file, even if it isn't mandatory. It is even better as the tool take into account the boot arguments of previous kernel and add it for the new one and regenerate automatically the file.
The basic file is:

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/bash
# Copyright (C) 2017-2018 Daniel Tartavel-jeannot <contact@librepc.com>
# Jean-Baptiste Biernacki <j.biernacki@free.fr>
@ -6,7 +6,7 @@
#
# 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
# the Free Software Foundation; either version 2 of the License,dnf or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@ -87,33 +87,35 @@ function createchroot()
title "Making chroot"
if ! [ -f /usr/share/distribution-gpg-keys/mageia/RPM-GPG-KEY-Mageia ]; then
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
error "line ${LINENO} can't install distribution-gpg-keys : exiting"
exit ${ERR_1}
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"
/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install qemu-user-static
if [ ${?} -ne 0 ]; then
#/usr/bin/dnf --assumeyes --setopt=install_weak_deps=False install qemu-user-static
installpkg "qemu-user-static" "--setopt=install_weak_deps=False"
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
/usr/bin/systemctl is-active systemd-binfmt.service
if [ ${?} -ne 0 ]; then
title "Starting systemd-binfmt.service"
/bin/systemctl start systemd-binfmt.service
/usr/bin/systemctl start systemd-binfmt.service
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't start qemu-user-static : exiting"
exit ${ERR_1}
fi
else
title "Restarting systemd-binfmt.service"
/bin/systemctl restart systemd-binfmt.service
/usr/bin/systemctl restart systemd-binfmt.service
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't start qemu-user-static : exiting"
exit ${ERR_1}
@ -166,7 +168,7 @@ function enableextrarepos()
if [ "${MAGEIA_VERSION}" != "cauldron" ]; then
DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-nonfree"
fi
/usr/bin/dnf $DNFPARAM;
/usr/bin/dnf $DNFPARAM
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate nonfree repositories : exiting"
@ -179,7 +181,7 @@ function enableextrarepos()
if [ "${MAGEIA_VERSION}" != "cauldron" ]; then
DNFPARAM=$DNFPARAM" --set-enabled ${extrasect_updatesprefix}-${ARM_VERSION}-tainted"
fi
/usr/bin/dnf $DNFPARAM²
/usr/bin/dnf $DNFPARAM
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate tainted repositories : exiting"
@ -240,7 +242,7 @@ function installbasesystem()
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"
/usr/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}
@ -266,7 +268,8 @@ function installbasesystem()
fi
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
error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
exit ${ERR_1}
@ -276,27 +279,43 @@ function installbasesystem()
# error "line ${LINENO} error installing basesystem-minimal : exiting"
# exit ${ERR_1}
#fi
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install dnf dnf-plugins-core locales
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing dnf or locales : exiting"
exit ${ERR_1}
fi
if [ "${ARM_VERSION}" = "armv7hl" ]; then
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install u-boot
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing u-boot : exiting"
exit ${ERR_1}
fi
fi
/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install urpmi
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing urpmi : exiting"
exit ${ERR_1}
fi
if [ ${INSTALL_METHOD} = "urpmi" ]; then
installpkg "urpmi locales"
else
installpkg "dnf dnf-plugins-core locales"
fi
#/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install dnf dnf-plugins-core locales
#if [ ${?} -ne 0 ]; then
# error "line ${LINENO} error installing dnf or locales : exiting"
# exit ${ERR_1}
#fi
#if [ "${ARM_VERSION}" = "aarch64" ]; then
#/usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install u-boot
# installpkg "/u-boot*"
# if [ ${?} -ne 0 ]; then
# error "line ${LINENO} error installing u-boot : exiting"
# 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
}
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()
{
title "Preparing chrooting in ${BUILD_PATH}"
@ -305,27 +324,33 @@ function preparechroot()
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}/"
#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"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying ${CONFIG_PATH}/second_stage_install.sh : exiting"
exit ${ERR_1}
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"
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
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
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"
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
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
else
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).
# 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
if [ ${?} -ne 0 ]; then
@ -349,49 +374,58 @@ function jumpchroot()
{
title "chrooting to ${BUILD_PATH}"
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
error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
exit ${ERR_1}
fi
/bin/mount -B /sys "${BUILD_PATH}/sys"
/usr/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"
/usr/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/"
/usr/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
info "chrooting to ${BUILD_PATH}"
if [ "$OPT" = "chroot" ]; then
info "/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
/sbin/chroot --userspec root:root "${BUILD_PATH}" /bin/bash -v -c 'bash /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))
info "/sbin/chroot --userspec root:root ${BUILD_PATH} /usr/bin/bash -v -c 'bash /second_stage_install.sh 2>&1'"
/sbin/chroot --userspec root:root "${BUILD_PATH}" /usr/bin/bash -v -c 'bash /second_stage_install.sh 2>&1'
RET=${?}
if [ ${RET} -ne 0 ]; then
error "line ${LINENO} Warning : chrooting to ${BUILD_PATH} retrurn an error ${RET}"
ERRORN=$((${ERRORN}+1))
fi
fi
info "unmounting dev, sys, proc"
/bin/umount -lf "${BUILD_PATH}/dev"
/usr/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"
/usr/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"
/usr/bin/umount -lf "${BUILD_PATH}/proc"
if [ ${?} -ne 0 ]; then
warning "line ${LINENO} Warning : error unmounting ${BUILD_PATH}/proc, continuing anyway"
ERRORN=$((${ERRORN}+1))
@ -423,7 +457,7 @@ function createimage()
title " in ${IMAGE}"
if [ -f "${INSTALL_PATH}/${IMAGE}" ]; then
warning "Deleting previous image"
/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
/usr/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}
@ -431,7 +465,7 @@ function createimage()
fi
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
error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting"
exit ${ERR_1}
@ -511,7 +545,7 @@ function generateExtlinux()
info "\tFound extlinux.conf"
if [ ! -d "${BUILD_PATH}/boot/extlinux" ]; then
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"
fi
if [ ! -f "${BUILD_PATH}/boot/extlinux/extlinux.conf" ]; then
@ -531,7 +565,7 @@ function copyingsystem()
generateExtlinux
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
ARM_BOOT="${BUILD_PATH}/mnt/arm_boot"
@ -540,12 +574,12 @@ function copyingsystem()
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}/"
/usr/bin/rsync -rlptogDH --exclude "${ARM_BOOT}/" --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
/usr/bin/rsync -rlptogDH "${ARM_BOOT}/" "${BOOT}/"
#/usr/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}/"
/usr/bin/rsync -rlptogDH --exclude "qemu-arm-static*" "${BUILD_PATH}/" "${ROOT}/"
fi
copyingCustomSystem
@ -567,13 +601,13 @@ function mountPartitions(){
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
if ! [ -d "${BOOT}" ]; then
/bin/mkdir "${BOOT}"
/usr/bin/mkdir "${BOOT}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error making directory ${BOOT} : exiting"
exit ${ERR_1}
fi
fi
/bin/mount "${BOOTP}" "${BOOT}"
/usr/bin/mount "${BOOTP}" "${BOOT}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BOOTP} : exiting"
exit ${ERR_1}
@ -581,13 +615,13 @@ function mountPartitions(){
fi
if ! [ -d "${ROOT}" ]; then
/bin/mkdir "${ROOT}"
/usr/bin/mkdir "${ROOT}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error making directory ${ROOT} : exiting"
exit ${ERR_1}
fi
fi
/bin/mount "${ROOTP}" "${ROOT}"
/usr/bin/mount "${ROOTP}" "${ROOT}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${ROOTP} : exiting"
exit ${ERR_1}
@ -613,7 +647,7 @@ function unmountingPartitions()
info "unmount ${PARTITION} and remove ${MOUNTPOINT}"
/usr/bin/umount "${PARTITION}"
if [ ${?} -eq 0 ]; then
/bin/rmdir "${MOUNTPOINT}"
/usr/bin/rmdir "${MOUNTPOINT}"
else
error "line ${LINENO} error unmounting ${BOOT}..."
fi
@ -624,14 +658,14 @@ function unmountingPartitions()
if [ ! -z "${BOOTP}" ]; then
/usr/bin/umount "${BOOTP}"
if [ ${?} -eq 0 ]; then
/bin/rmdir "${BOOT}"
/usr/bin/rmdir "${BOOT}"
else
error "line ${LINENO} error unmounting ${BOOT}..."
fi
fi
/usr/bin/umount "${ROOTP}"
if [ ${?} -eq 0 ]; then
/bin/rmdir "${ROOT}"
/usr/bin/rmdir "${ROOT}"
else
error "line ${LINENO} error unmounting ${ROOT}..."
fi
@ -667,8 +701,8 @@ 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/"
rsync -rlptDH "${SOURCE_PATH}/tools/"*.sh "${ROOT}/usr/local/usr/bin/"
chown root:root "${ROOT}/usr/local/usr/bin/"
return 0
}
@ -699,14 +733,14 @@ function clean()
# Removing old Build directory
if [ -d "${BUILD_PATH}" ]; then
info "Removing ${BUILD_PATH}"
/bin/rm -Rf "${BUILD_PATH}"
/usr/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}"
/usr/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
else
warning "${IMAGE} does not exists"
fi
@ -771,12 +805,12 @@ if [ 0 -ne $(id -u) ]; then
exit ${ERR_NOT_ROOT}
fi
SOURCE_PATH="$(/bin/dirname "$(readlink -f "${0}")")"
SOURCE_PATH="$(/usr/bin/dirname "$(readlink -f "${0}")")"
INSTALL_PATH="$(pwd)/build"
# FILES_PATH="${SOURCE_PATH}/files"
PLATFORMS_PATH="${SOURCE_PATH}/platforms"
CMDNAME=$(/bin/basename "${0}")
CMDNAME=$(/usr/bin/basename "${0}")
if [ ${#} == 0 ]; then
@ -786,7 +820,7 @@ fi
# 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
eval set -- "${TEMP}"
@ -826,6 +860,18 @@ while true; do
fi
shift
;;
--prepare-chroot)
if [ -z ${OPT} ]; then
OPT="preparechroot"
fi
shift
;;
--jump-chroot)
if [ -z ${OPT} ]; then
OPT="jumpchroot"
fi
shift
;;
--add-urpmimedia)
if [ -z ${OPT} ]; then
OPT="addurpmimedia"
@ -962,6 +1008,7 @@ info "Build path: ${BUILD_PATH}"
info "Commande : ${CMDNAME}"
info "Firmware path : ${FIRMWARE_PATH}"
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
@ -972,7 +1019,7 @@ fi
if [ "${OPT}" != "clean" ]; then
info "cd ${INSTALL_PATH}"
if ! [ -e "${INSTALL_PATH}" ]; then
/bin/mkdir -p "${INSTALL_PATH}"
/usr/bin/mkdir -p "${INSTALL_PATH}"
if [ -z ${?} ]; then
error "line ${LINENO} can't make directory ${INSTALL_PATH} , exiting"
exit ${ERR_1}
@ -1007,19 +1054,16 @@ case ${OPT} in
fi
createImageWrap #Create the empty .img
createchroot #Check qemu and activate it
genusemirroroptions #Generate mirror options, if needed
installbasesystem #Generate the rootfs, rootfiles, ...
enableextrarepos
# addurpmimedia
if [ ${INSTALL_METHOD} = "urpmi" ]; then
addurpmimedia
else
genusemirroroptions #Generate mirror options, if needed
enableextrarepos
fi
installbasesystem #Generate the rootfs, rootfiles, ...
mkfstab
preparechroot
jumpchroot
#Check before is useless (with $MIRROR
info "Use mirrorlist to light one server."
MIRROR=
genusemirroroptions
enableextrarepos
# addurpmimedia
mountPartitions
copyingsystem
unmountingPartitions
@ -1028,6 +1072,12 @@ case ${OPT} in
"createchroot")
createchroot
;;
"preparechroot")
preparechroot
;;
"jumpchroot")
jumpchroot
;;
"chroot")
jumpchroot
;;