summaryrefslogtreecommitdiffstats
path: root/redhat/build/get_latest_tarball_filename.sh
blob: 7901d09152a8981f566442ca76a97f0260bea0bb (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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 "${TDE_PACKAGING_DIR}" ] || TDE_PACKAGING_DIR=~/tde/tde-packaging
[ -d "${DIST_PACKAGING_DIR}" ] || DIST_PACKAGING_DIR=${TDE_PACKAGING_DIR}/redhat/

EXTRA_DIR="$(cd ${TARBALLS_DIR}/../extras/; pwd)"

RET=$(find "${TARBALLS_DIR}" -name "trinity-${PKGNAME}-${TDE_VERSION}*.tar.gz" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

RET=$(find "${TARBALLS_DIR}" "${EXTRA_DIR}" -follow -name "${PKGNAME}-${TDE_VERSION}*.tar.gz" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

RET=$(find "${TARBALLS_DIR}" -name "trinity-${PKGNAME}-[0-9]*.tar.gz" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

RET=$(find "${EXTRA_DIR}" -follow -name "${PKGNAME}[-_][0-9]*.tar.*" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

# Now look in the 'tde-packaging' directory
RET=$(find "${DIST_PACKAGING_DIR}" -name "${PKGNAME}-[0-9]*.tar*" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

# Retry without 'trinity-*', and allow any TAR extension.
RET=$(find "${DIST_PACKAGING_DIR}" -name "${PKGNAME}-[0-9]*.tar*" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

# Retry without 'trinity-*', and allow any TAR extension.
RET=$(find "${DIST_PACKAGING_DIR}" -name "${PKGNAME}-[0-9]*.tar*" | sort -n | tail -n 1)
[ -r "${RET}" ] && echo "${RET}" && exit 0

# 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)
[ -r "${RET}" ] && echo "${RET}" && exit 0


exit 0