bootgen.sh 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. if [ "$#" -ne 1 ]; then
  3. echo "Usage: bootgen.sh *build dir*"
  4. exit 1
  5. fi
  6. BUILD=$1
  7. # Re-locator Path
  8. RELOCATOR=bootmgr/relocator
  9. # Build location
  10. BOOTMGR=${BUILD}
  11. # Check for re-locator binary
  12. if [ ! -f $RELOCATOR/relocator.bin ]; then
  13. echo "Error : Relocator Not found!"
  14. exit 1
  15. else
  16. echo "Relocator found..."
  17. fi
  18. # Check for boot manager binary
  19. if [ ! -f $BOOTMGR/bootmgr.bin ]; then
  20. echo "Error : Boot Manager Not found!"
  21. exit 1
  22. else
  23. echo "Boot Manager found..."
  24. fi
  25. # echo
  26. echo "Generating bootloader..."
  27. # Generate an all 0 bin file
  28. dd if=/dev/zero of=__tmp.bin ibs=1 count=256 conv=notrunc >/dev/null 2>&1
  29. # Generate a 0 padded version of the relocator
  30. dd if=$RELOCATOR/relocator.bin of=__tmp.bin ibs=1 conv=notrunc >/dev/null 2>&1
  31. # Concatenate the re-locator and the boot-manager
  32. cat __tmp.bin $BOOTMGR/bootmgr.bin > $BOOTMGR/bootloader.bin
  33. # Remove the tmp files
  34. rm -f __tmp.bin
  35. # Remove bootmgr.bin
  36. rm -f $BOOTMGR/bootmgr.bin