#12 Cleanups
Merged a year ago by pbrobinson. Opened a year ago by kloczek.
kloczek/arm-image-installer master  into  master

file modified
+13 -13

@@ -19,14 +19,16 @@ 

  

  Usage: arm-image-installer <options>

  

-    --image=IMAGE    - xz compressed image file name

-    --target=TARGET  - target board

- 		      [Bananapi|beaglebone|Cubieboard|Cubieboard2|Cubietruck|Mele_A1000|Mele_A1000G|panda|trimslice|wandboard_dual|wandboard_quad|wandboard_solo]

-    --media=DEVICE   - media device file (/dev/[sdX|mmcblkX])

-    --selinux=ON/OFF - Turn SELinux off/on as needed

-    --norootpass     - Remove the root password

-     -y		    - Assumes yes, will not wait for confirmation

-    --version	    - Display version and exit

+ 	--addconsole    - Add system console to extlinux.conf

+ 	--addkey=       - /path/to/ssh-public-key

+ 	--image=IMAGE	- xz compressed image file name

+ 	--media=DEVICE	- media device file (/dev/[sdX|mmcblkX])

+ 	--norootpass	- Remove the root password

+ 	--resizefs	- Resize root filesystem to fill media device

+ 	--supported	- List of supported hardware

+ 	--target=TARGET	- target board

+ 	--version	- Display version and exit

+ 	-y		- Assumes yes, will not wait for confirmation

  

  Example: arm-image-installer --image=Fedora-Rawhide.xz --target=panda --media=/dev/mmcblk0 --selinux=OFF

  

@@ -38,10 +40,8 @@ 

  

  Usage: update-uboot <options>

  

-    --target=TARGET  - target board

-                       [Bananapi|beaglebone|Cubieboard|Cubieboard2|Cubietruck|Mele_A1000|Mele_A1000G|panda|trimslice|wandboard_dual|wandboard_quad|wandboard_solo]

-    --media=DEVICE   - media device file (/dev/[sdX|mmcblkX])

-    --tag=KOJI TAG   - koji tag (Default is f22. f21, f21-updates etc..)

+ 	--media=DEVICE	- media device file (/dev/[sdX|mmcblkX])

+ 	--tag=KOJI TAG	- koji tag to download build

+ 	--target=TARGET	- target board

  

  Example: update-uboot --target=panda --media=/dev/mmcblk0

- 

file modified
+24 -16

@@ -1,24 +1,32 @@ 

  AllWinner Devices:

- A10-OLinuXino-Lime A10s-OLinuXino-M A13-OLinuXino A13-OLinuXinoM 

-  A20-OLinuXino-Lime A20-OLinuXino-Lime2 A20-OLinuXino_MICRO 

-  A20-Olimex-SOM-EVB Ampe_A76 Auxtek-T003 Auxtek-T004 Bananapi Bananapro CHIP 

-  CSQ_CS908 Chuwi_V7_CW0825 Colombus Cubieboard Cubieboard2 Cubietruck 

-  Cubietruck_plus Hummingbird_A31 Hyundai_A7HD Itead_Ibox_A20 Lamobo_R1 

-  Linksprite_pcDuino Linksprite_pcDuino3 Linksprite_pcDuino3_Nano MK808C 

-  MSI_Primo73 MSI_Primo81 Marsboard_A10 Mele_A1000 Mele_A1000G_quad Mele_I7 

-  Mele_M3 Mele_M5 Mele_M9 Mini-X Orangepi Orangepi_mini Sinlinx_SinA31s 

-  UTOO_P66 Wexler_TAB7200 Wits_Pro_A20_DKT Yones_Toptech_BS1078_V2 ba10_tv_box 

-  colorfly_e708_q1 difrnce_dit4350 dserve_dsrv9703c i12-tvbox iNet_86VS 

-  icnova-a20-swac inet86dz jesurun_q5 mk802 mk802_a10s mk802ii orangepi_2 

-  orangepi_lite orangepi_pc orangepi_plus polaroid_mid2809pxe04 

-  pov_protab2_ips9 q8_a13_tablet q8_a23_tablet_800x480 q8_a33_tablet_1024x600 

-  q8_a33_tablet_800x480 r7-tv-dongle sunxi_Gemei_G9 

+ 

+ A10-OLinuXino-Lime A10s-OLinuXino-M A13-OLinuXino A13-OLinuXinoM

+  A20-Olimex-SOM-EVB A20-OLinuXino-Lime A20-OLinuXino-Lime2

+  A20-OLinuXino-Lime2-eMMC A20-OLinuXino_MICRO a64-olinuxino Ampe_A76

+  Auxtek-T003 Auxtek-T004 ba10_tv_box Bananapi Bananapi_M2_Ultra bananapi_m64

+  Bananapro CHIP Chuwi_V7_CW0825 Colombus colorfly_e708_q1 CSQ_CS908

