Skip to content

Commit d44861e

Browse files
committed
wip
1 parent fb37a40 commit d44861e

File tree

3 files changed

+61
-17
lines changed

3 files changed

+61
-17
lines changed

eng/scripts/get-aspire-cli-pr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ parse_args() {
171171
}
172172

173173
# =============================================================================
174-
# START: Code shared with get-aspire-cli*.sh
174+
# START: Shared code
175175
# =============================================================================
176176

177177
# Function for verbose logging
@@ -476,7 +476,7 @@ cleanup() {
476476
}
477477

478478
# =============================================================================
479-
# END: Code shared with get-aspire-cli*.sh
479+
# END: Shared code
480480
# =============================================================================
481481

482482
# Function to check if gh command is available

eng/scripts/get-aspire-cli.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ function Get-InstallPath {
466466
throw "Unable to determine user home directory. Please specify -InstallPath parameter."
467467
}
468468

469-
$defaultPath = Join-Path $homeDirectory ".aspire"
469+
$defaultPath = Join-Path $homeDirectory (Join-Path ".aspire" "bin")
470470
return [System.IO.Path]::GetFullPath($defaultPath)
471471
}
472472

eng/scripts/get-aspire-cli.sh

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ parse_args() {
149149
}
150150

151151
# =============================================================================
152-
# START: Code shared with other scripts
152+
# START: Shared code
153153
# =============================================================================
154154

155155
# Function for verbose logging
@@ -245,30 +245,74 @@ detect_architecture() {
245245

246246
# Function to compute the Runtime Identifier (RID)
247247
get_runtime_identifier() {
248-
local os="$1"
249-
local arch="$2"
248+
# set target_os to $1 and default to HOST_OS
249+
local target_os="$1"
250+
local target_arch="$2"
250251

251-
# Detect OS and architecture if not provided
252-
if [[ -z "$OS" ]]; then
253-
if ! os=$(detect_os); then
254-
say_error "Unsupported operating system. Current platform: $(uname -s)"
252+
if [[ -z "$target_os" ]]; then
253+
target_os=$HOST_OS
254+
fi
255+
256+
if [[ -z "$target_arch" ]]; then
257+
if ! target_arch=$(get_cli_architecture_from_architecture "<auto>"); then
255258
return 1
256259
fi
257260
else
258-
os="$OS"
261+
if ! target_arch=$(get_cli_architecture_from_architecture "$target_arch"); then
262+
return 1
263+
fi
264+
fi
265+
266+
printf "%s" "${target_os}-${target_arch}"
267+
}
268+
269+
# Function to install/unpack archive files
270+
install_archive() {
271+
local archive_file="$1"
272+
local destination_path="$2"
273+
274+
if [[ "$DRY_RUN" == true ]]; then
275+
say_info "[DRY RUN] Would install archive $archive_file to $destination_path"
276+
return 0
277+
fi
278+
279+
say_verbose "Installing archive to: $destination_path"
280+
281+
# Create install directory if it doesn't exist
282+
if [[ ! -d "$destination_path" ]]; then
283+
say_verbose "Creating install directory: $destination_path"
284+
mkdir -p "$destination_path"
259285
fi
260286

261-
if [[ -z "$ARCH" ]]; then
262-
if ! arch=$(get_cli_architecture_from_architecture "<auto>"); then
287+
# Check archive format and extract accordingly
288+
if [[ "$archive_file" == *.zip ]]; then
289+
# Use unzip for ZIP files
290+
if ! command -v unzip >/dev/null 2>&1; then
291+
say_error "unzip command not found. Please install unzip to extract ZIP files."
263292
return 1
264293
fi
265-
else
266-
if ! arch=$(get_cli_architecture_from_architecture "$ARCH"); then
294+
295+
if ! unzip -o "$archive_file" -d "$destination_path"; then
296+
say_error "Failed to extract ZIP archive: $archive_file"
297+
return 1
298+
fi
299+
elif [[ "$archive_file" == *.tar.gz ]]; then
300+
# Use tar for tar.gz files on Unix systems
301+
if ! command -v tar >/dev/null 2>&1; then
302+
say_error "tar command not found. Please install tar to extract tar.gz files."
267303
return 1
268304
fi
305+
306+
if ! tar -xzf "$archive_file" -C "$destination_path"; then
307+
say_error "Failed to extract tar.gz archive: $archive_file"
308+
return 1
309+
fi
310+
else
311+
say_error "Unsupported archive format: $archive_file. Only .zip and .tar.gz are supported."
312+
return 1
269313
fi
270314

271-
printf "%s" "${os}-${arch}"
315+
say_verbose "Successfully installed archive"
272316
}
273317

274318
# Function to add PATH to shell configuration file
@@ -410,7 +454,7 @@ cleanup() {
410454
}
411455

412456
# =============================================================================
413-
# END: Code shared with get-aspire-cli*.sh
457+
# END: Shared code
414458
# =============================================================================
415459

416460
# Common function for HTTP requests with centralized configuration

0 commit comments

Comments
 (0)