summaryrefslogtreecommitdiffstats
path: root/scripts/dbg_mkrpm
blob: 68ab9e2e998cfe418b08086203f6e5f6f8351202 (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
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

#set -e

#git clone git://git.fedorahosted.org/git/abrt.git
#SRCDIR="abrt"
#BUILDDIR="abrt"

SRCDIR="."
BUILDDIR="00_builddir"

rm -rf "$BUILDDIR"

if ! test -f "$SRCDIR/configure"; then
        echo "Autogenerating configure"
        (cd "$SRCDIR" && ./autogen.sh) || { rm -f "$SRCDIR/configure"; exit 1; }
fi

test -f "$SRCDIR/abrt.spec" || exit 1
ABRTVER=`grep ^Version: "$SRCDIR/abrt.spec" | head -n1 | sed 's/.* //'`

T=`mktemp -d`

# Prepare source snapshot
cp -a "$SRCDIR" "$T"/"abrt-$ABRTVER"

# Can't do it before copying, BUILDDIR may be a subdir of SRCDIR
mkdir "$BUILDDIR" 2>/dev/null

# Prepare sources for rpmbuild
(tar -czf - -C "$T" "abrt-$ABRTVER") >"$BUILDDIR"/"abrt-$ABRTVER".tar.gz
rm -rf "$T"
cp "$SRCDIR"/abrt.spec "$BUILDDIR"
cp "$SRCDIR"/abrt*.init "$BUILDDIR"
#cp "$SRCDIR"/dbg_* "$BUILDDIR" 2>/dev/null # developers' toys

{

cd "$BUILDDIR" || exit 1

# Build them
nice -n10 rpmbuild \
  --define "_topdir $PWD" \
  --define "_builddir $PWD" \
  --define "_rpmdir $PWD" \
  --define "_sourcedir $PWD" \
  --define "_specdir $PWD" \
  --define "_srcrpmdir $PWD" \
  --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
  -bb abrt.spec 2>&1
echo "Exitcode: $?"

} | tee -a "$0.log"

test x"`tail -n 1 "$0.log"`" = x"Exitcode: 0"
exit $?