From dd1e5b0b3ad9453ce9fcbc2c2a9ae374189ec312 Mon Sep 17 00:00:00 2001 From: Meredith Howard Date: Sun, 9 Jan 2022 16:46:37 -0600 Subject: [PATCH 1/4] Remove plenv (it's actually unused) --- bin/utils.sh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/bin/utils.sh b/bin/utils.sh index b4170a0..c7801ae 100755 --- a/bin/utils.sh +++ b/bin/utils.sh @@ -10,31 +10,29 @@ ensure_perl_build_installed() { download_perl_build() { echo "Downloading perl-build..." >&2 - local plenv_url="https://github.com/tokuhirom/plenv.git" local perl_build_url="https://github.com/tokuhirom/Perl-Build.git" - git clone $plenv_url "$(plenv_path)" - git clone $perl_build_url "$(plenv_path)/plugins/perl-build/" + git clone $perl_build_url "$(perl_build_checkout)" } -perl_build_path() { - echo "$(plenv_path)/plugins/perl-build/bin/perl-build" +perl_build_checkout() { + echo "$(dirname $(dirname $0))/perl-build" } -update_perl_build() { - cd "$(plenv_path)" && git fetch && git reset --hard origin/master > /dev/null 2>&1 +perl_build_path() { + echo "$(perl_build_checkout)/bin/perl-build" } -plenv_path() { - echo "$(dirname $(dirname $0))/plenv" +update_perl_build() { + cd "$(perl_build_checkout)" && git fetch && git reset --hard origin/master > /dev/null 2>&1 } -plenv_update_timestamp_path() { - echo "$(dirname $(dirname "$0"))/plenv_last_update" +update_timestamp_path() { + echo "$(dirname $(dirname "$0"))/last_update" } -plenv_should_update() { +should_update() { update_timeout=3600 - update_timestamp_path=$(plenv_update_timestamp_path) + update_timestamp_path=$(update_timestamp_path) if [ ! -f "$update_timestamp_path" ]; then return 0 @@ -50,8 +48,8 @@ plenv_should_update() { install_or_update_perl_build() { if [ ! -f "$(perl_build_path)" ]; then download_perl_build - elif plenv_should_update; then + elif should_update; then update_perl_build - date +%s > "$(plenv_update_timestamp_path)" + date +%s > "$(update_timestamp_path)" fi } From d1fd96253dbd4ffa8c1f923952781a35f8fc1f3f Mon Sep 17 00:00:00 2001 From: Meredith Howard Date: Sun, 9 Jan 2022 17:15:39 -0600 Subject: [PATCH 2/4] Use git's FETCH_HEAD for update tracking Get mtime portably across MacOS and Linux --- bin/utils.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/utils.sh b/bin/utils.sh index c7801ae..d1d1e3b 100755 --- a/bin/utils.sh +++ b/bin/utils.sh @@ -27,20 +27,20 @@ update_perl_build() { } update_timestamp_path() { - echo "$(dirname $(dirname "$0"))/last_update" + echo "$(perl_build_checkout)/.git/FETCH_HEAD" } should_update() { - update_timeout=3600 - update_timestamp_path=$(update_timestamp_path) + local update_timeout=3600 + local update_timestamp_path=$(update_timestamp_path) if [ ! -f "$update_timestamp_path" ]; then return 0 fi - last_update=$(cat "$update_timestamp_path") - current_timestamp=$(date +%s) - invalidated_at=$(($last_update + $update_timeout)) + local last_update="$(date -r "$update_timestamp_path" +%s)" + local current_timestamp="$(date +%s)" + local invalidated_at="$(($last_update + $update_timeout))" [ $invalidated_at -lt $current_timestamp ] } @@ -50,6 +50,5 @@ install_or_update_perl_build() { download_perl_build elif should_update; then update_perl_build - date +%s > "$(update_timestamp_path)" fi } From 8e5332def0d4c5fd294a810dead0588b838abca5 Mon Sep 17 00:00:00 2001 From: Meredith Howard Date: Sun, 9 Jan 2022 18:21:12 -0600 Subject: [PATCH 3/4] Perform shallow clone --- bin/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/utils.sh b/bin/utils.sh index d1d1e3b..2f8624e 100755 --- a/bin/utils.sh +++ b/bin/utils.sh @@ -11,7 +11,7 @@ ensure_perl_build_installed() { download_perl_build() { echo "Downloading perl-build..." >&2 local perl_build_url="https://github.com/tokuhirom/Perl-Build.git" - git clone $perl_build_url "$(perl_build_checkout)" + git clone --depth 1 $perl_build_url "$(perl_build_checkout)" } perl_build_checkout() { From 54311ea79c08a5dcd4fde81e53fca44076c5fe7f Mon Sep 17 00:00:00 2001 From: Meredith Howard Date: Sun, 9 Jan 2022 20:06:47 -0600 Subject: [PATCH 4/4] Switch from perl-build to perl-install, which doesn't require perl --- bin/install | 10 +++++----- bin/list-all | 4 ++-- bin/utils.sh | 36 ++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/bin/install b/bin/install index 38bfe88..3ac8e9d 100755 --- a/bin/install +++ b/bin/install @@ -15,14 +15,14 @@ install_perl() { echoerr "For a list of available versions, see \`asdf list-all perl\`." exit 1 fi - install_or_update_perl_build + install_or_update_perl_install - local build_args=("-j${concurrency}" -Dusethreads) + local build_args=("-j=${concurrency}" -Dusethreads) if is_development_version "$version"; then build_args+=(-Dusedevel --symlink-devel-executables) fi - echo "perl-build ${build_args[@]} $version $install_path" - $(perl_build_path) "${build_args[@]}" "$version" "$install_path" + echo "perl-install ${build_args[@]} $version $install_path" + $(perl_install_bin) "${build_args[@]}" "$version" "$install_path" } install_cpanm() { @@ -75,7 +75,7 @@ is_development_version() { return 0 } -ensure_perl_build_installed +ensure_perl_install_installed install_perl "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" install_cpanm "$ASDF_INSTALL_PATH" install_default_perl_modules diff --git a/bin/list-all b/bin/list-all index c7c9008..b9bc8fb 100755 --- a/bin/list-all +++ b/bin/list-all @@ -3,8 +3,8 @@ source "$(dirname "$0")/utils.sh" list_all() { - install_or_update_perl_build - $(perl_build_path) --definitions | tac | tr '\n' ' ' + install_or_update_perl_install + $(perl_install_bin) --list-all | tac | tr '\n' ' ' } list_all diff --git a/bin/utils.sh b/bin/utils.sh index 2f8624e..0acedf7 100755 --- a/bin/utils.sh +++ b/bin/utils.sh @@ -2,32 +2,32 @@ echoerr() { printf "\033[0;31m%s\033[0m" "$1" >&2 } -ensure_perl_build_installed() { - if [ ! -f "$(perl_build_path)" ]; then - download_perl_build +ensure_perl_install_installed() { + if [ ! -f "$(perl_install_bin)" ]; then + download_perl_install fi } -download_perl_build() { - echo "Downloading perl-build..." >&2 - local perl_build_url="https://github.com/tokuhirom/Perl-Build.git" - git clone --depth 1 $perl_build_url "$(perl_build_checkout)" +download_perl_install() { + echo "Downloading perl-install..." >&2 + local perl_install_url="https://github.com/skaji/perl-install.git" + git clone --depth 1 $perl_install_url "$(perl_install_checkout)" } -perl_build_checkout() { - echo "$(dirname $(dirname $0))/perl-build" +perl_install_checkout() { + echo "$(dirname $(dirname $0))/perl-install" } -perl_build_path() { - echo "$(perl_build_checkout)/bin/perl-build" +perl_install_bin() { + echo "$(perl_install_checkout)/perl-install" } -update_perl_build() { - cd "$(perl_build_checkout)" && git fetch && git reset --hard origin/master > /dev/null 2>&1 +update_perl_install() { + cd "$(perl_install_checkout)" && git fetch && git reset --hard origin/HEAD > /dev/null 2>&1 } update_timestamp_path() { - echo "$(perl_build_checkout)/.git/FETCH_HEAD" + echo "$(perl_install_checkout)/.git/FETCH_HEAD" } should_update() { @@ -45,10 +45,10 @@ should_update() { [ $invalidated_at -lt $current_timestamp ] } -install_or_update_perl_build() { - if [ ! -f "$(perl_build_path)" ]; then - download_perl_build +install_or_update_perl_install() { + if [ ! -f "$(perl_install_bin)" ]; then + download_perl_install elif should_update; then - update_perl_build + update_perl_install fi }