-
Notifications
You must be signed in to change notification settings - Fork 3
/
getSources
executable file
·137 lines (124 loc) · 4.58 KB
/
getSources
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
#!/bin/sh
# This script gets sources (Snap!, Snap4Arduino, BeetleBlocks and TurtleStitch) to build Snap!s assignment submission plugins in Moodle
# Sources will be updated (as git submodules) in /sources/'pluguinName' folders with their current master branch version. These sources will be used by 'build' script to build the Snap!s plugins.
# If you don't want to use git features or you want to use other custumizations, you can copy manually any "Snap!" source (any version, any fork) to these folders. Then 'build' script will use those sources.
# Include print_utils
. ./print_utils
print_help() {
echo
echo "Usage: ./getSources [OPTION]"
echo
echo "Where [OPTION] can be:"
echo
echo " --snap to download/update Snap! source"
echo
echo " --snap4arduino to download/update Snap4Arduino source"
echo
echo " --beetleblocks to download/update Beetleblocks source"
echo
echo " --turtlestitch to download/update Turtlestitch source"
echo
echo " --all to download/update all 4 sources"
echo
echo " --help"
echo " (or no options) to show this info"
echo
}
if test $# -eq 0;
then
print_help
exit 0
fi
# parse parameters
while echo $1 | grep ^- > /dev/null; do eval $( echo $1 | sed 's/-//g' | sed 's/=.*//g' | tr -d '\012')=$( echo $1 | sed 's/.*=//g' | tr -d '\012'); shift; done
if test -n "$help"; then
print_help
exit 0
fi
pullSource() {
echo
echo "Pulling $2 sources..."
echo
if ! git submodule deinit -f sources/$1; then
print_error "Could not set up $2 git submodule.\nPlease make sure that you have access to the Internet and git is installed in your system. You can also copy $2 source manually to 'sources/$1/ folder"
exit 1
fi
git submodule update --init --recursive -- sources/$1
print_ok "$2 sources up to date."
}
pullSnapSource() {
pullSource snap Snap!
}
pullSnap4ArduinoSource() {
pullSource snap4arduino Snap4Arduino
echo
echo "Building $2 web-chromium version from sources..."
echo
rm -rf tmp
echo "Fetching Snap! sources..."
if ! cp -R sources/snap4arduino/src/snap tmp; then
print_error "Problems with Snap! sources inside Snap4Arduino. Check this content."
exit 1
fi
echo "Fetching Snap4Arduino examples..."
cp -R sources/snap4arduino/src/Examples/*.xml tmp/Examples
cat sources/snap4arduino/src/Examples/EXAMPLES >> tmp/Examples/EXAMPLES
echo "Fetching Snap4Arduino libraries..."
cp -R sources/snap4arduino/src/libraries/*.xml tmp/libraries
cat sources/snap4arduino/src/libraries/LIBRARIES >> tmp/libraries/LIBRARIES
echo "Fetching Snap4Arduino Costumes..."
cp -R sources/snap4arduino/src/Costumes/*.png tmp/Costumes
cp -R sources/snap4arduino/src/Costumes/*.svg tmp/Costumes
cat sources/snap4arduino/src/Costumes/COSTUMES >> tmp/Costumes/COSTUMES
cat sources/snap4arduino/src/Costumes/COSTUMES >> tmp/Costumes/COSTUMES-full
echo "Fetching Snap4Arduino core..."
if ! cp -R sources/snap4arduino/src/s4a tmp; then
print_error "Could not find Snap4Arduino core. Please make sure a src/s4a exists and contains the Snap4Arduino core files."
exit 1
fi
echo "Fetching platform-specific sources..."
if ! cp -R -L sources/snap4arduino/src/platforms/web/chromium/root/* tmp; then
print_warning "Could not find any platform-specific files for $each."
fi
echo "Fetching assets..."
if ! cp sources/snap4arduino/assets/s4a.ico tmp; then
print_warning "Could not find Snap4Arduino icon."
fi
if ! cp sources/snap4arduino/assets/s4a_logo_sm.png tmp; then
print_warning "Could not find Snap4Arduino logo file."
fi
echo "Fetching version file..."
if ! cp sources/snap4arduino/src/version tmp; then
print_warning "Could not find version file. This may cause the build script to fail further ahead!"
fi
rm -rf sources/snap4arduino/*
rm -f sources/snap4arduino/.* 2>/dev/null
cp -r tmp/* sources/snap4arduino/
rm -rf tmp
print_ok "Snap4Arduino web-chromium version bas been built"
}
pullBeetleBlocksSource() {
pullSource beetleblocks BeetleBlocks
}
pullTurtleStitchSource() {
pullSource turtlestitch TurtleStitch
}
if test -n "$all"; then
pullSnapSource
pullSnap4ArduinoSource
pullBeetleBlocksSource
pullTurtleStitchSource
exit 0
fi
if test -n "$snap"; then
pullSnapSource
fi
if test -n "$snap4arduino"; then
pullSnap4ArduinoSource
fi
if test -n "$beetleblocks"; then
pullBeetleBlocksSource
fi
if test -n "$turtlestitch"; then
pullTurtleStitchSource
fi