#!/bin/bash if test "$Argc" -ne 1 { echo "Usage: bootgen.sh *build dir*" exit 1 } global BUILD := $1 # Re-locator Path global RELOCATOR := 'bootmgr/relocator' # Build location global BOOTMGR := $(BUILD) # Check for re-locator binary if test ! -f $RELOCATOR/relocator.bin { echo "Error : Relocator Not found!" exit 1 } else { echo "Relocator found..." } # Check for boot manager binary if test ! -f $BOOTMGR/bootmgr.bin { echo "Error : Boot Manager Not found!" exit 1 } else { echo "Boot Manager found..." } # echo echo "Generating bootloader..." # Generate an all 0 bin file dd if=/dev/zero of=__tmp.bin ibs=1 count=256 conv=notrunc >/dev/null !2 > !1 # Generate a 0 padded version of the relocator dd if=$RELOCATOR/relocator.bin of=__tmp.bin ibs=1 conv=notrunc >/dev/null !2 > !1 # Concatenate the re-locator and the boot-manager cat __tmp.bin $BOOTMGR/bootmgr.bin > $BOOTMGR/bootloader.bin # Remove the tmp files rm -f __tmp.bin # Remove bootmgr.bin rm -f $BOOTMGR/bootmgr.bin (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Pound "$#"))} {(-ne)} {(1)} {(Lit_Other "]")}) terminator: ) ] action: [(C {(echo)} {(DQ ("Usage: bootgen.sh *build dir*"))}) (C {(exit)} {(1)})] spids: [-1 19] ) ] spids: [-1 33] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:BUILD) op:Equal rhs:{($ VSub_Number "$1")} spids:[36])] spids: [36] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RELOCATOR) op: Equal rhs: {(bootmgr/relocator)} spids: [43] ) ] spids: [43] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:BOOTMGR) op:Equal rhs:{(${ VSub_Name BUILD)} spids:[50])] spids: [50] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {($ VSub_Name "$RELOCATOR") (/relocator.bin)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("Error : Relocator Not found!"))}) (C {(exit)} {(1)})] spids: [-1 73] ) ] else_action: [(C {(echo)} {(DQ ("Relocator found..."))})] spids: [88 97] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {($ VSub_Name "$BOOTMGR") (/bootmgr.bin)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ("Error : Boot Manager Not found!"))}) (C {(exit)} {(1)})] spids: [-1 117] ) ] else_action: [(C {(echo)} {(DQ ("Boot Manager found..."))})] spids: [132 141] ) (C {(echo)} {(DQ ("Generating bootloader..."))}) (SimpleCommand words: [ {(dd)} {(Lit_VarLike "if=") (/dev/zero)} {(Lit_VarLike "of=") (__tmp.bin)} {(Lit_VarLike "ibs=") (1)} {(Lit_VarLike "count=") (256)} {(Lit_VarLike "conv=") (notrunc)} ] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[174]) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[177]) ] ) (SimpleCommand words: [ {(dd)} {(Lit_VarLike "if=") ($ VSub_Name "$RELOCATOR") (/relocator.bin)} {(Lit_VarLike "of=") (__tmp.bin)} {(Lit_VarLike "ibs=") (1)} {(Lit_VarLike "conv=") (notrunc)} ] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[199]) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[202]) ] ) (SimpleCommand words: [{(cat)} {(__tmp.bin)} {($ VSub_Name "$BOOTMGR") (/bootmgr.bin)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {($ VSub_Name "$BOOTMGR") (/bootloader.bin)} spids: [216] ) ] ) (C {(rm)} {(-f)} {(__tmp.bin)}) (C {(rm)} {(-f)} {($ VSub_Name "$BOOTMGR") (/bootmgr.bin)}) ] )