-
Notifications
You must be signed in to change notification settings - Fork 38
/
catchup.sh
executable file
·455 lines (407 loc) · 12.6 KB
/
catchup.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
#!/bin/bash
curdir=$(pwd)
RED='\033[0;51;30m'
STD='\033[0;0;39m'
consumer() {
echo "performing Exercise 1 (consumer, with CMake)"
cd consumer
#sed -i 's/booost/boost/g' conanfile.txt
rm -rf build
mkdir -p build
cd build
conan install ..
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cd bin
./timer
conan search
conan search zlib/1.2.13@
}
consumer_debug() {
echo "performing Exercise 2 (consumer, with build_type Debug)"
cd consumer
rm -rf build
mkdir -p build
cd build
conan install .. -s build_type=Debug
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build .
cd bin
./timer
conan search
conan search zlib/1.2.13@
}
consumer_gcc() {
echo "performing Exercise 3 (consumer, with GCC)"
cd consumer_gcc
conan install . -g compiler_args
g++ timer.cpp @conanbuildinfo.args -o timer --std=c++11
./timer
}
consumer_cmake_find() {
echo "performing Exercise 4 (consumer, with cmake_find_package)"
cd consumer_cmake_find
#sed -i 's/cmake_find_pakcage/cmake_find_package/g' conanfile.txt
rm -rf build
mkdir -p build
cd build
conan install ..
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
./timer
}
create() {
echo "performing Exercise 5 (Create a Conan Package)"
cd create
conan new hello/0.1
conan create . user/testing
conan search
conan search hello/0.1@user/testing
conan create . user/testing -s build_type=Debug
conan search hello/0.1@user/testing
}
consume_hello() {
echo "performing Exercise 6 (Consume the hello package)"
cd consumer
sed -i "s#\[requires\]#\[requires\]\nhello/0.1@user/testing#g" conanfile.txt
sed -i 's/CONAN_PKG::poco/CONAN_PKG::poco CONAN_PKG::hello/g' CMakeLists.txt
sed -i 's/TimerExample example;/TimerExample example;\nhello();/g' timer.cpp
sed -i 's/#include <iostream>/#include <iostream>\n#include "hello.h"/g' timer.cpp
rm -rf build
mkdir -p build
cd build
conan install ..
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cd bin
./timer
}
create_test() {
echo "performing Exercise 7 (Create a Conan Package with test_package)"
cd create
conan new hello/0.1 -t
conan create . user/testing
conan create . user/testing -s build_type=Debug
}
create_sources() {
echo "performing Exercise 8 (Create Package with sources)"
cd create_sources
conan new hello/0.1 -t -s
conan create . user/testing
conan create . user/testing -s build_type=Debug
}
upload_artifactory() {
echo "performing Exercise 9 (Upload packages to artifactory)"
conan upload hello/0.1@user/testing -r artifactory --all
conan search -r=artifactory
conan search hello/0.1@user/testing -r=artifactory
conan upload "*" -r=artifactory --all --confirm
}
explore_cache() {
echo "performing Exercise 10 (Explorer cache and remove packages)"
ls ~/.conan
ls ~/.conan/data
ls ~/.conan/data/hello/0.1/user/testing
conan remove "*" -f
conan search
ls ~/.conan/data
}
consume_artifactory() {
echo "performing Exercise 11 (Consume packages from artifactory)"
# remove everything from local cache
conan remove "*" -f
cd consumer/build
conan install .. -r=artifactory
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cd bin
./timer
}
create_options_shared() {
echo "performing Exercise 12 (Package options: shared)"
cd create_sources
conan create . user/testing -o hello:shared=True
conan create . user/testing -o hello:shared=True -s build_type=Debug
conan search hello/0.1@user/testing
}
create_options_greet() {
echo "performing Exercise 13 (Custom options: language)"
cd create_options
#sed -i 's/self.copy2/self.copy/g' conanfile.py
conan create . user/testing -o greet:language=English
conan create . user/testing -o greet:language=Spanish
}
configuration_values() {
echo "performing Exercise 14 (Configuration values and errors)"
cd create_options
set +e
conan create . user/testing -o greet:language=Italian
set -e
conan inspect greet/0.1@user/testing
conan inspect zlib/1.2.11@
conan get zlib/1.2.11@
set +e
conan create . user/testing -s compiler=unknown
conan create . user/testing -s compiler.version=200
set -e
cat ~/.conan/settings.yml
}
cross_build_hello() {
echo "performing Exercise 15 (Cross building hello to RPI)"
cd cross_build
#sed -i 's/Linus/Linux/g' rpi_armv7
conan create . user/testing -pr=rpi_armv7
conan search
conan search hello/0.1@user/testing
}
requires() {
echo "performing Exercise 16 (Transitive requires)"
cd requires
#sed -i 's/ZLib/zlib/g' conanfile.py
conan create . user/testing
set +e
conan create . user/testing -pr=rpi_armv7
set -e
conan create . user/testing -pr=rpi_armv7 --build=missing
}
requires_conflict() {
echo "performing Exercise 17 (Transitive requires conflict)"
cd requires_conflict
conan create lib_a user/testing
conan create lib_b user/testing
set +e
conan install .
set -e
sed -i "s#\[requires\]#\[requires\]\nzlib/1.2.11#g" conanfile.txt
conan install .
}
requires_conditional() {
echo "performing Exercise 18 (Conditional requires)"
cd requires_conditional
conan create . user/testing -o hello:zip=False
sed -i 's#self.requires#if self.options.zip:\n self.requires#g' conanfile.py
conan create . user/testing -o hello:zip=False
}
gtest_require() {
echo "performing Exercise 19 (Requiring gtest)"
cd gtest/hello
#sed -i "s#import ConanFile#import ConanFile, CMake#g" conanfile.py
conan create . user/testing
cd ../consumer
conan install .
}
gtest_build_require() {
echo "performing Exercise 20 (Requiring gtest as build_require)"
cd gtest/hello
sed -i 's/requires =/build_requires = /g' conanfile.py
conan create . user/testing
cd ../consumer
conan install .
}
cmake_build_require() {
echo "performing Exercise 21 (cmake build_requires)"
cd gtest/hello
conan create . user/testing
echo 'include(default)
[build_requires]
cmake/3.16.3' > myprofile
cmake --version
conan create . user/testing -pr=myprofile
cmake --version
}
running_apps() {
echo "performing Exercise 22 (Running apps)"
cd running_apps
conan install cmake/3.16.3@ -g deploy
cmake/bin/cmake --version
rm -rf cmake
conan install cmake/3.16.3@ -g virtualrunenv
cmake --version
source activate_run.sh
cmake --version
source deactivate_run.sh
cmake --version
}
python_requires() {
echo "performing Exercise 23 (python_requires)"
cd python_requires/mytools
conan export . user/testing
cd ../consumer
#sed -i 's/mymsg()/mymsg(self)/g' conanfile.py
conan create . user/testing
}
version_ranges() {
echo "performing Exercise 24 (version ranges)"
cd version_ranges
conan create hello hello/0.1@user/testing
conan create chat user/testing
sed -i 's/World/World **** 0.2 ****/g' hello/src/hello.cpp
# generate a new hello/0.2 version
conan create hello hello/0.2@user/testing
# the chat package will use it because it is inside its valid range
conan create chat user/testing
}
revisions() {
echo "performing Exercise 25 (revisions)"
conan config set general.revisions_enabled=True
conan remove hello* -f
conan remote add artifactory http://localhost:8081/artifactory/api/conan/conan-local
cd revisions
conan create hello user/testing
conan upload hello* --all -r=artifactory --confirm
sed -i 's/World/World IMPROVED/g' hello/src/hello.cpp
conan create hello user/testing
conan upload hello* --all -r=artifactory --confirm
conan search hello/0.1@user/testing --revisions
conan search hello/0.1@user/testing --revisions -r=artifactory
}
lockfiles() {
echo "performing Exercise 26 (lockfiles)"
cd lockfiles
conan remove hello* -f
conan create hello hello/0.1@user/testing
# will generate a conan.lock file
conan lock create chat/conanfile.py --user=user --channel=testing --lockfile-out=conan.lock
sed -i 's/World/World **** 0.2 ****/g' hello/src/hello.cpp
conan create hello hello/0.2@user/testing
# NOT locked: This will use the latest 0.2
conan create chat user/testing
# LOCKED: the chat package will NOT use 0.2 it is locked to 0.1
conan create chat user/testing --lockfile conan.lock
}
package_id() {
echo "performing Exercise 27 (package_id)"
cd package_id
conan remove "*" -f
conan create hello hello/1.0@user/testing
conan create chat user/testing
conan create app user/testing
sed -i 's/World/World **** 1.1 ****/g' hello/src/hello.h
conan create hello hello/1.1@user/testing
conan create app user/testing
conan config set general.default_package_id_mode=full_version_mode
set +e
conan create app user/testing
set -e
conan create app user/testing --build=missing
conan search chat/1.0@user/testing
}
hooks_config_install() {
echo "performing Exercise 28 (Hooks and conan config install)"
conan config install myconfig
cd hooks
conan new Hello-Pkg/0.1 -s
set +e
conan export . user/testing
set -e
conan new hello-pkg/0.1 -s
conan export . user/testing
conan remove hello-pkg* -f
sed -i "s/#TODO/if '-' in ref:\n raise Exception('Use _ instead of -')/g" ../myconfig/hooks/check_name.py
conan config install ../myconfig
set +e
conan export . user/testing
set -e
rm conanfile.py
}
package_pico_json() {
cd pico_json
conan new picojson/1.3.0 -i -t
cp example.cpp test_package
echo 'from conans import ConanFile, tools
class PicojsonConan(ConanFile):
name = "picojson"
version = "1.3.0"
no_copy_source = True
# No settings/options are necessary, this is header only
def source(self):
tools.get("https://github.com/kazuho/picojson/archive/v1.3.0.zip")
def package(self):
self.copy("*.h", dst="include/picojson", src="picojson-1.3.0")' > conanfile.py
conan create . user/testing
}
run_option() {
set -e
case $1 in
1) consumer ;;
2) consumer_debug ;;
3) consumer_gcc ;;
4) consumer_cmake_find ;;
5) create ;;
6) consume_hello ;;
7) create_test ;;
8) create_sources ;;
9) upload_artifactory ;;
10) explore_cache ;;
11) consume_artifactory ;;
12) create_options_shared ;;
13) create_options_greet ;;
14) configuration_values ;;
15) cross_build_hello ;;
16) requires ;;
17) requires_conflict ;;
18) requires_conditional ;;
19) gtest_require ;;
20) gtest_build_require ;;
21) cmake_build_require ;;
22) running_apps ;;
23) python_requires ;;
24) version_ranges ;;
25) revisions ;;
26) lockfiles ;;
27) package_id ;;
28) hooks_config_install ;;
-1) exit 0 ;;
*) echo -e "${RED}Not valid option! ${STD}" && sleep 2
esac
}
# function to display menus
show_menu() {
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " Automation Catch Up Menu "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "============== Conan Essentials ================="
echo "1. Consume with CMake"
echo "2. Consume with CMake, with different build_type, Debug"
echo "3. Consume with GCC"
echo "4. Consume with CMake find_package"
echo "5. Create a conan 'hello' package"
echo "6. Consume the 'hello' package"
echo "7. Create & test the 'hello' package with test_package"
echo "8. Create a conan 'hello' package recipe in-source"
echo "9. Upload packages to Artifactory"
echo "10. Explore and remove packages from cache"
echo "11. Consume packages from Artifactory"
echo "12. Package options: shared"
echo "13. Custom package options: language"
echo "14. Configuration values and errors"
echo "15. Cross-build 'hello' pkg for RPI-armv7"
echo "=============== Conan Advanced ==================="
echo "16. 'hello' transitive requires 'zlib'"
echo "17. Transitive requirements conflicts"
echo "18. Conditional requirements"
echo "19. requires 'gtest'"
echo "20. build-requires 'gtest'"
echo "21. build-requires 'cmake'"
echo "22. Running apps"
echo "23. python-requires"
echo "24. Version ranges"
echo "25. Package revisions"
echo "26. Lockfiles"
echo "27. package_id"
echo "28. Hooks and conan config install"
echo "-1. Exit"
}
if [[ $1 ]]
then
run_option $1
else
while true
do
show_menu
cd ${curdir}
echo -n "Enter choice: "
read choice
run_option $choice
done
fi