+  Cubieboard Cubieboard2 Cubieboard4 Cubietruck Cubietruck_plus

+  difrnce_dit4350 dserve_dsrv9703c Hummingbird_A31 Hyundai_A7HD i12-tvbox

+  icnova-a20-swac inet86dz iNet_86VS Itead_Ibox_A20 jesurun_q5 Lamobo_R1

+  Linksprite_pcDuino Linksprite_pcDuino3 Linksprite_pcDuino3_Nano

+  Marsboard_A10 Mele_A1000 Mele_A1000G_quad Mele_I7 Mele_M3 Mele_M5 Mele_M9

+  Mini-X mk802 mk802_a10s mk802ii MK808C MSI_Primo73 MSI_Primo81 nanopi_a64

+  nanopi_m1 nanopi_m1_plus nanopi_neo nanopi_neo2 nanopi_neo_air Orangepi

+  orangepi_2 orangepi_lite Orangepi_mini orangepi_one orangepi_pc orangepi_pc2

+  orangepi_pc_plus orangepi_plus orangepi_plus2e orangepi_prime orangepi_win

+  orangepi_zero orangepi_zero_plus2 pine64_plus polaroid_mid2809pxe04

+  pov_protab2_ips9 q8_a13_tablet q8_a23_tablet_800x480 q8_a33_tablet_1024x600

+  q8_a33_tablet_800x480 r7-tv-dongle Sinlinx_SinA31s Sinovoip_BPI_M2_Plus

+  sopine_baseboard sunxi_Gemei_G9 UTOO_P66 Wexler_TAB7200 Wits_Pro_A20_DKT

+  Yones_Toptech_BS1078_V2

  

  MX6 Devices:

- cm_fx6 mx6cuboxi novena riotboard wandboard 

+ cm_fx6 liteboard marsboard mx6cuboxi novena riotboard udoo udoo_neo

+  usbarmory wandboard warp warp7

  

  OMAP Devices:

- am335x_boneblack am57xx_evm kc1 omap3_beagle omap4_panda omap5_uevm 

+ am335x_boneblack am335x_evm am57xx_evm chiliboard cl-som-am57x kc1

+  omap3_beagle omap4_panda omap5_uevm

  

  MVEBU Devices:

  clearfog 

file modified
-1

@@ -10,5 +10,4 @@ 

  - Duplicating a currently running system from a SD card to an onboard eMMC

  - Dynamic list of devices supported based on available u-boot firmwares and/or known means of writing out SoC options

  - Support writing images with hosts that support uEFI

- - Support for aarch64 devices

  - Support writing u-boot to NAND devices like C.H.I.P.

file modified
+225 -229

@@ -1,4 +1,4 @@ 

- #!/bin/bash

+ #!/bin/sh

  

  # Copyright (C) 2014-2015 Red Hat Inc.

  # SPDX-License-Identifier:  GPL-2.0+

@@ -12,20 +12,19 @@ 

      echo "

  Usage: $(basename ${0}) <options>

  

-    --image=IMAGE    - xz compressed image file name

-    --target=TARGET  - target board

-    --media=DEVICE   - media device file (/dev/[sdX|mmcblkX])

-    --norootpass     - Remove the root password

-    -y		    - Assumes yes, will not wait for confirmation

-    --version	    - Display version and exit

-    --resizefs	    - Resize root filesystem to fill media device

-    --addconsole     - Add system console to extlinux.conf

-    --addkey=        - /path/to/ssh-public-key

-    --supported	    - List of supported hardware

+ 	--addconsole    - Add system console to extlinux.conf

+ 	--addkey=       - /path/to/ssh-public-key

+ 	--image=IMAGE	- xz compressed image file name

+ 	--media=DEVICE	- media device file (/dev/[sdX|mmcblkX])

+ 	--norootpass	- Remove the root password

+ 	--resizefs	- Resize root filesystem to fill media device

+ 	--supported	- List of supported hardware

+ 	--target=TARGET	- target board

+ 	--version	- Display version and exit

+ 	-y		- Assumes yes, will not wait for confirmation

  

  Example: $(basename ${0}) --image=Fedora-Rawhide.xz --target=Bananapi --media=/dev/mmcblk0

  

- 

  "

  }

  

@@ -33,176 +32,175 @@ 

  # and valid targets.

  DIR=$(dirname $0)

  if [ -d "/usr/share/arm-image-installer/boards.d" ]; then

-         BOARDDIR="/usr/share/arm-image-installer/boards.d"

+ 	BOARDDIR="/usr/share/arm-image-installer/boards.d"

  	DOC_DIR="/usr/share/doc/fedora-arm-installer/"

  else

-         DIR=$(dirname $0)

-         BOARDDIR="${DIR}/boards.d"

+ 	DIR=$(dirname $0)

+ 	BOARDDIR="${DIR}/boards.d"

  	DOC_DIR="${DIR}/"

  fi

  

  # check the args

  while [ $# -gt 0 ]; do

-         case $1 in

-                 --debug)

