Advertisement
smithwinston

u-boot-beaglebone-eabi

Apr 30th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. INSTALL_DIR=/usr/local/share/u-boot/beaglebone-eabi
  4. UBOOT_IMG=bb-uboot.img
  5. TITLE=`basename $0`
  6.  
  7. usage() {
  8.     echo "Usage: $TITLE [-v|<installdir>]"
  9.     echo " -v: Print u-boot version information"
  10.     exit 2
  11. }
  12.  
  13. show_version() {
  14.    VER=`strings $INSTALL_DIR/$UBOOT_IMG | grep -E "U-Boot [^(]+\([^)]+\)" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`
  15.    if [ -z '$VER' ]; then
  16.       echo "Unable to extract version from $INSTALL_DIR/$UBOOT_IMG ..."
  17.       exit 5
  18.    fi
  19.  
  20.    echo $VER
  21.    exit 0
  22. }
  23.  
  24. check_install() {
  25.    if [ ! -d $INSTALL_DIR ]; then
  26.       echo "You must first install sysutils/u-boot-beaglebone-eabi"
  27.       exit 3
  28.    fi
  29.  
  30.    if [ ! -f $INSTALL_DIR/$UBOOT_IMG ]; then
  31.       echo "Please build and install sysutils/u-boot-beaglebone-eabi"
  32.       exit 4
  33.    fi
  34. }
  35.  
  36. check_install
  37.  
  38. args=`getopt v $*`
  39. if [ $? -ne 0 ]; then
  40.     usage
  41. fi
  42. set -- $args
  43. while true; do
  44.     case "$1" in
  45.     -v)
  46.         show_version
  47.         shift
  48.         ;;
  49.         --)
  50.             shift; break
  51.             ;;
  52.         *)
  53.             usage
  54.     esac
  55. done
  56.  
  57. if [ -z "$1" ]; then
  58.    usage
  59. else
  60.    TARGET_DIR=`(cd "$1"; pwd)`
  61. fi
  62.  
  63. echo "Installing $TITLE to $TARGET_DIR"
  64.  
  65. for FN in MLO bb-uboot.img bb-uenv.txt; do
  66.     echo "    $FN ..."
  67.     cp $INSTALL_DIR/$FN $TARGET_DIR/$FN
  68. done
  69.  
  70. # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement