Skip to content

Commit 87b659e

Browse files
authored
unixPB: Install capstone 4 from repositories or source (#3119)
* unixPB: Install capstone 4 from repositories or source * Add checksums to capstone download Signed-off-by: Stewart X Addison <sxa@redhat.com> * Only build correct capstone support for the machine --------- Signed-off-by: Stewart X Addison <sxa@redhat.com>
1 parent dbbe21d commit 87b659e

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
- role: cmake # OpenJ9 / OpenJFX
7979
when: ansible_distribution != "Solaris" # Compile fails on Solaris
8080
tags: [build_tools, build_tools_openj9, build_tools_openjfx]
81+
- role: capstone
82+
tags: [build_tools]
8183
- role: ccache
8284
when: ansible_distribution != "Solaris" # Compile fails on Solaris
8385
- role: nasm # OpenJ9

ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Debian.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Build_Tool_Packages:
1717
- gcc
1818
- gettext
1919
- libasound2-dev
20+
- libcapstone-dev
2021
- libcups2-dev
2122
- libcurl4-openssl-dev
2223
- libdwarf-dev # OpenJ9

ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Fedora.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Build_Tool_Packages:
1111
- bison # OpenJ9
1212
- bzip2
1313
- ca-certificates
14+
- capstone-devel
1415
- cpio
1516
- curl
1617
- cups-devel

ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Ubuntu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Build_Tool_Packages:
1919
- git
2020
- gnupg
2121
- libasound2-dev
22+
- libcapstone-dev
2223
- libcups2-dev
2324
- libcurl4-openssl-dev
2425
- libdwarf-dev # OpenJ9
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)