Skip to content
Open
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
9 changes: 9 additions & 0 deletions abs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
aggregate_check: false

upload_without_merge: true

upload_channels:
- services

channels:
- services
196 changes: 196 additions & 0 deletions recipe/0001-gh-106-install.sh-Perfomance-Use-more-shell-builtins.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
From 74ec46375ef943ad09ef8b461d3da5868cb37d26 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <uwe.korn@quantco.com>
Date: Tue, 15 Aug 2023 07:20:29 +0200
Subject: [PATCH] gh-106: install.sh: Perfomance Use more shell builtins

---
install.sh | 117 +++++++++++++++++++++++++++--------------------------
1 file changed, 59 insertions(+), 58 deletions(-)

diff --git a/install.sh b/install.sh
index d86cbf2..9a2913d 100755
--- a/install.sh
+++ b/install.sh
@@ -136,11 +136,16 @@ append_to_file() {

make_dir_recursive() {
local _dir="$1"
- local _line="$ umask 022 && mkdir -p \"$_dir\""
- umask 022 && mkdir -p "$_dir"
- local _retval=$?
- log_line "$_line"
- return $_retval
+ # Skip if the last invocation of make_dir_recursive had the same argument
+ if ! [ "$_dir" = "${_make_dir_recursive_cached_key:-}" ]
+ then
+ _make_dir_recursive_cached_key="$_dir"
+ local _line="$ umask 022 && mkdir -p \"$_dir\""
+ umask 022 && mkdir -p "$_dir"
+ local _retval=$?
+ log_line "$_line"
+ return $_retval
+ fi
}

putvar() {
@@ -165,11 +170,11 @@ valopt() {
eval $v="$default"
for arg in $CFG_ARGS
do
- if echo "$arg" | grep -q -- "--$op="
- then
- local val=$(echo "$arg" | cut -f2 -d=)
- eval $v=$val
- fi
+ case "${arg}" in
+ "--${op}="* )
+ local val="${arg#--${op}=}"
+ eval $v=$val
+ esac
done
putvar $v
else
@@ -271,10 +276,10 @@ validate_opt () {
done
for option in $VAL_OPTIONS
do
- if echo "$arg" | grep -q -- "--$option="
- then
- is_arg_valid=1
- fi
+ case "${arg}" in
+ "--${option}="* )
+ is_arg_valid=1
+ esac
done
if [ "$arg" = "--help" ]
then
@@ -293,9 +298,10 @@ validate_opt () {

absolutify() {
local file_path="$1"
- local file_path_dirname="$(dirname "$file_path")"
- local file_path_basename="$(basename "$file_path")"
- local file_abs_path="$(abs_path "$file_path_dirname")"
+ local file_path_dirname="${file_path%/*}"
+ local file_path_basename="${file_path##*/}"
+ abs_path_cached "$file_path_dirname"
+ local file_abs_path="$abs_path_cached_retval"
local file_path="$file_abs_path/$file_path_basename"
# This is the return value
RETVAL="$file_path"
@@ -303,11 +309,21 @@ absolutify() {

# Prints the absolute path of a directory to stdout
abs_path() {
+ abs_path_cached "$@"
+ printf %s "$abs_path_cached_retval"
+}
+
+abs_path_cached() {
local path="$1"
- # Unset CDPATH because it causes havok: it makes the destination unpredictable
- # and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
- # for good measure.
- (unset CDPATH && cd "$path" > /dev/null && pwd)
+ # Update return value only if the argument differs from the last invocation
+ if ! [ "$path" = "${_abs_path_cached_key:-}" ]
+ then
+ _abs_path_cached_key="$path"
+ # Unset CDPATH because it causes havok: it makes the destination unpredictable
+ # and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
+ # for good measure.
+ abs_path_cached_retval="$(unset CDPATH && cd "$path" > /dev/null && pwd)"
+ fi
}

uninstall_legacy() {
@@ -551,35 +567,23 @@ install_components() {
# Decide the destination of the file
local _file_install_path="$_dest_prefix/$_file"

- if echo "$_file" | grep "^etc/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^etc\///')"
- _file_install_path="$CFG_SYSCONFDIR/$_f"
- fi
-
- if echo "$_file" | grep "^bin/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^bin\///')"
- _file_install_path="$CFG_BINDIR/$_f"
- fi
-
- if echo "$_file" | grep "^lib/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^lib\///')"
- _file_install_path="$CFG_LIBDIR/$_f"
- fi
-
- if echo "$_file" | grep "^share" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\///')"
- _file_install_path="$CFG_DATADIR/$_f"
- fi
-
- if echo "$_file" | grep "^share/man/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\/man\///')"
- _file_install_path="$CFG_MANDIR/$_f"
- fi
+ case "${_file}" in
+ etc/* )
+ _file_install_path="$CFG_SYSCONFDIR/${_file#etc/}"
+ ;;
+ bin/* )
+ _file_install_path="$CFG_BINDIR/${_file#bin/}"
+ ;;
+ lib/* )
+ _file_install_path="$CFG_LIBDIR/${_file#lib/}"
+ ;;
+ share/man/* )
+ _file_install_path="$CFG_MANDIR/${_file#share/man/}"
+ ;;
+ share/* )
+ _file_install_path="$CFG_DATADIR/${_file#share/}"
+ ;;
+ esac

# HACK: Try to support overriding --docdir. Paths with the form
# "share/doc/$product/" can be redirected to a single --docdir
@@ -593,11 +597,10 @@ install_components() {
# this problem to be a big deal in practice.
if [ "$CFG_DOCDIR" != "<default>" ]
then
- if echo "$_file" | grep "^share/doc/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')"
- _file_install_path="$CFG_DOCDIR/$_f"
- fi
+ case "${_file}" in
+ share/doc/* )
+ _file_install_path="$CFG_DOCDIR/${_file#share/doc/*/}"
+ esac
fi

# Make sure there's a directory for it
@@ -617,7 +620,7 @@ install_components() {

maybe_backup_path "$_file_install_path"

- if echo "$_file" | grep "^bin/" > /dev/null || test -x "$_src_dir/$_component/$_file"
+ if test -z "${_file##bin/*}" || test -x "$_src_dir/$_component/$_file"
then
run cp "$_src_dir/$_component/$_file" "$_file_install_path"
run chmod 755 "$_file_install_path"
@@ -764,8 +767,6 @@ verbose_msg

need_cmd mkdir
need_cmd printf
-need_cmd cut
-need_cmd grep
need_cmd uname
need_cmd tr
need_cmd sed
--
2.39.2 (Apple Git-143)
9 changes: 9 additions & 0 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo on
set MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
FOR /F "delims=" %%i in ('cygpath.exe -u "%PREFIX%/Library"') DO set "PREFIX=%%i"
FOR /F "delims=" %%i in ('cygpath.exe -u "%SRC_DIR%"') DO set "SRC_DIR=%%i"
copy "%RECIPE_DIR%\build.sh" .
bash -lce "%SRC_DIR%/build.sh"
if errorlevel 1 exit 1
24 changes: 24 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -ex

# windows shell doesn't start here
cd $SRC_DIR

DESTDIR=$PWD/destdir/

# we want to install only a portion of the full installation.
# To do that, let's use destdir and then use the manifest-rust-std-* file
# to install the files corresponding to rust-std
./install.sh --prefix=$PREFIX --destdir=$DESTDIR

# install.log is large because it records full paths for each file.
# => conda-build is slow to parse ripgrep's output for prefix replacement.
# => replace path records beforehand:
install_log="${DESTDIR}${PREFIX}/lib/rustlib/install.log"
sed \
-e "s|${PREFIX}|/prefix|g" \
-e "s|${DESTDIR}|/destdir|g" \
-e "s|${PWD}|/source|g" \
-i.bak "${install_log}"
rm "${install_log}.bak"
24 changes: 18 additions & 6 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
rust_arch:
- x86_64-unknown-linux-gnu # [linux64]
- s390x-unknown-linux-gnu # [s390x]
- aarch64-unknown-linux-gnu # [aarch64]
- powerpc64le-unknown-linux-gnu # [ppc64le]
- x86_64-apple-darwin # [osx and x86_64]
- aarch64-apple-darwin # [osx and arm64]
- x86_64-unknown-linux-gnu # [linux64]
- aarch64-unknown-linux-gnu # [aarch64]
- powerpc64le-unknown-linux-gnu # [ppc64le]
- x86_64-pc-windows-msvc # [win64]
- x86_64-apple-darwin # [osx and x86_64]
- aarch64-apple-darwin # [osx and arm64]

rust_std_extra:
- aarch64-apple-ios
- x86_64-apple-ios
- aarch64-apple-ios-sim
- aarch64-linux-android
- arm-linux-androideabi
- armv7-linux-androideabi
- i686-linux-android
- wasm32-unknown-unknown
- x86_64-linux-android
- x86_64-pc-windows-msvc # [linux and x86_64]
24 changes: 0 additions & 24 deletions recipe/forge_test.sh

This file was deleted.

4 changes: 0 additions & 4 deletions recipe/install-gnu.bat

This file was deleted.

4 changes: 0 additions & 4 deletions recipe/install-msvc.bat

This file was deleted.

8 changes: 8 additions & 0 deletions recipe/install-rust-src.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
FOR /F "delims=" %%i in ('cygpath.exe -u "%PREFIX%"') DO set "PREFIX=%%i/Library"
FOR /F "delims=" %%i in ('cygpath.exe -u "%SRC_DIR%"') DO set "SRC_DIR=%%i"
copy "%RECIPE_DIR%\install-rust-src.sh" .
bash -lce "%SRC_DIR%/install-rust-src.sh"
if errorlevel 1 exit 1
14 changes: 14 additions & 0 deletions recipe/install-rust-src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -ex

cd rust-src

DESTDIR=/

./install.sh --prefix="$PREFIX" --destdir="$DESTDIR"

rm "${DESTDIR}"/"${PREFIX}"/lib/rustlib/components
rm "${DESTDIR}"/"${PREFIX}"/lib/rustlib/install.log
rm "${DESTDIR}"/"${PREFIX}"/lib/rustlib/rust-installer-version
rm "${DESTDIR}"/"${PREFIX}"/lib/rustlib/uninstall.sh
8 changes: 8 additions & 0 deletions recipe/install-rust-std-extra.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
FOR /F "delims=" %%i in ('cygpath.exe -u "%PREFIX%"') DO set "PREFIX=%%i/Library"
FOR /F "delims=" %%i in ('cygpath.exe -u "%SRC_DIR%"') DO set "SRC_DIR=%%i"
copy "%RECIPE_DIR%\install-rust-std-extra.sh" .
bash -lce "%SRC_DIR%/install-rust-std-extra.sh"
if errorlevel 1 exit 1
14 changes: 14 additions & 0 deletions recipe/install-rust-std-extra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -ex

cd $SRC_DIR/rust-std

echo $PKG_NAME > ./components

./install.sh --prefix="$PREFIX" --destdir="$DESTDIR"

rm "${PREFIX}"/lib/rustlib/components
rm "${PREFIX}"/lib/rustlib/install.log
rm "${PREFIX}"/lib/rustlib/rust-installer-version
rm "${PREFIX}"/lib/rustlib/uninstall.sh
8 changes: 8 additions & 0 deletions recipe/install-rust-std.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
iset MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
FOR /F "delims=" %%i in ('cygpath.exe -u "%PREFIX%/Library"') DO set "PREFIX=%%i"
FOR /F "delims=" %%i in ('cygpath.exe -u "%SRC_DIR%"') DO set "SRC_DIR=%%i"
copy "%RECIPE_DIR%\install-rust-std.sh" .
bash -lce "%SRC_DIR%/install-rust-std.sh"
if errorlevel 1 exit 1
19 changes: 19 additions & 0 deletions recipe/install-rust-std.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -ex

# windows shell doesn't start here
cd $SRC_DIR

DESTDIR=$PWD/destdir/

# we want to install only a portion of the full installation.
# To do that, let's use destdir (populated via build.sh) and then use the
# manifest-rust-std-* file to install the files corresponding to rust-std

while read line; do
file=$(echo $line | cut -b 6-)
destination=$(echo $file | cut -b ${#DESTDIR}-)
mkdir -p $(dirname $destination)
cp $file ${destination}
done < $DESTDIR$PREFIX/lib/rustlib/manifest-rust-std-$rust_arch
8 changes: 8 additions & 0 deletions recipe/install-rust.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
FOR /F "delims=" %%i in ('cygpath.exe -u "%PREFIX%/Library"') DO set "PREFIX=%%i"
FOR /F "delims=" %%i in ('cygpath.exe -u "%SRC_DIR%"') DO set "SRC_DIR=%%i"
copy "%RECIPE_DIR%\install-rust.sh" .
bash -lce "%SRC_DIR%/install-rust.sh"
if errorlevel 1 exit 1
Loading