Skip to content

Commit 7e9a781

Browse files
committed
chore: update buildenv script to download from GH
1 parent fedc647 commit 7e9a781

File tree

2 files changed

+123
-34
lines changed

2 files changed

+123
-34
lines changed

tools/macos_buildenv.sh

+66-20
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,82 @@ realpath() {
1515
cd "${OLDPWD}" || exit 1
1616
}
1717

18+
buildenv_from_download_server() { # 2.6
19+
http_code=$(curl -sI -w "%{http_code}" "https://downloads.mixxx.org/dependencies/${1}/macOS/${2}.zip" -o /dev/null)
20+
if [ "$http_code" -ne 200 ]; then
21+
>&2 echo "Downloading failed with HTTP status code: $http_code"
22+
exit 1
23+
fi
24+
curl "https://downloads.mixxx.org/dependencies/${1}/macOS/${2}.zip" -o "${3}.zip"
25+
OBSERVED_SHA256=$(shasum -a 256 "${3}.zip"|cut -f 1 -d' ')
26+
if [[ "$OBSERVED_SHA256" == "$4" ]]; then
27+
>&2 echo "Download matched expected SHA256 sum $4"
28+
echo "${3}.zip"
29+
else
30+
>&2 echo "ERROR: Download did not match expected SHA256 checksum!"
31+
>&2 echo "Expected $4"
32+
>&2 echo "Got $OBSERVED_SHA256"
33+
exit 1
34+
fi
35+
}
36+
37+
buildenv_from_gh_release() {
38+
part=0
39+
trap 'find . -name "mixxx-deps-${1}-${3}-${2}.*" -delete && exit' SIGINT SIGABRT
40+
part_uri="https://github.com/acolombier/vcpkg/releases/download/${1}-${2}/mixxx-deps-${1}-${3}-${2}.zip.part0${part}"
41+
while true; do
42+
http_code=$(curl -sI -w "%{http_code}" "$part_uri" -o /dev/null)
43+
if [ "$http_code" -ne 200 ] && [ "$http_code" -ne 302 ]; then
44+
if [ "$part" = 0 ]; then
45+
>&2 echo "Downloading $part_uri failed with HTTP status code: $http_code"
46+
exit 1
47+
else
48+
break
49+
fi
50+
fi
51+
curl -L "${part_uri}" -o "$(basename "${part_uri}")"
52+
part=$(( part + 1))
53+
part_uri="https://github.com/acolombier/vcpkg/releases/download/${1}-${2}/mixxx-deps-${1}-${3}-${2}.zip.part0${part}"
54+
done
55+
56+
cat mixxx-deps-"${1}-${3}-${2}".zip.part* > "${4}"
57+
find . -name "mixxx-deps-${1}-${3}-${2}.zip.part*" -delete
58+
59+
expected_sha256=$(curl -L "https://github.com/acolombier/vcpkg/releases/download/${1}-${2}/mixxx-deps-${1}-${3}-${2}.zip.sha256")
60+
observed_sha256=$(shasum -a 256 "${4}"|cut -f 1 -d' ')
61+
62+
if [ "$expected_sha256" = "$observed_sha256" ]; then
63+
>&2 echo "Download matched expected SHA256 sum"
64+
rm -f "mixxx-deps-${1}-${3}-${2}.sha256"
65+
else
66+
>&2 echo "ERROR: Download did not match expected SHA256 checksum!"
67+
find . -name "mixxx-deps-${1}-${3}-${2}.*" -delete
68+
exit 1
69+
fi
70+
}
71+
1872
# some hackery is required to be compatible with both bash and zsh
1973
THIS_SCRIPT_NAME=${BASH_SOURCE[0]}
2074
[ -z "$THIS_SCRIPT_NAME" ] && THIS_SCRIPT_NAME=$0
2175

