(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:IMAGE_FILE spids:[14])
          op: Equal
          rhs: {(raspbian-stretch-lite.zip)}
          spids: [14]
        )
      ]
      spids: [14]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:TODAY_EXT spids:[17])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [(C {(date)} {(Lit_Other '+') (DQ ('%Y-%m-%d-%H-%M'))})]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [18 25]
              )
            }
          spids: [17]
        )
      ]
      spids: [17]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:BUILD_ID spids:[27])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(hexdump)} {(-n)} {(4)} {(-e)} {(SQ <'4/4 "%X" 1 "\\n"'>)} {(/dev/random)})
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [28 42]
              )
            }
          spids: [27]
        )
      ]
      spids: [27]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:IMAGE_FILE_CUSTOMIZED spids:[44])
          op: Equal
          rhs: 
            {
              (word_part.BracedVarSub
                token: <VSub_Name IMAGE>
                suffix_op: 
                  (suffix_op.StringUnary
                    op_id: VTest_ColonHyphen
                    arg_word: 
                      {
                        (DQ (crankshaft-) (${ VSub_Name TODAY_EXT) (-) (${ VSub_Name BUILD_ID) (.img))
                      }
                  )
                spids: [45 59]
              )
            }
          spids: [44]
        )
      ]
      spids: [44]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:IMAGE_URL spids:[61])
          op: Equal
          rhs: {(https) (Lit_Other ':') (//downloads.raspberrypi.org/raspbian_lite_latest)}
          spids: [61]
        )
      ]
      spids: [61]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:TEMP_CHROOT_DIR spids:[66])
          op: Equal
          rhs: {(/mnt/raspbian-temp)}
          spids: [66]
        )
      ]
      spids: [66]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:DROP_IN spids:[69])
          op: Equal
          rhs: 
            {
              (word_part.BracedVarSub
                token: <VSub_Name DROP_IN>
                suffix_op: (suffix_op.StringUnary op_id:VTest_ColonHyphen arg_word:{(0)})
                spids: [70 74]
              )
            }
          spids: [69]
        )
      ]
      spids: [69]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:CUSTOM_SCRIPT spids:[76])
          op: Equal
          rhs: 
            {
              (word_part.BracedVarSub
                token: <VSub_Name CUSTOM_SCRIPT>
                suffix_op: (suffix_op.StringUnary op_id:VTest_ColonHyphen arg_word:{(DQ )})
                spids: [77 82]
              )
            }
          spids: [76]
        )
      ]
      spids: [76]
    )
    (C {(clear)})
    (C {(echo)} {(DQ ('###########################################################################'))})
    (C {(echo)} {(DQ )})
    (C {(echo)} {(DQ ('                  Welcome to the Crankshaft build script!'))})
    (C {(echo)} {(DQ )})
    (C {(echo)} {(DQ ('###########################################################################'))})
    (command.FuncDef
      name: bail_and_cleanup
      body: (command.BraceGroup children:[(C {(kpartx)} {(-d)} {($ VSub_Number '$1')})] spids:[130])
      spids: [126 129]
    )
    (command.FuncDef
      name: check_command_ok
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-x)} 
                              {
                                (DQ 
                                  (word_part.CommandSubPart
                                    command_list: 
                                      (command.CommandList
                                        children: [(C {(command)} {(-v)} {($ VSub_Number '$1')})]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [162 168]
                                  )
                                )
                              } {(Lit_Other ']')}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ )})
                    (command.SimpleCommand
                      words: [
                        {(echo)}
                        {
                          (DQ ('Error: ') ($ VSub_Number '$1') 
                            (' is not installed. Please install it.')
                          )
                        }
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (C {(echo)} {(DQ )})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                  spids: [16777215 174]
                )
              ]
              spids: [16777215 220]
            )
          ]
          spids: [150]
        )
      spids: [146 149]
    )
    (command.FuncDef
      name: check_root
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_Other '[')} {(DQ ($ VSub_DollarName '$EUID'))} {(-ne)} {(0)} 
                          {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ )})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
