commit: f3f140783d0e031fa6ef5ba6c71a91059d71eee6
parent 19c83b80daadff17d9a2e6b105daaca2a9316c2a
Author: fosslinux <fosslinux@aussies.space>
Date: Thu, 30 Jan 2025 22:19:16 +1100
Remove unneeded double quotes
from download-distfiles.sh and mirror.sh
Diffstat:
2 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/download-distfiles.sh b/download-distfiles.sh
@@ -7,54 +7,54 @@
# Optional arguments: Mirrors
download_source() {
- local distfiles="${1}"
- local url="${2}"
+ local distfiles=${1}
+ local url=${2}
shift 2
- if [[ "${url}" == git://* ]]; then
- url="${1}"
+ if [[ ${url} == git://* ]]; then
+ url=${1}
shift
fi
- local checksum="${1}"
- local fname="${2}"
+ local checksum=${1}
+ local fname=${2}
# Default to basename of url if not given
- fname="${fname:-$(basename "${url}")}"
+ fname=${fname:-$(basename "${url}")}
if [ "${fname}" = "_" ]; then
echo "ERROR: ${url} must have a filename specified"
exit 1
fi
- local dest_path="${distfiles}/${fname}"
+ local dest_path=${distfiles}/${fname}
if ! [ -e "${dest_path}" ]; then
echo "Downloading ${fname}"
if [ "${mirrors_len}" -ne 0 ]; then
- local mirror_ix="$((RANDOM % mirrors_len))"
- url="${mirrors[${mirror_ix}]}/${fname}"
+ local mirror_ix=$((RANDOM % mirrors_len))
+ url=${mirrors[${mirror_ix}]}/${fname}
fi
curl --fail --location "${url}" --output "${dest_path}" || true
fi
}
check_source() {
- local distfiles="${1}"
- local url="${2}"
+ local distfiles=${1}
+ local url=${2}
shift 2
- if [[ "${url}" == git://* ]]; then
- url="${1}"
+ if [[ ${url} == git://* ]]; then
+ url=${1}
shift
fi
- local checksum="${1}"
- local fname="${2}"
+ local checksum=${1}
+ local fname=${2}
# Default to basename of url if not given
- fname="${fname:-$(basename "${url}")}"
+ fname=${fname:-$(basename "${url}")}
- local dest_path="${distfiles}/${fname}"
+ local dest_path=${distfiles}/${fname}
echo "${checksum} ${dest_path}" | sha256sum -c
}
set -e
mirrors=( "$@" )
-mirrors_len="$#"
+mirrors_len=$#
cd "$(dirname "$(readlink -f "$0")")"
mkdir -p distfiles
diff --git a/mirror.sh b/mirror.sh
@@ -12,7 +12,7 @@ if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
exit 1
fi
-dest="$1"
+dest=$1
if [ ! -d "${dest}" ]; then
echo "${dest} must be a directory"
exit 1
@@ -22,9 +22,9 @@ if [ ! -w "${dest}" ]; then
echo "you must be able to write to ${dest}"
exit 1
fi
-dest="$(realpath "${dest}")"
+dest=$(realpath "${dest}")
-state="$2"
+state=$2
if [ "${state}" = "" ]; then
state="${PWD}/mirrorstate"
fi
@@ -34,8 +34,8 @@ state="$(realpath "${state}")"
# Download a HTTP file
download_file() {
- url="${1}"
- out="${2}"
+ url=${1}
+ out=${2}
# Download the file
continue_arg=""
if [ -e "${out}" ]; then
@@ -47,8 +47,8 @@ download_file() {
# Check if a git reference exists in a given repository
git_ref_exists() {
- repo="${1}"
- ref="${2}"
+ repo=${1}
+ ref=${2}
# change this to git show-ref once it is sufficiently not-new
( cd "${repo}" || exit && git cat-file -t "${ref}" >/dev/null 2>&1 )
return $?
@@ -59,21 +59,21 @@ checksum_file() {
}
do_file() {
- uri="${1}"
+ uri=${1}
echo "${uri}"
if echo "${uri}" | grep -qE "^https?://"; then
# HTTP file
- checksum="${2}"
- filename="${3}"
+ checksum=${2}
+ filename=${3}
if [ "${filename}" = "" ]; then
- filename="$(basename "${uri}")"
+ filename=$(basename "${uri}")
fi
# Check if the file is already downloaded & the checksum is the same
- dest_file="${dest}/${filename}"
+ dest_file=${dest}/${filename}
if [ -e "${dest_file}" ]; then
- existing_checksum="$(checksum_file "${dest_file}")"
+ existing_checksum=$(checksum_file "${dest_file}")
if [ "${checksum}" = "${existing_checksum}" ]; then
# There is nothing we need to do here
return
@@ -82,10 +82,10 @@ do_file() {
# Attempt up to 2 times
retries=2
- matching="no"
+ matching=no
while [ "${retries}" -gt 0 ]; do
download_file "${uri}" "${dest}/${filename}"
- my_checksum="$(checksum_file "${dest_file}")"
+ my_checksum=$(checksum_file "${dest_file}")
if [ "${checksum}" = "${my_checksum}" ]; then
matching="yes"
break
@@ -105,28 +105,28 @@ do_file() {
# Creating a tarball from a git repository
# Very unfortunately, different sites have different rules.
- uri_path="${uri#git://}"
+ uri_path=${uri#git://}
# GitHub does not have git:// protocol support
if echo "${uri}" | grep -Eq "^git://github.com"; then
- uri="https://${uri_path}"
+ uri=https://${uri_path}
fi
- repo="${uri%~*}"
- outdir="${state}/git/${repo#*://}"
- reference="${uri##*~}"
+ repo=${uri%~*}
+ outdir=${state}/git/${repo#*://}
+ reference=${uri##*~}
- http_src="${2}"
- checksum="${3}"
- tarball="${4:-$(basename "${http_src}")}"
+ http_src=${2}
+ checksum=${3}
+ tarball=${4:-$(basename "${http_src}")}
if [ "${tarball}" = "_" ]; then
echo "${uri}: ERROR! Must have tarball name if no http source."
exit 1
fi
- tarball="${dest}/${tarball}"
+ tarball=${dest}/${tarball}
# Check if tarball already generated + matches checksum
- checksum="${3}"
+ checksum=${3}
if [ -e "${tarball}" ]; then
- existing_checksum="$(checksum_file "${tarball}")"
+ existing_checksum=$(checksum_file "${tarball}")
if [ "${existing_checksum}" = "${checksum}" ]; then
return
fi
@@ -151,13 +151,13 @@ do_file() {
fi
# Generate the prefix for the tarball
- prefix_ref="${reference}"
+ prefix_ref=${reference}
# All git repositories we already use remove "v"s from the beginning
# of branch/tag names in the tarball prefix
if echo "${reference}" | grep -Eq "^v[0-9]"; then
- prefix_ref="$(echo "${reference}" | sed "s/^v//")"
+ prefix_ref=$(echo "${reference}" | sed "s/^v//")
fi
- prefix="$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}"
+ prefix=$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}
(
cd "${outdir}" || exit
@@ -168,7 +168,7 @@ do_file() {
git archive "${reference}" -o "${tarball}" --prefix "${prefix}/"
)
- my_checksum="$(sha256sum "${tarball}" | cut -d' ' -f1)"
+ my_checksum=$(sha256sum "${tarball}" | cut -d' ' -f1)
if [ "${my_checksum}" != "${checksum}" ]; then
echo "${uri}: generated tarball does not match checksum"
exit 1
@@ -180,6 +180,6 @@ for src in steps/*/sources; do
while read -r line; do
# shellcheck disable=SC2086
do_file ${line}
- uri="$(echo "${line}" | cut -d' ' -f1)"
+ uri=$(echo "${line}" | cut -d' ' -f1)
done < "${src}"
done