329329
330330# ----- Application Source -----
331331h1 " Step 6: Checking Application Source"
332+ AWS_CODE_DEPLOY_APP_BUNDLE_TYPE=${AWS_CODE_DEPLOY_APP_BUNDLE_TYPE:- zip}
332333APP_SOURCE=$( readlink -f " ${AWS_CODE_DEPLOY_APP_SOURCE:- .} " )
333334
334335if [ ! -d " $APP_SOURCE " -a ! -e " $APP_SOURCE " ]; then
@@ -341,19 +342,35 @@ if [ -d "$APP_SOURCE" ]; then
341342 error " The specified source directory \" ${APP_SOURCE} \" does not contain an \" appspec.yml\" in the application root."
342343 exit 1
343344 fi
344- if ! typeExists " zip" ; then
345- note " Installing zip binaries ..."
346- sudo apt-get install -y zip
347- note " Zip binaries installed."
345+ if [ $AWS_CODE_DEPLOY_APP_BUNDLE_TYPE == " tgz" ]; then
346+ if ! typeExists " tar" -o ! typeExists " gzip" ; then
347+ note " Installing tar and gzip binaries ..."
348+ sudo apt-get install -y tar gzip
349+ note " Tar and GZip binaries installed."
350+ fi
351+ BUNDLE_EXTENSION=" tar.gz"
352+ else # # defaults to zip
353+ if ! typeExists " zip" ; then
354+ note " Installing zip binaries ..."
355+ sudo apt-get install -y zip
356+ note " Zip binaries installed."
357+ fi
358+ BUNDLE_EXTENSION=" zip"
348359 fi
349360 DEPLOYMENT_COMPRESS_ORIG_DIR_SIZE=$( du -hs $APP_SOURCE | awk ' { print $1}' )
350- APP_LOCAL_FILE=" ${AWS_CODE_DEPLOY_S3_FILENAME% .* } .zip "
361+ APP_LOCAL_FILE=" ${AWS_CODE_DEPLOY_S3_FILENAME% .* } .${BUNDLE_EXTENSION} "
351362 APP_LOCAL_TEMP_FILE=" /tmp/$APP_LOCAL_FILE "
352363
353- runCommand " cd \" $APP_SOURCE \" && zip -rq \" ${APP_LOCAL_TEMP_FILE} \" ." \
354- " Unable to compress \" $APP_SOURCE \" "
364+ if [ $AWS_CODE_DEPLOY_APP_BUNDLE_TYPE == " tgz" ]; then
365+ runCommand " tar -zcvf \" ${APP_LOCAL_TEMP_FILE} \" -C \" $APP_SOURCE \" ." \
366+ " Unable to compress \" $APP_SOURCE \" "
367+ BUNDLE_TYPE=" tgz"
368+ else # # defaults to zip
369+ runCommand " cd \" $APP_SOURCE \" && zip -rq \" ${APP_LOCAL_TEMP_FILE} \" ." \
370+ " Unable to compress \" $APP_SOURCE \" "
371+ BUNDLE_TYPE=" zip"
372+ fi
355373 DEPLOYMENT_COMPRESS_FILESIZE=$( ls -lah " ${APP_LOCAL_TEMP_FILE} " | awk ' { print $5}' )
356- BUNDLE_TYPE=" zip"
357374 success " Successfully compressed \" $APP_SOURCE \" ($DEPLOYMENT_COMPRESS_ORIG_DIR_SIZE ) into \" $APP_LOCAL_FILE \" ($DEPLOYMENT_COMPRESS_FILESIZE )"
358375else
359376 APP_SOURCE_BASENAME=$( basename " $APP_SOURCE " )
0 commit comments