]>
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 | " | |
9f95a23c TL |
25 | # parse output like "octopus (dev)" |
26 | case $(librados-config --release | grep -Po ' \(\K[^\)]+') in | |
27 | dev) | |
28 | BRANCH=master;; | |
29 | rc|stable) | |
30 | BRANCH=$(librados-config --release | cut -d' ' -f1);; | |
31 | *) | |
32 | echo "unknown release '$(librados-config --release)'" >&2 | |
33 | return 1;; | |
34 | esac | |
35 | DL_PREFIX="http://git.ceph.com/?p=ceph.git;a=blob_plain;hb=${BRANCH};f=examples/librados/" | |
36 | #DL_PREFIX="https://raw.githubusercontent.com/ceph/ceph/master/examples/librados/" | |
91327a77 AA |
37 | DESTDIR=$(pwd) |
38 | ||
39 | function cleanup () { | |
40 | for f in $BINARIES$SOURCES ; do | |
41 | rm -f "${DESTDIR}/$f" | |
42 | done | |
43 | } | |
44 | ||
45 | function get_sources () { | |
46 | for s in $SOURCES ; do | |
39ae355f | 47 | curl --progress-bar --output $s -L ${DL_PREFIX}$s |
91327a77 AA |
48 | done |
49 | } | |
50 | ||
51 | function check_sources () { | |
52 | for s in $SOURCES ; do | |
53 | test -f $s | |
54 | done | |
55 | } | |
56 | ||
57 | function check_binaries () { | |
58 | for b in $BINARIES ; do | |
59 | file $b | |
60 | test -f $b | |
61 | done | |
62 | } | |
63 | ||
64 | function run_binaries () { | |
65 | for b in $BINARIES_TO_RUN ; do | |
66 | ./$b -c /etc/ceph/ceph.conf | |
67 | done | |
68 | } | |
69 | ||
70 | pushd $DESTDIR | |
494da23a TL |
71 | case $(distro_id) in |
72 | centos|fedora|rhel|opensuse*|suse|sles) | |
73 | install gcc-c++ make libradospp-devel librados-devel;; | |
20effc67 | 74 | ubuntu|debian|devuan|softiron) |
494da23a TL |
75 | install g++ make libradospp-dev librados-dev;; |
76 | *) | |
77 | echo "$(distro_id) is unknown, $@ will have to be installed manually." | |
78 | esac | |
91327a77 AA |
79 | get_sources |
80 | check_sources | |
81 | make all-system | |
82 | check_binaries | |
83 | run_binaries | |
84 | popd |