-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtgzsample
executable file
·141 lines (112 loc) · 3.11 KB
/
tgzsample
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env bash
##################################################################
#
# TGZs one or all samples
#
##################################################################
APPNAME="tgzsample"
#------------------------------------------------------------------------------
# BASIS
#------------------------------------------------------------------------------
# COLORS
# Sample: echo -e "I ${RED}love${NC} Stack Overflow\n"
#
BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BROWN='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHT_GRAY='\033[0;37m'
DARK_GREY='\033[1;30m'
LIGHT_RED='\033[1;31m'
LIGHT_GREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHT_BLUE='\033[1;34m'
LIGHT_PURPLE='\033[1;35m'
LIGHT_CYAN='\033[1;36m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
LOGFILE="${APPNAME}_`date +"%Y%m%d"`.log"
#MDLSAMPLES="/Volumes/Daten/DevLocal/DevDart/MaterialDesignLiteSite/samples"
MDLSAMPLES="samples"
#------------------------------------------------------------------------------
# Functions
#
genTGZ() {
SAMPLE=$1
SAMPLESFOLDER="${MDLSAMPLES}/${SAMPLE}"
TARGETFOLDER="web/downloads"
# Check if DIR exists
if [ -d "$SAMPLESFOLDER" ];then
echo "Generating ${SAMPLE}.tgz for ${SAMPLESFOLDER}..."
else
echo "${SAMPLESFOLDER} does not exist!!"
exit -1
fi
mv ${SAMPLESFOLDER}/pubspec.yaml ${SAMPLESFOLDER}/pubspec.yaml.tmp
cat ${SAMPLESFOLDER}/pubspec.yaml.tmp | sed "s/mdl:/mdl: ^1.0.0/" | sed "s/^[\t ]*path: .*$//" > ${SAMPLESFOLDER}/pubspec.yaml
tar -czvf ${TARGETFOLDER}/${SAMPLE}.tgz \
--exclude='*packages/*' \
--exclude='build' \
--exclude="*.lock" \
--exclude="*/pubspec.yaml.tmp" \
--exclude="*/.pub/" \
--exclude="*/.sass-cache" \
--exclude="*/.sitegen/refresh*" \
${SAMPLESFOLDER}/
rm -f ${SAMPLESFOLDER}/pubspec.yaml
mv ${SAMPLESFOLDER}/pubspec.yaml.tmp ${SAMPLESFOLDER}/pubspec.yaml
echo
echo "${TARGETFOLDER}/${SAMPLE}.tgz created!"
}
genAll() {
for i in $(ls -d ${MDLSAMPLES}/*/); do
SAMPLE=`echo ${i%%/} | sed "s#${MDLSAMPLES}/##"`
if [[ ${SAMPLE} =~ ^[^_]+ ]];
then
genTGZ ${SAMPLE}
fi
done
}
listSamples() {
for i in $(ls -d ${MDLSAMPLES}/*/); do
SAMPLE=`echo ${i%%/} | sed "s#${MDLSAMPLES}/##"`
if [[ ${SAMPLE} =~ ^[^_]+ ]];
then
echo ${SAMPLE}
fi
done
}
#------------------------------------------------------------------------------
# Options
#
usage() {
echo
echo "Usage: `basename $0` [ options ]"
echo -e "\t--gen <samplename> Generates TGZ for 'samplename'"
echo -e "\t--genall Generates all samples"
echo -e "\t--list List all samples"
echo
}
case "$1" in
help|-help|--help)
usage
;;
gen|-gen|--gen)
genTGZ $2
;;
genall|-genall|--genall)
genAll
;;
list|-list|--list)
listSamples
;;
*)
usage
;;
esac
#------------------------------------------------------------------------------
# Alles OK...
exit 0