Skip to content

Commit

Permalink
Merge branch 'branch-23.10' of github.com:rapidsai/devcontainers into…
Browse files Browse the repository at this point in the history
… fea/add-args-to-generated-rapids-build-scripts
  • Loading branch information
trxcllnt committed Aug 22, 2023
2 parents 20a7660 + 7bc1571 commit 0816aca
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ generate_script() {
fi
}

generate_all_script_impl() {
local bin="$SCRIPT-all";
if test -n "$bin" && ! test -f "/tmp/${bin}.sh"; then
cat - \
| envsubst '$NAMES
$SCRIPT' \
| sudo tee "/tmp/${bin}.sh" >/dev/null;

sudo chmod +x "/tmp/${bin}.sh";

sudo update-alternatives --install \
"/usr/bin/${bin}" "${bin}" "/tmp/${bin}.sh" 0 \
>/dev/null 2>&1;
fi
}

generate_all_script() {
(
cat ${TMPL}/all.tmpl.sh \
| generate_all_script_impl;
) || true;
}

generate_clone_script() {
(
cat ${TMPL}/clone.tmpl.sh \
Expand Down Expand Up @@ -97,6 +120,8 @@ generate_scripts() {
local j;
local k;

local repo_name_all=()

for ((i=0; i < ${repos_length:-0}; i+=1)); do

local repo="repos_${i}";
Expand All @@ -110,6 +135,8 @@ generate_scripts() {

repo_name="$(tr "[:upper:]" "[:lower:]" <<< "${!repo_name:-}")";

repo_name_all+=($repo_name)

# Generate a clone script for each repo
(
NAME="${repo_name:-}" \
Expand Down Expand Up @@ -215,6 +242,15 @@ generate_scripts() {
-o -type f -exec chmod 0755 {} \; \);

unset cpp_name_to_path;

for script in "clone" "clean" "configure" "build"; do
# Generate a script to run a script for all repos
(
NAMES="${repo_name_all[@]}" \
SCRIPT="${script}" \
generate_all_script ;
) || true;
done;
}

if test -n "${rapids_build_utils_debug:-}"; then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
${SCRIPT}_all() {
set -euo pipefail;

for name in $NAMES; do
$SCRIPT-$name "$@"
done;
}

if [[ -n "$devcontainer_utils_debug" ]]; then
PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x;
fi

${SCRIPT}_all "$@";
13 changes: 11 additions & 2 deletions features/src/utils/opt/devcontainer/bin/github/repo/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ get_user_fork_name() {
if [ "${user}" = "${owner}" ]; then
echo "${owner}/${name}";
else
gh repo list "${user}" --fork --json nameWithOwner --json parent --jq "$(cat <<________EOF | tr -s '[:space:]'
.
local query="$(cat <<________EOF | tr -s '[:space:]'
| map(select(
.parent.name == "${name}"
and
Expand All @@ -42,6 +41,16 @@ get_user_fork_name() {
| map(.nameWithOwner)[]
________EOF
)";
local nameWithOwner="$(gh repo list "${user}" --fork --json nameWithOwner --json parent --jq ". ${query}" 2>/dev/null || echo "")";
if test -z "${nameWithOwner}"; then
for repo in $(gh repo list "${user}" --fork --json name --jq 'map(.name)[]'); do
nameWithOwner="$(gh repo view "${repo}" --json nameWithOwner --json parent --jq "[.] ${query}" 2>/dev/null || echo "")";
if test -n "${nameWithOwner}"; then
break;
fi
done
fi
echo -n "${nameWithOwner:-}";
fi
}

Expand Down

0 comments on commit 0816aca

Please sign in to comment.