-                         set -x

-                         ;;

-                 -h|--help)

-                         usage

-                         exit 0

-                         ;;

-                 --target*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 TARGET=$(echo $1 | sed 's/^--target=//')

-                         else

-                                 TARGET=$2

-                                 shift

-                         fi

-                         ;;

-                 --image*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 IMAGE=$(echo $1 | sed 's/^--image=//')

-                         else

-                                 IMAGE=$2

-                                 shift

-                         fi

-                         ;;

-                 --media*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 MEDIA=$(echo $1 | sed 's/^--media=//')

-                         else

-                                 MEDIA=$2

-                                 shift

-                         fi

-                         ;;

-                 --addkey*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 SSH_KEY=$(echo $1 | sed 's/^--addkey=//')

-                         else

-                                 SSH_KEY=$2

-                                 shift

-                         fi

-                         ;;

-                 --selinux*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 SELINUX=$(echo $1 | sed 's/^--selinux=//')

-                         else

-                                 SELINUX=$2

-                                 shift

-                         fi

-                         ;;

-                 --norootpass)

-                         NOROOTPASS=1

-                         ;;

-                 --resizefs)

-                         RESIZEFS=1

-                         ;;

-                 --addconsole)

-                         CONSOLE=1

+ 	case $1 in

+ 		--debug)

+ 			set -x

+ 			;;

+ 		-h|--help)

+ 			usage

+ 			exit 0

+ 			;;

+ 		--target*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				TARGET=$(echo $1 | sed 's/^--target=//')

+ 			else

+ 				TARGET=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--image*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				IMAGE=$(echo $1 | sed 's/^--image=//')

+ 			else

+ 				IMAGE=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--media*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				MEDIA=$(echo $1 | sed 's/^--media=//')

+ 			else

+ 				MEDIA=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--addkey*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				SSH_KEY=$(echo $1 | sed 's/^--addkey=//')

+ 			else

+ 				SSH_KEY=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--selinux*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				SELINUX=$(echo $1 | sed 's/^--selinux=//')

+ 			else

+ 				SELINUX=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--norootpass)

+ 			NOROOTPASS=1

+ 			;;

+ 		--resizefs)

+ 			RESIZEFS=1

+ 			;;

+ 		--addconsole)

+ 			CONSOLE=1

  			;;

  		--blacklistvc4)

  			FIX_RPI=1	

-                         ;;

+ 			;;

  		--supported)

-                         cat $DOC_DIR/SUPPORTED-BOARDS

-                         exit 0

-                         ;;

-                 --version)

-                         echo "$(basename ${0})-"$VERSION""

-                         exit 0

-                         ;;

-                 -y)

-                         NOASK=1

-                         ;;

-                 *)

-                         echo "$(basename ${0}): Error - ${1}"

-                         usage

-                         exit 1

-                         ;;

-         esac

-         shift

+ 			cat $DOC_DIR/SUPPORTED-BOARDS

+ 			exit 0

+ 			;;

+ 		--version)

+ 			echo "$(basename ${0})-"$VERSION""

+ 			exit 0

+ 			;;

+ 		-y)

+ 			NOASK=1

+ 			;;

+ 		*)

+ 			echo "$(basename ${0}): Error - ${1}"

+ 			usage

+ 			exit 1

+ 			;;

+ 	esac

+ 	shift

  done

  

  contains() {

-     string="$1"

-     substring="$2"

-     if test "${string#*$substring}" != "$string"

-     then

-         return 0    # $substring is in $string

-     else

-         return 1    # $substring is not in $string

-     fi

+ 	string="$1"

+ 	substring="$2"

+ 	if test "${string#*$substring}" != "$string"; then

+ 		return 0    # $substring is in $string

+ 	else

+ 		return 1    # $substring is not in $string

+ 	fi

  }

  

  # ensure sudo user

- if [ "$(whoami)" != "root" ] ; then

-         echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

-         exit 1

+ if [ "$(whoami)" != "root" ]; then

+ 	echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

+ 	exit 1

  fi

  

  # check to make sure populated

- if [ "$MEDIA" = "" ] ; then

-         usage

-         exit 1

+ if [ "$MEDIA" = "" ]; then

+ 	usage

+ 	exit 1

  fi

  

  # change cubietruck target to uppercase

  if [ "$TARGET" = "cubietruck" ]; then

-         TARGET="Cubietruck"

+ 	TARGET="Cubietruck"

  fi

  

  # check for boards

- if [ "$TARGET" != "" -a ! -e "${BOARDDIR}/${TARGET}" ] ; then

-         echo "Error: You must choose a supported board or none at all." 

-         usage

-         exit 1

+ if [ "$TARGET" != "" -a ! -e "${BOARDDIR}/${TARGET}" ]; then

+ 	echo "Error: You must choose a supported board or none at all." 

+ 	usage

+ 	exit 1

  fi

  

  # image exists

- if [ ! -f "$IMAGE" ] && [ "$IMAGE" != "" ] ; then

-         echo "Error: $IMAGE not found! Please choose an existing image."

-         exit 1

+ if [ ! -f "$IMAGE" ] && [ "$IMAGE" != "" ]; then

+ 	echo "Error: $IMAGE not found! Please choose an existing image."

+ 	exit 1

  fi

  

  # device exists

- if [ ! -e "$MEDIA" ] ; then

-         echo "Error: $MEDIA not found! Please choose an existing device."

-         exit 1

+ if [ ! -e "$MEDIA" ]; then

+ 	echo "Error: $MEDIA not found! Please choose an existing device."

+ 	exit 1

  fi

  

  clear

  # Last chance to back out

- echo " "

+ echo ""

  echo "====================================================="

  # Image if included

- if [ "$IMAGE" != "" ] ; then

-         echo "= Selected Image:                                 "

-         echo "= $IMAGE"

+ if [ "$IMAGE" != "" ]; then

+ 	echo "= Selected Image:                                 "

+ 	echo "= $IMAGE"

  fi

  echo "= Selected Media : $MEDIA"

  # target hardware platform

- if [ "$TARGET" != "" ] ; then 

-         echo "= U-Boot Target : $TARGET"

+ if [ "$TARGET" != "" ]; then 

+ 	echo "= U-Boot Target : $TARGET"

  fi

  # SE Linux On/Off

- if [ "$SELINUX" != "" ] ; then

-         echo "= SELINUX = $SELINUX"

+ if [ "$SELINUX" != "" ]; then

+ 	echo "= SELINUX = $SELINUX"

  fi

  # Remove root password

- if [ "$NOROOTPASS" != "" ] ; then

-         echo "= Root Password will be removed."

+ if [ "$NOROOTPASS" != "" ]; then

+ 	echo "= Root Password will be removed."

  fi

  # Resize root filesystem to fill media device

- if [ "$RESIZEFS" != "" ] ; then

-         echo "= Root partition will be resized"

+ if [ "$RESIZEFS" != "" ]; then

+ 	echo "= Root partition will be resized"

  fi

  # Console to be added

- if [ "$CONSOLE" != "" ] ; then

-         echo "= Console for $TARGET will be added."

+ if [ "$CONSOLE" != "" ]; then

+ 	echo "= Console for $TARGET will be added."

  fi

  # User ssh key

- if [ "$SSH_KEY" != "" ] ; then

-         echo "= SSH Public Key $SSH_KEY will be added."

+ if [ "$SSH_KEY" != "" ]; then

+ 	echo "= SSH Public Key $SSH_KEY will be added."

  fi

  echo "====================================================="

  echo " "

@@ -211,79 +209,77 @@ 

  echo "******** WARNING! ALL DATA WILL BE DESTROYED ********"

  echo "*****************************************************"

  echo "*****************************************************"

- if [ "$NOASK" != 1 ] ; then 

-         echo " "

-         echo " Type 'YES' to proceed, anything else to exit now "

-         echo " "

-         # wait for agreement

-         read -p "= Proceed? " PROCEED

-         if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ] ; then

-                 echo "User exit, no image written."

-                 exit 0

-         fi

+ if [ "$NOASK" != 1 ]; then 

+ 	echo " "

+ 	echo " Type 'YES' to proceed, anything else to exit now "

+ 	echo " "

+ 	# wait for agreement

+ 	read -p "= Proceed? " PROCEED

+ 	if [ "$(echo ${PROCEED} | tr [:lower:] [:upper:])" != "YES" ]; then

+ 		echo "User exit, no image written."

+ 		exit 0

+ 	fi

  fi

  # umount before starting

  umount $MEDIA* &> /dev/null

  

  # Write the disk image to media

- if [ "$IMAGE" != "" ] ; then

-         echo "= Writing: "

-         echo "= $IMAGE "

-         echo "= To: $MEDIA ...."

-         xzcat $IMAGE | dd of=$MEDIA bs=4M; sync; sleep 3

-         echo "= Writing image complete!"

-         # read the new partition table

-         partprobe "$MEDIA"

+ if [ "$IMAGE" != "" ]; then

+ 	echo "= Writing: "

+ 	echo "= $IMAGE "

+ 	echo "= To: $MEDIA ...."

+ 	xzcat $IMAGE | dd of=$MEDIA bs=4M; sync; sleep 3

+ 	echo "= Writing image complete!"

+ 	# read the new partition table

+ 	partprobe "$MEDIA"

  fi

  # check to see how many partitions on the image

  partprobe "$MEDIA"

  sleep 1

  case $MEDIA in

-         "/dev/mmcblk"*)

-                 if [ -e "$MEDIA"p4 ]; then

-                         export FIRMPART="${MEDIA}p1"

-                         BOOTPART="${MEDIA}p2"

-                         ROOTPART="${MEDIA}p4"

-                         PARTNUM=4

