Created
September 19, 2012 06:15
-
-
Save wangshijun/3747978 to your computer and use it in GitHub Desktop.
shell: build application with tar, ignore certain patterns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| TMP_DIR="output" | |
| PRODUCT_DIR="project-production" | |
| IGNORE_FILE="$TMP_DIR build.sh tests" | |
| OUTPUT_FILE="project-production.tar.gz" | |
| # prepare tmp dir | |
| mkdir -p $TMP_DIR | |
| rm -rf $TMP_DIR/* | |
| mkdir -p $TMP_DIR/$PRODUCT_DIR | |
| # copy from source to tmp, ignore some files | |
| for i in `ls` | |
| do | |
| boolUse=1 | |
| for j in $IGNORE_FILE | |
| do | |
| if [ $j == $i ] | |
| then | |
| boolUse=0 | |
| break | |
| fi | |
| done | |
| if [ $boolUse == 1 ] | |
| then | |
| cp -r $i $TMP_DIR/$PRODUCT_DIR/ | |
| echo $i | |
| fi | |
| done | |
| cd $TMP_DIR | |
| # remove version control misc | |
| find ./ -name CVS -exec rm -rf {} \; | |
| find ./ -type d -name ".svn"|xargs rm -rf {} | |
| find ./ -type d -name ".git"|xargs rm -rf {} | |
| tar zcvf $OUTPUT_FILE $PRODUCT_DIR/* | |
| rm -rf $PRODUCT_DIR | |
| cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment