mirror of
https://git.centos.org/centos-git-common.git
synced 2025-02-23 08:12:56 +00:00
Merge #4 2 Changes to make get_sources more portable
This commit is contained in:
commit
8a81bc8622
1 changed files with 12 additions and 12 deletions
|
@ -102,13 +102,13 @@ else
|
||||||
QUIET=''
|
QUIET=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
which git >/dev/null 2>&1
|
command -v git >/dev/null 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo 'You need git in PATH' >&2
|
echo 'You need git in PATH' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
which curl >/dev/null 2>&1
|
command -v curl >/dev/null 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo 'You need curl in PATH' >&2
|
echo 'You need curl in PATH' >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -117,7 +117,7 @@ fi
|
||||||
# should go into a function section at some point
|
# should go into a function section at some point
|
||||||
weakHashDetection () {
|
weakHashDetection () {
|
||||||
strHash=${1};
|
strHash=${1};
|
||||||
case $((`echo ${strHash}|wc -m` - 1 )) in
|
case $((`echo "${strHash}"|wc -m` - 1 )) in
|
||||||
128)
|
128)
|
||||||
hashBin='sha512sum'
|
hashBin='sha512sum'
|
||||||
;;
|
;;
|
||||||
|
@ -181,20 +181,20 @@ else
|
||||||
else
|
else
|
||||||
branches=("${branches[@]}" "$branch")
|
branches=("${branches[@]}" "$branch")
|
||||||
fi
|
fi
|
||||||
done <<< "$(git branch --contains HEAD)"
|
done <<< "$(git branch -r --contains HEAD | grep '^\s\+origin/'| sed 's#origin/##g')"
|
||||||
fi
|
fi
|
||||||
while read -r fsha fname ; do
|
while read -r fsha fname ; do
|
||||||
if [ ".${fsha}" = ".da39a3ee5e6b4b0d3255bfef95601890afd80709" ]; then
|
if [ ".${fsha}" = ".da39a3ee5e6b4b0d3255bfef95601890afd80709" ]; then
|
||||||
# zero byte file
|
# zero byte file
|
||||||
touch ${fname}
|
touch "${fname}"
|
||||||
else
|
else
|
||||||
if [ ${CHECK} -eq 1 ]; then
|
if [ ${CHECK} -eq 1 ]; then
|
||||||
hashType=$(weakHashDetection ${fsha})
|
hashType=$(weakHashDetection "${fsha}")
|
||||||
if [ "${hashType}" == "unknown" ]; then
|
if [ "${hashType}" == "unknown" ]; then
|
||||||
echo 'Failure: Hash type unknown.' >&2
|
echo 'Failure: Hash type unknown.' >&2
|
||||||
exit 1;
|
exit 1;
|
||||||
else
|
else
|
||||||
which ${hashType} >/dev/null 2>&1
|
command -v "${hashType}" >/dev/null 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Failure: You need ${hashType} in PATH." >&2
|
echo "Failure: You need ${hashType} in PATH." >&2
|
||||||
exit 1;
|
exit 1;
|
||||||
|
@ -203,15 +203,15 @@ while read -r fsha fname ; do
|
||||||
fi
|
fi
|
||||||
if [ -e ${fname} -a ${CHECK} -eq 1 ]; then
|
if [ -e ${fname} -a ${CHECK} -eq 1 ]; then
|
||||||
# check hash sum and force download if wrong
|
# check hash sum and force download if wrong
|
||||||
downsum=$(${hashType} ${fname} | awk '{print $1}')
|
downsum=$(${hashType} "${fname}" | awk '{print $1}')
|
||||||
if [ "${fsha}" != "${downsum}" ]; then
|
if [ "${fsha}" != "${downsum}" ]; then
|
||||||
rm -f ${fname}
|
rm -f "${fname}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -e "${fname}" ]; then
|
if [ ! -e "${fname}" ]; then
|
||||||
for br in "${branches[@]}"
|
for br in "${branches[@]}"
|
||||||
do
|
do
|
||||||
br=$(echo ${br}| sed -e s'|remotes/origin/||')
|
br=$(echo "${br}"| sed -e s'|remotes/origin/||')
|
||||||
url="${SURL}/${pn}/${br}/${fsha}"
|
url="${SURL}/${pn}/${br}/${fsha}"
|
||||||
echo "Retrieving ${url}"
|
echo "Retrieving ${url}"
|
||||||
curl -L ${QUIET} -f "${url}" -o "${fname}" && break
|
curl -L ${QUIET} -f "${url}" -o "${fname}" && break
|
||||||
|
@ -220,9 +220,9 @@ while read -r fsha fname ; do
|
||||||
echo "${fname} exists. skipping"
|
echo "${fname} exists. skipping"
|
||||||
fi
|
fi
|
||||||
if [ ${CHECK} -eq 1 ]; then
|
if [ ${CHECK} -eq 1 ]; then
|
||||||
downsum=$(${hashType} ${fname} | awk '{print $1}')
|
downsum=$(${hashType} "${fname}" | awk '{print $1}')
|
||||||
if [ "${fsha}" != "${downsum}" ]; then
|
if [ "${fsha}" != "${downsum}" ]; then
|
||||||
rm -f ${fname}
|
rm -f "${fname}"
|
||||||
echo "Failure: ${fname} hash does not match hash from the .metadata file" >&2
|
echo "Failure: ${fname} hash does not match hash from the .metadata file" >&2
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue