#!/bin/sh
set -euC
cd "$(dirname "$0")"
## RFCs
# <https://www.rfc-editor.org/series/rfc-download/>
# Roughly 250M.
# The Debian (non-free) packages use the same upstream source but also compress
# the files, which would be nice since Vim handles compressed files
# transparently, but is deemed to fiddly for now. See `update-package.sh` and
# `distribute.sh` at <https://sources.debian.org/src/doc-rfc/latest/debian>.
rsync -avz \
--include '/rfc[0-9].txt' \
--include '/rfc[0-9][0-9].txt' \
--include '/rfc[0-9][0-9][0-9].txt' \
--include '/rfc[0-9][0-9][0-9][0-9].txt' \
--include '/rfc[0-9][0-9][0-9][0-9][0-9].txt' \
--exclude '*' \
'rsync.rfc-editor.org::rfcs-text-only' \
'rfc'
## Khronos
# These are available over HTTP(S) instead of Git, but getting them that way
# runs afoul of anti-bot measures in my experience.
printf '%s\n' \
'glsl' 'https://github.com/KhronosGroup/GLSL' '/extensions/*/*' \
'spv' 'https://github.com/KhronosGroup/SPIRV-Registry' '/extensions/*/*' \
'gl' 'https://github.com/KhronosGroup/OpenGL-Registry' '/extensions/*/*' \
'vk' 'https://github.com/KhronosGroup/Vulkan-Docs' '/proposals/VK_*' \
| while read name; read url; read pattern;
do
(
[ -d "$name" ] || git clone \
--no-checkout \
--depth=1 \
--filter=tree:0 \
"$url" "$name"
cd "$name"
git sparse-checkout init --no-cone
git sparse-checkout set "$pattern"
git checkout
)
done