-                 else

-                         BOOTPART="${MEDIA}p1"

-                         ROOTPART="${MEDIA}p3"

-                         PARTNUM=3

-                 fi

-                 ;;

-         *)

-                 if [ -e "$MEDIA"4 ]; then

-                         export FIRMPART="${MEDIA}1"

-                         BOOTPART="${MEDIA}2"

-                         ROOTPART="${MEDIA}4"

-                         PARTNUM=4

-                 else

-                         BOOTPART="${MEDIA}1"

-                         ROOTPART="${MEDIA}3"

-                         PARTNUM=3

-                 fi

-                 ;;

+ 	"/dev/mmcblk"*)

+ 		if [ -e "$MEDIA"p4 ]; then

+ 			export FIRMPART="${MEDIA}p1"

+ 			BOOTPART="${MEDIA}p2"

+ 			ROOTPART="${MEDIA}p4"

+ 			PARTNUM=4

+ 		else

+ 			BOOTPART="${MEDIA}p1"

+ 			ROOTPART="${MEDIA}p3"

+ 			PARTNUM=3

+ 		fi

+ 		;;

+ 	*)

+ 		if [ -e "$MEDIA"4 ]; then

+ 			export FIRMPART="${MEDIA}1"

+ 			BOOTPART="${MEDIA}2"

+ 			ROOTPART="${MEDIA}4"

+ 			PARTNUM=4

+ 		else

+ 			BOOTPART="${MEDIA}1"

+ 			ROOTPART="${MEDIA}3"

+ 			PARTNUM=3

+ 		fi

+ 		;;

  esac

  

  # resize root filesystem before mounting

- if [ "$RESIZEFS" != "" ] ; then

-         echo "= Resizing $MEDIA ...."

-         sync

+ if [ "$RESIZEFS" != "" ]; then

+ 	echo "= Resizing $MEDIA ...."

+ 	sync

  	count=0

-         echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA"

-         while [ $? != '0' ]; do

-                 sleep 5

-                 echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA"

+ 	echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA"

+ 	while [ $? != '0' ]; do

+ 		sleep 5

+ 		echo ", +" | sfdisk -N "$PARTNUM" "$MEDIA"

  		count=$((count+1))

- 		if [ $count -gt 5 ]

- 			then

- 				echo "= Partition Resize Failed."

- 		        	continue

+ 		if [ $count -gt 5 ]; then

+ 			echo "= Partition Resize Failed."

+ 			continue

  		fi

- 			

-         done

-         

-         partprobe "$MEDIA"

+ 	done

+ 

+ 	partprobe "$MEDIA"

  

  	FS_TYPE=$(file -s "$ROOTPART" | awk '{print $3}')

  		if [ "$FS_TYPE" = "XFS" ]; then

@@ -294,7 +290,7 @@ 

  			umount "$ROOTPART"

  		else

  			fsck.ext4 -fy "$ROOTPART"

-         		resize2fs "$ROOTPART"

+ 			resize2fs "$ROOTPART"

  		fi

  fi

  

@@ -302,66 +298,66 @@ 

  mkdir /tmp/{boot,root} &> /dev/null

  mount "$BOOTPART" /tmp/boot &> /dev/null

  if [ $? -ne 0 ]; then

-         echo "Error: mount $BOOTPART /tmp/boot failed"

-         exit 1

+ 	echo "Error: mount $BOOTPART /tmp/boot failed"

+ 	exit 1

  fi

  

  mount "$ROOTPART" /tmp/root &> /dev/null

  if [ $? -ne 0 ]; then

-         echo "Error: mount $ROOTPART /tmp/root failed"

-         exit 1

+ 	echo "Error: mount $ROOTPART /tmp/root failed"

+ 	exit 1

  fi

  

  # turn off selinux

- if [ "$SELINUX" != "" ] ; then

-         if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ] ; then

-                 echo "= Turning SELinux off ..."

-                 sed -i 's/append/& enforcing=0/' /tmp/boot/extlinux/extlinux.conf

-                 # turn on selinux

-         elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ] ; then

-                 echo "= Turning SELinux on ..."

-                 sed -i 's/ enforcing=0//' /tmp/boot/extlinux/extlinux.conf

-         fi

+ if [ "$SELINUX" != "" ]; then

+ 	if [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "OFF" ]; then

+ 		echo "= Turning SELinux off ..."

+ 		sed -i 's/append/& enforcing=0/' /tmp/boot/extlinux/extlinux.conf

+ 		# turn on selinux

+ 	elif [ "$(echo ${SELINUX} | tr [:lower:] [:upper:])" = "ON" ]; then

+ 		echo "= Turning SELinux on ..."

+ 		sed -i 's/ enforcing=0//' /tmp/boot/extlinux/extlinux.conf

+ 	fi

  fi

  # Remove root password

- if [ "$NOROOTPASS" = "1" ] ; then

-         echo "= Removing the root password."

