]>
Commit | Line | Data |
---|---|---|
91327a77 AA |
1 | #!/bin/bash -ex |
2 | # | |
3 | # Compile and run a librados application outside of the ceph build system, so | |
4 | # that we can be sure librados.h[pp] is still usable and hasn't accidentally | |
5 | # started depending on internal headers. | |
6 | # | |
7 | # The script assumes all dependencies - e.g. curl, make, gcc, librados headers, | |
8 | # libradosstriper headers, boost headers, etc. - are already installed. | |
9 | # | |
10 | ||
494da23a TL |
11 | source $(dirname $0)/../ceph-helpers-root.sh |
12 | ||
91327a77 AA |
13 | trap cleanup EXIT |
14 | ||
15 | SOURCES="hello_radosstriper.cc | |
16 | hello_world_c.c | |
17 | hello_world.cc | |
18 | Makefile | |
19 | " | |
20 | BINARIES_TO_RUN="hello_world_c | |
21 | hello_world_cpp | |
22 | " | |
23 | BINARIES="${BINARIES_TO_RUN}hello_radosstriper_cpp | |
24 | " | |
11fdf7f2 TL |
25 | DL_PREFIX="http://git.ceph.com/?p=ceph.git;a=blob_plain;hb=master;f=examples/librados/" |
26 | #DL_PREFIX="https://raw.githubusercontent.com/ceph/ceph/master/examples/librados/" | |
91327a77 AA |
27 | DESTDIR=$(pwd) |
28 | ||
29 | function cleanup () { | |
30 | for f in $BINARIES$SOURCES ; do | |
31 | rm -f "${DESTDIR}/$f" | |
32 | done | |
33 | } | |
34 | ||
35 | function get_sources () { | |
36 | for s in $SOURCES ; do | |
37 | curl --progress-bar --output $s ${DL_PREFIX}$s | |
38 | done | |
39 | } | |
40 | ||
41 | function check_sources () { | |
42 | for s in $SOURCES ; do | |
43 | test -f $s | |
44 | done | |
45 | } | |
46 | ||
47 | function check_binaries () { | |
48 | for b in $BINARIES ; do | |
49 | file $b | |
50 | test -f $b | |
51 | done | |
52 | } | |
53 | ||
54 | function run_binaries () { | |
55 | for b in $BINARIES_TO_RUN ; do | |
56 | ./$b -c /etc/ceph/ceph.conf | |
57 | done | |
58 | } | |
59 | ||
60 | pushd $DESTDIR | |
494da23a TL |
61 | case $(distro_id) in |
62 | centos|fedora|rhel|opensuse*|suse|sles) | |
63 | install gcc-c++ make libradospp-devel librados-devel;; | |
64 | ubuntu|debian|devuan) | |
65 | install g++ make libradospp-dev librados-dev;; | |
66 | *) | |
67 | echo "$(distro_id) is unknown, $@ will have to be installed manually." | |
68 | esac | |
91327a77 AA |
69 | get_sources |
70 | check_sources | |
71 | make all-system | |
72 | check_binaries | |
73 | run_binaries | |
74 | popd |