(command.CommandList
  children: [
    (C {(KW_Set set)} {(-euo)} {(pipefail)})
    (C {(shopt)} {(-s)} {(extglob)})
    (C {(rm)} {(-rf)} {(bundle)})
    (command.ShFunction
      name: fail
      body: 
        (command.BraceGroup
          children: [
            (command.Simple
              words: [{(echo)} {(DQ ('make-bundle.sh: FAILED at line ') ($ VSub_Number '$1'))}]
              redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
            )
            (C {(rm)} {(-rf)} {(bundle)})
            (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
          ]
        )
    )
    (C {(trap)} {(SQ <'fail ${LINENO}'>)} {(ERR)})
    (command.ShFunction
      name: copyDep
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Lit_VarLike 'FILE=') ($ VSub_Number '$1')})
            (C {(local)} 
              {(Lit_VarLike 'DST=') (bundle) 
                (DQ 
                  (braced_var_sub
                    token: <VSub_Name FILE>
                    suffix_op: 
                      (suffix_op.PatSub
                        pat: 
                          {(word_part.EscapedLiteral token:<Lit_EscapedChar '\\/'>) (usr) 
                            (word_part.EscapedLiteral
                              token: <Lit_EscapedChar '\\/'>
                            ) (local)
                          }
                        replace: {(word_part.EscapedLiteral token:<Lit_EscapedChar '\\/'>) (usr)}
                        replace_mode: Lit_Pound
                      )
                  )
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_LBracket '[')} {(-e)} {(DQ ($ VSub_DollarName '$DST'))} 
                          {(Lit_RBracket ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [(C {(Lit_Other ':')})]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: BoolBinary_GlobDEqual
                              left: {(DQ ($ VSub_DollarName '$FILE'))}
                              right: {(/etc/) (Lit_Other '*')}
                            )
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {(Lit_LBracket '[')} {(-f)} {(DQ ($ VSub_DollarName '$FILE'))} 
                                  {(Lit_RBracket ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (command.Simple
                              words: [{(echo)} {(DQ ($ VSub_DollarName '$FILE'))}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_DGreat '>>'>
                                  fd: 16777215
                                  arg_word: {(tmp/host.list)}
                                )
                              ]
                            )
                          ]
                        )
                      ]
                    )
                  ]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_LBracket '[')} {(-h)} {(DQ ($ VSub_DollarName '$FILE'))} 
                          {(Lit_RBracket ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(mkdir)} {(-p)} 
                      {
                        (command_sub
                          left_token: <Left_DollarParen '$('>
                          command_list: 
                            (command.CommandList
                              children: [(C {(dirname)} {(DQ ($ VSub_DollarName '$DST'))})]
                            )
                        )
                      }
                    )
                    (C {(local)} 
                      {(Lit_VarLike 'LINK=') 
                        (command_sub
                          left_token: <Left_DollarParen '$('>
                          command_list: 
                            (command.CommandList
                              children: [(C {(readlink)} {(-f)} {(DQ ($ VSub_DollarName '$FILE'))})]
                            )
                        )
                      }
                    )
                    (C {(ln)} {(-sf)} 
                      {
                        (DQ 
                          (braced_var_sub
                            token: <VSub_Name LINK>
                            suffix_op: 
                              (suffix_op.PatSub
                                pat: 
                                  {(word_part.EscapedLiteral token:<Lit_EscapedChar '\\/'>) (usr) 
                                    (word_part.EscapedLiteral
                                      token: <Lit_EscapedChar '\\/'>
                                    ) (local)
                                  }
                                replace: 
                                  {(word_part.EscapedLiteral token:<Lit_EscapedChar '\\/'>) (usr)}
                                replace_mode: Lit_Pound
                              )
                          )
                        )
                      } {(DQ ($ VSub_DollarName '$DST'))}
                    )
                    (C {(copyDep)} {(DQ ($ VSub_DollarName '$LINK'))})
                  ]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_LBracket '[')} {(-d)} {(DQ ($ VSub_DollarName '$FILE'))} 
                          {(Lit_RBracket ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [(C {(mkdir)} {(-p)} {(DQ ($ VSub_DollarName '$DST'))})]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Lit_LBracket '[')} {(-f)} {(DQ ($ VSub_DollarName '$FILE'))} 
                          {(Lit_RBracket ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(mkdir)} {(-p)} 
                      {
                        (command_sub
                          left_token: <Left_DollarParen '$('>
                          command_list: 
                            (command.CommandList
                              children: [(C {(dirname)} {(DQ ($ VSub_DollarName '$DST'))})]
                            )
                        )
                      }
                    )
                    (C {(cp)} {(DQ ($ VSub_DollarName '$FILE'))} {(DQ ($ VSub_DollarName '$DST'))})
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: copyDeps
      body: 
        (command.BraceGroup
          children: [
            (command.WhileUntil
              keyword: <KW_While while>
              cond: [(command.Sentence child:(C {(read)} {(FILE)}) terminator:<Op_Semi ';'>)]
              body: (command.DoGroup children:[(C {(copyDep)} {(DQ ($ VSub_DollarName '$FILE'))})])
            )
          ]
        )
    )
    (command.ForEach
      iter_name: CMD
      iter_words: [{(zip)} {(unzip)} {(xz)} {(gpg)}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (command.Simple
                              words: [{(which)} {(DQ ($ VSub_DollarName '$CMD'))}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(/dev/null)}
                                )
                              ]
                            )
                          ]
                          negated: T
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [{(echo)} {(DQ ('Please install ') ($ VSub_DollarName '$CMD'))}]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (C {(fail)} {(${ VSub_Name LINENO)})
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:METEOR_DEV_BUNDLE)
          op: Equal
          rhs: 
            {
              (command_sub
                left_token: <Left_DollarParen '$('>
                command_list: (command.CommandList children:[(C {(./find-meteor-dev-bundle.sh)})])
              )
            }
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:NODE_BUILD_ROOT)
          op: Equal
          rhs: {(/var/tmp/sandstorm-node-build-dir)}
        )
      ]
    )
    (C {(echo)} {(DQ ('Building node out-of-tree'))})
    (C {(rm)} {(-rf)} {(DQ ($ VSub_DollarName '$NODE_BUILD_ROOT'))})
    (C {(mkdir)} {(-p)} {(DQ ($ VSub_DollarName '$NODE_BUILD_ROOT'))})
    (C {(cp)} {(-a)} {(deps/node)} {(DQ ($ VSub_DollarName '$NODE_BUILD_ROOT'))})
    (C {(pushd)} {(DQ ($ VSub_DollarName '$NODE_BUILD_ROOT') (/node))})
    (C {(./configure)} {(--partly-static)})
    (C {(make)} 
      {(-j) 
        (command_sub
          left_token: <Left_DollarParen '$('>
          command_list: (command.CommandList children:[(C {(nproc)})])
        )
      }
    )
    (C {(popd)})
    (C {(mkdir)} {(-p)} {(deps/node/out)})
    (C {(rm)} {(-rf)} {(deps/node/out/) (Lit_Star '*')})
    (C {(mv)} {(DQ ($ VSub_DollarName '$NODE_BUILD_ROOT') (/node/out)) (/) (Lit_Star '*')} 
      {(deps/node/out/)}
    )
    (C {(cp)} {(-r)} {(shell-build/bundle)} {(bundle)})
    (C {(rm)} {(-f)} {(bundle/README)})
    (C {(cp)} {(meteor-bundle-main.js)} {(bundle/sandstorm-main.js)})
    (command.Subshell
      command_list: 
        (command.CommandList
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(cd)} {(bundle/programs/server)})
                (command.Simple
                  words: [{(DQ ($ VSub_DollarName '$METEOR_DEV_BUNDLE') (/bin/npm))} {(install)}]
                  more_env: [
                    (env_pair
                      name: PATH
                      val: 
                        {($ VSub_DollarName '$PWD') (/deps/node/out/Release) (Lit_Other ':') 
                          ($ VSub_DollarName '$METEOR_DEV_BUNDLE') (/lib/node_modules/.bin) (Lit_Other ':') ($ VSub_DollarName '$METEOR_DEV_BUNDLE') (/bin) (Lit_Other ':') 
                          ($ VSub_DollarName '$PATH')
                        }
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (C {(mkdir)} {(-p)} {(bundle/bin)})
    (C {(cp)} {(bin/sandstorm-http-bridge)} {(bundle/bin/sandstorm-http-bridge)})
    (C {(cp)} {(bin/sandstorm)} {(bundle/sandstorm)})
    (C {(cp)} {(deps/node/out/Release/node)} {(bundle/bin)})
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:OLD_BUNDLE_BASE) op:Equal rhs:{(sandstorm-171)})]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OLD_BUNDLE_FILENAME)
          op: Equal
          rhs: {($ VSub_DollarName '$OLD_BUNDLE_BASE') (.tar.xz)}
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OLD_BUNDLE_PATH)
          op: Equal
          rhs: {(hack/) ($ VSub_DollarName '$OLD_BUNDLE_FILENAME')}
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OLD_BUNDLE_SHA256)
          op: Equal
          rhs: {(ebffd643dffeba349f139bee34e4ce33fd9b1298fafc1d6a31eb35a191059a99)}
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OLD_MONGO_FILES)
          op: Equal
          rhs: 
            {
              (DQ ($ VSub_DollarName '$OLD_BUNDLE_BASE') ('/bin/mongo ') 
                ($ VSub_DollarName '$OLD_BUNDLE_BASE') (/bin/mongod)
              )
            }
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Lit_LBracket '[')} {(KW_Bang '!')} {(-e)} 
                  {(DQ ($ VSub_DollarName '$OLD_BUNDLE_PATH'))} {(Lit_RBracket ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (C {(echo)} 
              {
                (DQ ('Fetching ') ($ VSub_DollarName '$OLD_BUNDLE_FILENAME') 
                  (' to extract a mongo 2.6...')
                )
              }
            )
            (C {(curl)} {(--output)} {(DQ ($ VSub_DollarName '$OLD_BUNDLE_PATH'))} 
              {(https) (Lit_Other ':') (//dl.sandstorm.io/) ($ VSub_DollarName '$OLD_BUNDLE_FILENAME')}
            )
          ]
        )
      ]
    )
    (command.Simple
      words: [{(sha256sum)} {(--check)}]
      redirects: [
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 816
          stdin_parts: [
            ($ VSub_DollarName '$OLD_BUNDLE_SHA256')
            ('  ')
            ($ VSub_DollarName '$OLD_BUNDLE_PATH')
            ('\n')
          ]
        )
      ]
    )
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:rc) op:Equal rhs:{($ VSub_QMark '$?')})]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Lit_LBracket '[')} {($ VSub_DollarName '$rc')} {(-ne)} {(0)} {(Lit_RBracket ']')})
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (C {(echo)} {(DQ ('Old bundle did not match expected checksum.  Aborting.'))})
            (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
          ]
        )
      ]
    )
    (C {(tar)} {(xf)} {($ VSub_DollarName '$OLD_BUNDLE_PATH')} 
      {(--transform) (Lit_Equals '=') (s/) (Lit_Other '^') (${ VSub_Name OLD_BUNDLE_BASE) (/bundle/)} {($ VSub_DollarName '$OLD_MONGO_FILES')}
    )
    (C {(cp)} 
      {
        (command_sub
          left_token: <Left_DollarParen '$('>
          command_list: 
            (command.CommandList
              children: [(C {(which)} {(zip)} {(unzip)} {(xz)} {(gpg)})]
            )
        )
      } {(bundle/bin)}
    )
    (C {(ln)} {(-s)} {(../sandstorm)} {(bundle/bin/spk)})
    (C {(chmod)} {(u) (Lit_Other '+') (w)} {(bundle/bin/) (Lit_Star '*')})
    (C {(mkdir)} {(-p)} 
      (word.BracedTree
        parts: [(bundle/usr/include/) (word_part.BracedTuple words:[{(capnp)} {(sandstorm)}])]
      )
    )
    (C {(cp)} 
      {(src/capnp/) 
        (word_part.ExtGlob
          op: <ExtGlob_Bang '!('>
          arms: [{(Lit_Other '*') (test) (Lit_Other '*')}]
        ) (.capnp)
      } {(bundle/usr/include/capnp)}
    )
    (C {(cp)} {(src/sandstorm/) (Lit_Star '*') (.capnp)} {(bundle/usr/include/sandstorm)})
    (C {(cp)} {(-r)} {(node_modules)} {(bundle)})
    (command.Pipeline
      children: [
        (command.Subshell
          command_list: 
            (command.CommandList
              children: [
                (command.AndOr
                  ops: [Op_DPipe]
                  children: [
                    (C {(ldd)} {(bundle/bin/) (Lit_Star '*')} 
                      {
                        (command_sub
                          left_token: <Left_DollarParen '$('>
                          command_list: 
                            (command.CommandList
                              children: [(C {(find)} {(bundle)} {(-name)} {(SQ <'*.node'>)})]
                            )
                        )
                      }
                    )
                    (C {(true)})
                  ]
                )
              ]
            )
        )
        (C {(grep)} {(-o)} {(SQ <'[[:space:]]/[^ ]*'>)})
        (C {(copyDeps)})
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(tmp/dnstest.c)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(SQ <__EOF__>)}
          here_end_span_id: 1044
          stdin_parts: [
            ('#include <sys/types.h>\n')
            ('#include <sys/socket.h>\n')
            ('#include <netdb.h>\n')
            ('#include <stdlib.h>\n')
            ('\n')
            ('int main() {\n')
            ('  struct addrinfo* result;\n')
            ('  getaddrinfo("example.com", "http", NULL, &result);\n')
            ('  return 0;\n')
            ('}\n')
          ]
        )
      ]
    )
    (C {(gcc)} {(tmp/dnstest.c)} {(-o)} {(tmp/dnstest)})
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(strace)} {(tmp/dnstest)}]
          redirects: [(redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})]
        )
        (C {(grep)} {(-o)} {(SQ <'"/[^"]*"'>)})
        (C {(tr)} {(-d)} {(SQ <'"'>)})
        (C {(copyDeps)})
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(tmp/host.list)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(SQ <__EOF__>)}
          here_end_span_id: 1122
          stdin_parts: [
            ('/etc/gai.conf\n')
            ('/etc/host.conf\n')
            ('/etc/hosts\n')
            ('/etc/nsswitch.conf\n')
            ('/etc/resolvconf\n')
            ('/etc/resolv.conf\n')
            ('/etc/services\n')
            ('/run/resolvconf\n')
            ('/run/systemd/resolve/resolv.conf\n')
          ]
        )
      ]
    )
    (command.Pipeline
      children: [
        (C {(cat)} {(tmp/host.list)})
        (C {(grep)} {(-v)} {(SQ <'/ld[.]so[.]'>)})
        (C {(sort)})
        (command.Simple
          words: [{(uniq)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(bundle/host.list)})]
        )
      ]
      negated: F
    )
    (C {(mkdir)} {(-p)} 
      (word.BracedTree
        parts: [
          (bundle/)
          (word_part.BracedTuple
            words: [{(dev)} {(KW_Proc proc)} {(tmp)} {(etc)} {(etc.host)} {(run)} {(run.host)} {(KW_Var var)}]
          )
        ]
      )
    )
    (C {(touch)} 
      (word.BracedTree
        parts: [
          (bundle/dev/)
          (word_part.BracedTuple words:[{(null)} {(zero)} {(random)} {(urandom)} {(fuse)}])
        ]
      )
    )
    (C {(mkdir)} {(-p)} {(bundle/usr/lib/locale)})
    (C {(localedef)} {(--no-archive)} {(--inputfile) (Lit_Equals '=') (./localedata-C)} 
      {(--charmap) (Lit_Equals '=') (UTF-8)} {(bundle/usr/lib/locale/C.UTF-8)}
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: (C {(Lit_LBracket '[')} {(-e)} {(.git)} {(Lit_RBracket ']')})
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (command.Simple
              words: [{(git)} {(rev-parse)} {(HEAD)}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(bundle/git-revision)}
                )
              ]
            )
          ]
        )
      ]
      else_action: [
        (command.Simple
          words: [{(echo)} {(DQ (unknown))}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(bundle/git-revision)})]
        )
      ]
    )
    (command.Simple
      words: [
        {(echo)}
        {
          (DQ ($ VSub_DollarName '$USER') ('@') ($ VSub_DollarName '$HOSTNAME') (' ') 
            (command_sub
              left_token: <Left_DollarParen '$('>
              command_list: (command.CommandList children:[(C {(date)})])
            )
          )
        }
      ]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(bundle/buildstamp)})]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(bundle/README.md)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(SQ <__EOF__>)}
          here_end_span_id: 1316
          stdin_parts: [
            ('# Sandstorm Bundle\n')
            ('\n')
            ('See: http://sandstorm.io\n')
            ('\n')
            ('This is a self-contained, batteries-included Sandstorm server. It should\n')
            ('work on any Linux kernel whose version is 3.13 or newer. The rest of your\n')
            ('filesystem is not touched and may as well be empty; everything will run in\n')
            ('a chroot.\n')
            ('\n')
            ('This bundle is intended to be installed using the Sandstorm installer or\n')
            ('updater. To install Sandstorm, please run:\n')
            ('\n')
            ('    curl https://install.sandstorm.io | bash\n')
            ('\n')
            ('If you have already installed Sandstorm, you can update your installation to\n')
            ('this version by running:\n')
            ('\n')
            ('    service sandstorm update <filename>.tar.xz\n')
          ]
        )
      ]
    )
  ]
)