Compare commits
1 Commits
master
...
white-geck
Author | SHA1 | Date | |
---|---|---|---|
|
c3d2741ad8 |
360
flash-it.sh
360
flash-it.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION="0.3.3"
|
VERSION="0.3.3"
|
||||||
BRANCH=master
|
BRANCH=master
|
||||||
|
@ -28,225 +28,202 @@ MOUNT_BOOT=./boot
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
||||||
unset POSITIONAL
|
POSITIONAL=()
|
||||||
while [ "$#" -gt 0 ]; do
|
while [[ $# -gt 0 ]]
|
||||||
case "$1" in
|
do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
-b|--branch)
|
-b|--branch)
|
||||||
BRANCH="$2"
|
BRANCH="$2"
|
||||||
shift 2
|
shift
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
printf '%s\n' "Sailfish OS flashing script for Pine64 devices
|
echo "Sailfish OS flashing script for Pine64 devices"
|
||||||
This script will download the latest Sailfish OS image for the Pine
|
echo ""
|
||||||
Phone, Pine Phone dev kit, or Pine Tab. It requires that you have a
|
printf '%s\n' \
|
||||||
micro SD card inserted into the computer.
|
"This script will download the latest Sailfish OS image for the Pine" \
|
||||||
|
"Phone, Pine Phone dev kit, or Pine Tab. It requires that you have a" \
|
||||||
|
"micro SD card inserted into the computer." \
|
||||||
|
"" \
|
||||||
|
"usage: flash-it.sh [-b BRANCH]" \
|
||||||
|
"" \
|
||||||
|
"Options:" \
|
||||||
|
"" \
|
||||||
|
" -c, --custom Install from custom dir. Just put you rootfs.tar.bz2" \
|
||||||
|
" and u-boot-sunxi-with-spl.bin into dir and system will "\
|
||||||
|
" istalled from it" \
|
||||||
|
" -b, --branch BRANCH Download images from a specific Git branch." \
|
||||||
|
" -h, --help Print this help and exit." \
|
||||||
|
"" \
|
||||||
|
"This command requires: parted, sudo, wget, tar, unzip, lsblk," \
|
||||||
|
"mkfs.ext4." \
|
||||||
|
""\
|
||||||
|
"Some distros do not have parted on the PATH. If necessary, add" \
|
||||||
|
"parted to the PATH before running the script."
|
||||||
|
|
||||||
usage: flash-it.sh [-b BRANCH]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
|
|
||||||
-c, --custom Install from custom dir. Just put you rootfs.tar.bz2
|
|
||||||
and u-boot-sunxi-with-spl.bin into dir and system will
|
|
||||||
istalled from it
|
|
||||||
-b, --branch BRANCH Download images from a specific Git branch.
|
|
||||||
-h, --help Print this help and exit.
|
|
||||||
|
|
||||||
This command requires: parted; sudo, doas or su; wget or curl; tar, unzip, lsblk,
|
|
||||||
and mkfs.ext4.
|
|
||||||
|
|
||||||
Some distros do not have parted on the PATH. If necessary, add
|
|
||||||
parted to the PATH before running the script."
|
|
||||||
exit 0
|
exit 0
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-c|--custom)
|
-c|--custom)
|
||||||
CUSTOM="$2"
|
CUSTOM="$2"
|
||||||
shift 2
|
shift
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*) # unknown argument
|
*) # unknown argument
|
||||||
POSITIONAL="$POSITIONAL:$1" # save it in a list for later
|
POSITIONAL+=("$1") # save it in an array for later
|
||||||
shift # past argument
|
shift # past argument
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
# Retrieve saved arguments
|
set -- "${POSITIONAL[@]}" # restore positional parameters
|
||||||
IFS=: set -- ${POSITIONAL#:}
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|
||||||
# Run as root
|
|
||||||
as_root() {
|
|
||||||
command -V sudo >/dev/null 2>&1 && {
|
|
||||||
sudo "$@"
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
command -V doas >/dev/null 2>&1 && {
|
|
||||||
doas "$@"
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
command -V su >/dev/null 2>&1 && {
|
|
||||||
su -c "$*"
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print message to stderr and exit
|
|
||||||
die() {
|
|
||||||
printf '%s\n' "$*" >&2
|
|
||||||
exit "${status:-2}"
|
|
||||||
}
|
|
||||||
# Error out if the given command is not found on the PATH.
|
# Error out if the given command is not found on the PATH.
|
||||||
check_dependency() {
|
function check_dependency {
|
||||||
command -V "$1" >/dev/null 2>&1 ||
|
dependency=$1
|
||||||
status=1 die "$1 not found. Please make sure it is installed and in your PATH."
|
command -v $dependency >/dev/null 2>&1 || {
|
||||||
|
echo >&2 "${dependency} not found. Please make sure it is installed and on your PATH."; exit 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if one or more of depends are present
|
# Add sbin to the PATH to check for commands available to sudo
|
||||||
check_alternative_dependencies() {
|
function check_sudo_dependency {
|
||||||
IFS=', ' all="$*"
|
dependency=$1
|
||||||
unset found
|
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
||||||
while [ "$1" ]; do
|
check_dependency $dependency
|
||||||
command -V "$1" >/dev/null 2>&1 && {
|
|
||||||
found=y
|
|
||||||
break
|
|
||||||
}
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
[ "$found" ] || die "None of '$all found'. Please make sure one of them is installed and in your PATH."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine if wget supports the --show-progress option (introduced in
|
# Determine if wget supports the --show-progress option (introduced in
|
||||||
# 1.16). If so, make use of that instead of spewing out redirects and
|
# 1.16). If so, make use of that instead of spewing out redirects and
|
||||||
# loads of info into the terminal.
|
# loads of info into the terminal.
|
||||||
set_wget_cmd() {
|
function wget_cmd {
|
||||||
if command -V wget >/dev/null 2>&1; then
|
wget --show-progress > /dev/null 2>&1
|
||||||
|
status=$?
|
||||||
|
|
||||||
if wget --help 2>&1 | grep -q 'show-progress'; then
|
# Exit code 2 means command parsing error (i.e. option does not
|
||||||
WGET="wget -q --show-progress -O"
|
# exist).
|
||||||
|
if [ "$status" == "2" ]; then
|
||||||
|
echo "wget -O"
|
||||||
else
|
else
|
||||||
WGET="wget -O"
|
echo "wget -q --show-progress -O"
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
WGET="curl -Lo"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add sbin to the PATH to make sure all commands are found
|
|
||||||
export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
check_alternative_dependencies sudo doas su
|
check_dependency "sudo"
|
||||||
check_alternative_dependencies wget curl
|
check_dependency "wget"
|
||||||
check_dependency tar
|
check_dependency "tar"
|
||||||
check_dependency unzip
|
check_dependency "unzip"
|
||||||
check_dependency lsblk
|
check_dependency "lsblk"
|
||||||
check_dependency parted
|
check_sudo_dependency "parted"
|
||||||
check_dependency mkfs.ext4
|
check_sudo_dependency "mkfs.ext4"
|
||||||
check_dependency losetup
|
check_sudo_dependency "losetup"
|
||||||
|
|
||||||
# If use custom dir check it
|
# If use custom dir check it
|
||||||
if [ "$CUSTOM" ]; then
|
if [ "$CUSTOM" != "" ]; then
|
||||||
if [ ! -d "$CUSTOM" ]; then
|
if ! [ -d "$CUSTOM" ]; then
|
||||||
die "[1m[97m!!! Directory $CUSTOM not exist !!![0m"
|
echo -e "\e[1m\e[97m!!! Directory ${CUSTOM} not exist !!!\e[0m"
|
||||||
|
exit 2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$CUSTOM/rootfs.tar.bz2" ]; then
|
if ! [ -f "$CUSTOM/rootfs.tar.bz2" ]; then
|
||||||
die "[1m[97m!!! rootfs $CUSTOM/rootfs.tar.bz2 not found !!![0m"
|
echo -e "\e[1m\e[97m!!! rootfs ${CUSTOM}/rootfs.tar.bz2 not found !!!\e[0m"
|
||||||
|
exit 2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$CUSTOM/u-boot-sunxi-with-spl.bin" ]; then
|
if ! [ -f "$CUSTOM/u-boot-sunxi-with-spl.bin" ]; then
|
||||||
die "[1m[97m!!! uboot image $CUSTOM/u-boot-sunxi-with-spl.bin not found !!![0m"
|
echo -e "\e[1m\e[97m!!! uboot image ${CUSTOM}/u-boot-sunxi-with-spl.bin not found !!!\e[0m"
|
||||||
|
exit 2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -f "$CUSTOM/boot.scr" ]; then
|
if ! [ -f "$CUSTOM/boot.scr" ]; then
|
||||||
die "[1m[97m!!! uboot config $CUSTOM/boot.scr not found !!![0m"
|
echo -e "\e[1m\e[97m!!! uboot config ${CUSTOM}/boot.scr not found !!!\e[0m"
|
||||||
|
exit 2;
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Different branch for some reason?
|
# Different branch for some reason?
|
||||||
if [ "$BRANCH" != master ]; then
|
if [ "${BRANCH}" != "master" ]; then
|
||||||
printf '%s\n' "[1m[97m!!! Will flash image from $BRANCH branch !!![0m"
|
echo -e "\e[1m\e[97m!!! Will flash image from ${BRANCH} branch !!!\e[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
printf '%s\n' "[1m[91mSailfish OS Pine64 device flasher V$VERSION[0m
|
echo -e "\e[1m\e[91mSailfish OS Pine64 device flasher V$VERSION\e[0m"
|
||||||
======================================
|
echo "======================================"
|
||||||
"
|
echo ""
|
||||||
|
|
||||||
# Image selection
|
# Image selection
|
||||||
printf '%s\n' "[1mWhich image do you want to flash?[0m"
|
echo -e "\e[1mWhich image do you want to flash?\e[0m"
|
||||||
|
select OPTION in "PinePhone 1.0 (Development) device" "PinePhone 1.1 (Brave Heart) device" "PineTab device" "PineTab Dev device" "Dont Be Evil devkit"; do
|
||||||
: $(( i = 0 ))
|
case $OPTION in
|
||||||
for opt in "PinePhone 1.0 (Development) device" "PinePhone 1.1 (Brave Heart) or 1.2 (Community Editions) device" "PineTab device" "PineTab Dev device" "Dont Be Evil devkit"; do
|
"PinePhone 1.0 (Development) device" ) ROOTFS_JOB=$ROOTFS_PINEPHONE_1_0_JOB; ROOTFS_DIR=$ROOTFS_PINEPHONE_1_0_DIR; UBOOT_DEV_DIR=$UBOOT_PINEPHONE_1_0_DIR; break;;
|
||||||
: $(( i += 1 ))
|
"PinePhone 1.1 (Brave Heart) device" ) ROOTFS_JOB=$ROOTFS_PINEPHONE_1_1_JOB; ROOTFS_DIR=$ROOTFS_PINEPHONE_1_1_DIR; UBOOT_DEV_DIR=$UBOOT_PINEPHONE_1_1_DIR; break;;
|
||||||
printf '%s\n' "$i) $opt"
|
"PineTab device" ) ROOTFS_JOB=$ROOTFS_PINETAB_JOB; ROOTFS_DIR=$ROOTFS_PINETAB_DIR; UBOOT_DEV_DIR=$UBOOT_PINETAB_DIR; break;;
|
||||||
done
|
"PineTab Dev device" ) ROOTFS_JOB=$ROOTFS_PINETABDEV_JOB; ROOTFS_DIR=$ROOTFS_PINETABDEV_DIR; UBOOT_DEV_DIR=$UBOOT_PINETABDEV_DIR; break;;
|
||||||
printf '%s' "#? "
|
"Dont Be Evil devkit" ) ROOTFS_JOB=$ROOTFS_DEVKIT_JOB; ROOTFS_DIR=$ROOTFS_DEVKIT_DIR; UBOOT_DEV_DIR=$UBOOT_DEVKIT_DIR; break;;
|
||||||
read -r OPTION
|
|
||||||
|
|
||||||
case "$OPTION" in
|
|
||||||
1) ROOTFS_JOB=$ROOTFS_PINEPHONE_1_0_JOB; ROOTFS_DIR=$ROOTFS_PINEPHONE_1_0_DIR; UBOOT_DEV_DIR=$UBOOT_PINEPHONE_1_0_DIR;;
|
|
||||||
2) ROOTFS_JOB=$ROOTFS_PINEPHONE_1_1_JOB; ROOTFS_DIR=$ROOTFS_PINEPHONE_1_1_DIR; UBOOT_DEV_DIR=$UBOOT_PINEPHONE_1_1_DIR;;
|
|
||||||
3) ROOTFS_JOB=$ROOTFS_PINETAB_JOB; ROOTFS_DIR=$ROOTFS_PINETAB_DIR; UBOOT_DEV_DIR=$UBOOT_PINETAB_DIR;;
|
|
||||||
4) ROOTFS_JOB=$ROOTFS_PINETABDEV_JOB; ROOTFS_DIR=$ROOTFS_PINETABDEV_DIR; UBOOT_DEV_DIR=$UBOOT_PINETABDEV_DIR;;
|
|
||||||
5) ROOTFS_JOB=$ROOTFS_DEVKIT_JOB; ROOTFS_DIR=$ROOTFS_DEVKIT_DIR; UBOOT_DEV_DIR=$UBOOT_DEVKIT_DIR;;
|
|
||||||
*) die "Invalid selection";;
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# Downloading images
|
# Downloading images
|
||||||
printf '%s\n' "[1mDownloading images...[0m"
|
echo -e "\e[1mDownloading images...\e[0m"
|
||||||
set_wget_cmd
|
WGET=$(wget_cmd)
|
||||||
UBOOT_DOWNLOAD="https://gitlab.com/sailfishos-porters-ci/dont_be_evil-ci/-/jobs/artifacts/$BRANCH/download?job=$UBOOT_JOB"
|
UBOOT_DOWNLOAD="https://gitlab.com/sailfishos-porters-ci/dont_be_evil-ci/-/jobs/artifacts/$BRANCH/download?job=$UBOOT_JOB"
|
||||||
$WGET "$UBOOT_JOB.zip" "$UBOOT_DOWNLOAD" || {
|
$WGET "${UBOOT_JOB}.zip" "${UBOOT_DOWNLOAD}" || {
|
||||||
die "UBoot image download failed. Aborting."
|
echo >&2 "UBoot image download failed. Aborting."
|
||||||
}
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
UBOOT2_JOB=u-boot-sunxi-with-spl-pinephone.bin
|
UBOOT_DOWNLOAD2="https://gitlab.com/pine64-org/crust-meta/-/jobs/artifacts/master/raw/u-boot-sunxi-with-spl-pinephone.bin?job=build"
|
||||||
UBOOT_DOWNLOAD2="https://gitlab.com/pine64-org/crust-meta/-/jobs/artifacts/master/raw/u-boot-sunxi-with-spl-pinephone.bin?job=build"
|
$WGET "u-boot-sunxi-with-spl-pinephone.bin" "${UBOOT_DOWNLOAD2}" || {
|
||||||
$WGET "$UBOOT2_JOB" "$UBOOT_DOWNLOAD2" || {
|
echo >&2 "UBoot image download failed. Aborting."
|
||||||
die "UBoot image download failed. Aborting."
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
ROOTFS_DOWNLOAD="https://gitlab.com/sailfishos-porters-ci/dont_be_evil-ci/-/jobs/artifacts/$BRANCH/download?job=$ROOTFS_JOB"
|
|
||||||
$WGET "$ROOTFS_JOB.zip" "$ROOTFS_DOWNLOAD" || {
|
ROOTFS_DOWNLOAD="https://gitlab.com/sailfishos-porters-ci/dont_be_evil-ci/-/jobs/artifacts/$BRANCH/download?job=$ROOTFS_JOB"
|
||||||
die "Root filesystem image download failed. Aborting."
|
$WGET "${ROOTFS_JOB}.zip" "${ROOTFS_DOWNLOAD}" || {
|
||||||
}
|
echo >&2 "Root filesystem image download failed. Aborting."
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Select flash target
|
# Select flash target
|
||||||
printf '%s\n' "[1mWhich SD card do you want to flash?[0m"
|
echo -e "\e[1mWhich SD card do you want to flash?\e[0m"
|
||||||
lsblk
|
lsblk
|
||||||
printf '%s\n%s\n' "raw" "Device node (/dev/sdX): "
|
echo "raw"
|
||||||
read -r DEVICE_NODE
|
read -p "Device node (/dev/sdX): " DEVICE_NODE
|
||||||
printf '%s\n' "Flashing image to: $DEVICE_NODE
|
echo "Flashing image to: $DEVICE_NODE"
|
||||||
WARNING: All data will be erased! You have been warned!
|
echo "WARNING: All data will be erased! You have been warned!"
|
||||||
Some commands require root permissions, you might be asked to enter your password."
|
echo "Some commands require root permissions, you might be asked to enter your sudo password."
|
||||||
|
|
||||||
#create loop file for raw.img
|
#create loop file for raw.img
|
||||||
if [ "$DEVICE_NODE" = raw ]; then
|
if [ $DEVICE_NODE == "raw" ]; then
|
||||||
as_root dd if=/dev/zero of=sdcard.img bs=1 count=0 seek=4G
|
sudo dd if=/dev/zero of=sdcard.img bs=1 count=0 seek=4G
|
||||||
DEVICE_NODE=./sdcard.img
|
DEVICE_NODE="./sdcard.img"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Creating EXT4 file system
|
# Creating EXT4 file system
|
||||||
printf '%s\n' "[1mCreating EXT4 file system...[0m"
|
echo -e "\e[1mCreating EXT4 file system...\e[0m"
|
||||||
for PARTITION in "$DEVICE_NODE"*; do
|
for PARTITION in $(ls ${DEVICE_NODE}*)
|
||||||
|
do
|
||||||
echo "Unmounting $PARTITION"
|
echo "Unmounting $PARTITION"
|
||||||
as_root umount "$PARTITION"
|
sudo umount $PARTITION
|
||||||
done
|
done
|
||||||
as_root parted "$DEVICE_NODE" mklabel msdos --script
|
sudo parted $DEVICE_NODE mklabel msdos --script
|
||||||
as_root parted "$DEVICE_NODE" mkpart primary ext4 1MB 250MB --script
|
sudo parted $DEVICE_NODE mkpart primary ext4 1MB 250MB --script
|
||||||
as_root parted "$DEVICE_NODE" mkpart primary ext4 250MB 100% --script
|
sudo parted $DEVICE_NODE mkpart primary ext4 250MB 100% --script
|
||||||
|
|
||||||
if [ "$DEVICE_NODE" = ./sdcard.img ]; then
|
if [ $DEVICE_NODE == "./sdcard.img" ]; then
|
||||||
printf '%s\n' "Prepare loop file"
|
echo "Prepare loop file"
|
||||||
as_root losetup -D
|
sudo losetup -D
|
||||||
as_root losetup -Pf sdcard.img
|
sudo losetup -Pf sdcard.img
|
||||||
LOOP_NODE="$(echo /dev/loop?p1 | cut -c10-10)"
|
LOOP_NODE=`ls /dev/loop?p1 | cut -c10-10`
|
||||||
DEVICE_NODE="/dev/loop$LOOP_NODE"
|
DEVICE_NODE="/dev/loop$LOOP_NODE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# use p1, p2 extentions instead of 1, 2 when using sd drives
|
# use p1, p2 extentions instead of 1, 2 when using sd drives
|
||||||
if echo "$DEVICE_NODE" | grep -q -E 'mmcblk|loop'; then
|
if [ $(echo $DEVICE_NODE | grep mmcblk || echo $DEVICE_NODE | grep loop) ]; then
|
||||||
BOOTPART="${DEVICE_NODE}p1"
|
BOOTPART="${DEVICE_NODE}p1"
|
||||||
DATAPART="${DEVICE_NODE}p2"
|
DATAPART="${DEVICE_NODE}p2"
|
||||||
else
|
else
|
||||||
|
@ -254,63 +231,68 @@ else
|
||||||
DATAPART="${DEVICE_NODE}2"
|
DATAPART="${DEVICE_NODE}2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
as_root mkfs.ext4 -F -L boot "$BOOTPART" # 1st partition = boot
|
sudo mkfs.ext4 -F -L boot $BOOTPART # 1st partition = boot
|
||||||
as_root mkfs.ext4 -F -L data "$DATAPART" # 2nd partition = data
|
sudo mkfs.ext4 -F -L data $DATAPART # 2nd partition = data
|
||||||
|
|
||||||
# Flashing u-boot
|
# Flashing u-boot
|
||||||
printf '%s\n' "[1mFlashing U-boot...[0m"
|
echo -e "\e[1mFlashing U-boot...\e[0m"
|
||||||
if [ "$CUSTOM" ]; then
|
if [ "$CUSTOM" != "" ]; then
|
||||||
as_root dd if="$CUSTOM/u-boot-sunxi-with-spl.bin" of="$DEVICE_NODE" bs=8k seek=1
|
sudo dd if="${CUSTOM}/u-boot-sunxi-with-spl.bin" of="$DEVICE_NODE" bs=8k seek=1
|
||||||
else
|
else
|
||||||
unzip "$UBOOT_JOB.zip"
|
unzip "${UBOOT_JOB}.zip"
|
||||||
as_root dd if="./u-boot-sunxi-with-spl-pinephone.bin" of="$DEVICE_NODE" bs=8k seek=1
|
sudo dd if="./u-boot-sunxi-with-spl-pinephone.bin" of="$DEVICE_NODE" bs=8k seek=1
|
||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# Flashing rootFS
|
# Flashing rootFS
|
||||||
printf '%s\n' "[1mFlashing rootFS...[0m"
|
echo -e "\e[1mFlashing rootFS...\e[0m"
|
||||||
mkdir "$MOUNT_DATA"
|
mkdir "$MOUNT_DATA"
|
||||||
if [ "$CUSTOM" ]; then
|
if [ "$CUSTOM" != "" ]; then
|
||||||
TEMP="$CUSTOM/rootfs.tar.bz2"
|
TEMP="${CUSTOM}/rootfs.tar.bz2"
|
||||||
else
|
else
|
||||||
unzip "$ROOTFS_JOB.zip"
|
unzip "${ROOTFS_JOB}.zip"
|
||||||
TEMP="$(echo $ROOTFS_DIR/*/*.tar.bz2)"
|
TEMP=`ls $ROOTFS_DIR/*/*.tar.bz2`
|
||||||
echo "$TEMP"
|
echo "$TEMP"
|
||||||
fi
|
fi
|
||||||
as_root mount "$DATAPART" "$MOUNT_DATA" # Mount data partition
|
sudo mount $DATAPART "$MOUNT_DATA" # Mount data partition
|
||||||
as_root tar -xpf "$TEMP" -C "$MOUNT_DATA"
|
sudo tar -xpf "$TEMP" -C "$MOUNT_DATA"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# Copying kernel to boot partition
|
# Copying kernel to boot partition
|
||||||
printf '%s\n' "[1mCopying kernel to boot partition...[0m"
|
echo -e "\e[1mCopying kernel to boot partition...\e[0m"
|
||||||
mkdir "$MOUNT_BOOT"
|
mkdir "$MOUNT_BOOT"
|
||||||
as_root mount "$BOOTPART" "$MOUNT_BOOT" # Mount boot partition
|
sudo mount $BOOTPART "$MOUNT_BOOT" # Mount boot partition
|
||||||
printf '%s\n' "Boot partition mount: $MOUNT_BOOT"
|
echo "Boot partition mount: $MOUNT_BOOT"
|
||||||
as_root chmod a+rx "$MOUNT_DATA/boot"
|
sudo sh -c "cp -r $MOUNT_DATA/boot/* $MOUNT_BOOT"
|
||||||
as_root cp -r "$MOUNT_DATA/boot"/* "$MOUNT_BOOT"
|
|
||||||
|
|
||||||
echo "$MOUNT_BOOT"
|
echo `ls $MOUNT_BOOT`
|
||||||
if [ "$CUSTOM" ]; then
|
if [ "$CUSTOM" != "" ]; then
|
||||||
as_root cp "$CUSTOM/boot.scr" "$MOUNT_BOOT/boot.scr"
|
sudo sh -c "cp '${CUSTOM}/boot.scr' '$MOUNT_BOOT/boot.scr'"
|
||||||
else
|
else
|
||||||
as_root cp "./u-boot-bootloader/$UBOOT_DEV_DIR/boot.scr" "$MOUNT_BOOT/boot.scr"
|
sudo sh -c "cp './u-boot-bootloader/$UBOOT_DEV_DIR/boot.scr' '$MOUNT_BOOT/boot.scr'"
|
||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# Clean up files
|
# Clean up files
|
||||||
printf '%s\n' "[1mCleaning up![0m"
|
echo -e "\e[1mCleaning up!\e[0m"
|
||||||
for PARTITION in "$DEVICE_NODE"*; do
|
for PARTITION in $(ls ${DEVICE_NODE}*)
|
||||||
|
do
|
||||||
echo "Unmounting $PARTITION"
|
echo "Unmounting $PARTITION"
|
||||||
as_root umount "$PARTITION"
|
sudo umount $PARTITION
|
||||||
done
|
done
|
||||||
|
|
||||||
as_root losetup -D
|
sudo losetup -D
|
||||||
|
|
||||||
if [ -z "$CUSTOM" ]; then
|
if [ "$CUSTOM" == "" ]; then
|
||||||
rm -r "$UBOOT_JOB.zip" "$UBOOT2_JOB" "$UBOOT_DIR" "$ROOTFS_JOB.zip" "$ROOTFS_DIR"
|
rm "${UBOOT_JOB}.zip"
|
||||||
|
rm -r "$UBOOT_DIR"
|
||||||
|
rm "${ROOTFS_JOB}.zip"
|
||||||
|
rm -r "$ROOTFS_DIR"
|
||||||
|
rm "u-boot-sunxi-with-spl-pinephone.bin"
|
||||||
fi
|
fi
|
||||||
as_root rm -rf "$MOUNT_DATA" "$MOUNT_BOOT"
|
sudo rm -rf "$MOUNT_DATA"
|
||||||
|
sudo rm -rf "$MOUNT_BOOT"
|
||||||
|
|
||||||
# Done :)
|
# Done :)
|
||||||
printf '%s\n' "[1mFlashing $DEVICE_NODE OK![0m
|
echo -e "\e[1mFlashing $DEVICE_NODE OK!\e[0m"
|
||||||
You may now remove the SD card and insert it in your Pine64 device!"
|
echo "You may now remove the SD card and insert it in your Pine64 device!"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user