summaryrefslogtreecommitdiffstats
path: root/redhat/build/get_specfile.sh
blob: 81c20b1830d013980ee5a68244ac01b25b286e05 (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
#!/bin/bash

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

[ -z "${PKGNAME}" ] && echo "You must specify a package name !" && exit 1

[ -d "${TDE_PACKAGING_DIR}" ] || TDE_PACKAGING_DIR="${HOME}/tde/${TDE_BRANCH:-master}/tde-packaging"
[ -d "${DIST_PACKAGING_DIR}" ] || DIST_PACKAGING_DIR="${TDE_PACKAGING_DIR}/redhat"

# Special case for QT3
if [ "${PKGNAME}" = "qt3" ]; then
  case "$(rpmdist.sh --dist)" in
    .oss*) DIST_PACKAGING_DIR="${TDE_PACKAGING_DIR}/opensuse" ;;
    .mga*|.mdk*|.pclos*) DIST_PACKAGING_DIR="${TDE_PACKAGING_DIR}/mageia" ;;
  esac
fi

for filename in \
  "${PKGNAME}-${TDE_VERSION}.spec" \
  "${PKGNAME}-14.0.0.spec" \
  "${PKGNAME}.spec" \
  "trinity-${PKGNAME}-${TDE_VERSION}.spec" \
  "trinity-${PKGNAME}-14.0.0.spec" \
  "trinity-${PKGNAME}.spec" \
; do
  SPECFILE="$(find "${DIST_PACKAGING_DIR}" -follow -name "${filename}")"
  [ -r "${SPECFILE}" ] && break || continue
done

if [ -r "${SPECFILE}" ]; then
  echo "${SPECFILE}"
  exit 0
else
  exit 1
fi