Skip to content

Commit ec9d893

Browse files
committed
inital
1 parent 03f7ef2 commit ec9d893

File tree

17 files changed

+547
-226
lines changed

17 files changed

+547
-226
lines changed

aztec-up/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.terraform
22
.terraform*
33
.DS_Store
4-
bin/versions
4+
bin/0.0.1/versions
55
verdaccio-storage

aztec-up/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ RUN apt update && apt install -y \
77
build-essential \
88
python3 \
99
netcat-openbsd \
10-
parallel \
11-
jq \
1210
&& rm -rf /var/lib/apt/lists/*
1311
COPY --chown=1000:1000 verdaccio-storage /home/ubuntu/verdaccio-storage
1412
RUN touch /aztec_release_test_container

aztec-up/bin/0.0.1/install

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
#!/usr/bin/env bash
2+
# Per-version installer script
3+
# This script is called by aztec-up to install a specific version of the Aztec toolchain.
4+
# It expects VERSION and INSTALL_URI to be set.
5+
set -euo pipefail
6+
7+
# Colors
8+
g="\033[32m" # Green
9+
y="\033[33m" # Yellow
10+
b="\033[34m" # Blue
11+
r="\033[0m" # Reset
12+
13+
# Required environment variables
14+
VERSION="${VERSION:?VERSION must be set}"
15+
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
16+
INSTALL_URI="${INSTALL_URI:-https://install.aztec.network}"
17+
18+
# Version-specific paths
19+
version_path="$AZTEC_HOME/versions/$VERSION"
20+
version_bin_path="$version_path/bin"
21+
22+
function echo_green {
23+
echo -e "${g}$1${r}"
24+
}
25+
26+
function echo_yellow {
27+
echo -e "${y}$1${r}"
28+
}
29+
30+
function dump_fail {
31+
output=$(mktemp)
32+
33+
set +e
34+
($1) &>$output
35+
status=$?
36+
set -e
37+
38+
# 0 or SIGTERM considered a success.
39+
if [ "$status" -ne 0 ] && [ "$status" -ne 143 ]; then
40+
{
41+
echo
42+
echo -e "${y}command failed${r}: $1 (exit: $status)"
43+
echo -e "${b}--- output ---${r}"
44+
cat $output
45+
} >&2
46+
fi
47+
48+
rm $output
49+
50+
return $status
51+
}
52+
53+
function check_toolchains {
54+
# Check Node.js version.
55+
local node_min_version=$(cat "$version_path/versions" | grep node | cut -d' ' -f2)
56+
local node_installed_version=$(node --version 2>/dev/null | cut -d 'v' -f 2 || echo "none")
57+
if [[ "$(printf '%s\n' "$node_min_version" "$node_installed_version" | sort -V | head -n1)" != "$node_min_version" ]]; then
58+
echo "Minimum Node.js version $node_min_version not found (got $node_installed_version)."
59+
echo "Installation: nvm install --lts && nvm alias default lts/*"
60+
exit 1
61+
fi
62+
}
63+
64+
function install_versions_file {
65+
# Determine the correct URI for fetching the versions file
66+
local versions_uri="$INSTALL_URI"
67+
curl -fsSL "$versions_uri/$VERSION/versions" -o "$version_path/versions"
68+
}
69+
70+
function install_noir {
71+
set -euo pipefail
72+
local noir_version=$(cat "$version_path/versions" | grep noir | cut -d' ' -f2)
73+
74+
# Create a temp directory for noirup to install to
75+
local temp_nargo_home=$(mktemp -d)
76+
mkdir -p "$temp_nargo_home/bin"
77+
78+
# Install noirup if not already present
79+
if [ ! -f "$HOME/.nargo/bin/noirup" ]; then
80+
curl -Ls https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash
81+
fi
82+
83+
# Install noir to temp location and move to version directory
84+
NARGO_HOME="$temp_nargo_home" "$HOME/.nargo/bin/noirup" -v "$noir_version"
85+
86+
# Move the nargo binary to our version bin directory
87+
mv "$temp_nargo_home/bin/nargo" "$version_bin_path/nargo"
88+
89+
# Cleanup temp directory
90+
rm -rf "$temp_nargo_home"
91+
}
92+
93+
function install_foundry {
94+
set -euo pipefail
95+
local foundry_version=$(cat "$version_path/versions" | grep foundry | cut -d' ' -f2)
96+
97+
# Create a temp directory for foundryup to install to
98+
local temp_foundry_dir=$(mktemp -d)
99+
mkdir -p "$temp_foundry_dir/bin"
100+
101+
# Install foundryup if not already present
102+
if [ ! -f "$HOME/.foundry/bin/foundryup" ]; then
103+
curl -L https://foundry.paradigm.xyz | bash
104+
fi
105+
106+
# Install foundry to temp location and move to version directory
107+
FOUNDRY_DIR="$temp_foundry_dir" "$HOME/.foundry/bin/foundryup" -i "$foundry_version"
108+
109+
# Move the foundry binaries to our version bin directory
110+
for binary in forge cast anvil chisel; do
111+
if [ -f "$temp_foundry_dir/bin/$binary" ]; then
112+
mv "$temp_foundry_dir/bin/$binary" "$version_bin_path/$binary"
113+
fi
114+
done
115+
116+
# Cleanup temp directory
117+
rm -rf "$temp_foundry_dir"
118+
}
119+
120+
function install_aztec_packages {
121+
set -euo pipefail
122+
local aztec_version=$(cat "$version_path/versions" | grep aztec | cut -d' ' -f2)
123+
124+
# Install npm packages to the version directory using --prefix
125+
npm install @aztec/aztec@"$aztec_version" @aztec/cli-wallet@"$aztec_version" @aztec/bb.js@"$aztec_version" \
126+
--prefix "$version_path"
127+
}
128+
129+
function main {
130+
# Create version directory
131+
mkdir -p "$version_bin_path"
132+
133+
# Download versions manifest
134+
echo -n "Installing version manifest... "
135+
dump_fail install_versions_file
136+
echo_green "done."
137+
138+
# Check Node.js version
139+
check_toolchains
140+
141+
# Install noir
142+
echo -n "Installing nargo... "
143+
dump_fail install_noir
144+
echo_green "done."
145+
146+
# Install foundry
147+
echo -n "Installing foundry... "
148+
dump_fail install_foundry
149+
echo_green "done."
150+
151+
# Install aztec npm packages
152+
echo -n "Installing aztec packages... "
153+
dump_fail install_aztec_packages
154+
echo_green "done."
155+
}
156+
157+
main "$@"

aztec-up/bin/aliases/index

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
latest
2+
nightly

aztec-up/bin/aliases/latest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

aztec-up/bin/aliases/nightly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

0 commit comments

Comments
 (0)