1
0

resolved a bug creating chroot

This commit is contained in:
Daniel Tartavel 2019-03-29 22:50:46 +01:00
parent 48b451c6b8
commit 1b9bb7ed50

View File

@ -169,34 +169,7 @@ function createchroot()
fi fi
fi fi
# 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
#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
} }
# adding Mageia repositories # adding Mageia repositories
@ -230,6 +203,25 @@ function updatemirror()
function installbasesystem() 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" title "installing basesystem"
/sbin/urpmi --urpmi-root "$BUILD_PATH" --ignorearch --no-verify-rpm --auto --split-level 200 --split-length 200 shadow-utils basesystem-minimal /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 if [ $? -ne 0 ];then
@ -251,12 +243,27 @@ function installbasesystem()
function preparechroot() function preparechroot()
{ {
title "Preparing chrooting in $BUILD_PATH" 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" info "making /etc/hostname"
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 $SOURCE_PATH/$CONFIG_PATH/second_stage_install.sh $BUILD_PATH/" echo "/bin/cp $SOURCE_PATH/$CONFIG_PATH/second_stage_install.sh $BUILD_PATH/"
cp "$SOURCE_PATH/$CONFIG_PATH/second_stage_install.sh" "$BUILD_PATH/second_stage_install.sh" cp --preserve=mode "$SOURCE_PATH/$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 $SOURCE_PATH/$CONFIG_PATH/second_stage_install.sh : exiting" error "line $LINENO error copying $SOURCE_PATH/$CONFIG_PATH/second_stage_install.sh : exiting"
exit 1 exit 1
@ -285,9 +292,9 @@ EOF" >>"$BUILD_PATH/second_stage_install.sh"
#copying kernel odroid not existing in mageia repos #copying kernel odroid not existing in mageia repos
info "copying kernel-odroid and u-boot rpms in $BUILD_PATH/root" info "copying kernel-odroid and u-boot rpms in $BUILD_PATH/root"
echo "/bin/cp $SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm $BUILD_PATH/root/" echo "/bin/cp $SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm $BUILD_PATH/root/"
/usr/bin/cp "$SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm" "$BUILD_PATH/root/" /usr/bin/cp --preserve=mode "$SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm" "$BUILD_PATH/root/"
echo "/bin/cp $SOURCE_PATH/$CONFIG_PATH/u-boot-20180507-3.mga7.armv7hl.rpm $BUILD_PATH/root/" echo "/bin/cp $SOURCE_PATH/$CONFIG_PATH/u-boot-20180507-3.mga7.armv7hl.rpm $BUILD_PATH/root/"
/usr/bin/cp "$SOURCE_PATH/$CONFIG_PATH/u-boot-20180507-3.mga7.armv7hl.rpm" "$BUILD_PATH/root/" /usr/bin/cp --preserve=mode "$SOURCE_PATH/$CONFIG_PATH/u-boot-20180507-3.mga7.armv7hl.rpm" "$BUILD_PATH/root/"
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
error "line $LINENO error copying $SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm : exiting" error "line $LINENO error copying $SOURCE_PATH/$CONFIG_PATH/kernel-odroid-4.14.y-1.armv7hl.rpm : exiting"
exit 1 exit 1
@ -318,7 +325,7 @@ function jumpchroot()
exit 1 exit 1
fi fi
info "Copying resolv.conf" info "Copying resolv.conf"
/bin/cp -a /etc/resolv.conf "$BUILD_PATH/etc/" /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 1 exit 1
@ -539,7 +546,7 @@ sed -i -e s/\<FDTDIR\>/$KERNEL_ID/g "$BUILD_PATH/boot/extlinux/extlinux.conf"
rpi) rpi)
info "copying 10-vchiq-permissions.rules" info "copying 10-vchiq-permissions.rules"
cp "$SOURCE_PATH/$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/" cp --preserve=mode "$SOURCE_PATH/$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
info "Making /etc/modules" info "Making /etc/modules"
echo "vchiq echo "vchiq
snd_bcm2835 snd_bcm2835
@ -551,37 +558,37 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
mkdir -p "$ARM_BOOT" mkdir -p "$ARM_BOOT"
fi fi
info "copying modprobe.conf" info "copying modprobe.conf"
/bin/cp -a "$SOURCE_PATH/$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/" /usr/bin/cp -v --preserve=mode "$SOURCE_PATH/$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
chown root:root "$BUILD_PATH/etc/modprobe.conf" chown root:root "$BUILD_PATH/etc/modprobe.conf"
info "copying firmware, overlays in rpi boot partition" info "copying firmware, overlays in rpi boot partition"
# cp -a "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb" # cp -v --preserve=mode "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
cp -av "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/" cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$ARM_BOOT/"
cp -av "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/" cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$ARM_BOOT/"
cp -av "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/" cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/bootcode.bin"* "$ARM_BOOT/"
cp -av "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/" cp -v --preserve=mode "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$ARM_BOOT/"
info "copying u-boot binary to $ARM_BOOT" info "copying u-boot binary to $ARM_BOOT"
case $TARGET_VERSION in case $TARGET_VERSION in
2) 2)
info "copying u-boot for $TARGET 2" info "copying u-boot for $TARGET 2"
cp "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$ARM_BOOT/kernel.img"
;; ;;
0) 0)
info "copying u-boot for $TARGET 0" info "copying u-boot for $TARGET 0"
cp "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$ARM_BOOT/kernel.img"
;; ;;
1) 1)
info "copying u-boot for $TARGET 1" info "copying u-boot for $TARGET 1"
cp "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$ARM_BOOT/kernel.img"
;; ;;
3_32) 3_32)
info "copying u-boot for $TARGET 3 32 bits" info "copying u-boot for $TARGET 3 32 bits"
cp "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
;; ;;
3+) 3+)
info "copying u-boot for $TARGET 3b+ 32 bits" info "copying u-boot for $TARGET 3b+ 32 bits"
cp "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$ARM_BOOT/kernel.img"
;; ;;
esac esac
@ -593,7 +600,7 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
/bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/" /bin/mkdir -p "$ROOT/usr/lib/firmware/brcm/"
fi fi
if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then if ! [ -f "$ROOT/usr/lib/firmware/brcm/brcmfmac434"* ];then
/bin/cp "$SOURCE_PATH/$CONFIG_PATH/brcmfmac434"* "$ROOT/usr/lib/firmware/brcm/" /bin/cp --preserve=mode "$SOURCE_PATH/$CONFIG_PATH/brcmfmac434"* "$ROOT/usr/lib/firmware/brcm/"
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
error "line $LINENO error copying wifi firmware in $ROOTP/usr/lib/firmware/brcm/ : exiting" error "line $LINENO error copying wifi firmware in $ROOTP/usr/lib/firmware/brcm/ : exiting"
exit 1 exit 1
@ -612,13 +619,13 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
case $TARGET_VERSION in case $TARGET_VERSION in
xu4) xu4)
info "copying u-boot for $TARGET $TARGET_VERSION" info "copying u-boot for $TARGET $TARGET_VERSION"
cp "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/" cp --preserve=mode "$BUILD_PATH/usr/lib/u-boot/$TARGET-$TARGET_VERSION/u-boot.bin" "$ARM_BOOT/"
;; ;;
esac esac
# temporary code waiting inclusion of xu4 in Mageia kernel and u-boot # temporary code waiting inclusion of xu4 in Mageia kernel and u-boot
info "Copying extlinux.conf on $ODROID_BOOT" info "Copying extlinux.conf on $ODROID_BOOT"
cp -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/" cp --preserve=mode -R "$BUILD_PATH/boot/extlinux" "$ODROID_BOOT/"
info "copying Mageia image to root partition" info "copying Mageia image to root partition"
/bin/rsync -rlptDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/" /bin/rsync -rlptDH --exclude "$ODROID_BOOT/" --exclude "qemu-arm-static*" "$BUILD_PATH/" "$ROOT/"
/bin/rsync -rlptDH "$ODROID_BOOT/" "$BOOT/" /bin/rsync -rlptDH "$ODROID_BOOT/" "$BOOT/"
@ -626,7 +633,7 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
esac esac
# info "copying tools in /usr/local/bin/" # info "copying tools in /usr/local/bin/"
# /bin/cp -a "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/" # /bin/cp -v --preserve=mode "$SOURCE_PATH/tools/" "$BUILD_PATH/usr/local/bin/"
# if ! [ $? -eq 0 ];then # if ! [ $? -eq 0 ];then
# error "line $LINENO error copying tools" # error "line $LINENO error copying tools"
# ERRORN=$((ERRORN++)) # ERRORN=$((ERRORN++))
@ -774,7 +781,7 @@ if [ -d "$SOURCE_PATH/$CONFIG_PATH" ];then
warning "Config file does not exists, do you want i copy template ? [Y|n] " warning "Config file does not exists, do you want i copy template ? [Y|n] "
read yn read yn
if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
/usr/bin/cp "$SOURCE_PATH/mageia4arm.cfg.template" "$SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg" /usr/bin/cp --preserve=mode "$SOURCE_PATH/mageia4arm.cfg.template" "$SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg"
warning "You need now to modify the config file ($SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg) and relaunch the script" warning "You need now to modify the config file ($SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
exit 2 exit 2
fi fi
@ -784,7 +791,7 @@ else
read yn read yn
if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then if [ -z $yn ] || [ $yn = "Y" ] || [ $yn = "y" ];then
/usr/bin/mkdir "$SOURCE_PATH/$CONFIG_PATH/" /usr/bin/mkdir "$SOURCE_PATH/$CONFIG_PATH/"
/usr/bin/cp "$SOURCE_PATH/config.template" "$SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg" /usr/bin/cp --preserve=mode "$SOURCE_PATH/config.template" "$SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg"
warning "You need now to modify the config file ($SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg) and relaunch the script" warning "You need now to modify the config file ($SOURCE_PATH/$CONFIG_PATH/mageia4arm.cfg) and relaunch the script"
exit 2 exit 2
fi fi