-         sed -i 's/root:x:/root::/' /tmp/root/etc/passwd

+ if [ "$NOROOTPASS" = "1" ]; then

+ 	echo "= Removing the root password."

+ 	sed -i 's/root:x:/root::/' /tmp/root/etc/passwd

  fi

  # Add ssh key to the image

- if [ "$SSH_KEY" != "" ] ; then

-         if [ -f $SSH_KEY ]; then

-                 echo "= Adding SSH key to authorized keys."

-                 mkdir /tmp/root/root/.ssh/ &> /dev/null

-                 cat $SSH_KEY >> /tmp/root/root/.ssh/authorized_keys

-                 chmod -R u=rwX,o=,g= /tmp/root/root/.ssh/

-         else

-                 echo "= SSH key $SSH_KEY : Not Found!"

-                 echo "= WARNING: No SSH Key Added."

-         fi

-         

+ if [ "$SSH_KEY" != "" ]; then

+ 	if [ -f $SSH_KEY ]; then

+ 		echo "= Adding SSH key to authorized keys."

+ 		mkdir /tmp/root/root/.ssh/ &> /dev/null

+ 		cat $SSH_KEY >> /tmp/root/root/.ssh/authorized_keys

+ 		chmod -R u=rwX,o=,g= /tmp/root/root/.ssh/

+ 	else

+ 		echo "= SSH key $SSH_KEY : Not Found!"

+ 		echo "= WARNING: No SSH Key Added."

+ 	fi

+ 	

  fi

  # determine uboot and write to disk 

  if [ "$TARGET" = "" ]; then

-         echo "= No U-boot will be written."

-         TARGET="Mystery Board"

+ 	echo "= No U-boot will be written."

+ 	TARGET="Mystery Board"

  else

-         PREFIX=/tmp/root

-         . "${BOARDDIR}/${TARGET}"

-         # Add console

-         if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ] ; then

-                 echo "= Adding console $SYSCON to extlinux.conf ..."

-                 sed -i "s|append|& console=$SYSCON|" /tmp/boot/extlinux/extlinux.conf

+ 	PREFIX=/tmp/root

+ 	. "${BOARDDIR}/${TARGET}"

+ 	# Add console

+ 	if [ "$CONSOLE" = "1" ] && [ "$SYSCON" != "" ]; then

+ 		echo "= Adding console $SYSCON to extlinux.conf ..."

+ 		sed -i "s|append|& console=$SYSCON|" /tmp/boot/extlinux/extlinux.conf

  		if [ "$TARGET" = "rpi2" ] || [ "$TARGET" = "rpi3" ]; then

-                         mkdir /tmp/fw &> /dev/null

-                         mount "$FIRMPART" /tmp/fw &> /dev/null

-                         sed -i "s|# enable_uart=1|enable_uart=1|" /tmp/fw/config.txt

-                 fi

-         fi

+ 			mkdir /tmp/fw &> /dev/null

+ 			mount "$FIRMPART" /tmp/fw &> /dev/null

+ 			sed -i "s|# enable_uart=1|enable_uart=1|" /tmp/fw/config.txt

+ 		fi

+ 	fi

  

  fi

  # fix up rpi2/3

- if [ "$FIX_RPI" != "" ] ; then

+ if [ "$FIX_RPI" != "" ]; then

  	echo "= Blacklisting the VC4 Driver for the Raspberry Pi 2/3"

  	echo blacklist vc4 > /tmp/root/etc/modprobe.d/blacklist-vc4.conf

  	sed -i 's/append/& rd.driver.blacklist=vc4/' /tmp/boot/extlinux/extlinux.conf

file modified
+33 -35

@@ -1,9 +1,9 @@ 

- #!/bin/bash

+ #!/bin/sh

  

  # ensure sudo user

- if [ "$(whoami)" != "root" ] ; then

-         echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

-         exit 1

+ if [ "$(whoami)" != "root" ]; then

+ 	echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

+ 	exit 1

  fi

  

  echo

@@ -11,58 +11,56 @@ 

  echo "= Raspberry Pi Firmware to the latest."

  UBOOT=$(rpm -q uboot-images-armv7)

  if [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then

-         echo

-         echo "$UBOOT"

-         read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT

-         if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ] ; thee

- n

-         dnf install -y uboot-images-armv7

-         UBOOT=$(rpm -q uboot-images-armv7)

-         fi

+ 	echo

+ 	echo "$UBOOT"

+ 	read -p "Would you like to install uboot-images-armv7 (yes or no)? " INSTALL_UBOOT

+ 	if [ "$(echo ${INSTALL_UBOOT} | tr [:lower:] [:upper:])" = "YES" ]; then

+ 		dnf install -y uboot-images-armv7

+ 		UBOOT=$(rpm -q uboot-images-armv7)

+ 	fi

  fi

  FW=$(rpm -q bcm283x-firmware)

  if [ "$FW" = "package bcm283x-firmware is not installed" ]; then

