Skip to content

Commit

Permalink
Fix and improve curl use
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff committed Dec 5, 2023
1 parent 5ceff1a commit 09433c2
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 47 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ENV OUT="${OUT:?}"
ENV PREFIX="/opt/prefix"
ENV SYSROOT="/opt/sysroot"
ENV CCTOOLS="/opt/cctools"
ENV CIPHERSUITES="TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"

# Ensure sysroot and cctools are present on PATH
ENV PATH="${CCTOOLS}/bin:${SYSROOT}/bin:$PATH"
Expand Down
4 changes: 4 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export CFLAGS="${CFLAGS} ${FFLAGS}"
export LDFLAGS="${LDFLAGS} ${FFLAGS}"
export CXXFLAGS="${CFLAGS}"

curl () {
env curl --proto '=https' --tlsv1.2 --ciphers "${CIPHERSUITES:?Missing curl ciphersuite}" --silent --show-error --fail --location "$@"
}

bak_src() {
if ! { [ "$#" -eq 1 ] && [ -d "$1" ]; }; then
echo "bak_src: <SRC_DIR>" >&2
Expand Down
3 changes: 1 addition & 2 deletions scripts/curl_tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ fi

_url="$1"
_cache="/root/.cache/_curl_tar/$(md5sum - <<<"$_url" | awk '{ print $1 }')"
_ciphersuites="TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"

mkdir -p "$(dirname "$_cache")"

if ! [ -s "$_cache" ]; then
curl --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$_url" >"$_cache"
curl --proto '=https' --tlsv1.2 --ciphers "${CIPHERSUITES:?Missing curl ciphersuite}" --silent --show-error --fail --location "$_url" >"$_cache"
fi

trap 'rm -rf "$_cache"' ERR
Expand Down
7 changes: 0 additions & 7 deletions stages/00-apple/04-cctools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ mkdir -p "cctools"

curl_tar 'https://github.com/tpoechtrager/cctools-port/archive/59f5fb8.tar.gz' 'cctools' 1

# Patch check to force script to use clang
sed -i "/^if readelf -p .comment \$LIBDIR\/libLTO.so | grep clang &>\/dev\/null; then/,/^fi/d;" cctools/tools/fix_liblto.sh
# Replace wget with curl
sed -ie 's/wget/curl -LSsOJ/' cctools/tools/fix_liblto.sh
# Fix LTO
env LLVM_CONFIG=llvm-config-16 cctools/tools/fix_liblto.sh

cd cctools/cctools

./configure \
Expand Down
2 changes: 1 addition & 1 deletion stages/10-sse2neon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mkdir -p sse2neon

curl_tar 'https://github.com/DLTcollab/sse2neon/archive/refs/tags/v1.6.0.tar.gz' 'sse2neon' 1

curl -LSs 'https://raw.githubusercontent.com/HandBrake/HandBrake/172cd5d/contrib/sse2neon/A01-types-fix.patch' \
curl 'https://raw.githubusercontent.com/HandBrake/HandBrake/172cd5d/contrib/sse2neon/A01-types-fix.patch' \
| patch -F5 -lp1 -d "sse2neon" -t

# Remove unused components
Expand Down
12 changes: 6 additions & 6 deletions stages/25-lcms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ esac

# Some required patches for fixing meson and windows cross-compile issues
for patch in \
https://github.com/mm2/Little-CMS/commit/4e55c55.patch \
https://github.com/mm2/Little-CMS/commit/8ddc268.patch \
https://github.com/mm2/Little-CMS/commit/8769c0e.patch \
https://github.com/mm2/Little-CMS/commit/7984408.patch \
https://github.com/mm2/Little-CMS/commit/b35e271.patch; do
curl -LSs "$patch" | patch -F5 -lp1 -d lcms -t
'https://github.com/mm2/Little-CMS/commit/4e55c55.patch' \
'https://github.com/mm2/Little-CMS/commit/8ddc268.patch' \
'https://github.com/mm2/Little-CMS/commit/8769c0e.patch' \
'https://github.com/mm2/Little-CMS/commit/7984408.patch' \
'https://github.com/mm2/Little-CMS/commit/b35e271.patch'; do
curl "$patch" | patch -F5 -lp1 -d lcms -t
done

sed -i "/subdir('utils')/d" lcms/meson.build
Expand Down
2 changes: 1 addition & 1 deletion stages/50-lame.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ curl_tar 'https://deb.debian.org/debian/pool/main/l/lame/lame_3.100.orig.tar.gz'
curl_tar 'https://github.com/mesonbuild/wrapdb/releases/download/lame_3.100-9/lame_3.100-9_patch.zip' lame 1

# Fix warning on 64 bit machines. explicitly set variables as unsigned ints.
curl -LSs 'https://sources.debian.org/data/main/l/lame/3.100-6/debian/patches/07-field-width-fix.patch' \
curl 'https://sources.debian.org/data/main/l/lame/3.100-6/debian/patches/07-field-width-fix.patch' \
| patch -F5 -lp1 -d lame -t

# Remove some superfluous files
Expand Down
2 changes: 1 addition & 1 deletion stages/50-opus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mkdir -p opus
curl_tar 'https://github.com/xiph/opus/releases/download/v1.4/opus-1.4.tar.gz' opus 1

# Required patch to fix meson for arm builds
curl -LSs 'https://github.com/xiph/opus/commit/20c032d.patch' \
curl 'https://github.com/xiph/opus/commit/20c032d.patch' \
| patch -F5 -lp1 -d opus -t

# Remove unused components
Expand Down
2 changes: 1 addition & 1 deletion stages/50-svt-av1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ case "$TARGET" in
aarch64*)
ENABLE_NASM=Off
# Patch to enable NEON in aarch64
curl -LSs 'https://gitlab.com/AOMediaCodec/SVT-AV1/-/merge_requests/2135.patch' | patch -F5 -lp1 -d svt-av1 -t
curl 'https://gitlab.com/AOMediaCodec/SVT-AV1/-/merge_requests/2135.patch' | patch -F5 -lp1 -d svt-av1 -t
;;
esac

