#! /bin/sh # This script takes the result of "make dist" and: # 1) Unpacks it. # 2) Ensures all contents are user-writable. Some version control systems # keep code read-only until you explicitly ask to edit it, and the normal # "make dist" process does not correct for this, so the result is that # the entire dist is still marked read-only when unpacked, which is # annoying. So, we fix it. # 3) Convert MSVC project files to MSVC 2005, so that anyone who has version # 2005 *or* 2008 can open them. (In version control, we keep things in # MSVC 2008 format since that's what we use in development.) # 4) Uses the result to create .tar.gz, .tar.bz2, and .zip versions and # deposites them in the "dist" directory. In the .zip version, all # non-testdata .txt files are converted to Windows-style line endings. # 5) Cleans up after itself. if test $1 == "" { echo "USAGE: $0 DISTFILE" > !2 exit 1 } if test ! -e $1 { echo $1": File not found." > !2 exit 1 } set -ex global LANGUAGES := '"cpp csharp java javanano js objectivec python ruby php'" global BASENAME := $[basename $1 .tar.gz] global VERSION := $(BASENAME:9) # Create a directory called "dist", copy the tarball there and unpack it. mkdir dist cp $1 dist cd dist tar zxvf $BASENAME.tar.gz rm $BASENAME.tar.gz # Set the entire contents to be user-writable. chmod -R u+w $BASENAME cd $BASENAME for LANG in [$LANGUAGES] { # Build the dist again in .tar.gz ./configure DIST_LANG=$LANG make dist-gzip mv $BASENAME.tar.gz ../protobuf-$LANG-$VERSION.tar.gz } # Convert all text files to use DOS-style line endings, then build a .zip # distribution. todos *.txt */*.txt for LANG in [$LANGUAGES] { # Build the dist again in .zip ./configure DIST_LANG=$LANG make dist-zip mv $BASENAME.zip ../protobuf-$LANG-$VERSION.zip } cd .. rm -rf $BASENAME (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=") (Lit_Other "=")} {(DQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ("USAGE: ") ($ VSub_Number "$0") (" DISTFILE"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[75])] ) (C {(exit)} {(1)}) ] spids: [-1 64] ) ] spids: [-1 83] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-e)} {($ VSub_Number "$1")} {(Lit_Other "]")}) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {($ VSub_Number "$1") (DQ (": File not found."))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[109])] ) (C {(exit)} {(1)}) ] spids: [-1 99] ) ] spids: [-1 117] ) (C {(set)} {(-ex)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LANGUAGES) op: Equal rhs: {(DQ ("cpp csharp java javanano js objectivec python ruby php"))} spids: [125] ) ] spids: [125] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BASENAME) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(basename)} {($ VSub_Number "$1")} {(.tar.gz)})] ) left_token: spids: [131 137] ) } spids: [130] ) ] spids: [130] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VERSION) op: Equal rhs: { (BracedVarSub token: suffix_op: (Slice begin:(ArithWord w:{(Lit_Digits 9)})) spids: [140 144] ) } spids: [139] ) ] spids: [139] ) (C {(mkdir)} {(dist)}) (C {(cp)} {($ VSub_Number "$1")} {(dist)}) (C {(cd)} {(dist)}) (C {(tar)} {(zxvf)} {($ VSub_Name "$BASENAME") (.tar.gz)}) (C {(rm)} {($ VSub_Name "$BASENAME") (.tar.gz)}) (C {(chmod)} {(-R)} {(u) (Lit_Other "+") (w)} {($ VSub_Name "$BASENAME")}) (C {(cd)} {($ VSub_Name "$BASENAME")}) (ForEach iter_name: LANG iter_words: [{($ VSub_Name "$LANGUAGES")}] do_arg_iter: False body: (DoGroup children: [ (C {(./configure)} {(Lit_VarLike "DIST_LANG=") ($ VSub_Name "$LANG")}) (C {(make)} {(dist-gzip)}) (C {(mv)} {($ VSub_Name "$BASENAME") (.tar.gz)} {(../protobuf-) ($ VSub_Name "$LANG") (-) ($ VSub_Name "$VERSION") (.tar.gz)} ) ] spids: [204 233] ) spids: [200 202] ) (C {(todos)} {(Lit_Other "*") (.txt)} {(Lit_Other "*") (/) (Lit_Other "*") (.txt)}) (ForEach iter_name: LANG iter_words: [{($ VSub_Name "$LANGUAGES")}] do_arg_iter: False body: (DoGroup children: [ (C {(./configure)} {(Lit_VarLike "DIST_LANG=") ($ VSub_Name "$LANG")}) (C {(make)} {(dist-zip)}) (C {(mv)} {($ VSub_Name "$BASENAME") (.zip)} {(../protobuf-) ($ VSub_Name "$LANG") (-) ($ VSub_Name "$VERSION") (.zip)} ) ] spids: [262 291] ) spids: [258 260] ) (C {(cd)} {(..)}) (C {(rm)} {(-rf)} {($ VSub_Name "$BASENAME")}) ] )