-         echo

-         echo "$FW"

-         read -p "Would you like to install bcm283x-firmware (yes or no)? " INSTALL_FW

-         if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ] ; then

-                 dnf install -y bcm283x-firmware

-                 FW=$(rpm -q bcm283x-firmware)

-         fi

+ 	echo

+ 	echo "$FW"

+ 	read -p "Would you like to install bcm283x-firmware (yes or no)? " INSTALL_FW

+ 	if [ "$(echo ${INSTALL_FW} | tr [:lower:] [:upper:])" = "YES" ]; then

+ 		dnf install -y bcm283x-firmware

+ 		FW=$(rpm -q bcm283x-firmware)

+ 	fi

  fi

  if [ "$FW" = "package bcm283x-firmware is not installed" ] && [ "$UBOOT" = "package uboot-images-armv7 is not installed" ]; then

-         echo

-         echo "Nothing to update, exiting."

-         exit 0

+ 	echo

+ 	echo "Nothing to update, exiting."

+ 	exit 0

  fi

  echo

  echo "= Uboot: $UBOOT"

  echo "= Firmware: $FW"

  if [ -d /boot/fw ]; then

-         	mount /dev/mmcblk0p1 /boot/fw

-         else

-         	mkdir /boot/fw

-         	mount /dev/mmcblk0p1 /boot/fw

+ 	mount /dev/mmcblk0p1 /boot/fw

+ else

+ 	mkdir /boot/fw

+ 	mount /dev/mmcblk0p1 /boot/fw

  fi

  # copy uboot

  if [ -f /usr/share/uboot/rpi_2/u-boot.bin ]; then

-         cp -rp /usr/share/uboot/rpi_2/u-boot.bin /boot/fw/rpi2-u-boot.bin

-         else

-         echo "Missing U-Boot for Raspberry Pi 2, no file copied."

+ 	cp -rp /usr/share/uboot/rpi_2/u-boot.bin /boot/fw/rpi2-u-boot.bin

+ 	else

+ 	echo "Missing U-Boot for Raspberry Pi 2, no file copied."

  fi

  if [ -f /usr/share/uboot/rpi_3_32b/u-boot.bin ]; then

-         cp -rp /usr/share/uboot/rpi_3_32b/u-boot.bin /boot/fw/rpi3-u-boot.bin

-         else

-         echo "Missing U-Boot for Raspberry Pi 3, no file copied."

+ 	cp -rp /usr/share/uboot/rpi_3_32b/u-boot.bin /boot/fw/rpi3-u-boot.bin

+ 	else

+ 	echo "Missing U-Boot for Raspberry Pi 3, no file copied."

  fi

  # copy fw

  if [ -d /usr/share/bcm283x-firmware ]; then

-         cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/fw/

+ 	cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/fw/

  else

-         echo "Missing bcm283x-firmware, no files copied."

+ 	echo "Missing bcm283x-firmware, no files copied."

  fi

  umount /boot/fw

  echo 

  echo "== Complete!"

  echo

- 

file modified
+81 -81

@@ -1,4 +1,4 @@ 

- #!/bin/bash

+ #!/bin/sh

  

  # Copyright (C) 2013 Red Hat Inc.

  # SPDX-License-Identifier:  GPL-2.0+

@@ -10,9 +10,9 @@ 

      echo "

  Usage: $(basename ${0}) <options>

  

-    --target=TARGET  - target board

-    --media=DEVICE   - media device file (/dev/[sdX|mmcblkX])

-    --tag=KOJI TAG   - koji tag to download build

+ 	--media=DEVICE	- media device file (/dev/[sdX|mmcblkX])

+ 	--tag=KOJI TAG	- koji tag to download build

+ 	--target=TARGET	- target board

  

  Example: $(basename ${0}) --target=panda --media=/dev/mmcblk0

  

@@ -22,100 +22,100 @@ 

  

  # check the args

  while [ $# -gt 0 ]; do

-         case $1 in

-                 --debug)

-                         set -x

-                         ;;

-                 -h|--help)

-                         usage

-                         ;;

-                 --target*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 TARGET=$(echo $1 | sed 's/^--target=//')

-                         else

-                                 TARGET=$2

-                                 shift

-                         fi

-                         ;;

-                 --media*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 MEDIA=$(echo $1 | sed 's/^--media=//')

-                         else

-                                 MEDIA=$2

-                                 shift

-                         fi

-                         ;;

-                 --tag*)

-                         if echo $1 | grep '=' >/dev/null ; then

-                                 KOJI_TAG=$(echo $1 | sed 's/^--tag=//')

-                         else

-                                 KOJI_TAG=$2

-                                 shift

-                         fi

-                         ;;

-                 *)

-                         echo "$(basename ${0}): Error - ${1}"

-                         usage

-                         exit 1

-                         ;;

-         esac

-         shift

+ 	case $1 in

+ 		--debug)

+ 			set -x

+ 			;;

