Repository navigation
Expand file tree
/
Copy pathcomposer-install
More file actions
executable file
·56 lines (49 loc) · 1.72 KB
/
Copy pathcomposer-install
File metadata and controls
executable file
·56 lines (49 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
################################################################################
#
# composer-install
#
# Install/Update Composer for current user. This also works as a version manager.
# If version is not specified, the latest version will be installed.
#
# Homepage: https://getcomposer.org/
#
# Usage:
# composer-install [<version>]
#
# Example:
# composer-install
# composer-install 2.9.2
# composer-install v2.9.2
#
# MIT License.
# Copyright (C) 2025 Nguyen Nhat Tung.
#
################################################################################
set -ex
# Application info
GITHUB_OWNER="composer"
GITHUB_REPO="composer"
PROGRAM_ID="composer"
PROGRAM_EXEC="composer.phar"
# Shared library
CTXDIR="$(cd "$(dirname "$0")" && pwd)"
. "${CTXDIR}/shared/install-common.sh"
# Prepare environment
get_install_version_from_github "${GITHUB_OWNER}" "${GITHUB_REPO}" "$1"
init_install_env "${PROGRAM_ID}" "${INSTALL_VERSION}"
# Download and install binaries
if [ ! -d "${INSTALL_TARGET}" ]; then
BIN_URI_AMD64="https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases/download/${INSTALL_VERSION}/composer.phar"
BIN_URI_ARM64="https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases/download/${INSTALL_VERSION}/composer.phar"
BIN_TMP_FILE="${TEMP_TARGET}.bin"
download_uri_per_arch "${BIN_URI_AMD64}" "${BIN_URI_ARM64}" "${BIN_TMP_FILE}"
create_dir "${TEMP_TARGET}"
make_executable "${BIN_TMP_FILE}"
move_item "${BIN_TMP_FILE}" "${TEMP_TARGET}/${PROGRAM_EXEC}"
move_item "${TEMP_TARGET}" "${INSTALL_TARGET}"
remove_item "${TEMP_TARGET}"
fi
# Finalize install
symlink_item_overwrite "${INSTALL_TARGET}" "${ACTIVE_TARGET}"
symlink_item_overwrite "${ACTIVE_TARGET}/${PROGRAM_EXEC}" "${SYSTEM_BIN_ROOT}/${PROGRAM_ID}"