55 lines
1.3 KiB
Bash
Executable file
55 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
if [[ ${#@} -lt 2 ]]; then
|
|
echo "not enough arguments provided" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
BINARYLOOKUPPATH="${1}"
|
|
FILEBASENAME="${2}"
|
|
RENAME="${3}"
|
|
|
|
if [[ ${#@} -gt 3 ]] && ! [[ "${4}" == "" ]]; then
|
|
FILEVERSION="${4}"
|
|
else
|
|
FILEVERSION="${DEFAULTTAGNAME:-main}"
|
|
fi
|
|
|
|
OUTFILENAME=""
|
|
if [[ "$RENAME" == "false" ]]; then
|
|
OUTFILENAME="${FILEBASENAME}"
|
|
elif [["$RENAME" == "true" ]]; then
|
|
OUTFILENAME=gitea
|
|
else
|
|
OUTFILENAME="${RENAME}"
|
|
fi
|
|
|
|
FILE_WIHTOUT_PLATFORM="${FILEBASENAME}-${FILEVERSION}"
|
|
|
|
DOCKERDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|
WS_BASE="${DOCKERDIR%/docker}"
|
|
|
|
if [[ ! -f "${DOCKERDIR}/archmap.txt" ]]; then
|
|
echo "no archmap found" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
function map(){
|
|
local file="${1}"
|
|
local bin_platform="${file##./$FILE_WIHTOUT_PLATFORM-}"
|
|
if ! grep -q "$bin_platform" "${DOCKERDIR}/archmap.txt"; then
|
|
echo "no matching platform for $file found" 2>&1
|
|
return 0
|
|
fi
|
|
|
|
local platform="$(grep $bin_platform "${DOCKERDIR}/archmap.txt" | cut -d':' -f2)"
|
|
mkdir -p "${DOCKERDIR}/bin/$platform"
|
|
echo "Mapped ${file} to $platform, copying to ${DOCKERDIR}/bin/$platform/${OUTFILENAME}"
|
|
cp "${file}" "${DOCKERDIR}/bin/$platform/${OUTFILENAME}"
|
|
}
|
|
|
|
cd "$WS_BASE/${BINARYLOOKUPPATH}"
|
|
|
|
while IFS= read -r -d $'\0' infile; do
|
|
map "$infile"
|
|
done < <(find . -maxdepth 1 -type f -name "${FILE_WIHTOUT_PLATFORM}-*" -print0)
|