|
| 1 | +--- |
| 2 | +########################## |
| 3 | +# Install capstone 4.0.2 # |
| 4 | +########################## |
| 5 | +# Required to build with hsdis disassembler support. |
| 6 | +# Note that at present this is only supported in the openjdk codebase |
| 7 | +# on x64 and aarch64, but this installs on all archs except RISC-V |
| 8 | + |
| 9 | +- name: Set capstone version |
| 10 | + set_fact: |
| 11 | + capstone_version: 4.0.2 |
| 12 | + tags: capstone_source |
| 13 | + |
| 14 | +# check if it is installed in custom location or as system |
| 15 | + |
| 16 | +- name: Test if capstone 4 is installed |
| 17 | + shell: test -f /usr/local/lib/libcapstone.so.4 || test -f /usr/lib/libcapstone.so.4 |
| 18 | + when: |
| 19 | + - (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES") |
| 20 | + register: capstone_installed |
| 21 | + changed_when: false |
| 22 | + failed_when: false |
| 23 | + tags: capstone_source |
| 24 | + |
| 25 | +- name: Download capstone {{ capstone_version }} |
| 26 | + get_url: |
| 27 | + url: https://github.com/capstone-engine/capstone/archive/{{ capstone_version }}.tar.gz |
| 28 | + dest: /tmp/capstone-{{ capstone_version }}.tar.gz |
| 29 | + force: no |
| 30 | + mode: 0440 |
| 31 | + checksum: sha512:7f93534517307b737422a8825b66b2a1f3e1cca2049465d60ab12595940154aaf843ba40ed348fce58de58b990c19a0caef289060eb72898cb008a88c470970e |
| 32 | + when: |
| 33 | + - (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES") |
| 34 | + - capstone_installed.rc != 0 |
| 35 | + - (ansible_architecture != "riscv64") |
| 36 | + tags: capstone_source |
| 37 | + |
| 38 | +- name: Extract capstone {{ capstone_version }} |
| 39 | + unarchive: |
| 40 | + src: /tmp/capstone-{{ capstone_version }}.tar.gz |
| 41 | + dest: /tmp |
| 42 | + copy: False |
| 43 | + when: |
| 44 | + - (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES") |
| 45 | + - capstone_installed.rc != 0 |
| 46 | + - (ansible_architecture != "riscv64") |
| 47 | + tags: capstone_source |
| 48 | + |
| 49 | +- name: Set architecture variable for x64 |
| 50 | + set_fact: capstone_architecture=x86 |
| 51 | + when: ansible_architecture == "x86_64" |
| 52 | + |
| 53 | +- name: Set architecture variable for arm32 |
| 54 | + set_fact: capstone_architecture=arm |
| 55 | + when: ansible_architecture == "armv7l" |
| 56 | + |
| 57 | +- name: Set architecture variable for aarch64 |
| 58 | + set_fact: capstone_architecture=aarch64 |
| 59 | + when: ansible_architecture == "aarch64" |
| 60 | + |
| 61 | +- name: Set architecture variable for ppc64le |
| 62 | + set_fact: capstone_architecture=powerpc |
| 63 | + when: ansible_architecture == "ppc64le" |
| 64 | + |
| 65 | +- name: Set architecture variable for s390x |
| 66 | + set_fact: capstone_architecture=systemz |
| 67 | + when: ansible_architecture == "s390x" |
| 68 | + |
| 69 | +- name: Build and install capstone {{ capstone_version }} |
| 70 | + shell: cd /tmp/capstone-{{ capstone_version }} && CAPSTONE_ARCHS={{ capstone_architecture }} ./make.sh && PREFIX=/usr/local ./make.sh install |
| 71 | + when: |
| 72 | + - (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES") |
| 73 | + - capstone_installed.rc != 0 |
| 74 | + - (ansible_architecture != "riscv64") |
| 75 | + tags: capstone_source |
| 76 | + |
| 77 | +- name: Remove downloaded packages for capstone {{ capstone_version }} |
| 78 | + file: |
| 79 | + path: /tmp/capstone-{{ capstone_version }}.tar.gz |
| 80 | + state: absent |
| 81 | + failed_when: false |
| 82 | + when: |
| 83 | + - (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES") |
| 84 | + - capstone_installed.rc != 0 |
| 85 | + tags: capstone_source |
0 commit comments