summaryrefslogtreecommitdiffstats
path: root/redhat/build/get_latest_tarball_filename.sh
blob: e4c58d2b6aaa537cae98074690cfc16f4d9c77a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

PKGNAME="${1##*/}"
TDE_VERSION="${2:-14.0.0}"

[ -z "${PKGNAME}" ] && echo "You must specify a package name !" && exit 1
[ -d "${TARBALLS_DIR}" ] || TARBALLS_DIR=~/tde/tde-tarballs/${TDE_VERSION}/
[ -d "${PACKAGING_DIR}" ] || PACKAGING_DIR=~/tde/tde-packaging
[ -d "${DIST_PACKAGING_DIR}" ] || DIST_PACKAGING_DIR=${PACKAGING_DIR}/redhat/

RET=$(find "${TARBALLS_DIR}" -name "trinity-${PKGNAME}-[0-9]*.tar.gz" | sort -n | tail -n 1)
if [ -z "${RET}" ]; then
  RET=$(find "${TARBALLS_DIR}/../extras/" -name "${PKGNAME}-[0-9]*.tar.*" | sort -n | tail -n 1)
fi
if [ ! -r "${RET}" ]; then
	# Retry without 'trinity-*', and allow any TAR extension.
	RET=$(find "${DIST_PACKAGING_DIR}" -name "${PKGNAME}-[0-9]*.tar*" | sort -n | tail -n 1)
	if [ ! -r "${RET}" ]; then
		# Retry by removing numbers in package name, e.g "imlib1" => "imlib"
		RET=$(find "${DIST_PACKAGING_DIR}" -name "$(tr -d "[0-9]" <<< ${PKGNAME})-[0-9]*.tar*" | sort -n | tail -n 1)
	fi
fi

[ -z "${RET}" ] && exit 2

echo "${RET}"
exit 0