76+
VCPKG_COMMIT_SHA="d3b6db3"
77+
BUILDENV_MINOR_VERSION="2.6"
78+
2279
if [ -n "${BUILDENV_ARM64}" ]; then
2380
VCPKG_TARGET_TRIPLET="arm64-osx-min1100-release"
24-
BUILDENV_BRANCH="2.5-rel"
25-
BUILDENV_NAME="mixxx-deps-2.5-arm64-osx-min1100-release-40c29ff"
81+
BUILDENV_BRANCH_SUFFIX="-rel"
2682
BUILDENV_SHA256="b76685e77f681baf8fdc5037297b0f16d323a405d09ce276d8844304530278e1"
2783
else
2884
if [ -n "${BUILDENV_RELEASE}" ]; then
2985
VCPKG_TARGET_TRIPLET="x64-osx-min1100-release"
30-
BUILDENV_BRANCH="2.5-rel"
31-
BUILDENV_NAME="mixxx-deps-2.5-x64-osx-min1100-release-40c29ff"
86+
BUILDENV_BRANCH_SUFFIX="-rel"
3287
BUILDENV_SHA256="a9b7dd2cb9ab00db6d05ac1f05aab933ed0ab2697f71db1a1bad70305befcf1b"
3388
else
3489
VCPKG_TARGET_TRIPLET="x64-osx-min1100"
35-
BUILDENV_BRANCH="2.5"
36-
BUILDENV_NAME="mixxx-deps-2.5-x64-osx-min1100-c15790e"
3790
BUILDENV_SHA256="0252293436efed1b043d5c6ee384a9502ca0ade712eff95b2c0d2199d94598bb"
3891
fi
3992
fi
93+
BUILDENV_NAME="mixxx-deps-${BUILDENV_MINOR_VERSION}-${VCPKG_TARGET_TRIPLET}-${VCPKG_COMMIT_SHA}"
4094

4195
MIXXX_ROOT="$(realpath "$(dirname "$THIS_SCRIPT_NAME")/..")"
4296

@@ -56,22 +110,14 @@ case "$1" in
56110
mkdir -p "${BUILDENV_BASEPATH}"
57111
if [ ! -d "${BUILDENV_PATH}" ]; then
58112
if [ "$1" != "--profile" ]; then
59-
echo "Build environment $BUILDENV_NAME not found in mixxx repository, downloading https://downloads.mixxx.org/dependencies/${BUILDENV_BRANCH}/macOS/${BUILDENV_NAME}.zip"
60-
http_code=$(curl -sI -w "%{http_code}" "https://downloads.mixxx.org/dependencies/${BUILDENV_BRANCH}/macOS/${BUILDENV_NAME}.zip" -o /dev/null)
61-
if [ "$http_code" -ne 200 ]; then
62-
echo "Downloading failed with HTTP status code: $http_code"
63-
exit 1
64-
fi
65-
curl "https://downloads.mixxx.org/dependencies/${BUILDENV_BRANCH}/macOS/${BUILDENV_NAME}.zip" -o "${BUILDENV_PATH}.zip"
66-
OBSERVED_SHA256=$(shasum -a 256 "${BUILDENV_PATH}.zip"|cut -f 1 -d' ')
67-
if [[ "$OBSERVED_SHA256" == "$BUILDENV_SHA256" ]]; then
68-
echo "Download matched expected SHA256 sum $BUILDENV_SHA256"
113+
if [ "$BUILDENV_SRC" = "gh" ]; then
114+
echo "Build environment $BUILDENV_NAME not found in mixxx repository, downloading from Mixxx's VCPKG repo"
115+
buildenv_from_gh_release "${BUILDENV_MINOR_VERSION}" "${VCPKG_COMMIT_SHA}" "${VCPKG_TARGET_TRIPLET}" "${BUILDENV_PATH}.zip"
69116
else
70-
echo "ERROR: Download did not match expected SHA256 checksum!"
71-
echo "Expected $BUILDENV_SHA256"
72-
echo "Got $OBSERVED_SHA256"
73-
exit 1
117+
echo "Build environment $BUILDENV_NAME not found in mixxx repository, downloading from Mixxx download server"
118+
buildenv_from_download_server "${BUILDENV_BRANCH}${BUILDENV_BRANCH_SUFFIX}" "${BUILDENV_NAME}" "${BUILDENV_PATH}" "${BUILDENV_SHA256}"
74119
fi
120+
75121
echo ""
76122
echo "Extracting ${BUILDENV_NAME}.zip..."
77123
unzip "${BUILDENV_PATH}.zip" -d "${BUILDENV_BASEPATH}" && \

tools/windows_buildenv.bat

+57-14
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ IF NOT DEFINED INSTALL_ROOT (
2020
SET INSTALL_ROOT=%MIXXX_ROOT%\install
2121
)
2222

