Skip to content

unixPB: Install capstone 4 from repositories or source #3119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
- role: cmake # OpenJ9 / OpenJFX
when: ansible_distribution != "Solaris" # Compile fails on Solaris
tags: [build_tools, build_tools_openj9, build_tools_openjfx]
- role: capstone
tags: [build_tools]
- role: ccache
when: ansible_distribution != "Solaris" # Compile fails on Solaris
- role: nasm # OpenJ9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Build_Tool_Packages:
- gcc
- gettext
- libasound2-dev
- libcapstone-dev
- libcups2-dev
- libcurl4-openssl-dev
- libdwarf-dev # OpenJ9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Build_Tool_Packages:
- bison # OpenJ9
- bzip2
- ca-certificates
- capstone-devel
- cpio
- curl
- cups-devel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Build_Tool_Packages:
- git
- gnupg
- libasound2-dev
- libcapstone-dev
- libcups2-dev
- libcurl4-openssl-dev
- libdwarf-dev # OpenJ9
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
##########################
# Install capstone 4.0.2 #
##########################
# Required to build with hsdis disassembler support.
# Note that at present this is only supported in the openjdk codebase
# on x64 and aarch64, but this installs on all archs except RISC-V

- name: Set capstone version
set_fact:
capstone_version: 4.0.2
tags: capstone_source

# check if it is installed in custom location or as system

- name: Test if capstone 4 is installed
shell: test -f /usr/local/lib/libcapstone.so.4 || test -f /usr/lib/libcapstone.so.4
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES")
register: capstone_installed
changed_when: false
failed_when: false
tags: capstone_source

- name: Download capstone {{ capstone_version }}
get_url:
url: https://github.com/capstone-engine/capstone/archive/{{ capstone_version }}.tar.gz
dest: /tmp/capstone-{{ capstone_version }}.tar.gz
force: no
mode: 0440
checksum: sha512:7f93534517307b737422a8825b66b2a1f3e1cca2049465d60ab12595940154aaf843ba40ed348fce58de58b990c19a0caef289060eb72898cb008a88c470970e
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES")
- capstone_installed.rc != 0
- (ansible_architecture != "riscv64")
tags: capstone_source

- name: Extract capstone {{ capstone_version }}
unarchive:
src: /tmp/capstone-{{ capstone_version }}.tar.gz
dest: /tmp
copy: False
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES")
- capstone_installed.rc != 0
- (ansible_architecture != "riscv64")
tags: capstone_source

- name: Set architecture variable for x64
set_fact: capstone_architecture=x86
when: ansible_architecture == "x86_64"

- name: Set architecture variable for arm32
set_fact: capstone_architecture=arm
when: ansible_architecture == "armv7l"

- name: Set architecture variable for aarch64
set_fact: capstone_architecture=aarch64
when: ansible_architecture == "aarch64"

- name: Set architecture variable for ppc64le
set_fact: capstone_architecture=powerpc
when: ansible_architecture == "ppc64le"

- name: Set architecture variable for s390x
set_fact: capstone_architecture=systemz
when: ansible_architecture == "s390x"

- name: Build and install capstone {{ capstone_version }}
shell: cd /tmp/capstone-{{ capstone_version }} && CAPSTONE_ARCHS={{ capstone_architecture }} ./make.sh && PREFIX=/usr/local ./make.sh install
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES")
- capstone_installed.rc != 0
- (ansible_architecture != "riscv64")
tags: capstone_source

- name: Remove downloaded packages for capstone {{ capstone_version }}
file:
path: /tmp/capstone-{{ capstone_version }}.tar.gz
state: absent
failed_when: false
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or ansible_distribution == "Ubuntu" or ansible_distribution == "SLES")
- capstone_installed.rc != 0
tags: capstone_source