(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:IMAGE_FILE)
          op: Equal
          rhs: {(raspbian-stretch-lite.zip)}
          spids: [14]
        )
      ]
      spids: [14]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:TODAY_EXT)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [(C {(date)} {(Lit_Other '+') (DQ ('%Y-%m-%d-%H-%M'))})]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [18 25]
              )
            }
          spids: [17]
        )
      ]
      spids: [17]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:BUILD_ID)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (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]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:IMAGE_FILE_CUSTOMIZED)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Name IMAGE>
                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]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:IMAGE_URL)
          op: Equal
          rhs: {(https) (Lit_Other ':') (//downloads.raspberrypi.org/raspbian_lite_latest)}
          spids: [61]
        )
      ]
      spids: [61]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:TEMP_CHROOT_DIR)
          op: Equal
          rhs: {(/mnt/raspbian-temp)}
          spids: [66]
        )
      ]
      spids: [66]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:DROP_IN)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Name DROP_IN>
                suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(0)})
                spids: [70 74]
              )
            }
          spids: [69]
        )
      ]
      spids: [69]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:CUSTOM_SCRIPT)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Name CUSTOM_SCRIPT>
                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 ('###########################################################################'))})
    (FuncDef
      name: bail_and_cleanup
      body: (BraceGroup children:[(C {(kpartx)} {(-d)} {($ VSub_Number '$1')})] spids:[130])
      spids: [126 129]
    )
    (FuncDef
      name: check_command_ok
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (C {(Lit_Other '[')} {(-x)} 
                              {
                                (DQ 
                                  (CommandSubPart
                                    command_list: 
                                      (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 )})
                    (SimpleCommand
                      words: [
                        {(echo)}
                        {
                          (DQ ('Error: ') ($ VSub_Number '$1') 
                            (' is not installed. Please install it.')
                          )
                        }
                      ]
                      redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[198])]
                    )
                    (C {(echo)} {(DQ )})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
                  ]
                  spids: [16777215 174]
                )
              ]
              spids: [16777215 220]
            )
          ]
          spids: [150]
        )
      spids: [146 149]
    )
    (FuncDef
      name: check_root
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$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 
                          (
'###########################################################################'
                          )
                        )
                      }
                    )
                    (ControlFlow token:<ControlFlow_Exit exit>)
                  ]
                  spids: [16777215 251]
                )
              ]
              spids: [16777215 291]
            )
          ]
          spids: [229]
        )
      spids: [225 228]
    )
    (FuncDef
      name: check_dependencies
      body: 
        (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]
    )
    (FuncDef
      name: get_unzip_image
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: (C {(Lit_Other '[')} {(-f)} {(${ VSub_Name IMAGE_FILE)} {(Lit_Other ']')})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:remotesize)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (Pipeline
                                        children: [
                                          (SimpleCommand
                                            words: [
                                              {(wget)}
                                              {(https) (Lit_Other ':') 
                                                (//downloads.raspberrypi.org/raspbian_lite_latest)
                                              }
                                              {(--spider)}
                                              {(--server-response)}
                                              {(-O)}
                                              {(-)}
                                            ]
                                            redirects: [
                                              (Redir
                                                op_id: Redir_GreatAnd
                                                fd: 2
                                                arg_word: {(1)}
                                                spids: [386]
                                              )
                                            ]
                                          )
                                          (C {(sed)} {(-ne)} {(SQ <'/Content-Length/{s/.*: //;p}'>)})
                                        ]
                                        negated: F
                                      )
                                    ]
                                  )
                                left_token: <Left_Backtick '`'>
                                spids: [371 398]
                              )
                            }
                          spids: [370]
                        )
                      ]
                      spids: [370]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:localsize)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (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]
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} 
                                  {
                                    (BracedVarSub
                                      token: <VSub_Name remotesize>
                                      prefix_op: VSub_Pound
                                      spids: [429 432]
                                    )
                                  } {(KW_Bang '!') (Lit_Other '=')} 
                                  {
                                    (BracedVarSub
                                      token: <VSub_Name localsize>
                                      prefix_op: VSub_Pound
                                      spids: [437 440]
                                    )
                                  } {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:remotesize)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (Pipeline
                                                children: [
                                                  (SimpleCommand
                                                    words: [
                                                      {(wget)}
                                                      {(https) (Lit_Other ':') 
                                                        (
//downloads.raspberrypi.org/raspbian_lite_latest
                                                        )
                                                      }
                                                      {(--spider)}
                                                      {(--server-response)}
                                                      {(-O)}
                                                      {(-)}
                                                    ]
                                                    redirects: [
                                                      (Redir
                                                        op_id: Redir_GreatAnd
                                                        fd: 2
                                                        arg_word: {(1)}
                                                        spids: [464]
                                                      )
                                                    ]
                                                  )
                                                  (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]
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$remotesize'))} 
                                  {(Lit_Other '=')} {(DQ ($ VSub_Name '$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]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:IMAGE_FILE_UNZIPPED)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [(C {(zipinfo)} {(-1)} {(${ VSub_Name IMAGE_FILE)})]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [627 635]
                      )
                    }
                  spids: [626]
                )
              ]
              spids: [626]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:IMAGE_FILE_UNZIPPED_SIZE)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (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]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (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 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (Pipeline
                      children: [
                        (C {(unzip)} {(-o)} {(-p)} {(${ VSub_Name IMAGE_FILE)})
                        (SimpleCommand
                          words: [
                            {(pv)}
                            {(-p)}
                            {(-s)}
                            {(${ VSub_Name IMAGE_FILE_UNZIPPED_SIZE)}
                            {(-w)}
                            {(80)}
                          ]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: 16777215
                              arg_word: {(${ VSub_Name IMAGE_FILE_UNZIPPED)}
                              spids: [737]
                            )
                          ]
                        )
                      ]
                      negated: F
                    )
                  ]
                  spids: [16777215 687]
                )
              ]
              spids: [16777215 744]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (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]
    )
    (FuncDef
      name: resize_raw_image
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:IMAGE_SIZE_RAW)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (SimpleCommand
                                words: [{(wc)} {(-c)}]
                                redirects: [
                                  (Redir
                                    op_id: Redir_Less
                                    fd: 16777215
                                    arg_word: {(DQ (${ VSub_Name IMAGE_FILE_UNZIPPED))}
                                    spids: [844]
                                  )
                                ]
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [839 851]
                      )
                    }
                  spids: [838]
                )
              ]
              spids: [838]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:IMAGE_SIZE_ACTUAL)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (SimpleCommand
                                words: [{(wc)} {(-c)}]
                                redirects: [
                                  (Redir
                                    op_id: Redir_Less
                                    fd: 16777215
                                    arg_word: {(DQ (${ VSub_Name IMAGE_FILE_CUSTOMIZED))}
                                    spids: [860]
                                  )
                                ]
                              )
                            ]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [855 867]
                      )
                    }
                  spids: [854]
                )
              ]
              spids: [854]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:IMAGE_ROOTPART_START)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (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]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (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 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (ControlFlow token:<ControlFlow_Return return>)
                  ]
                  spids: [16777215 928]
                )
              ]
              spids: [16777215 962]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Resizing image...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (SimpleCommand
              words: [
                {(dd)}
                {(Lit_VarLike 'if=') (/dev/zero)}
                {(Lit_VarLike 'bs=') (1M)}
                {(Lit_VarLike 'count=') (512)}
              ]
              redirects: [
                (Redir
                  op_id: Redir_DGreat
                  fd: 16777215
                  arg_word: {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}
                  spids: [1002]
                )
              ]
            )
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:PART_NUM) op:Equal rhs:{(2)} spids:[1010])]
              spids: [1010]
            )
            (SimpleCommand
              words: [{(fdisk)} {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)}]
              redirects: [
                (HereDoc
                  op_id: Redir_DLess
                  fd: 16777215
                  body: 
                    {
                      (DQ ('p\n') ('d\n') ($ VSub_Name '$PART_NUM') ('\n') ('n\n') ('p\n') 
                        ($ VSub_Name '$PART_NUM') ('\n') ($ VSub_Name '$IMAGE_ROOTPART_START') ('\n') ('\n') ('p\n') ('w\n')
                      )
                    }
                  do_expansion: True
                  here_end: EOF
                  was_filled: T
                  spids: [1021]
                )
              ]
            )
          ]
          spids: [835]
        )
      spids: [831 834]
    )
    (FuncDef
      name: set_up_loopdevs
      body: 
        (BraceGroup
          children: [
            (Pipeline
              children: [
                (C {(kpartx)} {(-v)} {(-a)} {(${ VSub_Name IMAGE_FILE_CUSTOMIZED)})
                (C {(tee)} {(/tmp/kpartx-output.txt)})
              ]
              negated: F
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:LOOPPARTSID)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (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: [1071 1108]
                      )
                    }
                  spids: [1070]
                )
              ]
              spids: [1070]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('The loop device is ') (${ VSub_Name LOOPPARTSID))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(sync)})
            (C {(sleep)} {(2)})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (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)}
                    )
                    (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
                  ]
                  spids: [16777215 1170]
                )
              ]
              spids: [16777215 1229]
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} 
              {
                (DQ ('Found the loopdev partitions at /dev/mapper/') (${ VSub_Name LOOPPARTSID) ('!'))
              }
            )
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:LOOPDEVPARTS)
                  op: Equal
                  rhs: {(/dev/mapper/) (${ VSub_Name LOOPPARTSID)}
                  spids: [1258]
                )
              ]
              spids: [1258]
            )
            (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)} 
              {
                (CommandSubPart
                  command_list: (CommandList children:[(C {(which)} {(qemu-arm-static)})])
                  left_token: <Left_Backtick '`'>
                  spids: [1399 1403]
                )
              } {(${ VSub_Name TEMP_CHROOT_DIR) (/usr/bin/)}
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (DBracket
                          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 1427]
                )
              ]
              else_action: [
                (If
                  arms: [
                    (if_arm
                      cond: [
                        (Sentence
                          child: 
                            (DBracket
                              expr: 
                                (BoolUnary
                                  op_id: BoolUnary_n
                                  child: {(DQ (${ VSub_Name CUSTOM_SCRIPT))}
                                )
                            )
                          terminator: <Op_Semi ';'>
                        )
                      ]
                      action: [(C {(eval)} {(${ VSub_Name CUSTOM_SCRIPT)})]
                      spids: [16777215 1484]
                    )
                  ]
                  else_action: [
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (C {(echo)} {(DQ ('Unpacking qt5 libraries...'))})
                    (C {(echo)} 
                      {
                        (DQ 
                          (
---------------------------------------------------------------------------
                          )
                        )
                      }
                    )
                    (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: [1501 1637]
                )
              ]
              spids: [1464 1641]
            )
            (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: [1046]
        )
      spids: [1042 1045]
    )
    (FuncDef
      name: mount_chroot_dirs
      body: 
        (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)})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (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')})
                    (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
                  ]
                  spids: [16777215 1864]
                )
              ]
              spids: [16777215 1919]
            )
          ]
          spids: [1727]
        )
      spids: [1723 1726]
    )
    (FuncDef
      name: umount_chroot_dirs
      body: 
        (BraceGroup
          children: [
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Unmount chroot dirs...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(sync)})
            (C {(umount)} 
              (BracedWordTree
                parts: [
                  (${ VSub_Name TEMP_CHROOT_DIR)
                  (/)
                  (BracedAltPart
                    words: [{(dev/pts)} {(dev)} {(sys)} {(proc)} {(boot)} {}]
                  )
                ]
              )
            )
          ]
          spids: [1929]
        )
      spids: [1925 1928]
    )
    (FuncDef
      name: umount_loop_dev
      body: 
        (BraceGroup
          children: [
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (C {(echo)} {(DQ ('Unmount loop devices...'))})
            (C {(echo)} 
              {(DQ (---------------------------------------------------------------------------))}
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:loopdev)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (Pipeline
                                children: [
                                  (C {(echo)} {($ VSub_Number '$1')})
                                  (C {(cut)} {(-d) (DQ (/))} {(-f3)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        left_token: <Left_Backtick '`'>
                        spids: [2007 2022]
                      )
                    }
                  spids: [2006]
                )
              ]
              spids: [2006]
            )
            (C {(dmsetup)} {(remove)} {(-f)} {($ VSub_Name '$loopdev') (DQ (p1))})
            (C {(dmsetup)} {(remove)} {(-f)} {($ VSub_Name '$loopdev') (DQ (p2))})
            (C {(kpartx)} {(-d)} {($ VSub_Number '$1')})
          ]
          spids: [1982]
        )
      spids: [1978 1981]
    )
    (C {(check_dependencies)})
    (C {(check_root)})
    (C {(get_unzip_image)})
    (C {(resize_raw_image)})
    (C {(set_up_loopdevs)})
  ]
)