aboutsummaryrefslogtreecommitdiffstats
path: root/create_arm_img_urpmi.sh
diff options
context:
space:
mode:
authorDaniel Tartavel <contact@librepc.com>2018-12-13 23:18:14 +0100
committerDaniel Tartavel <contact@librepc.com>2018-12-13 23:18:14 +0100
commit47e85a6d3a727cbe86208e3ae5a69a24b6e818c2 (patch)
treef8458dda504c1819de0fc5659844e8bce9deff9e /create_arm_img_urpmi.sh
parent77065fa0c81d31aee081e67a2e7df30e614b8466 (diff)
downloadmageia4arm-47e85a6d3a727cbe86208e3ae5a69a24b6e818c2.tar
mageia4arm-47e85a6d3a727cbe86208e3ae5a69a24b6e818c2.tar.gz
mageia4arm-47e85a6d3a727cbe86208e3ae5a69a24b6e818c2.tar.bz2
mageia4arm-47e85a6d3a727cbe86208e3ae5a69a24b6e818c2.tar.xz
mageia4arm-47e85a6d3a727cbe86208e3ae5a69a24b6e818c2.zip
modifications for booting with mageia stock kernel
Diffstat (limited to 'create_arm_img_urpmi.sh')
-rwxr-xr-xcreate_arm_img_urpmi.sh132
1 files changed, 81 insertions, 51 deletions
diff --git a/create_arm_img_urpmi.sh b/create_arm_img_urpmi.sh
index 2e18568..836905e 100755
--- a/create_arm_img_urpmi.sh
+++ b/create_arm_img_urpmi.sh
@@ -68,7 +68,8 @@ function help()
echo "--chroot chroot to arm directory and launch packages installation"
echo "--create-image Create the image of Mageia $MAGEIA_VERSION"
echo "--build-path Path to the build directory of the image of Mageia $MAGEIA_VERSION"
-# echo "--target target system (for now rpi, xu3, xu4)"
+ echo "--target target system (for now rpi, odroid)"
+ echo "--target-version version of the taget (0, 1, 2, 3 for rpi, 3 or 4 for odroid)"
echo "--config Path to config files"
echo "--bootfs filesystem of boot partition (ext4 or vfat) default: etx4"
echo -e "\nFor image size, make sure it fit on physical support. (Default size is 7 Go)"
@@ -245,32 +246,9 @@ function installbasesystem()
fi
}
-function jumpchroot()
+function preparechroot()
{
title "Preparing chrooting in $BUILD_PATH"
- info "mounting dev, sys, proc directories in chroot"
- /bin/mount -B /dev "$BUILD_PATH/dev"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
- exit 1
- fi
- /bin/mount -B /sys "$BUILD_PATH/sys"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
- exit 1
- fi
- /bin/mount -B /proc "$BUILD_PATH/proc"
- if [ $? -ne 0 ];then
- error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
- exit 1
- fi
- info "Copying resolv.conf"
- /bin/cp -a /etc/resolv.conf "$BUILD_PATH/etc/"
- if [ $? -ne 0 ];then
- error "line $LINENO error copying $BUILD_PATH/etc : exiting"
- exit 1
- fi
-
info "making /etc/hostname"
echo "$HOSTNAME" > "$BUILD_PATH/etc/hostname"
@@ -300,7 +278,7 @@ EOF" >>"$BUILD_PATH/second_stage_install.sh"
case $TARGET in
- xu3|xu4)
+ ODROID)
#TEMPORARY CODE
#copying kernel odroid not existing in mageia repos
info "copying kernel-odroid rpm in $BUILD_PATH/root"
@@ -314,26 +292,55 @@ EOF" >>"$BUILD_PATH/second_stage_install.sh"
rpi)
;;
esac
-
+}
+
+function jumpchroot()
+{
title "chrooting to $BUILD_PATH"
- /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
+ info "mounting dev, sys, proc directories in chroot"
+ /bin/mount -B /dev "$BUILD_PATH/dev"
+ if [ $? -ne 0 ];then
+ error "line $LINENO error mounting $BUILD_PATH/dev : exiting"
+ exit 1
+ fi
+ /bin/mount -B /sys "$BUILD_PATH/sys"
+ if [ $? -ne 0 ];then
+ error "line $LINENO error mounting $BUILD_PATH/sys : exiting"
+ exit 1
+ fi
+ /bin/mount -B /proc "$BUILD_PATH/proc"
+ if [ $? -ne 0 ];then
+ error "line $LINENO error mounting $BUILD_PATH/proc : exiting"
+ exit 1
+ fi
+ info "Copying resolv.conf"
+ /bin/cp -a /etc/resolv.conf "$BUILD_PATH/etc/"
+ if [ $? -ne 0 ];then
+ error "line $LINENO error copying $BUILD_PATH/etc/resolv.conf : exiting"
+ exit 1
+ fi
+ if [ "$OPT" = "chroot" ];then
+ /sbin/chroot "$BUILD_PATH"
+ else
+ /sbin/chroot --userspec root:root "$BUILD_PATH" /bin/bash -v -c 'sh /second_stage_install.sh'
+ fi
RET=$?
if [ $RET -ne 0 ];then
error "line $LINENO Warning : chrooting to $BUILD_PATH retrurn an error $RET"
ERRORN=$((ERRORN++))
fi
info "unmounting dev, sys, proc"
- /bin/umount "$BUILD_PATH/dev"
+ /bin/umount -lf "$BUILD_PATH/dev"
if [ $? -ne 0 ];then
warning "line $LINENO Warning : error unmounting $BUILD_PATH/dev, continuing anyway"
ERRORN=$((ERRORN++))
fi
- /bin/umount "$BUILD_PATH/sys"
+ /bin/umount -lf "$BUILD_PATH/sys"
if [ $? -ne 0 ];then
warning "line $LINENO Warning : error unmounting $BUILD_PATH/sys, continuing anyway"
ERRORN=$((ERRORN++))
fi
- /bin/umount "$BUILD_PATH/proc"
+ /bin/umount -lf "$BUILD_PATH/proc"
if [ $? -ne 0 ];then
warning "line $LINENO Warning : error unmounting $BUILD_PATH/proc, continuing anyway"
ERRORN=$((ERRORN++))
@@ -505,16 +512,8 @@ UUID=$ROOT_UUID / ext4 defaults 0 0" > "$BUILD_PA
case $TARGET in
rpi)
-# info "copying raspberry firmware in /boot"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/" "$BOOT"
-#TODO copy to bootstrap /boot
- cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start*" "$BOOT"
- cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup*" "$BOOT"
- #cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/extra/uname_string" "$BOOT"
- #cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/extra/uname_string7" "$BOOT"
+
info "copying config.txt, boot.cmd and 10-vchiq-permissions.rules"
- cp "$SOURCE_PATH/$CONFIG_PATH/config.txt" "$BOOT"
- cp "$SOURCE_PATH/$CONFIG_PATH/boot.cmd" "$BOOT"
cp "$SOURCE_PATH/$CONFIG_PATH/10-vchiq-permissions.rules" "$BUILD_PATH/etc/udev/rules.d/"
# Making /etc/modules
echo "vchiq
@@ -526,11 +525,37 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
/bin/cp -a "$SOURCE_PATH/$CONFIG_PATH/modprobe.conf" "$BUILD_PATH/etc/"
chown root:root "$BUILD_PATH/etc/modprobe.conf"
- #info "making /boot/cmdline.txt"
- #echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait fsck.repair=1" > "$BOOT/cmdline.txt"
-# info "copying raspberry modules in /lib/modules"
-# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/modules/" "$BUILD_PATH/lib/modules/"
-# info "copying raspberry optionals files in opt"
+ info "making /boot/extlinux/extlinux.conf"
+ mkdir "$BUILD_PATH/boot/extlinux"
+ sed -e s/\<UUID\>/$BOOT_UUID/g $SOURCE_PATH/$CONFIG_PATH/extlinux.conf >"$BUILD_PATH/boot/extlinux/extlinux.conf"
+
+ info "copying firmware, overlays and dtb in /boot"
+ cp -a "$BUILD_PATH/usr/lib/linux-"* "$BOOT/dtb"
+ cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/start"* "$BUILD_PATH/boot/"
+ cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/fixup"* "$BUILD_PATH/boot/"
+ cp -a "$FIRMWARE_PATH/$FIRMWARE_DIR/boot/overlays" "$BUILD_PATH/boot/"
+
+ info "copying u-boot binary to /boot"
+ case $TARGET_VERSION in
+ 2)
+ info "copying u-boot for $TARGET 2"
+ cp "$BUILD_PATH/usr/lib/u-boot/rpi_2/u-boot.bin" "$BUILD_PATH/boot/kernel7"
+ ;;
+ 0)
+ info "copying u-boot for $TARGET 0"
+ cp "$BUILD_PATH/usr/lib/u-boot/rpi_0_w/u-boot.bin" "$BUILD_PATH/boot/kernel7"
+ ;;
+ 1)
+ info "copying u-boot for $TARGET 1"
+ cp "$BUILD_PATH/usr/lib/u-boot/rpi/u-boot.bin" "$BUILD_PATH/boot/kernel7"
+ ;;
+ 3_32)
+ info "copying u-boot for $TARGET 3 32 bits"
+ cp "$BUILD_PATH/usr/lib/u-boot/rpi_3_32b/u-boot.bin" "$BUILD_PATH/boot/kernel7"
+ ;;
+ esac
+
+ info "copying raspberry optionals files in opt"
# /bin/rsync -rlptDH "$FIRMWARE_PATH/$FIRMWARE_DIR/opt/" "$BUILD_PATH/opt/"
info "copying wifi firmware file missing in kernel-firmware-nonfree"
@@ -550,7 +575,7 @@ brcmfmac" >> "$BUILD_PATH"/etc/modules
fi
info "copying "
;;
- xu3 | xu4)
+ ODROID)
;;
esac
@@ -593,7 +618,7 @@ fi
# parsing commandline
-TEMP=$(getopt -o h,a --long all,help,clean,create-chroot,addmedia,create-image,,config:,target:,chroot,bootfs:,install-basesystem,update-mirror,build-path:,size: -n $CMDNAME -- "$@")
+TEMP=$(getopt -o h,a --long all,help,clean,create-chroot,addmedia,create-image,,config:,target:,target-version:,chroot,bootfs:,install-basesystem,update-mirror,build-path:,size: -n $CMDNAME -- "$@")
if [ $? -ne 0 ] ; then error "line $LINENO Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
@@ -659,8 +684,12 @@ do
fi
shift
;;
- --system)
- SYSTEM=$2
+ --target)
+ TARGET=$2
+ shift 2
+ ;;
+ --target-version)
+ TARGET_VERSION=$2
shift 2
;;
--config)
@@ -684,7 +713,7 @@ done
info "Option: "$OPT
-IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET.img"
+IMAGE="Mageia-${MAGEIA_VERSION}-$TARGET$TARGET_VERSION.img"
BOOT="/mnt/boot"
ROOT="/mnt/root"
BUILD_PATH="$INSTALL_PATH/build"
@@ -722,7 +751,7 @@ fi
# assign function for building image of TARGET ( rpi, xu3 or xu4 )
case $TARGET in
-xu3|xu4)
+odroid)
CREATEIMG="createxu3image"
;;
rpi)
@@ -788,6 +817,7 @@ case $OPT in
addmedia
updatemirror
installbasesystem
+ preparechroot
jumpchroot
$CREATEIMG
;;