diff --git a/script/makeinstaller-assets.json b/script/makeinstaller-assets.json new file mode 100644 index 00000000..a180a622 --- /dev/null +++ b/script/makeinstaller-assets.json @@ -0,0 +1,52 @@ +[ + { + "url": "https://github.com/streamlink/streamlink-assets/releases/download/2020.4.21/ffmpeg-4.2.2-win32-static.zip", + "sha256": "1f6adff50db6cad54fdab15013c4c95cb6f83d7fe6d1167f3896cf4550573565", + "filename": "ffmpeg-4.2.2-win32-static.zip", + "type": "zip", + "sourcedir": "ffmpeg-4.2.2-win32-static", + "targetdir": "ffmpeg", + "files": [ + { + "from": "bin/ffmpeg.exe", + "to": "ffmpeg.exe" + }, + { + "from": "LICENSE.txt", + "to": "LICENSE.txt" + } + ] + }, + { + "url": "https://github.com/streamlink/streamlink-assets/releases/download/2020.4.21/ffmpeg-4.2.2-win32-static-readme.txt", + "sha256": "6252abd8981ff3b61728bf58868c3dab2d4f96495907bae15ebbdad6b9bb9934", + "filename": "ffmpeg-4.2.2-win32-static-readme.txt", + "type": "file", + "sourcedir": null, + "targetdir": "ffmpeg", + "files": [ + { + "from": "ffmpeg-4.2.2-win32-static-readme.txt", + "to": "BUILDINFO.txt" + } + ] + }, + { + "url": "https://github.com/streamlink/streamlink-assets/releases/download/2020.4.21/rtmpdump-2.3-windows.zip", + "sha256": "6948aa372f04952d5675917c6ca2c7c0bf6b109de21a4323adc93247fff0189f", + "filename": "rtmpdump-2.3-windows.zip", + "type": "zip", + "sourcedir": "rtmpdump-2.3", + "targetdir": "rtmpdump", + "files": [ + { + "from": "rtmpdump.exe", + "to": "rtmpdump.exe" + }, + { + "from": "COPYING", + "to": "LICENSE.txt" + } + ] + } +] diff --git a/script/makeinstaller.sh b/script/makeinstaller.sh index 6c8a0d07..e96334cc 100755 --- a/script/makeinstaller.sh +++ b/script/makeinstaller.sh @@ -34,8 +34,7 @@ STREAMLINK_VERSION=$(python setup.py --version) STREAMLINK_VERSION_PLAIN="${STREAMLINK_VERSION%%+*}" STREAMLINK_INSTALLER="${1:-"streamlink-${STREAMLINK_VERSION/\+/_}"}" STREAMLINK_PYTHON_VERSION=3.9.6 -STREAMLINK_ASSETS_REPO="${STREAMLINK_ASSETS_REPO:-streamlink/streamlink-assets}" -STREAMLINK_ASSETS_RELEASE="${STREAMLINK_ASSETS_RELEASE:-latest}" +STREAMLINK_ASSETS_FILE="${ROOT}/script/makeinstaller-assets.json" CI_BUILD_NUMBER=${GITHUB_RUN_ID:-0} STREAMLINK_VI_VERSION="${STREAMLINK_VERSION_PLAIN}.${CI_BUILD_NUMBER}" @@ -273,51 +272,43 @@ cp "${ROOT}/win32/config" "${files_dir}/config" cp "${ROOT}/LICENSE" "${files_dir}/LICENSE.txt" -# download binary assets like ffmpeg and rtmpdump from the streamlink assets repo -# parse the data.json manifest, validate archives and copy specific files to their destination -log "Fetching assets data from \"${STREAMLINK_ASSETS_REPO}\" (${STREAMLINK_ASSETS_RELEASE})" -assets_release_data=$(curl -s --fail \ - -H 'Accept: application/vnd.github.v3+json' \ - -H "User-Agent: ${GITHUB_REPOSITORY:-"streamlink/streamlink"}" \ - "https://api.github.com/repos/${STREAMLINK_ASSETS_REPO}/releases/${STREAMLINK_ASSETS_RELEASE}" \ - || err "Could not fetch release data" -) -assets_release_tag=$(echo "${assets_release_data}" | jq -r ".tag_name") -assets_data=$(curl -s --fail \ - -H "User-Agent: ${GITHUB_REPOSITORY:-"streamlink/streamlink"}" \ - "https://raw.githubusercontent.com/${STREAMLINK_ASSETS_REPO}/${assets_release_tag}/data.json" \ - || err "Could not fetch manifest data" -) +ASSETS_DATA=$(cat "${STREAMLINK_ASSETS_FILE}") -log "Retrieving assets" -while read -r filename size url; do - if ! [[ -f "${cache_dir}/${filename}" ]]; then - log "Downloading asset: ${filename} (${size} Bytes)" - curl -s -L --output "${cache_dir}/${filename}" "${url}" - fi - checksum=$(jq -r "[.[] | select(.filename == \"${filename}\")] | first | .checksum" <<< "${assets_data}") - echo "${checksum} ${cache_dir}/${filename}" | sha256sum --check - -done < <(jq -r '.assets[] | "\(.name) \(.size) \(.browser_download_url)"' <<< "${assets_release_data}") +assets_prepare() { + log "Preparing assets" + while read -r filename sha256 url; do + if ! [[ -f "${cache_dir}/${filename}" ]]; then + log "Downloading asset: ${filename}" + curl -L -o "${cache_dir}/${filename}" "${url}" + fi + echo "${sha256} ${cache_dir}/${filename}" | sha256sum --check - + done < <(jq -r '.[] | "\(.filename) \(.sha256) \(.url)"' <<< "${ASSETS_DATA}") +} -log "Assembling files directory" -TEMP=$(mktemp -d) && trap "rm -rf ${TEMP}" EXIT || exit 255 -for ((i=$(jq length <<< "${assets_data}") - 1; i >= 0; --i)); do - read -r filename sourcedir targetdir \ - < <(jq -r ".[$i] | \"\(.filename) \(.sourcedir) \(.targetdir)\"" <<< "${assets_data}") - sourcedir="${TEMP}/${sourcedir}" - case "${filename}" in - *.zip) - unzip "${cache_dir}/${filename}" -d "${TEMP}" - ;; - *) - sourcedir="${cache_dir}" - ;; - esac - while read -r from to; do - install -v -D -T "${sourcedir}/${from}" "${files_dir}/${targetdir}/${to}" - done < <(jq -r ".[$i].files[] | \"\(.from) \(.to)\"" <<< "${assets_data}") -done +assets_assemble() { + log "Assembling files directory" + local tmp=$(mktemp -d) && trap "rm -rf '${tmp}'" RETURN || exit 255 + for ((i=$(jq length <<< "${ASSETS_DATA}") - 1; i >= 0; --i)); do + read -r type filename sourcedir targetdir \ + < <(jq -r ".[$i] | \"\(.type) \(.filename) \(.sourcedir) \(.targetdir)\"" <<< "${ASSETS_DATA}") + case "${type}" in + zip) + mkdir -p "${tmp}/${i}" + unzip "${cache_dir}/${filename}" -d "${tmp}/${i}" + sourcedir="${tmp}/${i}/${sourcedir}" + ;; + *) + sourcedir="${cache_dir}" + ;; + esac + while read -r from to; do + install -v -D -T "${sourcedir}/${from}" "${files_dir}/${targetdir}/${to}" + done < <(jq -r ".[$i].files[] | \"\(.from) \(.to)\"" <<< "${ASSETS_DATA}") + done +} +assets_prepare +assets_assemble log "Building ${STREAMLINK_INSTALLER} installer" pynsist "${build_dir}/streamlink.cfg"