Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add musl support #188

Merged
merged 3 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amber"
version = "0.3.2-alpha"
version = "0.3.3-alpha"
edition = "2021"
repository = "https://github.com/Ph0enixKM/Amber"

Expand Down Expand Up @@ -33,10 +33,10 @@ ci = "github"
# The installers to generate for each app
installers = []
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
# Publish jobs to run in CI
pr-run-mode = "skip"
# Whether cargo-dist should create a Github Release or use an existing draft
create-release = false
# Allow modifying the release.yml
# Skip checking whether the specified configuration files are up to date
allow-dirty = ["ci"]
17 changes: 0 additions & 17 deletions build.ab
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
let targets = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-musl",
"x86_64-apple-darwin",
"x86_64-unknown-linux-musl"
]

// Check if such directory exists
$test -f "Cargo.toml" > /dev/null$ failed {
echo "Please run this command in the project root directory"
Expand All @@ -13,16 +6,6 @@ $test -f "Cargo.toml" > /dev/null$ failed {

unsafe {
if status == 0 {
let target_str = ""
loop target in targets {
target_str += "--target {target} "
}
$cargo build --release {target_str}$
// Move ambers to the release directory
$mv target/aarch64-apple-darwin/release/amber target/release/amber_macos_aarch64$
$mv target/aarch64-unknown-linux-musl/release/amber target/release/amber_linux_aarch64$
$mv target/x86_64-apple-darwin/release/amber target/release/amber_macos_x86_64$
$mv target/x86_64-unknown-linux-musl/release/amber target/release/amber_linux_x86_64$
Comment on lines -16 to -25
Copy link
Member Author

@Ph0enixKM Ph0enixKM Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used to use this script to recompile binaries. Now they are compiled in the cloud hence the code deletion. This script only recompiles the installer and uninstaller scripts now.

// Recompile installer scripts
$cargo run -- setup/install.ab setup/install.sh$
$cargo run -- setup/uninstall.ab setup/uninstall.sh$
Expand Down
1 change: 1 addition & 0 deletions setup/install.ab
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fun get_latest_release_tag() {

main(args) {
let os = get_os()
echo "OS: {os}"
let arch = get_arch()

let user_only_install = includes(args, "--user")
Expand Down
169 changes: 93 additions & 76 deletions setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,80 @@ done
__AF_includes24_v0=0;
return 0
}
function get_os__31_v0 {
function get_os__32_v0 {
__AMBER_VAL_0=$(uname -s);
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to determine OS type."
echo "Please try again or use another download method."
echo "Failed to determine OS type (using \`uname\` command)."
echo "Please try again or make sure you have it installed."
exit__23_v0 1;
__AF_exit23_v0__8=$__AF_exit23_v0;
echo $__AF_exit23_v0__8 > /dev/null 2>&1
fi;
local os_type="${__AMBER_VAL_0}"
local os=$(if [ $([ "_${os_type}" != "_Darwin" ]; echo $?) != 0 ]; then echo "apple-darwin"; else echo "unknown-linux-gnu"; fi)
__AF_get_os31_v0="${os}";
if [ $([ "_${os_type}" != "_Darwin" ]; echo $?) != 0 ]; then
__AF_get_os32_v0="apple-darwin";
return 0
fi
if [ $([ "_${os_type}" == "_Linux" ]; echo $?) != 0 ]; then
echo "Unsupported OS type: ${os_type}"
echo "Please try again or use another download method."
exit__23_v0 1;
__AF_exit23_v0__16=$__AF_exit23_v0;
echo $__AF_exit23_v0__16 > /dev/null 2>&1
fi
has_failed__22_v0 "ls -l /lib | grep libc.musl";
__AF_has_failed22_v0__19=$__AF_has_failed22_v0;
if [ $(echo '!' $__AF_has_failed22_v0__19 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') != 0 ]; then
__AF_get_os32_v0="unknown-linux-musl";
return 0
fi
__AF_get_os32_v0="unknown-linux-gnu";
return 0
}
function get_arch__32_v0 {
function get_arch__33_v0 {
__AMBER_VAL_1=$(uname -m);
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to determine architecture."
echo "Please try again or use another download method."
exit__23_v0 1;
__AF_exit23_v0__22=$__AF_exit23_v0;
echo $__AF_exit23_v0__22 > /dev/null 2>&1
__AF_exit23_v0__30=$__AF_exit23_v0;
echo $__AF_exit23_v0__30 > /dev/null 2>&1
fi;
local arch_type="${__AMBER_VAL_1}"
__AMBER_ARRAY_0=("arm64" "aarch64");
includes__24_v0 __AMBER_ARRAY_0[@] "${arch_type}";
__AF_includes24_v0__25=$__AF_includes24_v0;
local arch=$(if [ $__AF_includes24_v0__25 != 0 ]; then echo "aarch64"; else echo "x86_64"; fi)
__AF_get_arch32_v0="${arch}";
__AF_includes24_v0__33=$__AF_includes24_v0;
local arch=$(if [ $__AF_includes24_v0__33 != 0 ]; then echo "aarch64"; else echo "x86_64"; fi)
__AF_get_arch33_v0="${arch}";
return 0
}
function get_home__33_v0 {
function get_home__34_v0 {
__AMBER_VAL_2=$(echo $HOME);
__AS=$?;
if [ $__AS != 0 ]; then
echo "User installation requested, but unable to retrieve home directory from $HOME environment."
exit__23_v0 1;
__AF_exit23_v0__35=$__AF_exit23_v0;
echo $__AF_exit23_v0__35 > /dev/null 2>&1
__AF_exit23_v0__43=$__AF_exit23_v0;
echo $__AF_exit23_v0__43 > /dev/null 2>&1
fi;
local home="${__AMBER_VAL_2}"
if [ $([ "_${home}" != "_" ]; echo $?) != 0 ]; then
echo "User installation requested, but unable to find home directory."
exit__23_v0 1;
__AF_exit23_v0__39=$__AF_exit23_v0;
echo $__AF_exit23_v0__39 > /dev/null 2>&1
__AF_exit23_v0__47=$__AF_exit23_v0;
echo $__AF_exit23_v0__47 > /dev/null 2>&1
fi
__AF_get_home33_v0="${home}";
__AF_get_home34_v0="${home}";
return 0
}
function get_bins_folder__34_v0 {
function get_bins_folder__35_v0 {
local user_only=$1
if [ ${user_only} != 0 ]; then
get_home__33_v0 ;
__AF_get_home33_v0__46="${__AF_get_home33_v0}";
__AF_get_bins_folder34_v0="${__AF_get_home33_v0__46}/.local/bin";
get_home__34_v0 ;
__AF_get_home34_v0__54="${__AF_get_home34_v0}";
__AF_get_bins_folder35_v0="${__AF_get_home34_v0__54}/.local/bin";
return 0
else
local bins_folder="/usr/local/bin"
Expand All @@ -95,25 +111,25 @@ __AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to create ${bins_folder} directory."
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__53=$__AF_exit23_v0;
echo $__AF_exit23_v0__53 > /dev/null 2>&1
__AF_exit23_v0__61=$__AF_exit23_v0;
echo $__AF_exit23_v0__61 > /dev/null 2>&1
fi
fi
__AF_get_bins_folder34_v0="${bins_folder}";
__AF_get_bins_folder35_v0="${bins_folder}";
return 0
fi
}
function get_place__35_v0 {
function get_place__36_v0 {
local user_only=$1
if [ ${user_only} != 0 ]; then
get_home__33_v0 ;
__AF_get_home33_v0__62="${__AF_get_home33_v0}";
get_arch__32_v0 ;
__AF_get_arch32_v0__62="${__AF_get_arch32_v0}";
__AF_get_place35_v0="${__AF_get_home33_v0__62}/.local/lib/${__AF_get_arch32_v0__62}/amber";
get_home__34_v0 ;
__AF_get_home34_v0__70="${__AF_get_home34_v0}";
get_arch__33_v0 ;
__AF_get_arch33_v0__70="${__AF_get_arch33_v0}";
__AF_get_place36_v0="${__AF_get_home34_v0__70}/.local/lib/${__AF_get_arch33_v0__70}/amber";
return 0
else
__AF_get_place35_v0="/opt/amber";
__AF_get_place36_v0="/opt/amber";
return 0
fi
}
Expand All @@ -126,41 +142,42 @@ __AMBER_VAL_3=$(uname -a);
__AS=$?;
__3_agent=$(if [ $__AF_has_failed22_v0__7 != 0 ]; then echo "unknown"; else echo "${__AMBER_VAL_3}"; fi)
echo ""
function get_latest_release_tag__40_v0 {
function get_latest_release_tag__41_v0 {
local tag_url="https://api.github.com/repos/Ph0enixKM/${__0_name}/releases/latest"
__AMBER_VAL_4=$(curl -L "${tag_url}" 2>/dev/null);
__AS=$?;
if [ $__AS != 0 ]; then
__AF_get_latest_release_tag40_v0=''
__AF_get_latest_release_tag41_v0=''
return $__AS
fi;
local tag_json="${__AMBER_VAL_4}"
__AMBER_VAL_5=$(echo "$tag_json" | grep -Eo "tag_name\"[^\"]*\"([^\"]+)\"" | grep -Eo "\"[^\"]+\"$" | grep -Eo "[^\"\s]+");
__AS=$?;
if [ $__AS != 0 ]; then
__AF_get_latest_release_tag40_v0=''
__AF_get_latest_release_tag41_v0=''
return $__AS
fi;
local tag="${__AMBER_VAL_5}"
__AF_get_latest_release_tag40_v0="${tag}";
__AF_get_latest_release_tag41_v0="${tag}";
return 0
}
args=("$@")
get_os__31_v0 ;
__AF_get_os31_v0__25="${__AF_get_os31_v0}";
os="${__AF_get_os31_v0__25}"
get_arch__32_v0 ;
__AF_get_arch32_v0__26="${__AF_get_arch32_v0}";
arch="${__AF_get_arch32_v0__26}"
get_os__32_v0 ;
__AF_get_os32_v0__25="${__AF_get_os32_v0}";
os="${__AF_get_os32_v0__25}"
echo "OS: ${os}"
get_arch__33_v0 ;
__AF_get_arch33_v0__27="${__AF_get_arch33_v0}";
arch="${__AF_get_arch33_v0__27}"
includes__24_v0 args[@] "--user";
__AF_includes24_v0__28=$__AF_includes24_v0;
user_only_install=$__AF_includes24_v0__28
get_place__35_v0 ${user_only_install};
__AF_get_place35_v0__29="${__AF_get_place35_v0}";
place="${__AF_get_place35_v0__29}"
get_bins_folder__34_v0 ${user_only_install};
__AF_get_bins_folder34_v0__30="${__AF_get_bins_folder34_v0}";
bins_folder="${__AF_get_bins_folder34_v0__30}"
__AF_includes24_v0__29=$__AF_includes24_v0;
user_only_install=$__AF_includes24_v0__29
get_place__36_v0 ${user_only_install};
__AF_get_place36_v0__30="${__AF_get_place36_v0}";
place="${__AF_get_place36_v0__30}"
get_bins_folder__35_v0 ${user_only_install};
__AF_get_bins_folder35_v0__31="${__AF_get_bins_folder35_v0}";
bins_folder="${__AF_get_bins_folder35_v0__31}"
test -d "${place}"
__AS=$?
if [ $(echo $__AS '==' 0 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') != 0 ]; then
Expand All @@ -169,17 +186,17 @@ __AS=$?
echo "If you want to reinstall Amber, uninstall it first."
echo "(Find out more at https://docs.amber-lang.com/getting_started/installation#uninstallation)"
exit__23_v0 2;
__AF_exit23_v0__40=$__AF_exit23_v0;
echo $__AF_exit23_v0__40 > /dev/null 2>&1
__AF_exit23_v0__41=$__AF_exit23_v0;
echo $__AF_exit23_v0__41 > /dev/null 2>&1
fi
has_failed__22_v0 "curl -V";
__AF_has_failed22_v0__44=$__AF_has_failed22_v0;
if [ $__AF_has_failed22_v0__44 != 0 ]; then
__AF_has_failed22_v0__45=$__AF_has_failed22_v0;
if [ $__AF_has_failed22_v0__45 != 0 ]; then
echo "Curl is not installed on your system."
echo "Please install \`curl\` and try again."
exit__23_v0 1;
__AF_exit23_v0__47=$__AF_exit23_v0;
echo $__AF_exit23_v0__47 > /dev/null 2>&1
__AF_exit23_v0__48=$__AF_exit23_v0;
echo $__AF_exit23_v0__48 > /dev/null 2>&1
fi
echo "Installing Amber... 🚀"
sudo=$(if [ ${user_only_install} != 0 ]; then echo ""; else echo "sudo"; fi)
Expand All @@ -193,83 +210,83 @@ else
echo "Please make sure that your user can access ${place} directory."
fi
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__63=$__AF_exit23_v0;
echo $__AF_exit23_v0__63 > /dev/null 2>&1
__AF_exit23_v0__64=$__AF_exit23_v0;
echo $__AF_exit23_v0__64 > /dev/null 2>&1
fi
if [ ${user_only_install} != 0 ]; then
mkdir -p "${bins_folder}" > /dev/null 2>&1
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to create directory for amber bin at ${bins_folder}."
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__68=$__AF_exit23_v0;
echo $__AF_exit23_v0__68 > /dev/null 2>&1
__AF_exit23_v0__69=$__AF_exit23_v0;
echo $__AF_exit23_v0__69 > /dev/null 2>&1
fi
fi
get_latest_release_tag__40_v0 ;
get_latest_release_tag__41_v0 ;
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to get the latest release tag."
echo "Please try again or use another download method."
exit__23_v0 1;
__AF_exit23_v0__75=$__AF_exit23_v0;
echo $__AF_exit23_v0__75 > /dev/null 2>&1
__AF_exit23_v0__76=$__AF_exit23_v0;
echo $__AF_exit23_v0__76 > /dev/null 2>&1
fi;
__AF_get_latest_release_tag40_v0__72="${__AF_get_latest_release_tag40_v0}";
tag="${__AF_get_latest_release_tag40_v0__72}"
__AF_get_latest_release_tag41_v0__73="${__AF_get_latest_release_tag41_v0}";
tag="${__AF_get_latest_release_tag41_v0__73}"
url="https://github.com/Ph0enixKM/${__0_name}/releases/download/${tag}/amber-${arch}-${os}.tar.xz"
curl -L -o "${__2_archive}" "${url}" > /dev/null 2>&1
__AS=$?;
if [ $__AS != 0 ]; then
echo "Curl failed to download amber."
echo "Something went wrong. Please try again later."
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__85=$__AF_exit23_v0;
echo $__AF_exit23_v0__85 > /dev/null 2>&1
__AF_exit23_v0__86=$__AF_exit23_v0;
echo $__AF_exit23_v0__86 > /dev/null 2>&1
fi
${sudo} mv "${__2_archive}" "${place}/${__2_archive}"
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to move amber to the installation directory."
echo "Please make sure that root user can access ${place} directory."
exit__23_v0 1;
__AF_exit23_v0__92=$__AF_exit23_v0;
echo $__AF_exit23_v0__92 > /dev/null 2>&1
__AF_exit23_v0__93=$__AF_exit23_v0;
echo $__AF_exit23_v0__93 > /dev/null 2>&1
fi
${sudo} tar --strip-components=1 -xvf ${place}/${__2_archive} -C ${place} > /dev/null 2>&1
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to unarchive amber at ${place}/${__2_archive}"
echo "Please make sure that you have \`tar\` command installed."
exit__23_v0 1 > /dev/null 2>&1;
__AF_exit23_v0__99=$__AF_exit23_v0;
echo $__AF_exit23_v0__99 > /dev/null 2>&1
__AF_exit23_v0__100=$__AF_exit23_v0;
echo $__AF_exit23_v0__100 > /dev/null 2>&1
fi
${sudo} rm ${place}/${__2_archive}
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to remove downloaded archive at ${place}/${__2_archive}"
exit__23_v0 1;
__AF_exit23_v0__105=$__AF_exit23_v0;
echo $__AF_exit23_v0__105 > /dev/null 2>&1
__AF_exit23_v0__106=$__AF_exit23_v0;
echo $__AF_exit23_v0__106 > /dev/null 2>&1
fi
${sudo} chmod +x "${place}/${__1_target}"
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to give permissions to execute amber."
echo "Please make sure that root user can access ${place} directory."
exit__23_v0 1;
__AF_exit23_v0__112=$__AF_exit23_v0;
echo $__AF_exit23_v0__112 > /dev/null 2>&1
__AF_exit23_v0__113=$__AF_exit23_v0;
echo $__AF_exit23_v0__113 > /dev/null 2>&1
fi
${sudo} ln -s "${place}/${__1_target}" "${bins_folder}/${__1_target}"
__AS=$?;
if [ $__AS != 0 ]; then
echo "Failed to create amber symbol link."
echo "Please make sure that root user can access /usr/local/bin directory."
exit__23_v0 1;
__AF_exit23_v0__119=$__AF_exit23_v0;
echo $__AF_exit23_v0__119 > /dev/null 2>&1
__AF_exit23_v0__120=$__AF_exit23_v0;
echo $__AF_exit23_v0__120 > /dev/null 2>&1
fi
curl -G --data-urlencode "agent=${__3_agent}" --data-urlencode "name=download" "https://amber-lang.com/api/visit" > /dev/null 2>&1
__AS=$?
Expand Down
Loading