Expand Down
6 changes: 3 additions & 3 deletions stages/50-x264.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ curl_tar 'https://code.videolan.org/videolan/x264/-/archive/c1962404/x264.tar.bz

# Some minor fixes to x264's pkg-config
for patch in \
https://github.com/msys2/MINGW-packages/raw/f4bd368/mingw-w64-x264/0001-beautify-pc.all.patch \
https://github.com/msys2/MINGW-packages/raw/f4bd368/mingw-w64-x264/0003-pkgconfig-add-Cflags-private.patch; do
curl -LSs "$patch" | patch -F5 -lp1 -d x264 -t
'https://github.com/msys2/MINGW-packages/raw/f4bd368/mingw-w64-x264/0001-beautify-pc.all.patch' \
'https://github.com/msys2/MINGW-packages/raw/f4bd368/mingw-w64-x264/0003-pkgconfig-add-Cflags-private.patch'; do
curl "$patch" | patch -F5 -lp1 -d x264 -t
done

case "$TARGET" in
Expand Down
6 changes: 3 additions & 3 deletions stages/50-x265.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ rm -rf x265/{doc,build}

# Handbreak patches
for patch in \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/x265/A03-sei-length-crash-fix.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/x265/A05-memory-leaks.patch; do
curl -LSs "$patch" | patch -F5 -lp1 -d x265 -t
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/x265/A03-sei-length-crash-fix.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/x265/A05-memory-leaks.patch'; do
curl "$patch" | patch -F5 -lp1 -d x265 -t
done

# Backup source
Expand Down
40 changes: 20 additions & 20 deletions stages/99-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ curl_tar 'https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n6.1.tar.gz' ffmpeg

# Handbreak patches
for patch in \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A01-mov-read-name-track-tag-written-by-movenc.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A02-movenc-write-3gpp-track-titl-tag.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A03-mov-read-3gpp-udta-tags.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A04-movenc-write-3gpp-track-names-tags-for-all-available.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A05-dvdsubdec-fix-processing-of-partial-packets.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A06-dvdsubdec-return-number-of-bytes-used.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A07-dvdsubdec-use-pts-of-initial-packet.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A08-ccaption_dec-fix-pts-in-real_time-mode.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A09-matroskaenc-aac-extradata-updated.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A10-amfenc-Add-support-for-pict_type-field.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A11-amfenc-Fixes-the-color-information-in-the-ou.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A12-amfenc-HDR-metadata.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A13-libavcodec-amfenc-Fix-issue-with-missing-headers-in-.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A14-avcodec-add-ambient-viewing-environment-packet-side-.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A15-avformat-mov-add-support-for-amve-ambient-viewing-en.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A16-videotoolbox-dec-h264-10bit.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A17-libswscale-fix-yuv420p-to-p01xle-color-conversion-bu.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A18-qsv-fix-decode-10bit-hdr.patch \
https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A19-ffbuild-common-use-gzip-n-flag-for-cuda.patch; do
curl -LSs "$patch" | patch -F5 -lp1 -d ffmpeg -t
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A01-mov-read-name-track-tag-written-by-movenc.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A02-movenc-write-3gpp-track-titl-tag.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A03-mov-read-3gpp-udta-tags.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A04-movenc-write-3gpp-track-names-tags-for-all-available.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A05-dvdsubdec-fix-processing-of-partial-packets.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A06-dvdsubdec-return-number-of-bytes-used.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A07-dvdsubdec-use-pts-of-initial-packet.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A08-ccaption_dec-fix-pts-in-real_time-mode.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A09-matroskaenc-aac-extradata-updated.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A10-amfenc-Add-support-for-pict_type-field.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A11-amfenc-Fixes-the-color-information-in-the-ou.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A12-amfenc-HDR-metadata.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A13-libavcodec-amfenc-Fix-issue-with-missing-headers-in-.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A14-avcodec-add-ambient-viewing-environment-packet-side-.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A15-avformat-mov-add-support-for-amve-ambient-viewing-en.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A16-videotoolbox-dec-h264-10bit.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A17-libswscale-fix-yuv420p-to-p01xle-color-conversion-bu.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A18-qsv-fix-decode-10bit-hdr.patch' \
'https://github.com/HandBrake/HandBrake/raw/9c9cf41/contrib/ffmpeg/A19-ffbuild-common-use-gzip-n-flag-for-cuda.patch'; do
curl "$patch" | patch -F5 -lp1 -d ffmpeg -t
done

# Backup source
Expand Down
4 changes: 2 additions & 2 deletions stages/99-yolov8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ case "$TARGET" in
esac

mkdir -p "$OUT"/{models,licenses}
curl -LSsO "${OUT}/models/yolov8s.onnx" "https://github.com/spacedriveapp/native-deps/releases/download/${_tag}/${_name}"
curl -LSsO "https://raw.githubusercontent.com/ultralytics/assets/main/LICENSE" "${OUT}/licenses/yolov8s.LICENSE"
curl -o "${OUT}/models/yolov8s.onnx" "https://github.com/spacedriveapp/native-deps/releases/download/${_tag}/${_name}"
curl -o "${OUT}/licenses/yolov8s.LICENSE" 'https://raw.githubusercontent.com/ultralytics/assets/main/LICENSE'

0 comments on commit 09433c2

Please sign in to comment.