Skip to content

Commit eeb2019

Browse files
committed
Update external deps and improve download script.
Now we make sure to use commit hashes. This is much better than just pointing at branches or tags when cloning a repository.
1 parent 0983c86 commit eeb2019

File tree

4 files changed

+80
-5
lines changed

4 files changed

+80
-5
lines changed

deps/download.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
22

33
set -ex
44

5-
test -d x264 || git clone --depth 1 -b stable https://code.videolan.org/videolan/x264.git x264
6-
test -d ffmpeg || git clone --depth 1 -b n8.0 https://git.ffmpeg.org/ffmpeg.git ffmpeg
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
source "$SCRIPT_DIR/refs.sh"
7+
source "$SCRIPT_DIR/hashes.sh"
8+
9+
clone_at_commit() {
10+
local url="$1" dir="$2" commit="$3"
11+
if [ ! -d "$dir" ]; then
12+
git clone --filter=blob:none "$url" "$dir"
13+
git -C "$dir" checkout "$commit"
14+
fi
15+
}
16+
17+
clone_at_commit "$X264_URL" x264 "$X264_COMMIT"
18+
clone_at_commit "$FFMPEG_URL" ffmpeg "$FFMPEG_COMMIT"
19+
720
if [ "$TARGET_OS" == "linux" ]; then
8-
test -d nv-codec-headers || git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
9-
test -d libva || git clone --depth 1 -b 2.22.0 https://github.com/intel/libva
21+
clone_at_commit "$NV_CODEC_URL" nv-codec-headers "$NV_CODEC_COMMIT"
22+
clone_at_commit "$LIBVA_URL" libva "$LIBVA_COMMIT"
1023
fi
1124
if [ "$TARGET_OS" == "windows" ]; then
12-
test -d nv-codec-headers || git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
25+
clone_at_commit "$NV_CODEC_URL" nv-codec-headers "$NV_CODEC_COMMIT"
1326
fi
1427

1528
if [ "$TARGET_OS" == "windows" ] && [ "$HOST_OS" == "windows" ]; then
1629
cd ffmpeg
1730
git apply ../command_limit.patch
1831
git apply ../awk.patch
1932
fi
33+
34+
35+
36+

deps/hashes.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Generated by update_hashes.sh — do not edit manually.
4+
# Run ./update_hashes.sh to regenerate.
5+
6+
X264_COMMIT="b35605ace3ddf7c1a5d67a2eb553f034aef41d55" # refs/heads/stable
7+
FFMPEG_COMMIT="a4044e04486d1136022498891088a90baf5b2775" # refs/tags/n8.0
8+
NV_CODEC_COMMIT="876af32a202d0de83bd1d36fe74ee0f7fcf86b0d" # HEAD
9+
LIBVA_COMMIT="e85b1569b738fd8866cb9fa2452319f7148d663f" # refs/tags/2.23.0

deps/refs.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# Dependency URLs and the branch/tag/ref to pin.
4+
# After editing, run ./update_hashes.sh to regenerate hashes.sh.
5+
6+
X264_URL="https://code.videolan.org/videolan/x264.git"
7+
X264_REF="refs/heads/stable"
8+
9+
FFMPEG_URL="https://code.ffmpeg.org/FFmpeg/FFmpeg.git"
10+
FFMPEG_REF="refs/tags/n8.0"
11+
12+
NV_CODEC_URL="https://git.videolan.org/git/ffmpeg/nv-codec-headers.git"
13+
NV_CODEC_REF="HEAD"
14+
15+
LIBVA_URL="https://github.com/intel/libva"
16+
LIBVA_REF="refs/tags/2.23.0"

deps/update_hashes.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# Resolves each ref in refs.sh to a commit hash and writes hashes.sh.
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
source "$SCRIPT_DIR/refs.sh"
9+
10+
resolve() {
11+
local name="$1" url="$2" ref="$3"
12+
local hash
13+
hash=$(git ls-remote "$url" "$ref" | awk 'END { print $1 }')
14+
if [ -z "$hash" ]; then
15+
echo "ERROR: could not resolve $name $ref from $url" >&2
16+
exit 1
17+
fi
18+
echo "${name}_COMMIT=\"${hash}\" # ${ref}"
19+
}
20+
21+
cat > "$SCRIPT_DIR/hashes.sh" <<EOF
22+
#!/usr/bin/env bash
23+
24+
# Generated by update_hashes.sh — do not edit manually.
25+
# Run ./update_hashes.sh to regenerate.
26+
27+
$(resolve X264 "$X264_URL" "$X264_REF")
28+
$(resolve FFMPEG "$FFMPEG_URL" "$FFMPEG_REF")
29+
$(resolve NV_CODEC "$NV_CODEC_URL" "$NV_CODEC_REF")
30+
$(resolve LIBVA "$LIBVA_URL" "$LIBVA_REF")
31+
EOF
32+
33+
echo "hashes.sh updated."

0 commit comments

Comments
 (0)