23-
IF DEFINED BUILDENV_RELEASE (
24-
SET BUILDENV_BRANCH=2.5-rel
25-
SET VCPKG_TARGET_TRIPLET=x64-windows-release
26-
vcpkg_update_main
27-
SET BUILDENV_NAME=mixxx-deps-2.5-x64-windows-release-40c29ff
28-
SET BUILDENV_SHA256=a9d809ae9c52d8a553af1bb8a58565649ced7b1f938d1d37c1c7d83ad53aacf3
29-
) ELSE (
30-
SET BUILDENV_BRANCH=2.5
23+
VCPKG_COMMIT_SHA="d3b6db3"
24+
BUILDENV_MINOR_VERSION="2.6"
25+
26+
@REM IF DEFINED BUILDENV_RELEASE (
27+
@REM SET BUILDENV_BRANCH=2.5-rel
28+
@REM SET VCPKG_TARGET_TRIPLET=x64-windows-release
29+
@REM vcpkg_update_main
30+
@REM SET BUILDENV_NAME=mixxx-deps-2.5-x64-windows-release-40c29ff
31+
@REM SET BUILDENV_SHA256=a9d809ae9c52d8a553af1bb8a58565649ced7b1f938d1d37c1c7d83ad53aacf3
32+
@REM ) ELSE (
3133
SET VCPKG_TARGET_TRIPLET=x64-windows
32-
SET BUILDENV_NAME=mixxx-deps-2.5-x64-windows-c15790e
3334
SET BUILDENV_SHA256=138e4685ec73c6a6a509f71f8573be581403b091e4ecea2314df2cc79f9720b9
34-
)
35+
@REM )
36+
SET BUILDENV_NAME=mixxx-deps-!BUILDENV_MINOR_VERSION!-!VCPKG_TARGET_TRIPLET!-!VCPKG_COMMIT_SHA!
37+
3538

3639
IF "%~1"=="" (
3740
REM In case of manual start by double click no arguments are specified: Default to COMMAND_setup
@@ -61,11 +64,51 @@ EXIT /B 0
6164
)
6265

6366
IF NOT EXIST "%BUILDENV_PATH%" (
64-
SET BUILDENV_URL=https://downloads.mixxx.org/dependencies/!BUILDENV_BRANCH!/Windows/!BUILDENV_NAME!.zip
67+
SET BUILDENV_URL=https://github.com/acolombier/vcpkg/releases/download/!BUILDENV_MINOR_VERSION!-!VCPKG_COMMIT_SHA!/!BUILDENV_NAME!.zip
6568
IF NOT EXIST "!BUILDENV_PATH!.zip" (
66-
ECHO ^Download prebuilt build environment from "!BUILDENV_URL!" to "!BUILDENV_PATH!.zip"...
67-
REM TODO: The /DYNAMIC parameter is required because our server does not yet support HTTP range headers
68-
BITSADMIN /transfer buildenvjob /download /priority normal /DYNAMIC !BUILDENV_URL! "!BUILDENV_PATH!.zip"
69+
ECHO ^Download prebuilt build environment from "!BUILDENV_URL!"...
70+
REM Create a temporary directory to store the parts
71+
IF NOT EXIST "%TEMP%\~buildenv" MD "%TEMP%\~buildenv"
72+
73+
SET "PART_NUMBER=0"
74+
75+
:DOWNLOAD_LOOP
76+
ECHO ^Attempting to download part !PART_NUMBER!...
77+
78+
REM Construct the URL for this part
79+
SET "PART_URL=!BUILDENV_URL!.part!PART_NUMBER!"
80+
SET "PART_FILE=!BUILDENV_PATH!.zip.part!PART_NUMBER!"
81+
82+
REM Download the part using BitsAdmin
83+
BITSADMIN /transfer buildenvjob_part!PART_NUMBER! /download /priority normal /DYNAMIC !PART_URL! "!PART_FILE!"
84+
IF %ERRORLEVEL% NEQ 0 (
85+
IF %ERRORLEVEL% NEQ 0 (
86+
ECHO ^Part !PART_NUMBER! not found. Stopping download loop.
87+
GOTO :CONCATENATE
88+
) ELSE (
89+
ECHO ^Error downloading part !PART_NUMBER!
90+
PAUSE
91+
EXIT /B 1
92+
)
93+
)
94+
95+
SET /A PART_NUMBER +=1
96+
GOTO :DOWNLOAD_LOOP
97+
98+
:CONCATENATE
99+
ECHO ^Concatenating all parts into "!BUILDENV_PATH!.zip"...
100+
101+
REM Concatenate the files in binary mode
102+
COPY /b "!BUILDENV_PATH!.zip.part*" "!BUILDENV_PATH!.zip" >nul 2>&1
103+
IF %ERRORLEVEL% NEQ 0 (
104+
ECHO ^Error concatenating parts!
105+
PAUSE
106+
EXIT /B 1
107+
)
108+
109+
REM Clean up temporary files and directory
110+
RD /S /Q "%TEMP%\~buildenv"
111+
69112
ECHO ^Download complete.
70113
certutil -hashfile "!BUILDENV_PATH!.zip" SHA256 | FIND /C "!BUILDENV_SHA256!"
71114
IF errorlevel 1 (

0 commit comments

Comments
 (0)