mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-02 01:18:08 +01:00
Remove unneeded double quotes
from download-distfiles.sh and mirror.sh
This commit is contained in:
parent
19c83b80da
commit
f3f140783d
2 changed files with 50 additions and 50 deletions
62
mirror.sh
62
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue