329
329
330
330
# ----- Application Source -----
331
331
h1 " Step 6: Checking Application Source"
332
+ AWS_CODE_DEPLOY_APP_BUNDLE_TYPE=${AWS_CODE_DEPLOY_APP_BUNDLE_TYPE:- zip}
332
333
APP_SOURCE=$( readlink -f " ${AWS_CODE_DEPLOY_APP_SOURCE:- .} " )
333
334
334
335
if [ ! -d " $APP_SOURCE " -a ! -e " $APP_SOURCE " ]; then
@@ -341,19 +342,35 @@ if [ -d "$APP_SOURCE" ]; then
341
342
error " The specified source directory \" ${APP_SOURCE} \" does not contain an \" appspec.yml\" in the application root."
342
343
exit 1
343
344
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"
348
359
fi
349
360
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} "
351
362
APP_LOCAL_TEMP_FILE=" /tmp/$APP_LOCAL_FILE "
352
363
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
355
373
DEPLOYMENT_COMPRESS_FILESIZE=$( ls -lah " ${APP_LOCAL_TEMP_FILE} " | awk ' { print $5}' )
356
- BUNDLE_TYPE=" zip"
357
374
success " Successfully compressed \" $APP_SOURCE \" ($DEPLOYMENT_COMPRESS_ORIG_DIR_SIZE ) into \" $APP_LOCAL_FILE \" ($DEPLOYMENT_COMPRESS_FILESIZE )"
358
375
else
359
376
APP_SOURCE_BASENAME=$( basename " $APP_SOURCE " )
0 commit comments