|
1 | 1 | #!/bin/bash -ex |
2 | 2 |
|
3 | | -SRC_DIR=$1 |
| 3 | +if [ $# -eq 1 ]; then |
| 4 | + SRC_DIR=$1 |
| 5 | +elif [ $# -eq 0 ]; then |
| 6 | + SCRIPTNAME="`readlink --canonicalize $0`" |
| 7 | + SRC_DIR="`dirname "$SCRIPTNAME"`/../../../.." |
| 8 | + SRC_DIR="`readlink --canonicalize $SRC_DIR`" |
| 9 | +else |
| 10 | + echo "Error: Cound not deduce SRC_DIR, exiting" >&2 |
| 11 | +fi |
| 12 | + |
4 | 13 | PKG_NAME=f5-sdk |
5 | 14 | DIST_DIR="${PKG_NAME}-dist" |
6 | 15 | RPMBUILD_DIR="rpmbuild" |
7 | | -OS_VERSION=7 |
8 | | - |
9 | 16 | DEST_DIR="${SRC_DIR}/${DIST_DIR}" |
10 | 17 |
|
| 18 | +# Deduce the DIST name from "rpm --showrc" |
| 19 | +getdist() { |
| 20 | + rpm --showrc | while read arg1 arg2 arg3; do |
| 21 | + case $arg1 in |
| 22 | + -[1-9]*:) |
| 23 | + #echo found valid arg1: arg2: $arg2, arg3: $arg3 |
| 24 | + case $arg2 in |
| 25 | + dist) |
| 26 | + #echo found valid arg: arg3: $arg3 |
| 27 | + #echo DIST=$arg3 |
| 28 | + echo $arg3 |
| 29 | + ;; |
| 30 | + esac |
| 31 | + esac |
| 32 | + done |
| 33 | +} |
| 34 | +DIST="`getdist`" |
| 35 | +DISTDIR="`echo $DIST | tr -d '.'`" |
| 36 | + |
11 | 37 | echo "Building ${PKG_NAME} RPM packages..." |
12 | 38 | buildroot=$(mktemp -d /tmp/${PKG_NAME}.XXXXX) |
13 | 39 |
|
14 | 40 | cp -R $SRC_DIR/* ${buildroot} |
15 | 41 |
|
16 | 42 | pushd ${buildroot} |
17 | | -python setup.py build bdist_rpm --rpm-base rpmbuild |
| 43 | +python setup.py build bdist_rpm --rpm-base rpmbuild --release=1$DIST |
18 | 44 |
|
19 | 45 | echo "%_topdir ${buildroot}/rpmbuild" > ~/.rpmmacros |
20 | 46 |
|
21 | | -python setup.py bdist_rpm --spec-only --dist-dir rpmbuild/SPECS |
| 47 | +python setup.py bdist_rpm --spec-only --dist-dir rpmbuild/SPECS --release=1$DIST |
22 | 48 |
|
23 | 49 | rpmbuild -ba rpmbuild/SPECS/${PKG_NAME}.spec |
24 | 50 |
|
25 | | -mkdir -p ${DEST_DIR}/rpms/build |
26 | | - |
27 | | -for pkg in $(ls rpmbuild/RPMS/noarch/*.rpm); do |
28 | | - if [[ $pkg =~ ".noarch." ]]; then |
29 | | - mv $pkg ${pkg%%.noarch.rpm}.el${OS_VERSION}.noarch.rpm |
30 | | - fi |
31 | | -done |
32 | | -cp -R rpmbuild/RPMS/noarch/*.rpm ${DEST_DIR}/rpms/build |
| 51 | +# Use DIST specific subdirectories |
| 52 | +install -d "${DEST_DIR}/rpms/build/$DISTDIR/RPMS" |
| 53 | +install rpmbuild/RPMS/*/*.rpm "${DEST_DIR}/rpms/build/$DISTDIR/RPMS/" |
| 54 | +install -d "${DEST_DIR}/rpms/build/$DISTDIR/SRPMS" |
| 55 | +install rpmbuild/SRPMS/*.rpm "${DEST_DIR}/rpms/build/$DISTDIR/SRPMS/" |
33 | 56 |
|
34 | 57 | popd |
35 | 58 |
|
|
0 commit comments