+ 		-h|--help)

+ 			usage

+ 			;;

+ 		--target*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				TARGET=$(echo $1 | sed 's/^--target=//')

+ 			else

+ 				TARGET=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--media*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				MEDIA=$(echo $1 | sed 's/^--media=//')

+ 			else

+ 				MEDIA=$2

+ 				shift

+ 			fi

+ 			;;

+ 		--tag*)

+ 			if echo $1 | grep '=' >/dev/null ; then

+ 				KOJI_TAG=$(echo $1 | sed 's/^--tag=//')

+ 			else

+ 				KOJI_TAG=$2

+ 				shift

+ 			fi

+ 			;;

+ 		*)

+ 			echo "$(basename ${0}): Error - ${1}"

+ 			usage

+ 			exit 1

+ 			;;

+ 	esac

+ 	shift

  done

  

  if [ -d "/usr/share/arm-image-installer/boards.d" ]; then

-         BOARDDIR="/usr/share/arm-image-installer/boards.d"

+ 	BOARDDIR="/usr/share/arm-image-installer/boards.d"

  else

-         DIR=$(dirname $0)

-         BOARDDIR="${DIR}/boards.d"

+ 	DIR=$(dirname $0)

+ 	BOARDDIR="${DIR}/boards.d"

  fi

  # ensure sudo user

- if [ "$(whoami)" != "root" ] ; then

-         echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

-         exit 1

+ if [ "$(whoami)" != "root" ]; then

+ 	echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media."

+ 	exit 1

  fi

  

  # check if media exists

- if [[ ! -e $MEDIA ]] ; then

-         echo "Missing media"

-         usage

-         exit 1

+ if [[ ! -e $MEDIA ]]; then

+ 	echo "Missing media"

+ 	usage

+ 	exit 1

  fi

  

- if [[ $TARGET = '' ]] ; then

-         echo "Missing target"

-         usage

-         exit 1

+ if [[ $TARGET = '' ]]; then

+ 	echo "Missing target"

+ 	usage

+ 	exit 1

  fi

- if [[ $KOJI_TAG != '' ]] ; then

-         if [[ ! -f /usr/bin/koji ]]; then

-                 echo "Please install koji-utils for this option."

-                 exit 1

-         else

-                 PREFIX='/tmp/root/'

-                 rm -rf /tmp/root &> /dev/null

-                 mkdir $PREFIX

+ if [[ $KOJI_TAG != '' ]]; then

+ 	if [[ ! -f /usr/bin/koji ]]; then

+ 		echo "Please install koji-utils for this option."

+ 		exit 1

+ 	else

+ 		PREFIX='/tmp/root/'

+ 		rm -rf /tmp/root &> /dev/null

+ 		mkdir $PREFIX

  

-                 #get the latest uboot

-                 pushd $PREFIX &> /dev/null

-                 if [ $KOJI_TAG = f22 ]; then

-                         koji download-build --arch=armv7hl --latestfrom=$KOJI_TAG uboot-tools

-                 else

-                         koji download-build --arch=noarch --latestfrom=$KOJI_TAG uboot-tools

-                 fi

-                 # unpack uboot

-                 for rpm in uboot-images*.rpm

-                 do

-                         rpm2cpio "${rpm}" | cpio -idv &> /dev/null

-                 done

-                 popd &> /dev/null

-         fi

+ 		#get the latest uboot

+ 		pushd $PREFIX &> /dev/null

+ 		if [ $KOJI_TAG = f22 ]; then

+ 			koji download-build --arch=armv7hl --latestfrom=$KOJI_TAG uboot-tools

+ 		else

+ 			koji download-build --arch=noarch --latestfrom=$KOJI_TAG uboot-tools

+ 		fi

+ 		# unpack uboot

+ 		for rpm in uboot-images*.rpm

+ 		do

+ 			rpm2cpio "${rpm}" | cpio -idv &> /dev/null

+ 		done

+ 		popd &> /dev/null

+ 	fi

  fi

  # determine uboot and write to disk 

  if [ "$TARGET" = "" ]; then

-         echo "= No U-boot will be written."

-         TARGET="Mystery Board"

+ 	echo "= No U-boot will be written."

+ 	TARGET="Mystery Board"

  else

-         . "${DIR}/${BOARDDIR}/${TARGET}"

+ 	. "${DIR}/${BOARDDIR}/${TARGET}"

  fi

  

  echo "= Complete!"

  • use output of the list-targets.py to update list of supported boards.
  • change spaces to tabs.
  • fixed if []; then syntax and few other cleanups.
  • use everywhere the same if []; then syntax ('s/] ; then/]; then/)
  • add use more tabs in usage() and sort alphabetically options.
  • looks like aarch64 support is now done.
  • update usage output of the scripts.
    uses bash specyfic syntax.
  • changed from /bin/bash to /bin/sh as long as nothing in scripts

Pull-Request has been merged by pbrobinson

a year ago