A short example of using subtree for stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 lines
1.9 KiB

#!/usr/bin/env bash
set -e
function print_help() {
echo "Usage: $0 -t [pitfttype]"
echo " -h Print this help"
echo " -t [type] Specify the type of PiTFT: '28r' (PID 1601) or '28c' (PID 1983) or '35r' or '22'"
echo
echo "You must specify a type of display."
exit 1
}
args=$(getopt -uo 'ht:i:' -- $*)
[ $? != 0 ] && print_help
set -- $args
for i
do
case "$i"
in
-h)
print_help
;;
-t)
pitfttype="$2"
echo "Type = ${2}"
shift
shift
;;
-i)
target_image="$2"
echo "Image = ${2}"
shift
shift
;;
esac
done
if [[ $EUID -ne 0 ]]; then
echo "$0 must be run as root. try: sudo $0"
exit 1
fi
if [ "${pitfttype}" != "28r" ] && [ "${pitfttype}" != "28c" ] && [ "${pitfttype}" != "35r" ] && [ "${pitfttype}" != "22" ]
then
echo "Type must be '28r' (2.8\" resistive, PID 1601) or '28c' (2.8\" capacitive, PID 1983) or '35r' (3.5\" Resistive) or '22' (2.2\" no touch)"
print_help
fi
target_mnt="/media/raspbian-target"
echo "Mounting $target_image on $target_mnt"
kpartx -av $target_image
mkdir -p $target_mnt
mount /dev/mapper/loop0p2 $target_mnt
mount /dev/mapper/loop0p1 $target_mnt/boot
echo "Adding apt.adafruit.com to sources.list"
curl -SLs https://apt.adafruit.com/add | chroot $target_mnt /bin/bash
echo "Installing adafruit-pitft-helper and dependencies"
chroot $target_mnt sudo apt-get install adafruit-pitft-helper
echo "Running adafruit-pitft-helper"
chroot $target_mnt sudo adafruit-pitft-helper -t $pitfttype
echo "Dropping you into Bash"
chroot $target_mnt sudo /bin/bash
echo "Unmounting $target_image"
umount $target_mnt/boot
umount $target_mnt
kpartx -d $target_image