-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_packages.sh
43 lines (34 loc) · 1.2 KB
/
build_packages.sh
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
set -x
make clean
VERSION=`grep Version: *.spec | cut -d : -f 2 | sed -e 's@\s@@g'`
RELEASE=`grep "define _release" *.spec | cut -d" " -f"4"| sed -r -e 's/}//'`
if [ "X$VERSION" == "X" ] || [ "X$RELEASE" == "X" ]; then
echo "Failed to get version numbers!" >&2
exit 1
fi
tmpdir=`mktemp -d /tmp/gdr.XXXXXX`
if [ ! -d "$tmpdir" ]; then
echo "Failed to create a temp directory!" >&2
exit 1
fi
echo "Working in $tmpdir ..."
cwd=$PWD
#cp gdrcopy.spec ~/work/mellanox/rpmbuild/SPECS/
mkdir -p $tmpdir/gdrcopy
rm -rf $tmpdir/gdrcopy/*
cp -r * $tmpdir/gdrcopy/
rm -f $tmpdir/gdrcopy-$VERSION.tar.gz
cd $tmpdir
mv gdrcopy gdrcopy-$VERSION
tar czvf gdrcopy-$VERSION.tar.gz gdrcopy-$VERSION
mkdir -p $tmpdir/topdir/{SRPMS,RPMS,SPECS,BUILD,SOURCES}
cp gdrcopy-$VERSION/gdrcopy.spec $tmpdir/topdir/SPECS/
cp gdrcopy-$VERSION.tar.gz $tmpdir/topdir/SOURCES/
rpmbuild -ba --nodeps --define "_topdir $tmpdir/topdir" --define 'dist %{nil}' --define 'CUDA /usr/local/cuda-7.5' --define "KVERSION $(uname -r)" $tmpdir/topdir/SPECS/gdrcopy.spec
rpms=`ls -1 $tmpdir/topdir/RPMS/*/*.rpm`
srpm=`ls -1 $tmpdir/topdir/SRPMS/`
echo $srpm $rpms
cd $cwd
mv $tmpdir/topdir/SRPMS/*.rpm .
mv $tmpdir/topdir/RPMS/*/*.rpm .
rm -rf $tmpdir