]>
Commit | Line | Data |
---|---|---|
c07f9fc5 FG |
1 | #!/bin/bash |
2 | ||
3 | # This can be run from e.g. the senta machines which have docker available. You | |
4 | # may need to run this script with sudo. | |
5 | # | |
6 | # Once you have booted into the image, you should be able to debug the core file: | |
7 | # $ gdb -q /ceph/teuthology-archive/.../coredump/1500013578.8678.core | |
8 | # | |
9 | # You may want to install other packages (yum) as desired. | |
10 | # | |
11 | # Once you're finished, please delete old images in a timely fashion. | |
12 | ||
13 | set -e | |
14 | ||
15 | CACHE="" | |
16 | ||
17 | function run { | |
18 | printf "%s\n" "$*" | |
19 | "$@" | |
20 | } | |
21 | ||
22 | function main { | |
23 | eval set -- $(getopt --name "$0" --options 'h' --longoptions 'help,no-cache' -- "$@") | |
24 | ||
25 | while [ "$#" -gt 0 ]; do | |
26 | case "$1" in | |
27 | -h|--help) | |
28 | printf '%s: [--no-cache] <branch> <enviornment>\n' "$0" | |
29 | exit 0 | |
30 | ;; | |
31 | --no-cache) | |
32 | CACHE="--no-cache" | |
33 | shift | |
34 | ;; | |
35 | --) | |
36 | shift | |
37 | break | |
38 | ;; | |
39 | esac | |
40 | done | |
41 | ||
42 | if [ -z "$1" ]; then | |
43 | printf "specify the branch [default \"master\"]: " | |
44 | read branch | |
45 | if [ -z "$branch" ]; then | |
46 | branch=master | |
47 | fi | |
48 | else | |
49 | branch="$1" | |
50 | fi | |
51 | printf "branch: %s\n" "$branch" | |
52 | ||
53 | if [ -z "$2" ]; then | |
54 | printf "specify the build environment [default \"centos:7\"]: " | |
55 | read env | |
56 | if [ -z "$env" ]; then | |
57 | env=centos:7 | |
58 | fi | |
59 | else | |
60 | env="$2" | |
61 | fi | |
62 | printf "env: %s\n" "$env" | |
63 | ||
64 | if [ -n "$SUDO_USER" ]; then | |
65 | user="$SUDO_USER" | |
66 | elif [ -n "$USER" ]; then | |
67 | user="$USER" | |
68 | else | |
69 | user="$(whoami)" | |
70 | fi | |
71 | ||
72 | image="${user}/ceph-ci:${branch}-${env/:/-}" | |
73 | ||
74 | T=$(mktemp -d) | |
75 | pushd "$T" | |
76 | if grep ubuntu <<<"$env" > /dev/null 2>&1; then | |
77 | # Docker makes it impossible to access anything outside the CWD : / | |
78 | cp -- /ceph/shaman/cephdev.asc . | |
79 | cat > Dockerfile <<EOF | |
80 | FROM ${env} | |
81 | ||
82 | WORKDIR /root | |
83 | RUN apt-get update --yes --quiet && \ | |
84 | apt-get install --yes --quiet screen wget gdb software-properties-common python-software-properties apt-transport-https | |
85 | COPY cephdev.asc cephdev.asc | |
86 | RUN apt-key add cephdev.asc | |
87 | RUN add-apt-repository "\$(wget --quiet -O - https://shaman.ceph.com/api/repos/ceph/${branch}/latest/${env/://}/repo)" && \ | |
88 | apt-get update --yes && \ | |
89 | apt-get install --yes --allow-unauthenticated ceph ceph-mds-dbg ceph-mgr-dbg ceph-mon-dbg ceph-fuse-dbg ceph-test-dbg radosgw-dbg | |
90 | EOF | |
91 | time run docker build $CACHE --tag "$image" . | |
92 | else # try RHEL flavor | |
93 | time run docker build $CACHE --tag "$image" - <<EOF | |
94 | FROM ${env} | |
95 | ||
96 | WORKDIR /root | |
97 | RUN yum update -y && \ | |
98 | yum install -y screen epel-release wget psmisc ca-certificates gdb | |
99 | RUN wget -O /etc/yum.repos.d/ceph-dev.repo https://shaman.ceph.com/api/repos/ceph/${branch}/latest/centos/7/repo && \ | |
100 | yum clean all && \ | |
101 | yum upgrade -y && \ | |
102 | yum install -y ceph ceph-debuginfo ceph-fuse | |
103 | EOF | |
104 | fi | |
105 | popd | |
106 | rm -rf -- "$T" | |
107 | ||
108 | printf "built image %s\n" "$image" | |
109 | ||
110 | run docker run -ti -v /ceph:/ceph:ro "$image" | |
111 | return 0 | |
112 | } | |
113 | ||
114 | main "$@" |