-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
706cc82
commit d750b24
Showing
813 changed files
with
7,253 additions
and
3,567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
|
||
if test -z "${GITHUB_TOKEN}"; then | ||
echo "ERROR: GITHUB_TOKEN is not set" | ||
exit 1 | ||
fi | ||
: "${ref:=main}" | ||
: "${workflow:=rebuild.yml}" | ||
: "${repository:=uniget-org/tools}" | ||
: "${batch_size:=100}" | ||
|
||
function dispatch() { | ||
local repository="${1}" | ||
local ref="${2}" | ||
local workflow="${3}" | ||
local tools="${4}" | ||
local dryrun="${5:-false}" | ||
|
||
CURL="curl" | ||
if test -n "${dryrun}" && test "${dryrun}" == "true"; then | ||
CURL="echo curl" | ||
fi | ||
|
||
${CURL} --silent --show-error --location --fail \ | ||
--header "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
--url "https://api.github.com/repos/${repository}/actions/workflows/${workflow}/dispatches" \ | ||
--data "{\"ref\": \"${ref}\", \"inputs\": {\"tool\": \"$(echo "${tools}" | xargs echo)\"}}" | ||
} | ||
|
||
make metadata.json | ||
|
||
TOOLS_DEPS="$( | ||
jq --raw-output '.tools[] | select(.build_dependencies != null) | .build_dependencies[]' <metadata.json \ | ||
| sort \ | ||
| uniq | ||
)" | ||
dispatch "${repository}" "${ref}" "${workflow}" "${TOOLS_DEPS}" | ||
TOOLS_DEPS_REGEX_OR="$( | ||
echo "${TOOLS_DEPS}" \ | ||
| jq --raw-input --raw-output '[inputs] | join("|")' | ||
)" | ||
|
||
TOOLS="$( | ||
jq --raw-output '.tools[].name' <metadata.json \ | ||
| sort \ | ||
| grep -E -v "(${TOOLS_DEPS_REGEX_OR})" | ||
)" | ||
SHUFFLED_TOOLS="$( | ||
echo "${TOOLS}" | shuf | ||
)" | ||
TOOLS_COUNT="$(echo "${TOOLS}" | wc -l)" | ||
|
||
start_index=1 | ||
end_index="${TOOLS_COUNT}" | ||
echo "### Processing ${TOOLS_COUNT} tools" | ||
while test "${start_index}" -lt "${end_index}"; do | ||
echo "### Starting at ${start_index}" | ||
NEXT_TOOLS="$( | ||
echo "${SHUFFLED_TOOLS}" | tail -n +$(( start_index + 1 )) | head -n "${batch_size}" | ||
)" | ||
|
||
dispatch "${repository}" "${ref}" "${workflow}" "${NEXT_TOOLS}" true | ||
|
||
start_index=$(( start_index + 100 )) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
|
||
find tools -type f -name Dockerfile.template \ | ||
| sort \ | ||
| while read -r FILENAME; do | ||
|
||
if grep -P -z -q 'RUN <<EOF # no download cache\n' "${FILENAME}"; then | ||
#echo "Ignoring ${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\nnpm install ' "${FILENAME}"; then | ||
#echo "Ignoring ${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\nshiv ' "${FILENAME}"; then | ||
#echo "Ignoring ${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -q "^unzip -q " "${FILENAME}"; then | ||
sed -E -z -i 's@RUN <<EOF\ncheck-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n\n?url="([^"]+)"\nfilename=".+"\ncurl --silent --show-error --location --fail --remote-name "([^"]+)"\nunzip -q -o -d "([^"]+)" "([^"]+)"@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\nurl="\4"\nfilename="$( basename "${url}" )"\n\ncheck-github-release-asset "\1" "\2" "${filename}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\nunzip -t "${uniget_cache_download}/${filename}"\nunzip -q -o -d "\6" "${uniget_cache_download}/${filename}"@' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ncurl ' "${FILENAME}"; then | ||
echo "Missing handler ${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ngit clone ' "${FILENAME}"; then | ||
#sed -E -z -i 's@RUN <<EOF\ngit clone -q --config advice.detachedHead=false --depth 1 --branch "([^"]+)" https://github.com/([^ ]+) .@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\nurl="https://github.com/\2/archive/refs/tags/\1.tar.gz"\nfilename="$( basename "${url}" )"\n\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n@' "${FILENAME}" | ||
#echo "Ignoring ${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ncheck-github-release-asset "[^"]+" "[^"]+" "[^"]+"\n\n?curl --silent --show-error --location --fail "[^"]+" \\\n| tar' "${FILENAME}"; then | ||
sed -E -z -i 's@RUN <<EOF\ncheck-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n\n?curl --silent --show-error --location --fail "([^"]+)" \\\n\| tar @RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\nurl="\4"\nfilename="$( basename "${url}" )"\n\ncheck-github-release-asset "\1" "\2" "${filename}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\ntar --file "${uniget_cache_download}/${filename}" --list\ntar --file "${uniget_cache_download}/${filename}" @' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ncheck-github-release-asset "[^"]+" "[^"]+" "[^"]+"\n\n?curl --silent --show-error --location --fail --output "[^"]+" \\\n\s+"[^"]+"' "${FILENAME}"; then | ||
sed -E -z -i 's@RUN <<EOF\ncheck-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n\n?curl --silent --show-error --location --fail --output "([^"]+)" \\\n\s+"([^"]+)"\nchmod \+x "([^"]+)"@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\nurl="\5"\nfilename="$( basename "${url}" )"\n\ncheck-github-release-asset "\1" "\2" "${filename}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\ninstall --mode=0755 \\\n "${uniget_cache_download}/${filename}" \\\n "\6"\n@' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ncheck-github-release-asset "[^"]+" "[^"]+" "[^"]+"\n' "${FILENAME}"; then | ||
sed -E -z -i 's@RUN <<EOF\ncheck-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\ncheck-github-release-asset "\1" "\2" "\3"\n@' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\ncheck-download "[^"]+"\n\n?curl --silent --show-error --location --fail --output "[^"]+" \\\n\s+"[^"]+"' "${FILENAME}"; then | ||
sed -E -z -i 's@RUN <<EOF\ncheck-download "([^"]+)"\n\n?curl --silent --show-error --location --fail --output "([^"]+)" \\\n\s+"([^"]+)"\nchmod \+x "([^"]+)"@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\nurl="\1"\nfilename="$( basename "${url}" )"\n\ncheck-download "${url}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\ninstall --mode=0755 \\\n "${uniget_cache_download}/${filename}" \\\n "\4"\n@' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -P -z -q 'RUN <<EOF\necho "### Setting' "${FILENAME}" && grep -P -z -q 'check-github-release-asset' "${FILENAME}"; then | ||
sed -E -z -i 's@echo "### Downloading [^"]+"\n@@; s@RUN <<EOF\n@RUN --mount=type=cache,target=/var/cache/uniget/download <<EOF\n@; s@check-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n\n?curl --silent --show-error --location --fail "([^"]+)" \\\n\| tar @url="\4"\nfilename="$( basename "${url}" )"\n\ncheck-github-release-asset "\1" "\2" "${filename}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\ntar --file "${uniget_cache_download}/${filename}" --list\ntar --file "${uniget_cache_download}/${filename}" @; s@check-github-release-asset "([^"]+)" "([^"]+)" "([^"]+)"\n\n?curl --silent --show-error --location --fail --output "([^"]+)" \\\n\s+"([^"]+)"\nchmod \+x "([^"]+)"@url="\5"\nfilename="$( basename "${url}" )"\n\ncheck-github-release-asset "\1" "\2" "${filename}"\ncurl --silent --show-error --location --fail --output "${uniget_cache_download}/${filename}" \\\n "${url}"\n\ninstall --mode=0755 \\\n "${uniget_cache_download}/${filename}" \\\n "\6"\n@' "${FILENAME}" | ||
continue | ||
fi | ||
|
||
if grep -q "RUN <<EOF" "${FILENAME}"; then | ||
echo "Unhandled ${FILENAME}" | ||
fi | ||
|
||
done |
Oops, something went wrong.