#!/bin/bash set -e show_usage() { cat </dev/null 2>&1 # find first avaliable free device DEVICE=$(losetup -f) TYPE="loop" # mount image as block device losetup $DEVICE $DEST/$IMAGE >/dev/null 2>&1 sync fi # create one partition starting at 2048 which is default echo "- Partitioning" parted --script -a optimal $DEVICE unit GB mklabel msdos parted --script -a optimal $DEVICE unit GB mkpart primary ext4 2048s 99% parted --script -a optimal $DEVICE unit GB align-check optimal 1 if [ "${TYPE}" == "loop" ] ; then DEVICEP1=${DEVICE}p1 else DEVICEP1=${DEVICE}1 fi echo "- Formating" # create filesystem mkfs.ext4 $DEVICEP1 >/dev/null 2>&1 # tune filesystem tune2fs -o journal_data_writeback $DEVICEP1 >/dev/null 2>&1 echo "- Mount filesystem" # mount image to already prepared mount point mount -t ext4 $DEVICEP1 $MNT echo "- Copy bootstrap files" # copy debootstrap cp -ar olinux/debootstrap/* $MNT/ sync echo "- Write sunxi-with-spl" dd if=olinux/sunxi/u-boot/u-boot-sunxi-with-spl.bin of=${DEVICE} bs=1024 seek=8 >/dev/null 2>&1 echo "- Umount" if [ "${TYPE}" == "loop" ] ; then umount $MNT losetup -d $DEVICE else umount $MNT fi