-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add installation scripts for various toolchains and generate…
… Swagger UI Signed-off-by: Schubert Anselme <[email protected]>
- Loading branch information
Showing
6 changed files
with
189 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
# ref: https://github.com/johanbrandhorst/grpc-gateway-boilerplate/blob/main/scripts/generate-swagger-ui.sh | ||
# source scripts/aliases.sh | ||
# source scripts/environment.sh | ||
|
||
cache_dir=".cache/swagger-ui" | ||
output_dir="docs/openapi" | ||
swagger_ui_repo="https://github.com/swagger-api/swagger-ui.git" | ||
swagger_ui_version="${1:-v5.18.2}" | ||
|
||
escape_str() { | ||
echo "$1" | sed -e 's/[]\/$*.^[]/\\&/g' | ||
} | ||
|
||
if [[ -z ${swagger_ui_version} ]]; then | ||
echo "missing ${swagger_ui_version}" | ||
exit 1 | ||
fi | ||
|
||
[[ ! -d ${output_dir} ]] && mkdir -p "${output_dir}" | ||
|
||
# cache swagger-ui dist | ||
if [[ ! -d ${cache_dir} ]]; then | ||
mkdir -p "${cache_dir}" | ||
tmp="$(mktemp -d)" | ||
git clone --depth 1 --branch "${swagger_ui_version}" "${swagger_ui_repo}" "${tmp}" | ||
cp -r "${tmp}/dist/"* "${cache_dir}" | ||
cp -r "${tmp}/LICENSE" "${cache_dir}" | ||
rm -rf "${tmp}" | ||
fi | ||
|
||
# fixme: populate swagger.json | ||
buf generate | ||
tmp=" urls: [" | ||
for i in $(find "${output_dir}" -name "*.swagger.json"); do | ||
escaped_gen_dir="$(escape_str "${output_dir}/")" | ||
path="${i//${escaped_gen_dir}/}" | ||
tmp="${tmp}{\"url\":\"${path}\",\"name\":\"${path}\"}," | ||
done | ||
# delete last characters from $tmp | ||
tmp="${tmp//.$/}" | ||
tmp="${tmp}]," | ||
|
||
# generate swagger-ui | ||
#find "${output_dir}" -type f -name "*.swagger.json" -delete | ||
mkdir -p "${output_dir}" | ||
cp -r "${cache_dir}/"* "${output_dir}" | ||
|
||
# fixme: replace the default URL | ||
line="$(cat "${output_dir}/swagger-initializer.js" | grep -n "url" | cut -f1 -d:)" | ||
escaped_tmp="$(escape_str "${tmp}")" | ||
sed -i'' -e "${line} s/^.*$/${escaped_tmp}/" "${output_dir}/swagger-initializer.js" | ||
rm -f "${output_dir}/swagger-initializer.js-e" | ||
|
||
# fixme: optionally trunk.io | ||
trunk fmt "${output_dir}" |
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,20 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
# source ../alias.sh | ||
source ../environment.sh | ||
|
||
# install golang | ||
if [[ -z $(command -v go) ]]; then | ||
sudo apt-get update -yq | ||
sudo apt-get install -yq --no-install-recommends golang | ||
fi | ||
|
||
# install sbctl | ||
if [[ -z $(command -v sbctl) ]]; then | ||
# version: 0.16 | ||
# https://github.com/Foxboron/sbctl/commit/53e074d6934f5ecfffa81a576293219c717f7d19 | ||
go install github.com/foxboron/sbctl/cmd/sbctl@53e074d6934f5ecfffa81a576293219c717f7d19 | ||
fi | ||
|
||
go version | ||
sbctl status |
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,23 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
# source ../alias.sh | ||
source ../environment.sh | ||
|
||
# install rust | ||
if [[ -z $(command -v rustup) ]]; then | ||
sudo apt-get update -yq | ||
sudo apt-get install -yq --no-install-recommends rustup | ||
fi | ||
|
||
# set rust toolchain | ||
if [[ -n $(command -v rustc) ]]; then | ||
rustup default stable | ||
rustup component add rust-src | ||
fi | ||
|
||
# install bindgen-cli | ||
[[ -n $(command -v bindgen-cli) ]] || cargo install bindgen-cli | ||
|
||
rustc --version | ||
cargo --version | ||
bindgen --version |
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,28 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
# source ../alias.sh | ||
source ../environment.sh | ||
|
||
ARCH="$(uname -m)" | ||
SWIFT_VERSION="6.0.2" | ||
SWIFT_STATIC_SDK_CHECKSUM="aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075" | ||
|
||
# install swift | ||
if [[ -z $(command -v swift) ]]; then | ||
curl -fsSLo /tmp/swift.tgz "https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2404-${ARCH}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04-${ARCH}.tar.gz" | ||
# fixme: verify download | ||
# curl -fsSLo /tmp/swift.tgz.sig "https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2404-${ARCH}/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu24.04-${ARCH}.tar.gz.sig" | ||
# curl https://swift.org/keys/all-keys.asc | gpg --import - | ||
# gpg --keyserver hkp://keyserver.ubuntu.com --refresh-keys Swift | ||
# gpg --verify /tmp/swift.tgz.sig /tmp/swift.tgz | ||
tar -xzf /tmp/swift.tgz -C / --strip-components=1 | ||
rm -f /tmp/swift.tgz* | ||
fi | ||
|
||
# static sdk | ||
grep -q "swift-${SWIFT_VERSION}-RELEASE_static-linux-0.0.1" <(swift sdk list) || swift sdk install \ | ||
--checksum "${SWIFT_STATIC_SDK_CHECKSUM}" \ | ||
"https://download.swift.org/swift-${SWIFT_VERSION}-release/static-sdk/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz" | ||
|
||
swift --version | ||
swift sdk list |
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,43 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
# source scripts/alias.sh | ||
# source scripts/environment.sh | ||
|
||
apt-get update -yq | ||
apt-get install -yq --no-install-recommends \ | ||
binutils \ | ||
bison \ | ||
build-essential \ | ||
ccache \ | ||
clang \ | ||
cmake \ | ||
dfu-util \ | ||
flex \ | ||
gcc \ | ||
git \ | ||
gnupg2 \ | ||
gperf \ | ||
libc6-dev \ | ||
libcurl4 \ | ||
libedit2 \ | ||
libelf-dev \ | ||
libffi-dev \ | ||
libgcc-9-dev \ | ||
libncurses6 \ | ||
libsqlite3-0 \ | ||
libssl-dev \ | ||
libstdc++-9-dev \ | ||
libusb-1.0-0 \ | ||
libxml2 \ | ||
libz3-dev \ | ||
lld \ | ||
llvm \ | ||
ninja-build \ | ||
pkg-config \ | ||
python3 \ | ||
python3-pip \ | ||
python3-venv \ | ||
tzdata \ | ||
uuid-dev \ | ||
wget \ | ||
zlib1g-dev |