#!/bin/bash if [[ ${#@} -lt 2 ]]; then echo "not enough arguments provided" 1>&2 exit 1 fi BINARYLOOKUPPATH="${1}" FILEBASENAME="${2}" if [[ ${#@} -gt 2 ]] && ! [[ "${3}" == "" ]]; then FILEVERSION="${3}" else FILEVERSION="$DEFAULTTAGNAME" 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" cp "${file}" "${DOCKERDIR}/bin/$platform/${FILEBASENAME}" } 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)