build: compress download - #7
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the update and installation processes to download and decompress gzip-compressed release binaries instead of uncompressed ones. Feedback on the changes suggests using gunzip -c or gzip -dc and redirecting the output to the target filename explicitly in install.sh to prevent issues with unexpected output filenames caused by gzip headers or environment variables.
| if command -v gunzip >/dev/null 2>&1; then | ||
| gunzip_cmd="gunzip" | ||
| elif command -v gzip >/dev/null 2>&1; then | ||
| gunzip_cmd="gzip -d" |
There was a problem hiding this comment.
Using gunzip or gzip -d directly on the file can sometimes cause issues if the GZIP environment variable is set (e.g., with --name or -N) or if the platform's default behavior is to restore the original filename stored in the gzip header. This would result in a decompressed file with a different name (e.g., anfra-linux-x64 instead of anfra), causing subsequent steps to fail.
To prevent this, we can configure the commands to output to stdout (-c or -dc) and redirect the output to the target filename explicitly.
| if command -v gunzip >/dev/null 2>&1; then | |
| gunzip_cmd="gunzip" | |
| elif command -v gzip >/dev/null 2>&1; then | |
| gunzip_cmd="gzip -d" | |
| if command -v gunzip >/dev/null 2>&1; then | |
| gunzip_cmd="gunzip -c" | |
| elif command -v gzip >/dev/null 2>&1; then | |
| gunzip_cmd="gzip -dc" |
| if ! $gunzip_cmd "${tmp}/${BIN_NAME}.gz"; then # -> ${tmp}/${BIN_NAME} | ||
| err "failed to decompress ${asset}" | ||
| fi |
There was a problem hiding this comment.
Redirect the decompressed output to the target filename explicitly to ensure the output file is always named ${BIN_NAME} regardless of the original filename stored in the gzip header or any user-configured environment variables.
| if ! $gunzip_cmd "${tmp}/${BIN_NAME}.gz"; then # -> ${tmp}/${BIN_NAME} | |
| err "failed to decompress ${asset}" | |
| fi | |
| if ! $gunzip_cmd "${tmp}/${BIN_NAME}.gz" > "${tmp}/${BIN_NAME}"; then | |
| err "failed to decompress ${asset}" | |
| fi |
No description provided.