-
Notifications
You must be signed in to change notification settings - Fork 9
/
distribution.sh
executable file
·106 lines (78 loc) · 2.29 KB
/
distribution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
echo $0
[ "$(dirname $0)" == '.' ] || {
echo
echo Please run only from the directory where the script lives
echo
exit 1
}
declare fullPath=$(pwd)
declare sourceDir=$(basename $fullPath)
declare excludeListFile=zip-exclude.txt
set -u
# do not get files ignored by git
while read item
do
if [[ $item =~ \/$ ]]; then
item="$item"'*'
fi
# skip if just single '?' or double '??'
# this is used to skip single/double letter files in git, but will translate to the directories '.' and '..' here
[[ $item == '?' ]] && { continue; }
[[ $item == '??' ]] && { continue; }
# expand the '?' git wildcard if necessary
if [[ $item =~ '?' ]]; then
echo "Exanding git wildcards to full file names" >&2
echo " for this expression: $item" >&2
for foundFile in $( find . -name "$item" )
do
echo "Exclude: $sourceDir/$foundFile" >&2
# the pattern must be exact for zip
# bash will resolve dir/./dir/file, but zip will not
echo "$sourceDir/$foundFile" | sed -e 's#/\./#/#g'
done
else
echo "$sourceDir/$item"
fi
done < <(grep -vE "^\s*$|^\s*#" .gitignore ) > $excludeListFile
echo $excludeListFile
# do not include untracked files
while read untracked
do
echo -n "$sourceDir/$untracked"
if [[ $untracked =~ \/$ ]]; then
echo '*'
else
echo ''
fi
done < <(git status -s --porcelain | cut -f2 -d' ' ) >> $excludeListFile
# do not include working files that are frequently a single letter
for item in $(find . -name "?" -type f)
do
echo "$sourceDir/$item" | sed -e 's#/\./#/#g'
done >> $excludeListFile
# exclude a few others
for exItem in afiedt.buf sqlnet.log
do
for item in $(find . -name "$exItem" -type f)
do
echo "$sourceDir/$item" | sed -e 's#/\./#/#g'
done >> $excludeListFile
done
# do not get .git
echo "$sourceDir/.git/*" >> $excludeListFile
echo "$sourceDir/$excludeListFile" >> $excludeListFile
echo Exclude File: $excludeListFile
cd ..
declare zipFile=asm-metrics.zip
rm -f $zipFile
echo "zip --symlinks -r $zipFile $sourceDir --exclude @$sourceDir/$excludeListFile"
#exit
zip --symlinks -r $zipFile $sourceDir --exclude @$sourceDir/$excludeListFile
engagementToolsDir='/mnt/zips/tmp/pythian/oracle-engagement-tools'
cp $zipFile $engagementToolsDir
echo
echo "zip file locations"
echo
ls -ld $(pwd)/$zipFile
ls -ld $engagementToolsDir/$zipFile