Skip to content

Commit fb001e9

Browse files
nkadelcaphrim007
authored andcommitted
Provide "dist" handling for RPM builds (#1477)
* Include f5-sdk-dist/rpms in .gitignore * Teach build-rpms.sh to autoconfigure SRC_DIR and "dist"
1 parent 975fbd7 commit fb001e9

3 files changed

Lines changed: 74 additions & 27 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ docs/venv/*
5454

5555
# iControl REST logs
5656
logs
57+
58+
# Locally built RPMS
59+
f5-sdk-dist/rpms/
Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,58 @@
11
#!/bin/bash -ex
22

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+
413
PKG_NAME=f5-sdk
514
DIST_DIR="${PKG_NAME}-dist"
615
RPMBUILD_DIR="rpmbuild"
7-
OS_VERSION=6
8-
916
DEST_DIR="${SRC_DIR}/${DIST_DIR}"
1017

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+
1137
echo "Building ${PKG_NAME} RPM packages..."
1238
buildroot=$(mktemp -d /tmp/${PKG_NAME}.XXXXX)
1339

1440
cp -R $SRC_DIR/* ${buildroot}
1541

1642
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
1844

1945
echo "%_topdir ${buildroot}/rpmbuild" > ~/.rpmmacros
2046

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
2248

2349
rpmbuild -ba rpmbuild/SPECS/${PKG_NAME}.spec
2450

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 rpmbuild/RPMS/*/*.rpm "${DEST_DIR}/rpms/build/$DISTDIR/RPMS/"
53+
install -D rpmbuild/SRPMS/*.rpm "${DEST_DIR}/rpms/build/$DISTDIR/SRPMS/"
3354

3455
popd
3556

36-
rm -rf ${buildroot}
57+
#rm -rf ${buildroot}
3758

f5-sdk-dist/Docker/redhat/7/build-rpms.sh

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,58 @@
11
#!/bin/bash -ex
22

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+
413
PKG_NAME=f5-sdk
514
DIST_DIR="${PKG_NAME}-dist"
615
RPMBUILD_DIR="rpmbuild"
7-
OS_VERSION=7
8-
916
DEST_DIR="${SRC_DIR}/${DIST_DIR}"
1017

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+
1137
echo "Building ${PKG_NAME} RPM packages..."
1238
buildroot=$(mktemp -d /tmp/${PKG_NAME}.XXXXX)
1339

1440
cp -R $SRC_DIR/* ${buildroot}
1541

1642
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
1844

1945
echo "%_topdir ${buildroot}/rpmbuild" > ~/.rpmmacros
2046

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
2248

2349
rpmbuild -ba rpmbuild/SPECS/${PKG_NAME}.spec
2450

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/"
3356

3457
popd
3558

0 commit comments

Comments
 (0)