Skip to content

Commit 88c55d8

Browse files
authored
[cli] Update CLI build script to run with SH, and more platforms (aptos-labs#16739)
* [cli] Update CLI build script to run with SH, and more platforms * [cli] fix emerge support * [cli] Add cargo install script for specific versions
1 parent f2ce6cc commit 88c55d8

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

scripts/cli/cargo_install_cli.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#/bin/sh
2+
# Check if version is provided
3+
if [ -z "$1" ]; then
4+
echo "Error: Version argument is required"
5+
exit 1
6+
fi
7+
8+
export VERSION=$1
9+
10+
# Check if version matches expected format
11+
if ! echo "$VERSION" | grep -q "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
12+
echo "Error: Version must be in format X.X.X"
13+
exit 1
14+
fi
15+
16+
RUSTFLAGS="--cfg tokio_unstable" cargo install --locked --git https://github.com/aptos-labs/aptos-core.git --profile cli aptos --tag aptos-cli-v$VERSION

scripts/cli/minimal_cli_build.sh

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# Copyright © Aptos Foundation
33
# Parts of the project are originally copyright © Meta Platforms, Inc.
44
# SPDX-License-Identifier: Apache-2.0
55

6+
has_command() {
7+
command -v "$1" > /dev/null 2>&1
8+
}
69

710
# This script is used to set up a minimal environment for building the Aptos CLI and other tools.
811
# The `dev_setup.sh` script is way too complex, and too hard to figure out what is actually happening. This script
912
# simplifies the process
10-
if command -v wget &>/dev/null; then
13+
if has_command wget; then
1114
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
1316
curl -O https://raw.githubusercontent.com/gregnazario/universal-installer/refs/heads/main/scripts/install_pkg.sh
1417
else
1518
echo "Unable to download install script, no wget or curl. Abort"
@@ -18,69 +21,52 @@ fi
1821

1922
# TODO: Do we need to add `ca-certificates`, `curl`, `unzip`, `wget`
2023
# Install rustup
21-
if ! command -v rustup&>/dev/null; then
24+
if ! has_command cargo; then
2225
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2326
fi
2427

2528
OS="$(uname)"
2629
case "$OS" in
2730
Linux)
28-
if command -v apt-get &>/dev/null; then
31+
if has_command apt-get; then
2932
# Ubuntu / Debian based APT-GET
3033
sudo apt-get update
3134
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
3336
# RHEL / CentOS based DNF
3437
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
3639
# RHEL / CentOS based YUM
3740
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
3942
# Arch based PACMAN
4043
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
4245
# Alpine based APK
4346
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
4548
# OpenSUSE zypper
4649
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
4851
# 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
5355
# Void linux xbps
5456
sh install_pkg.sh gcc make pkg-config git lld elfutils-devel clang llvm cmake
5557
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"
5859
exit 1
5960
fi
6061
;;
6162
Darwin)
62-
# TODO: May need to do a different path for macports, but atm brew is expected here
6363
sh install_pkg.sh pkgconfig openssl git llvm cmake
6464
;;
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+
;;
6968
*)
7069
echo "Unknown OS. Abort."
7170
exit 1
7271
;;
7372
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

Comments
 (0)