summaryrefslogtreecommitdiffstats
path: root/redhat/build/gather_rpm_sources.sh
blob: fd8b21a2b594da41204a98c852804cb54f9a52a7 (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
43
44
45
#!/bin/bash

# Usage: gather_rpm_sources.sh <TDE_PACKAGE> <TDE_VERSION> <DESTINATION>
# Example: gather_rpm_sources.sh tdebase 14.0.12 /tmp/tdebase

PKGNAME="${1%/}"
PKGNAME="${PKGNAME##*/}"
TDE_VERSION="${2:-${TDE_VERSION:-14.0.12}}"
TARGETDIR="${3:-/tmp/${PKGNAME}-${TDE_VERSION}}"
DIST="$4"

SPECFILE=$(get_specfile.sh ${PKGNAME} ${TDE_VERSION})
[ -z "${SPECFILE}" ] && exit 1

SOURCES=$(get_source_files.sh ${PKGNAME} ${TDE_VERSION} ${DIST})
TARBALL=$(get_latest_tarball_filename.sh ${PKGNAME} ${TDE_VERSION} || :)
VERSION=$(get_latest_tarball_version.sh ${PKGNAME} ${TDE_VERSION} || :)
case "${VERSION}" in *~pre*) PREVERSION="${VERSION#*~}";; esac

DIST="$(rpmdist.sh --dist)"
[ -z "${TMPPATH}" ] && TMPPATH="/dev/shm"
BUILDDIR="${TMPPATH}/BUILD${DIST}.$(uname -i)"
BUILDROOTDIR="${TMPPATH}/BUILDROOT${DIST}.$(uname -i)"
LOGFILE="${TMPPATH}/log.${COMP##*/}"

mkdir -p "${TARGETDIR}"
rm -f "${TARGETDIR}/"*

cp -f ${SPECFILE} ${SOURCES} ${TARBALL} "${TARGETDIR}"

### Check for patches

PATCHDIR="${HOME}/tde/patches/${TDE_VERSION}/$1"
if [ -d "${PATCHDIR}" ]; then
  cat "${PATCHDIR}/"*".patch" "${PATCHDIR}/"*".patch${DIST}" >>"${TARGETDIR}/one.patch" 2>/dev/null
  if [ "$(cat "${TARGETDIR}/one.patch" | wc -c)" = 0 ]; then
    rm -f "${TARGETDIR}/one.patch"
  else
    sed -i "${TARGETDIR}/"*".spec" \
        -e "/^Source0:/ s/$/\nPatch389: one.patch/" \
        -e "/%setup/ s/$/\n%patch389 -p1/"
  fi
fi

exit $RET