(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'IMAGE_FILE='> name:IMAGE_FILE)
          op: assign_op.Equal
          rhs: {<raspbian-stretch-lite.zip>}
          spids: [14]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'TODAY_EXT='> name:TODAY_EXT)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: (C {<date>} {<Id.Lit_Other '+'> (DQ <'%Y-%m-%d-%H-%M'>)})
                right: <Id.Eof_RParen _>
              )
            }
          spids: [17]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'BUILD_ID='> name:BUILD_ID)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<hexdump>} {<-n>} {<4>} {<-e>} {(SQ <'4/4 "%X" 1 "\\n"'>)} {<'/dev/random'>})
                right: <Id.Eof_RParen _>
              )
            }
          spids: [27]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: 
            (sh_lhs_expr.Name
              left: <Id.Lit_VarLike 'IMAGE_FILE_CUSTOMIZED='>
              name: IMAGE_FILE_CUSTOMIZED
            )
          op: assign_op.Equal
          rhs: 
            {
              (braced_var_sub
                left: <Id.Left_DollarBrace '${'>
                token: <Id.VSub_Name IMAGE>
                var_name: IMAGE
                suffix_op: 
                  (suffix_op.Unary
                    op: <Id.VTest_ColonHyphen _>
                    arg_word: 
                      {
                        (DQ <crankshaft-> (${ Id.VSub_Name TODAY_EXT) <-> (${ Id.VSub_Name BUILD_ID) 
                          <.img>
                        )
                      }
                  )
                right: <Id.Right_DollarBrace '}'>
              )
            }
          spids: [44]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'IMAGE_URL='> name:IMAGE_URL)
          op: assign_op.Equal
          rhs: {<https> <Id.Lit_Colon ':'> <'//downloads.raspberrypi.org/raspbian_lite_latest'>}
          spids: [61]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'TEMP_CHROOT_DIR='> name:TEMP_CHROOT_DIR)
          op: assign_op.Equal
          rhs: {<'/mnt/raspbian-temp'>}
          spids: [66]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'DROP_IN='> name:DROP_IN)
          op: assign_op.Equal
          rhs: 
            {
              (braced_var_sub
                left: <Id.Left_DollarBrace '${'>
                token: <Id.VSub_Name DROP_IN>
                var_name: DROP_IN
                suffix_op: (suffix_op.Unary op:<Id.VTest_ColonHyphen _> arg_word:{<0>})
                right: <Id.Right_DollarBrace '}'>
              )
            }
          spids: [69]
        )
      ]
      redirects: []
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'CUSTOM_SCRIPT='> name:CUSTOM_SCRIPT)
          op: assign_op.Equal
          rhs: 
            {
              (braced_var_sub
                left: <Id.Left_DollarBrace '${'>
                token: <Id.VSub_Name CUSTOM_SCRIPT>
                var_name: CUSTOM_SCRIPT
                suffix_op: (suffix_op.Unary op:<Id.VTest_ColonHyphen _> arg_word:{(DQ )})
                right: <Id.Right_DollarBrace '}'>
              )
            }
          spids: [76]
        )
      ]
      redirects: []
    )
    (C {<clear>})
    (C {<echo>} {(DQ <'###########################################################################'>)})
    (C {<echo>} {(DQ )})
    (C {<echo>} {(DQ <'                  Welcome to the Crankshaft build script!'>)})
    (C {<echo>} {(DQ )})
    (C {<echo>} {(DQ <'###########################################################################'>)})
    (command.ShFunction
      name: bail_and_cleanup
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [(C {<kpartx>} {<-d>} {($ Id.VSub_Number 1)})]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: check_command_ok
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Pipeline
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-x>} 
                                  {
                                    (DQ 
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: (C {<command>} {<-v>} {($ Id.VSub_Number 1)})
                                        right: <Id.Eof_RParen _>
                                      )
                                    )
                                  } {<Id.Lit_RBracket ']'>}
                                )
                              ]
                              negated: T
                              stderr_indices: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (C {<echo>} {(DQ )})
                    (command.Simple
                      words: [
                        {<echo>}
                        {
                          (DQ <'Error: '> ($ Id.VSub_Number 1) 
                            <' is not installed. Please install it.'>
                          )
                        }
                      ]
                      redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
                      more_env: []
                      do_fork: T
                    )
                    (C {<echo>} {(DQ )})
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Exit exit>
                      arg_word: {<1>}
                    )
                  ]
                  spids: [153 174]
                )
              ]
              else_action: []
              redirects: []
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: check_root
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName EUID))} {<-ne>} {<0>} 
                              {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.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:<Id.ControlFlow_Exit exit>)
                  ]
                  spids: [236 251]
                )
              ]
              else_action: []
              redirects: []
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: check_dependencies
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          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>})
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: get_unzip_image
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {<-f>} {(${ Id.VSub_Name IMAGE_FILE)} 
                              {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'remotesize='> name:remotesize)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_Backtick '`'>
                                child: 
                                  (command.Pipeline
                                    children: [
                                      (command.Simple
                                        words: [
                                          {<wget>}
                                          {<https> <Id.Lit_Colon ':'> 
                                            <'//downloads.raspberrypi.org/raspbian_lite_latest'>
                                          }
                                          {<--spider>}
                                          {<--server-response>}
                                          {<-O>}
                                          {<->}
                                        ]
                                        redirects: [
                                          (redir
                                            op: <Id.Redir_GreatAnd '2>&'>
                                            loc: (redir_loc.Fd fd:2)
                                            arg: {<1>}
                                          )
                                        ]
                                        more_env: []
                                        do_fork: T
                                      )
                                      (C {<sed>} {<-ne>} {(SQ <'/Content-Length/{s/.*: //;p}'>)})
                                    ]
                                    negated: F
                                    stderr_indices: []
                                  )
                                right: <Id.Backtick_Right '`'>
                              )
                            }
                          spids: [370]
                        )
                      ]
                      redirects: []
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'localsize='> name:localsize)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_Backtick '`'>
                                child: 
                                  (command.Pipeline
                                    children: [
                                      (C {<wc>} {<-c>} {(${ Id.VSub_Name IMAGE_FILE)})
                                      (C {<awk>} {(SQ <'{print $1}'>)})
                                    ]
                                    negated: F
                                    stderr_indices: []
                                  )
                                right: <Id.Backtick_Right '`'>
                              )
                            }
                          spids: [403]
                        )
                      ]
                      redirects: []
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.Sentence
                                  child: 
                                    (C {<Id.Lit_LBracket '['>} 
                                      {
                                        (braced_var_sub
                                          left: <Id.Left_DollarBrace '${'>
                                          token: <Id.VSub_Name remotesize>
                                          var_name: remotesize
                                          prefix_op: <Id.VSub_Pound '#'>
                                          right: <Id.Right_DollarBrace '}'>
                                        )
                                      } {<Id.KW_Bang '!'> <Id.Lit_Equals '='>} 
                                      {
                                        (braced_var_sub
                                          left: <Id.Left_DollarBrace '${'>
                                          token: <Id.VSub_Name localsize>
                                          var_name: localsize
                                          prefix_op: <Id.VSub_Pound '#'>
                                          right: <Id.Right_DollarBrace '}'>
                                        )
                                      } {<Id.Lit_RBracket ']'>}
                                    )
                                  terminator: <Id.Op_Semi _>
                                )
                              ]
                            )
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: 
                                    (sh_lhs_expr.Name
                                      left: <Id.Lit_VarLike 'remotesize='>
                                      name: remotesize
                                    )
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_Backtick '`'>
                                        child: 
                                          (command.Pipeline
                                            children: [
                                              (command.Simple
                                                words: [
                                                  {<wget>}
                                                  {<https> <Id.Lit_Colon ':'> 
                                                    <
'//downloads.raspberrypi.org/raspbian_lite_latest'
                                                    >
                                                  }
                                                  {<--spider>}
                                                  {<--server-response>}
                                                  {<-O>}
                                                  {<->}
                                                ]
                                                redirects: [
                                                  (redir
                                                    op: <Id.Redir_GreatAnd '2>&'>
                                                    loc: (redir_loc.Fd fd:2)
                                                    arg: {<1>}
                                                  )
                                                ]
                                                more_env: []
                                                do_fork: T
                                              )
                                              (C {<sed>} {<-ne>} {(SQ <'/Content-Length/{s/.*: //;p}'>)})
                                            ]
                                            negated: F
                                            stderr_indices: []
                                          )
                                        right: <Id.Backtick_Right '`'>
                                      )
                                    }
                                  spids: [452]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [429 449]
                        )
                      ]
                      else_action: []
                      redirects: []
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.Sentence
                                  child: 
                                    (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName remotesize))} 
                                      {<Id.Lit_Equals '='>} {(DQ ($ Id.VSub_DollarName localsize))} {<Id.Lit_RBracket ']'>}
                                    )
                                  terminator: <Id.Op_Semi _>
                                )
                              ]
                            )
                          action: [
                            (C {<echo>} 
                              {
                                (DQ 
                                  <
---------------------------------------------------------------------------
                                  >
                                )
                              }
                            )
                            (C {<echo>} 
                              {
                                (DQ <'Image file '> (${ Id.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: [489 506]
                        )
                      ]
                      else_action: [
                        (C {<echo>} 
                          {
                            (DQ 
                              <
---------------------------------------------------------------------------
                              >
                            )
                          }
                        )
                        (C {<echo>} {(DQ <'Downloading new version of raspbian image from server...'>)})
                        (C {<wget>} {<-q>} {<--show-progress>} {<-O> (${ Id.VSub_Name IMAGE_FILE)} 
                          {(${ Id.VSub_Name IMAGE_URL)}
                        )
                        (C {<echo>} 
                          {
                            (DQ 
                              <
---------------------------------------------------------------------------
                              >
                            )
                          }
                        )
                      ]
                      redirects: []
                    )
                  ]
                  spids: [350 363]
                )
              ]
              else_action: [
                (C {<echo>} 
                  {(DQ <--------------------------------------------------------------------------->)}
                )
                (C {<echo>} {(DQ <'Downloading raspbian image from server...'>)})
                (C {<wget>} {<-q>} {<--show-progress>} {<-O> (${ Id.VSub_Name IMAGE_FILE)} 
                  {(${ Id.VSub_Name IMAGE_URL)}
                )
                (C {<echo>} 
                  {(DQ <--------------------------------------------------------------------------->)}
                )
              ]
              redirects: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: 
                    (sh_lhs_expr.Name
                      left: <Id.Lit_VarLike 'IMAGE_FILE_UNZIPPED='>
                      name: IMAGE_FILE_UNZIPPED
                    )
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_Backtick '`'>
                        child: (C {<zipinfo>} {<-1>} {(${ Id.VSub_Name IMAGE_FILE)})
                        right: <Id.Backtick_Right '`'>
                      )
                    }
                  spids: [632]
                )
              ]
              redirects: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: 
                    (sh_lhs_expr.Name
                      left: <Id.Lit_VarLike 'IMAGE_FILE_UNZIPPED_SIZE='>
                      name: IMAGE_FILE_UNZIPPED_SIZE
                    )
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_Backtick '`'>
                        child: 
                          (command.Pipeline
                            children: [
                              (C {<zipinfo>} {<-l>} {(${ Id.VSub_Name IMAGE_FILE)})
                              (C {<tail>} {<-1>})
                              (C {<xargs>})
                              (C {<cut>} {<-d> (SQ <' '>)} {<-f3>})
                            ]
                            negated: F
                            stderr_indices: []
                          )
                        right: <Id.Backtick_Right '`'>
                      )
                    }
                  spids: [646]
                )
              ]
              redirects: []
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Pipeline
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-f>} 
                                  {(${ Id.VSub_Name IMAGE_FILE_UNZIPPED)} {<Id.Lit_RBracket ']'>}
                                )
                              ]
                              negated: T
                              stderr_indices: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<echo>} {(DQ <'Unpacking raspbian image...'>)})
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (command.Pipeline
                      children: [
                        (C {<unzip>} {<-o>} {<-p>} {(${ Id.VSub_Name IMAGE_FILE)})
                        (command.Simple
                          words: [
                            {<pv>}
                            {<-p>}
                            {<-s>}
                            {(${ Id.VSub_Name IMAGE_FILE_UNZIPPED_SIZE)}
                            {<-w>}
                            {<80>}
                          ]
                          redirects: [
                            (redir
                              op: <Id.Redir_Great '>'>
                              loc: (redir_loc.Fd fd:1)
                              arg: {(${ Id.VSub_Name IMAGE_FILE_UNZIPPED)}
                            )
                          ]
                          more_env: []
                          do_fork: T
                        )
                      ]
                      negated: F
                      stderr_indices: []
                    )
                  ]
                  spids: [682 697]
                )
              ]
              else_action: []
              redirects: []
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Pipeline
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-f>} 
                                  {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)} {<Id.Lit_RBracket ']'>}
                                )
                              ]
                              negated: T
                              stderr_indices: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<echo>} {(DQ <'Copying a big file...'>)})
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<cp>} {(${ Id.VSub_Name IMAGE_FILE_UNZIPPED)} 
                      {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)}
                    )
                  ]
                  spids: [758 773]
                )
              ]
              else_action: [
                (C {<echo>} 
                  {(DQ <--------------------------------------------------------------------------->)}
                )
                (C {<echo>} 
                  {
                    (DQ <'Skipping creation of '> (${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED) 
                      <', it\'s already there. To re-create, delete it.'>
                    )
                  }
                )
                (C {<echo>} 
                  {(DQ <--------------------------------------------------------------------------->)}
                )
              ]
              redirects: []
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: resize_raw_image
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'IMAGE_SIZE_RAW='> name:IMAGE_SIZE_RAW)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: 
                          (command.Simple
                            words: [{<wc>} {<-c>}]
                            redirects: [
                              (redir
                                op: <Id.Redir_Less '<'>
                                loc: (redir_loc.Fd fd:0)
                                arg: {(DQ (${ Id.VSub_Name IMAGE_FILE_UNZIPPED))}
                              )
                            ]
                            more_env: []
                            do_fork: T
                          )
                        right: <Id.Eof_RParen _>
                      )
                    }
                  spids: [848]
                )
              ]
              redirects: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: 
                    (sh_lhs_expr.Name
                      left: <Id.Lit_VarLike 'IMAGE_SIZE_ACTUAL='>
                      name: IMAGE_SIZE_ACTUAL
                    )
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: 
                          (command.Simple
                            words: [{<wc>} {<-c>}]
                            redirects: [
                              (redir
                                op: <Id.Redir_Less '<'>
                                loc: (redir_loc.Fd fd:0)
                                arg: {(DQ (${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED))}
                              )
                            ]
                            more_env: []
                            do_fork: T
                          )
                        right: <Id.Eof_RParen _>
                      )
                    }
                  spids: [864]
                )
              ]
              redirects: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: 
                    (sh_lhs_expr.Name
                      left: <Id.Lit_VarLike 'IMAGE_ROOTPART_START='>
                      name: IMAGE_ROOTPART_START
                    )
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: 
                          (command.Pipeline
                            children: [
                              (C {<parted>} {(${ Id.VSub_Name IMAGE_FILE_UNZIPPED)} {<unit>} {<s>} 
                                {<print>} {<-sm>}
                              )
                              (C {<tail>} {<-1>})
                              (C {<cut>} {<-d> <Id.Lit_Colon ':'>} {<-f2>})
                              (C {<sed>} {(SQ <'s/s//'>)})
                            ]
                            negated: F
                            stderr_indices: []
                          )
                        right: <Id.Eof_RParen _>
                      )
                    }
                  spids: [880]
                )
              ]
              redirects: []
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {(${ Id.VSub_Name IMAGE_SIZE_ACTUAL)} {<-gt>} 
                              {(${ Id.VSub_Name IMAGE_SIZE_RAW)} {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.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:<Id.ControlFlow_Return return>)
                  ]
                  spids: [921 938]
                )
              ]
              else_action: []
              redirects: []
            )
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Resizing image...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (command.Simple
              words: [
                {<dd>}
                {<Id.Lit_VarLike 'if='> <'/dev/zero'>}
                {<Id.Lit_VarLike 'bs='> <1M>}
                {<Id.Lit_VarLike 'count='> <512>}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_DGreat '>>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)}
                )
              ]
              more_env: []
              do_fork: T
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'PART_NUM='> name:PART_NUM)
                  op: assign_op.Equal
                  rhs: {<2>}
                  spids: [1020]
                )
              ]
              redirects: []
            )
            (command.Simple
              words: [{<fdisk>} {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 1048
                      stdin_parts: [
                        <'p\n'>
                        <'d\n'>
                        ($ Id.VSub_DollarName PART_NUM)
                        <'\n'>
                        <'n\n'>
                        <'p\n'>
                        ($ Id.VSub_DollarName PART_NUM)
                        <'\n'>
                        ($ Id.VSub_DollarName IMAGE_ROOTPART_START)
                        <'\n'>
                        <'\n'>
                        <'p\n'>
                        <'w\n'>
                      ]
                    )
                )
              ]
              more_env: []
              do_fork: T
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: set_up_loopdevs
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.Pipeline
              children: [
                (C {<kpartx>} {<-v>} {<-a>} {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)})
                (C {<tee>} {<'/tmp/kpartx-output.txt'>})
              ]
              negated: F
              stderr_indices: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'LOOPPARTSID='> name:LOOPPARTSID)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_Backtick '`'>
                        child: 
                          (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
                            stderr_indices: []
                          )
                        right: <Id.Backtick_Right '`'>
                      )
                    }
                  spids: [1081]
                )
              ]
              redirects: []
            )
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'The loop device is '> (${ Id.VSub_Name LOOPPARTSID))})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<sync>})
            (C {<sleep>} {<2>})
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Pipeline
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-L>} 
                                  {<'/dev/mapper/'> (${ Id.VSub_Name LOOPPARTSID) <p1>} {<Id.Lit_RBracket ']'>}
                                )
                              ]
                              negated: T
                              stderr_indices: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'                                                                           '
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ <'Couldn\'t find the loopdev partitions at /dev/mapper/'> 
                          (${ Id.VSub_Name LOOPPARTSID) <'p1!'>
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'                                                                           '
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (C {<bail_and_cleanup>} {<'/dev/'> (${ Id.VSub_Name LOOPPARTSID)} 
                      {(${ Id.VSub_Name IMAGE_FILE_CUSTOMIZED)}
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Exit exit>
                      arg_word: {<1>}
                    )
                  ]
                  spids: [1166 1183]
                )
              ]
              else_action: []
              redirects: []
            )
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} 
              {
                (DQ <'Found the loopdev partitions at /dev/mapper/'> (${ Id.VSub_Name LOOPPARTSID) 
                  <'!'>
                )
              }
            )
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'LOOPDEVPARTS='> name:LOOPDEVPARTS)
                  op: assign_op.Equal
                  rhs: {<'/dev/mapper/'> (${ Id.VSub_Name LOOPPARTSID)}
                  spids: [1271]
                )
              ]
              redirects: []
            )
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Check rootfs before resize...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<e2fsck>} {<-f>} {(${ Id.VSub_Name LOOPDEVPARTS) <p2>})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Resize rootfs...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<resize2fs>} {<-p>} {(${ Id.VSub_Name LOOPDEVPARTS) <p2>})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Check rootfs afer resize...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<e2fsck>} {<-f>} {(${ Id.VSub_Name LOOPDEVPARTS) <p2>})
            (C {<mount_chroot_dirs>} {(${ Id.VSub_Name LOOPDEVPARTS)} {(${ Id.VSub_Name LOOPPARTSID)})
            (C {<sed>} {<-i>} {(SQ <'s/^/#CHROOT /g'>)} 
              {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/etc/ld.so.preload'>}
            )
            (C {<cp>} 
              {
                (command_sub
                  left_token: <Id.Left_Backtick '`'>
                  child: (C {<which>} {<qemu-arm-static>})
                  right: <Id.Backtick_Right '`'>
                )
              } {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/usr/bin/'>}
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.DBracket
                              expr: 
                                (bool_expr.Binary
                                  op_id: Id.BoolBinary_ne
                                  left: {(${ Id.VSub_Name DROP_IN)}
                                  right: {<0>}
                                )
                              redirects: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<echo>} {<-e>} {(DQ <'Dropping you in the chroot shell.'>)})
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<chroot>} {(${ Id.VSub_Name TEMP_CHROOT_DIR)} {<'/bin/bash'>})
                  ]
                  spids: [1427 1442]
                )
              ]
              else_action: [
                (command.If
                  arms: [
                    (if_arm
                      cond: 
                        (condition.Shell
                          commands: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Unary
                                      op_id: Id.BoolUnary_n
                                      child: {(DQ (${ Id.VSub_Name CUSTOM_SCRIPT))}
                                    )
                                  redirects: []
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                        )
                      action: [(C {<eval>} {(${ Id.VSub_Name CUSTOM_SCRIPT)})]
                      spids: [1484 1499]
                    )
                  ]
                  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>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/'>})
                      ]
                      negated: F
                      stderr_indices: []
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<echo>} {(DQ <'Copy crankshaft files to root...'>)})
                    (C {<echo>} 
                      {
                        (DQ 
                          <
---------------------------------------------------------------------------
                          >
                        )
                      }
                    )
                    (C {<cp>} {<-a>} {<'crankshaft/.'>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/root/'>})
                    (C {<sync>})
                    (C {<sleep>} {<1>})
                    (C {<chroot>} {(${ Id.VSub_Name TEMP_CHROOT_DIR)} {<'/bin/bash'>} 
                      {<'/root/scripts/customize-image-pi.sh'>}
                    )
                    (C {<chroot>} {(${ Id.VSub_Name TEMP_CHROOT_DIR)} {<'/bin/bash'>} 
                      {<'/root/scripts/read-only-fs.sh'>}
                    )
                  ]
                  redirects: []
                )
              ]
              redirects: []
            )
            (C {<sed>} {<-i>} {(SQ <'s/^#CHROOT //g'>)} 
              {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/etc/ld.so.preload'>}
            )
            (C {<umount_chroot_dirs>})
            (C {<zerofree>} {(${ Id.VSub_Name LOOPDEVPARTS) <p2>})
            (C {<umount_loop_dev>} {<'/dev/'> (${ Id.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 <'###########################################################################'>)}
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: mount_chroot_dirs
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Mounting CHROOT directories'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<mkdir>} {<-p>} {(${ Id.VSub_Name TEMP_CHROOT_DIR)})
            (C {<mount>} {<-o>} {<rw>} {(${ Id.VSub_Number 1) <p2>} {(${ Id.VSub_Name TEMP_CHROOT_DIR)})
            (C {<mount>} {<-o>} {<rw>} {(${ Id.VSub_Number 1) <p1>} 
              {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/boot'>}
            )
            (C {<mount>} {<--bind>} {<'/dev'>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/dev/'>})
            (C {<mount>} {<--bind>} {<'/sys'>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/sys/'>})
            (C {<mount>} {<--bind>} {<'/proc'>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/proc/'>})
            (C {<mount>} {<--bind>} {<'/dev/pts'>} {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/dev/pts'>})
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Pipeline
                              children: [
                                (C {<Id.Lit_LBracket '['>} {<-f>} 
                                  {(${ Id.VSub_Name TEMP_CHROOT_DIR) <'/etc/ld.so.preload'>} {<Id.Lit_RBracket ']'>}
                                )
                              ]
                              negated: T
                              stderr_indices: []
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'                                                                           '
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ <'I didn\'t see '> (${ Id.VSub_Name TEMP_CHROOT_DIR) 
                          <'/etc/ folder. Bailing!'>
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'                                                                           '
                          >
                        )
                      }
                    )
                    (C {<echo>} 
                      {
                        (DQ 
                          <
'###########################################################################'
                          >
                        )
                      }
                    )
                    (C {<umount_chroot_dirs>})
                    (C {<umount_loop_dev>} {($ Id.VSub_Number 2)})
                    (command.ControlFlow
                      token: <Id.ControlFlow_Exit exit>
                      arg_word: {<1>}
                    )
                  ]
                  spids: [1863 1879]
                )
              ]
              else_action: []
              redirects: []
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: umount_chroot_dirs
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Unmount chroot dirs...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<sync>})
            (C {<umount>} 
              (word.BracedTree
                parts: [
                  (${ Id.VSub_Name TEMP_CHROOT_DIR)
                  <'/'>
                  (word_part.BracedTuple
                    words: [{<'dev/pts'>} {<dev>} {<sys>} {<Id.KW_Proc proc>} {<boot>} {}]
                  )
                ]
              )
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name: umount_loop_dev
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (C {<echo>} {(DQ <'Unmount loop devices...'>)})
            (C {<echo>} 
              {(DQ <--------------------------------------------------------------------------->)}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'loopdev='> name:loopdev)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_Backtick '`'>
                        child: 
                          (command.Pipeline
                            children: [
                              (C {<echo>} {($ Id.VSub_Number 1)})
                              (C {<cut>} {<-d> (DQ <'/'>)} {<-f3>})
                            ]
                            negated: F
                            stderr_indices: []
                          )
                        right: <Id.Backtick_Right '`'>
                      )
                    }
                  spids: [2021]
                )
              ]
              redirects: []
            )
            (C {<dmsetup>} {<remove>} {<-f>} {($ Id.VSub_DollarName loopdev) (DQ <p1>)})
            (C {<dmsetup>} {<remove>} {<-f>} {($ Id.VSub_DollarName loopdev) (DQ <p2>)})
            (C {<kpartx>} {<-d>} {($ Id.VSub_Number 1)})
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (C {<check_dependencies>})
    (C {<check_root>})
    (C {<get_unzip_image>})
    (C {<resize_raw_image>})
    (C {<set_up_loopdevs>})
  ]
)