(command.CommandList children: [ (C {<set>} {<-e>}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [{<command>} {<-v>} {<qemu-nbd>}] redirects: [ (redir op: <Id.Redir_AndGreat '&>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) ] do_fork: T ) ] negated: T ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [{<echo>} {(SQ <'error: "qemu-nbd" not found!'>)}] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [8 23] ) ] ) (command.ShFunction name: usage body: (BraceGroup children: [ (C {<echo>} {(DQ <'Convert disk image to docker image'>)}) (C {<echo>} {(DQ )}) (C {<echo>} { (DQ <'usage: '> ($ Id.VSub_Number '$0') <' image-name disk-image-file [ base-image ]'>) } ) (C {<echo>} { (DQ <' ie: '> ($ Id.VSub_Number '$0') <' cirros:0.3.3 cirros-0.3.3-x86_64-disk.img'>) } ) (C {<echo>} { (DQ <' '> ($ Id.VSub_Number '$0') <' ubuntu:cloud ubuntu-14.04-server-cloudimg-amd64-disk1.img ubuntu:14.04'> ) } ) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Pound '$#'))} {<-lt>} {<2>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})] spids: [92 107] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:CURDIR) op: assign_op.Equal rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>}))} spids: [120] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_name) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok: <Id.VOp1_Percent '%'> arg_word: {<':'> <Id.Lit_Other '*'>} ) ) ) } spids: [126] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_tag) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok: <Id.VOp1_Pound '#'> arg_word: {<Id.Lit_Other '*'> <':'>} ) ) ) } spids: [136] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$image_tag'))} {<Id.Lit_Equals '='> <Id.Lit_Equals '='>} {(DQ ($ Id.VSub_Number '$1'))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_tag) op: assign_op.Equal rhs: {(DQ <latest>)} spids: [167] ) ] ) ] spids: [146 164] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:disk_image_file) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$2'))} spids: [175] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:docker_base_image) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$3'))} spids: [180] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:block_device) op: assign_op.Equal rhs: {<'/dev/nbd0'>} spids: [186] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:builddir) op: assign_op.Equal rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<mktemp>} {<-d>}))} spids: [190] ) ] ) (command.ShFunction name: cleanup body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<umount>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/disk_image'>)}) (C {<true>}) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<umount>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/workdir'>)}) (C {<true>}) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (command.Simple words: [{<qemu-nbd>} {<-d>} {($ Id.VSub_DollarName '$block_device')}] redirects: [ (redir op: <Id.Redir_AndGreat '&>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) ] do_fork: T ) (C {<true>}) ] ) (C {<rm>} {<-rf>} {($ Id.VSub_DollarName '$builddir')}) ] ) ) (C {<trap>} {<cleanup>} {<EXIT>}) (C {<modprobe>} {<nbd>} {<Id.Lit_VarLike 'max_part='> <63>}) (C {<qemu-nbd>} {<-rc>} {(${ Id.VSub_Name block_device)} {<-P>} {<1>} {(DQ ($ Id.VSub_DollarName '$disk_image_file'))} ) (C {<mkdir>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/disk_image'>)}) (C {<mount>} {<-o>} {<ro>} {(${ Id.VSub_Name block_device)} {(DQ ($ Id.VSub_DollarName '$builddir') <'/disk_image'>)} ) (C {<mkdir>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/workdir'>)}) (C {<mkdir>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/diff'>)}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:base_image_mounts) op: assign_op.Equal rhs: {(DQ )} spids: [323] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<mkdir>} {<-p>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/base'>)}) (C {<docker>} {<pull>} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))}) (command.Pipeline children: [ (C {<docker>} {<save>} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))}) (C {<tar>} {<-xC>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/base'>)}) ] negated: F ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_id) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<docker>} {<inspect>} {<-f>} {(DQ <'{{.Id}}'>)} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))} ) ) } spids: [387] ) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ ($ Id.VSub_DollarName '$image_id'))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) body: (command.DoGroup children: [ (C {<mkdir>} {<-p>} { (DQ ($ Id.VSub_DollarName '$builddir') <'/base/'> ($ Id.VSub_DollarName '$image_id') <'/layer'> ) } ) (C {<tar>} {<-xf>} { (DQ ($ Id.VSub_DollarName '$builddir') <'/base/'> ($ Id.VSub_DollarName '$image_id') <'/layer.tar'> ) } {<-C>} { (DQ ($ Id.VSub_DollarName '$builddir') <'/base/'> ($ Id.VSub_DollarName '$image_id') <'/layer'> ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:base_image_mounts) op: assign_op.Equal rhs: { (DQ (${ Id.VSub_Name base_image_mounts) <':'> ($ Id.VSub_DollarName '$builddir') <'/base/'> ($ Id.VSub_DollarName '$image_id') <'/layer=ro+wh'> ) } spids: [455] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_id) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<docker>} {<inspect>} {<-f>} {(DQ <'{{.Parent}}'>)} {(DQ ($ Id.VSub_DollarName '$image_id'))} ) ) } spids: [468] ) ] ) ] ) ) ] spids: [331 344] ) ] ) (C {<mount>} {<-t>} {<aufs>} {<-o>} { (DQ <'br='> ($ Id.VSub_DollarName '$builddir') <'/diff=rw'> (${ Id.VSub_Name base_image_mounts) <',dio,xino=/dev/shm/aufs.xino'> ) } {<none>} {(DQ ($ Id.VSub_DollarName '$builddir') <'/workdir'>)} ) (C {<cd>} {($ Id.VSub_DollarName '$builddir')}) (command.Pipeline children: [ (command.Simple words: [{<diff>} {<-rq>} {<disk_image>} {<workdir>}] more_env: [(env_pair name:LC_ALL val:{<C>} spids:[527])] do_fork: T ) (C {<sed>} {<-re>} { (DQ <'s|Only in workdir(.*?): |DEL '> <Id.Lit_BadBackslash '\\'> <'1/|g;s|Only in disk_image(.*?): |ADD '> <Id.Lit_BadBackslash '\\'> <'1/|g;s|Files disk_image/(.+) and workdir/(.+) differ|UPDATE /'> <Id.Lit_BadBackslash '\\'> <'1|g'> ) } ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands: [ (command.Sentence child: (C {<read>} {<action>} {<entry>}) terminator: <Id.Op_Semi _> ) ] ) body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$action'))} arms: [ (case_arm pat_list: [{<ADD>} {<UPDATE>}] action: [ (C {<cp>} {<-a>} {(DQ <disk_image> ($ Id.VSub_DollarName '$entry'))} {(DQ <workdir> ($ Id.VSub_DollarName '$entry'))} ) ] spids: [581 584 602 -1] ) (case_arm pat_list: [{<DEL>}] action: [(C {<rm>} {<-rf>} {(DQ <workdir> ($ Id.VSub_DollarName '$entry'))})] spids: [605 606 619 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.Simple words: [ {<echo>} { (DQ <'Error: unknown diff line: '> ($ Id.VSub_DollarName '$action') <' '> ($ Id.VSub_DollarName '$entry') ) } ] redirects: [ (redir op: <Id.Redir_GreatAnd '>&'> loc: (redir_loc.Fd fd:1) arg: {<2>} ) ] do_fork: T ) ] spids: [622 623 639 -1] ) ] ) ] ) ) ] negated: F ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:new_image_id) op: assign_op.Equal rhs: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.ForEach iter_name: i iter_words: [ { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<seq>} {<1>} {<32>}) ) } ] do_arg_iter: F body: (command.DoGroup children: [ (command.Sentence child: (C {<printf>} {(DQ <'%02x'>)} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Percent left: {($ Id.VSub_DollarName '$RANDOM')} right: {<Id.Lit_Digits 256>} ) ) } ) terminator: <Id.Op_Semi _> ) ] ) ) ) ) } spids: [651] ) ] ) (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id')} ) (C {<cd>} {<diff>}) (C {<tar>} {<-cf>} {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id') <'/layer.tar'> } {<Id.Lit_Star '*'>} ) (command.Simple words: [{<echo>} {(DQ <1.0>)}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id') <'/VERSION'> } ) ] do_fork: T ) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id') <'/json'> } ) (redir op: <Id.Redir_DLessDash '<<-'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOS>} here_end_span_id: 789 stdin_parts: [ <'{ '> <Id.Right_DoubleQuote '"'> <docker_version> <Id.Right_DoubleQuote '"'> <': '> <Id.Right_DoubleQuote '"'> <1.4.1> <Id.Right_DoubleQuote '"'> <'\n'> <', '> <Id.Right_DoubleQuote '"'> <id> <Id.Right_DoubleQuote '"'> <': '> <Id.Right_DoubleQuote '"'> ($ Id.VSub_DollarName '$new_image_id') <Id.Right_DoubleQuote '"'> <'\n'> <', '> <Id.Right_DoubleQuote '"'> <created> <Id.Right_DoubleQuote '"'> <': '> <Id.Right_DoubleQuote '"'> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<date>} {<-u>} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <Y-> <Id.Lit_Other '%'> <m-> <Id.Lit_Other '%'> <dT> <Id.Lit_Other '%'> <H> <Id.Lit_Colon ':'> <Id.Lit_Other '%'> <M> <Id.Lit_Colon ':'> <Id.Lit_Other '%'> <S.> <Id.Lit_Other '%'> <NZ> } ) ) <Id.Right_DoubleQuote '"'> <'\n'> ] ) ) ] do_fork: T ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:image_id) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<docker>} {<inspect>} {<-f>} {(DQ <'{{.Id}}'>)} {(DQ ($ Id.VSub_DollarName '$docker_base_image'))} ) ) } spids: [807] ) ] ) (command.Simple words: [ {<echo>} { (DQ <', '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <parent> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <': '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) ($ Id.VSub_DollarName '$image_id') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) ) } ] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id') <'/json'> } ) ] do_fork: T ) ] spids: [791 804] ) ] ) (command.Simple words: [{<echo>} {(DQ <'}'>)}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$builddir') <'/result/'> ($ Id.VSub_DollarName '$new_image_id') <'/json'> } ) ] do_fork: T ) (command.Simple words: [ {<echo>} { (DQ <'{'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) ($ Id.VSub_DollarName '$image_name') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <':{'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) ($ Id.VSub_DollarName '$image_tag') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <':'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) ($ Id.VSub_DollarName '$new_image_id') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <'}}'> ) } ] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {($ Id.VSub_DollarName '$builddir') <'/result/repositories'>} ) ] do_fork: T ) (C {<cd>} {($ Id.VSub_DollarName '$builddir') <'/result'>}) (command.Pipeline children: [(C {<tar>} {<-c>} {<Id.Lit_Star '*'>}) (C {<docker>} {<load>})] negated: F ) ] )