1
- #! /bin/bash
1
+ #! /bin/sh
2
2
# Copyright © Aptos Foundation
3
3
# Parts of the project are originally copyright © Meta Platforms, Inc.
4
4
# SPDX-License-Identifier: Apache-2.0
5
5
6
+ has_command () {
7
+ command -v " $1 " > /dev/null 2>&1
8
+ }
6
9
7
10
# This script is used to set up a minimal environment for building the Aptos CLI and other tools.
8
11
# The `dev_setup.sh` script is way too complex, and too hard to figure out what is actually happening. This script
9
12
# simplifies the process
10
- if command -v wget & > /dev/null ; then
13
+ if has_command wget; then
11
14
wget https://raw.githubusercontent.com/gregnazario/universal-installer/refs/heads/main/scripts/install_pkg.sh
12
- elif command -v curl & > /dev/null ; then
15
+ elif has_command curl; then
13
16
curl -O https://raw.githubusercontent.com/gregnazario/universal-installer/refs/heads/main/scripts/install_pkg.sh
14
17
else
15
18
echo " Unable to download install script, no wget or curl. Abort"
18
21
19
22
# TODO: Do we need to add `ca-certificates`, `curl`, `unzip`, `wget`
20
23
# Install rustup
21
- if ! command -v rustup & > /dev/null ; then
24
+ if ! has_command cargo ; then
22
25
curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
23
26
fi
24
27
25
28
OS=" $( uname) "
26
29
case " $OS " in
27
30
Linux)
28
- if command -v apt-get & > /dev/null ; then
31
+ if has_command apt-get; then
29
32
# Ubuntu / Debian based APT-GET
30
33
sudo apt-get update
31
34
sh install_pkg.sh build-essential pkgconf libssl-dev git libudev-dev lld libdw-dev clang llvm cmake
32
- elif command -v dnf & > /dev/null ; then
35
+ elif has_command dnf; then
33
36
# RHEL / CentOS based DNF
34
37
sh install_pkg.sh gcc gcc-c++ make pkgconf openssl-devel git rust-libudev-devel lld elfutils-devel clang llvm cmake
35
- elif command -v yum & > /dev/null ; then
38
+ elif has_command yum; then
36
39
# RHEL / CentOS based YUM
37
40
sh install_pkg.sh gcc gcc-c++ make pkgconf openssl-devel git rust-libudev-devel lld elfutils-devel clang llvm cmake
38
- elif command -v pacman & > /dev/null ; then
41
+ elif has_command pacman; then
39
42
# Arch based PACMAN
40
43
sh install_pkg.sh base-devel pkgconf openssl git lld clang llvm cmake
41
- elif command -v apk & > /dev/null ; then
44
+ elif has_command apk; then
42
45
# Alpine based APK
43
46
sh install_pkg.sh alpine-sdk coreutils pkgconfig openssl-dev git lld elfutils-dev clang llvm cmake libc-dev
44
- elif command -v zypper & > /dev/null ; then
47
+ elif has_command zypper; then
45
48
# OpenSUSE zypper
46
49
sh install_pkg.sh gcc gcc-c++ make pkg-config libopenssl-devel git libudev-devel lld libdw-devel clang llvm cmake
47
- # elif command -v emerge &>/dev/null ; then
50
+ elif has_command emerge; then
48
51
# Gentoo Emerge
49
- # TODO: This doesn't quite work correctly yet
50
- # sudo emerge --sync
51
- # sh install_pkg.sh --skip-overrides sys-devel/gcc dev-libs/openssl dev-vcs/git dev-lang/rust
52
- elif command -v xbps-install & > /dev/null; then
52
+ sudo emerge --sync
53
+ sh install_pkg.sh --skip-overrides sys-devel/gcc dev-libs/openssl dev-vcs/git dev-lang/rust llvm-core/clang
54
+ elif has_command xbps-install; then
53
55
# Void linux xbps
54
56
sh install_pkg.sh gcc make pkg-config git lld elfutils-devel clang llvm cmake
55
57
else
56
- # TODO: Support more package managers?
57
- echo " Unable to find supported package manager (apt-get, dnf, yum, zypper, xbps or pacman). Abort"
58
+ echo " Unable to find supported Linux package manager (apt-get, dnf, yum, zypper, xbps or pacman). Abort"
58
59
exit 1
59
60
fi
60
61
;;
61
62
Darwin)
62
- # TODO: May need to do a different path for macports, but atm brew is expected here
63
63
sh install_pkg.sh pkgconfig openssl git llvm cmake
64
64
;;
65
- # TODO: Does not work yet
66
- # FreeBSD)
67
- # sh install_pkg.sh gcc gmake binutils pkgconf git openssl cmake llvm
68
- # ;;
65
+ FreeBSD)
66
+ sh install_pkg.sh gcc gmake binutils pkgconf git openssl cmake llvm hidapi
67
+ ;;
69
68
* )
70
69
echo " Unknown OS. Abort."
71
70
exit 1
72
71
;;
73
72
esac
74
-
75
- # TODO: Determine how best to install on it's own
76
- # git clone https://github.com/aptos-labs/aptos-core.git
77
- # cd aptos-core || exit 1
78
-
79
- # If cargo is installed correctly use it, but otherwise, you may need to initialize rustup, depends on OS
80
- # if command -v cargo &>/dev/null; then
81
- # cargo build -p aptos --profile cli
82
- # else
83
- # if you use rustup init, you may need to use the .cargo/bin cargo
84
- # /usr/bin/rustup-init -y
85
- # ~/.cargo/bin/cargo build -p aptos --profile cli
86
- # fi
0 commit comments