"Please run this script as using sudo/as root, otherwise it can't continue. "
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ )})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (command.ControlFlow token:<ControlFlow_Exit exit>)
                  ]
                  spids: [16777215 251]
                )
              ]
              spids: [16777215 291]
            )
          ]
          spids: [229]
        )
      spids: [225 228]
    )
    (command.FuncDef
      name: check_dependencies
      body: 
        (command.BraceGroup
          children: [
            (C {(check_command_ok)} {(kpartx)})
            (C {(check_command_ok)} {(qemu-arm-static)})
            (C {(check_command_ok)} {(chroot)})
            (C {(check_command_ok)} {(pv)})
            (C {(check_command_ok)} {(zipinfo)})
            (C {(check_command_ok)} {(zerofree)})
          ]
          spids: [300]
        )
      spids: [296 299]
    )
    (command.FuncDef
      name: get_unzip_image
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: (C {(Lit_Other '[')} {(-f)} {(${ VSub_Name IMAGE_FILE)} {(Lit_Other ']')})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:remotesize spids:[370])
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSubPart
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.Pipeline
                                        children: [
                                          (command.SimpleCommand
                                            words: [
                                              {(wget)}
                                              {(https) (Lit_Other ':') 
                                                (//downloads.raspberrypi.org/raspbian_lite_latest)
                                              }
                                              {(--spider)}
                                              {(--server-response)}
                                              {(-O)}
                                              {(-)}
                                            ]
                                            redirects: [
                                              (redir.Redir
                                                op: <Redir_GreatAnd '2>&'>
                                                fd: 2
                                                arg_word: {(1)}
                                              )
                                            ]
                                          )
                                          (C {(sed)} {(-ne)} {(SQ <'/Content-Length/{s/.*: //;p}'>)})
                                        ]
                                        negated: F
                                      )
                                    ]
                                  )
                                left_token: <Left_Backtick '`'>
                                spids: [371 398]
                              )
                            }
                          spids: [370]
                        )
                      ]
                      spids: [370]
                    )
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:localsize spids:[401])
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSubPart
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.Pipeline
                                        children: [
                                          (C {(wc)} {(-c)} {(${ VSub_Name IMAGE_FILE)})
                                          (C {(awk)} {(SQ <'{print $1}'>)})
                                        ]
                                        negated: F
                                      )
                                    ]
                                  )
                                left_token: <Left_Backtick '`'>
                                spids: [402 418]
                              )
                            }
                          spids: [401]
                        )
                      ]
                      spids: [401]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {(Lit_Other '[')} 
                                  {
                                    (word_part.BracedVarSub
                                      token: <VSub_Name remotesize>
                                      prefix_op: VSub_Pound
                                      spids: [429 432]
                                    )
                                  } {(KW_Bang '!') (Lit_Other '=')} 
                                  {
                                    (word_part.BracedVarSub
                                      token: <VSub_Name localsize>
                                      prefix_op: VSub_Pound
                                      spids: [437 440]
                                    )
                                  } {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (command.Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:remotesize spids:[448])
                                  op: Equal
                                  rhs: 
                                    {
                                      (word_part.CommandSubPart
                                        command_list: 
                                          (command.CommandList
                                            children: [
                                              (command.Pipeline
                                                children: [
                                                  (command.SimpleCommand
                                                    words: [
                                                      {(wget)}
                                                      {(https) (Lit_Other ':') 
                                                        (
//downloads.raspberrypi.org/raspbian_lite_latest
                                                        )
                                                      }
                                                      {(--spider)}
                                                      {(--server-response)}
                                                      {(-O)}
                                                      {(-)}
                                                    ]
                                                    redirects: [
                                                      (redir.Redir
                                                        op: <Redir_GreatAnd '2>&'>
                                                        fd: 2
                                                        arg_word: {(1)}
                                                      )
                                                    ]
                                                  )
                                                  (C {(sed)} {(-ne)} 
                                                    {(SQ <'/Content-Length/{s/.*: //;p}'>)}
                                                  )
                                                ]
                                                negated: F
                                              )
                                            ]
                                          )
                                        left_token: <Left_Backtick '`'>
                                        spids: [449 476]
                                      )
                                    }
                                  spids: [448]
                                )
                              ]
                              spids: [448]
                            )
                          ]
                          spids: [16777215 445]
                        )
                      ]
                      spids: [16777215 479]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ ($ VSub_DollarName '$remotesize'))} 
                                  {(Lit_Other '=')} {(DQ ($ VSub_DollarName '$localsize'))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (C {(echo)} 
                              {
                                (DQ 
                                  (
---------------------------------------------------------------------------
                                  )
                                )
                              }
                            )
                            (C {(echo)} 
                              {
                                (DQ ('Image file ') (${ VSub_Name IMAGE_FILE) 
                                  (' is already the same, skipping download.')
                                )
                              }
                            )
                            (C {(echo)} {(DQ ('It will be re-downloaded if remote file has changed.'))})
                            (C {(echo)} 
                              {
                                (DQ 
                                  (
---------------------------------------------------------------------------
                                  )
                                )
                              }
                            )
                          ]
                          spids: [16777215 500]
                        )
                      ]
                      else_action: [
                        (C {(echo)} 
                          {
                            (DQ 
                              (
---------------------------------------------------------------------------
                              )
                            )
                          }
                        )
                        (C {(echo)} {(DQ ('Downloading new version of raspbian image from server...'))})
                        (C {(wget)} {(-q)} {(--show-progress)} {(-O) (${ VSub_Name IMAGE_FILE)} 
                          {(${ VSub_Name IMAGE_URL)}
                        )
                        (C {(echo)} 
                          {
                            (DQ 
                              (
---------------------------------------------------------------------------
                              )
                            )
                          }
                        )
                      ]
                      spids: [535 579]
                    )
                  ]
                  spids: [16777215 363]
                )
              ]
              else_action: [
                (C {(echo)} 
                  {
                    (DQ (---------------------------------------------------------------------------))
                  }
                )
                (C {(echo)} {(DQ ('Downloading raspbian image from server...'))})
                (C {(wget)} {(-q)} {(--show-progress)} {(-O) (${ VSub_Name IMAGE_FILE)} 
                  {(${ VSub_Name IMAGE_URL)}
                )
                (C {(echo)} 
                  {
                    (DQ (---------------------------------------------------------------------------))
                  }
                )
              ]
              spids: [582 622]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:IMAGE_FILE_UNZIPPED spids:[626])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [(C {(zipinfo)} {(-1)} {(${ VSub_Name IMAGE_FILE)})]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [627 635]
                      )
                    }
                  spids: [626]
                )
              ]
              spids: [626]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:IMAGE_FILE_UNZIPPED_SIZE spids:[638])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(zipinfo)} {(-l)} {(${ VSub_Name IMAGE_FILE)})
                                  (C {(tail)} {(-1)})
                                  (C {(xargs)})
                                  (C {(cut)} {(-d) (SQ <' '>)} {(-f3)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [639 668]
                      )
                    }
                  spids: [638]
                )
              ]
              spids: [638]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-f)} {(${ VSub_Name IMAGE_FILE_UNZIPPED)} 
                              {(Lit_Other ']')}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Unpacking raspbian image...'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (command.Pipeline
                      children: [
                        (C {(unzip)} {(-o)} {(-p)} {(${ VSub_Name IMAGE_FILE)})
                        (command.SimpleCommand
                          words: [
                            {(pv)}
                            {(-p)}
                            {(-s)}
                            {(${ VSub_Name IMAGE_FILE_UNZIPPED_SIZE)}
                            {(-w)}
                            {(80)}
                          ]
                          redirects: [
                            (redir.Redir
                              op: <Redir_Great '>'>
                              fd: 16777215
                              arg_word: {(${ VSub_Name IMAGE_FILE_UNZIPPED)}
                            )
                          ]
                        )
                      ]
                      negated: F
                    )
                  ]
                  spids: [16777215 687]
                )
              ]
              spids: [16777215 744]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-f)} {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)} 
                              {(Lit_Other ']')}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Copying a big file...'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(cp)} {(${ VSub_Name IMAGE_FILE_UNZIPPED)} 
                      {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}
                    )
                  ]
                  spids: [16777215 763]
                )
              ]
              else_action: [
                (C {(echo)} 
                  {
                    (DQ (---------------------------------------------------------------------------))
                  }
                )
                (C {(echo)} 
                  {
                    (DQ ('Skipping creation of ') (${ VSub_Name IMAGE_FILE_CUSTOMIZED) 
                      (", it's already there. To re-create, delete it.")
                    )
                  }
                )
                (C {(echo)} 
                  {
                    (DQ (---------------------------------------------------------------------------))
                  }
                )
              ]
              spids: [798 826]
            )
          ]
          spids: [343]
        )
      spids: [339 342]
    )
    (command.FuncDef
      name: resize_raw_image
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:IMAGE_SIZE_RAW spids:[838])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.SimpleCommand
                                words: [{(wc)} {(-c)}]
                                redirects: [
                                  (redir.Redir
                                    op: <Redir_Less '<'>
                                    fd: 16777215
                                    arg_word: {(DQ (${ VSub_Name IMAGE_FILE_UNZIPPED))}
                                  )
                                ]
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [839 851]
                      )
                    }
                  spids: [838]
                )
              ]
              spids: [838]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:IMAGE_SIZE_ACTUAL spids:[854])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.SimpleCommand
                                words: [{(wc)} {(-c)}]
                                redirects: [
                                  (redir.Redir
                                    op: <Redir_Less '<'>
                                    fd: 16777215
                                    arg_word: {(DQ (${ VSub_Name IMAGE_FILE_CUSTOMIZED))}
                                  )
                                ]
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [855 867]
                      )
                    }
                  spids: [854]
                )
              ]
              spids: [854]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:IMAGE_ROOTPART_START spids:[870])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(parted)} {(${ VSub_Name IMAGE_FILE_UNZIPPED)} {(unit)} {(s)} 
                                    {(print)} {(-sm)}
                                  )
                                  (C {(tail)} {(-1)})
                                  (C {(cut)} {(-d) (Lit_Other ':')} {(-f2)})
                                  (C {(sed)} {(SQ <s/s//>)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [871 908]
                      )
                    }
                  spids: [870]
                )
              ]
              spids: [870]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_Other '[')} {(${ VSub_Name IMAGE_SIZE_ACTUAL)} {(-gt)} 
                          {(${ VSub_Name IMAGE_SIZE_RAW)} {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Image seems already resized, or something is wrong.'))})
                    (C {(echo)} 
                      {(DQ ("If the image doesn't work, try removing the .img and try again."))}
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (command.ControlFlow token:<ControlFlow_Return return>)
                  ]
                  spids: [16777215 928]
                )
              ]
              spids: [16777215 962]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Resizing image...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (command.SimpleCommand
              words: [
                {(dd)}
                {(Lit_VarLike 'if=') (/dev/zero)}
                {(Lit_VarLike 'bs=') (1M)}
                {(Lit_VarLike 'count=') (512)}
              ]
              redirects: [
                (redir.Redir
                  op: <Redir_DGreat '>>'>
                  fd: 16777215
                  arg_word: {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}
                )
              ]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:PART_NUM spids:[1010])
                  op: Equal
                  rhs: {(2)}
                  spids: [1010]
                )
              ]
              spids: [1010]
            )
            (command.SimpleCommand
              words: [{(fdisk)} {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}]
              redirects: [
                (redir.HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 1038
                  stdin_parts: [
                    ('p\n')
                    ('d\n')
                    ($ VSub_DollarName '$PART_NUM')
                    ('\n')
                    ('n\n')
                    ('p\n')
                    ($ VSub_DollarName '$PART_NUM')
                    ('\n')
                    ($ VSub_DollarName '$IMAGE_ROOTPART_START')
                    ('\n')
                    ('\n')
                    ('p\n')
                    ('w\n')
                  ]
                )
              ]
            )
          ]
          spids: [835]
        )
      spids: [831 834]
    )
    (command.FuncDef
      name: set_up_loopdevs
      body: 
        (command.BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {(kpartx)} {(-v)} {(-a)} {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)})
                (C {(tee)} {(/tmp/kpartx-output.txt)})
              ]
              negated: F
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:LOOPPARTSID spids:[1071])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(cat)} {(/tmp/kpartx-output.txt)})
                                  (C {(head)} {(-n1)})
                                  (C {(sed)} {(SQ <'s/add map //'>)})
                                  (C {(cut)} {(-f1)} {(-d) (SQ <' '>)})
                                  (C {(sed)} {(SQ <'s/p1$//'>)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [1072 1109]
                      )
                    }
                  spids: [1071]
                )
              ]
              spids: [1071]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('The loop device is ') (${ VSub_Name LOOPPARTSID))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(sync)})
            (C {(sleep)} {(2)})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-L)} {(/dev/mapper/) (${ VSub_Name LOOPPARTSID) (p1)} 
                              {(Lit_Other ']')}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'                                                                           '
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ ("Couldn't find the loopdev partitions at /dev/mapper/") 
                          (${ VSub_Name LOOPPARTSID) ('p1!')
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'                                                                           '
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(bail_and_cleanup)} {(/dev/) (${ VSub_Name LOOPPARTSID)} 
                      {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                  spids: [16777215 1171]
                )
              ]
              spids: [16777215 1230]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} 
              {
                (DQ ('Found the loopdev partitions at /dev/mapper/') (${ VSub_Name LOOPPARTSID) ('!'))
              }
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:LOOPDEVPARTS spids:[1259])
                  op: Equal
                  rhs: {(/dev/mapper/) (${ VSub_Name LOOPPARTSID)}
                  spids: [1259]
                )
              ]
              spids: [1259]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Check rootfs before resize...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(e2fsck)} {(-f)} {(${ VSub_Name LOOPDEVPARTS) (p2)})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Resize rootfs...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(resize2fs)} {(-p)} {(${ VSub_Name LOOPDEVPARTS) (p2)})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Check rootfs afer resize...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(e2fsck)} {(-f)} {(${ VSub_Name LOOPDEVPARTS) (p2)})
            (C {(mount_chroot_dirs)} {(${ VSub_Name LOOPDEVPARTS)} {(${ VSub_Name LOOPPARTSID)})
            (C {(sed)} {(-i)} {(SQ <'s/^/#CHROOT /g'>)} 
              {(${ VSub_Name TEMP_CHROOT_DIR) (/etc/ld.so.preload)}
            )
            (C {(cp)} 
              {
                (word_part.CommandSubPart
                  command_list: (command.CommandList children:[(C {(which)} {(qemu-arm-static)})])
                  left_token: <Left_Backtick '`'>
                  spids: [1400 1404]
                )
              } {(${ VSub_Name TEMP_CHROOT_DIR) (/usr/bin/)}
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.BoolBinary
                              op_id: BoolBinary_ne
                              left: {(${ VSub_Name DROP_IN)}
                              right: {(0)}
                            )
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(-e)} {(DQ ('Dropping you in the chroot shell.'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(chroot)} {(${ VSub_Name TEMP_CHROOT_DIR)} {(/bin/bash)})
                  ]
                  spids: [16777215 1428]
                )
              ]
              else_action: [
                (command.If
                  arms: [
                    (if_arm
                      cond: [
                        (command.Sentence
                          child: 
                            (command.DBracket
                              expr: 
                                (bool_expr.BoolUnary
                                  op_id: BoolUnary_n
                                  child: {(DQ (${ VSub_Name CUSTOM_SCRIPT))}
                                )
                            )
                          terminator: <Op_Semi ';'>
                        )
                      ]
                      action: [(C {(eval)} {(${ VSub_Name CUSTOM_SCRIPT)})]
                      spids: [16777215 1485]
                    )
                  ]
                  else_action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Unpacking qt5 libraries...'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (command.Pipeline
                      children: [
                        (C {(pv)} {(-p)} {(-w)} {(80)} {(prebuilt/libQt5_OpenGLES2.tar.xz)})
                        (C {(tar)} {(-xf)} {(-)} {(-C)} {(${ VSub_Name TEMP_CHROOT_DIR) (/)})
                      ]
                      negated: F
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Copy crankshaft files to root...'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(cp)} {(-a)} {(crankshaft/.)} {(${ VSub_Name TEMP_CHROOT_DIR) (/root/)})
                    (C {(sync)})
                    (C {(sleep)} {(1)})
                    (C {(chroot)} {(${ VSub_Name TEMP_CHROOT_DIR)} {(/bin/bash)} 
                      {(/root/scripts/customize-image-pi.sh)}
                    )
                    (C {(chroot)} {(${ VSub_Name TEMP_CHROOT_DIR)} {(/bin/bash)} 
                      {(/root/scripts/read-only-fs.sh)}
                    )
                  ]
                  spids: [1502 1638]
                )
              ]
              spids: [1465 1642]
            )
            (C {(sed)} {(-i)} {(SQ <'s/^#CHROOT //g'>)} 
              {(${ VSub_Name TEMP_CHROOT_DIR) (/etc/ld.so.preload)}
            )
            (C {(umount_chroot_dirs)})
            (C {(zerofree)} {(${ VSub_Name LOOPDEVPARTS) (p2)})
            (C {(umount_loop_dev)} {(/dev/) (${ VSub_Name LOOPPARTSID)})
            (C {(echo)} 
              {(DQ ('###########################################################################'))}
            )
            (C {(echo)} 
              {(DQ ('                                                                           '))}
            )
            (C {(echo)} {(DQ ('If you reach here, it means the image is ready. :)'))})
            (C {(echo)} 
              {(DQ ('                                                                           '))}
            )
            (C {(echo)} 
              {(DQ ('###########################################################################'))}
            )
          ]
          spids: [1047]
        )
      spids: [1043 1046]
    )
    (command.FuncDef
      name: mount_chroot_dirs
      body: 
        (command.BraceGroup
          children: [
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Mounting CHROOT directories'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(mkdir)} {(-p)} {(${ VSub_Name TEMP_CHROOT_DIR)})
            (C {(mount)} {(-o)} {(rw)} {(${ VSub_Number 1) (p2)} {(${ VSub_Name TEMP_CHROOT_DIR)})
            (C {(mount)} {(-o)} {(rw)} {(${ VSub_Number 1) (p1)} {(${ VSub_Name TEMP_CHROOT_DIR) (/boot)})
            (C {(mount)} {(--bind)} {(/dev)} {(${ VSub_Name TEMP_CHROOT_DIR) (/dev/)})
            (C {(mount)} {(--bind)} {(/sys)} {(${ VSub_Name TEMP_CHROOT_DIR) (/sys/)})
            (C {(mount)} {(--bind)} {(/proc)} {(${ VSub_Name TEMP_CHROOT_DIR) (/proc/)})
            (C {(mount)} {(--bind)} {(/dev/pts)} {(${ VSub_Name TEMP_CHROOT_DIR) (/dev/pts)})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-f)} 
                              {(${ VSub_Name TEMP_CHROOT_DIR) (/etc/ld.so.preload)} {(Lit_Other ']')}
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'                                                                           '
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ ("I didn't see ") (${ VSub_Name TEMP_CHROOT_DIR) ('/etc/ folder. Bailing!'))
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'                                                                           '
                          )
                        )
                      }
                    )
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (C {(umount_chroot_dirs)})
                    (C {(umount_loop_dev)} {($ VSub_Number '$2')})
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                  spids: [16777215 1865]
                )
              ]
              spids: [16777215 1920]
            )
          ]
          spids: [1728]
        )
      spids: [1724 1727]
    )
    (command.FuncDef
      name: umount_chroot_dirs
      body: 
        (command.BraceGroup
          children: [
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Unmount chroot dirs...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(sync)})
            (C {(umount)} 
              (word.BracedWordTree
                parts: [
                  (${ VSub_Name TEMP_CHROOT_DIR)
                  (/)
                  (word_part.BracedAltPart
                    words: [{(dev/pts)} {(dev)} {(sys)} {(proc)} {(boot)} {}]
                  )
                ]
              )
            )
          ]
          spids: [1930]
        )
      spids: [1926 1929]
    )
    (command.FuncDef
      name: umount_loop_dev
      body: 
        (command.BraceGroup
          children: [
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Unmount loop devices...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:loopdev spids:[2007])
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSubPart
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(echo)} {($ VSub_Number '$1')})
                                  (C {(cut)} {(-d) (DQ (/))} {(-f3)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [2008 2023]
                      )
                    }
                  spids: [2007]
                )
              ]
              spids: [2007]
            )
            (C {(dmsetup)} {(remove)} {(-f)} {($ VSub_DollarName '$loopdev') (DQ (p1))})
            (C {(dmsetup)} {(remove)} {(-f)} {($ VSub_DollarName '$loopdev') (DQ (p2))})
            (C {(kpartx)} {(-d)} {($ VSub_Number '$1')})
          ]
          spids: [1983]
        )
      spids: [1979 1982]
    )
    (C {(check_dependencies)})
    (C {(check_root)})
    (C {(get_unzip_image)})
    (C {(resize_raw_image)})
    (C {(set_up_loopdevs)})
  ]
)