From 743a8ad850fe389e76219b2547d238638b5a7239 Mon Sep 17 00:00:00 2001 From: Martin Dietze Date: Tue, 24 Feb 2026 12:34:46 +0100 Subject: [PATCH] RedHat build script: support for overriding release * Use the same entry point for calling `rpmbuild' * The rpm release can be overridden by `--release ' from the CL * Simplified build error handling * Automatically determine ${NEXTSPACE_DIR} in `build_all.sh' * Make `build_all.sh' work again --- Packaging/RedHat/0.build_libraries.sh | 42 ++---------- Packaging/RedHat/1.build_frameworks.sh | 10 +-- Packaging/RedHat/2.build_applications.sh | 10 +-- Packaging/RedHat/3.build_selinux.sh | 19 +----- Packaging/RedHat/SPECS/libcorefoundation.spec | 3 +- Packaging/RedHat/SPECS/libdispatch.spec | 3 +- Packaging/RedHat/SPECS/libobjc2.spec | 3 +- Packaging/RedHat/SPECS/libwraster.spec | 3 +- .../RedHat/SPECS/nextspace-applications.spec | 3 +- Packaging/RedHat/SPECS/nextspace-core.spec | 3 +- .../RedHat/SPECS/nextspace-frameworks.spec | 3 +- Packaging/RedHat/SPECS/nextspace-gnustep.spec | 3 +- Packaging/RedHat/SPECS/nextspace-selinux.spec | 3 +- Packaging/RedHat/build_all.sh | 34 +++------- Packaging/RedHat/build_libcorefoundation.sh | 4 +- Packaging/RedHat/build_libdispatch.sh | 4 +- Packaging/RedHat/build_libobjc2.sh | 4 +- Packaging/RedHat/build_libwraster.sh | 4 +- Packaging/RedHat/build_nextspace-core.sh | 4 +- Packaging/RedHat/build_nextspace-gnustep.sh | 4 +- Packaging/RedHat/build_nextspace-selinux.sh | 4 +- Packaging/functions.sh | 64 ++++++++++++++----- 22 files changed, 103 insertions(+), 131 deletions(-) diff --git a/Packaging/RedHat/0.build_libraries.sh b/Packaging/RedHat/0.build_libraries.sh index 4a39e861b..02be13b3a 100755 --- a/Packaging/RedHat/0.build_libraries.sh +++ b/Packaging/RedHat/0.build_libraries.sh @@ -8,53 +8,25 @@ BUILD_RPM=1 . `dirname $0`/../functions.sh . `dirname $0`/../environment.sh -prepare_redhat_environment -if [ $? -ne 0 ];then - print_ERR "Failed to setup building environment. Exiting..." - exit 1 -fi +prepare_redhat_environment || error_exit "Failed to setup building environment. Exiting..." # Apple Grand Central Dispatch -`dirname $0`/build_libdispatch.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_libdispatch.sh "$@" || abort_with_message # Apple Core Foundation -`dirname $0`/build_libcorefoundation.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_libcorefoundation.sh "$@" || abort_with_message # GNUstep Objective-C runtime -`dirname $0`/build_libobjc2.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_libobjc2.sh "$@" || abort_with_message # NextSpace Core -`dirname $0`/build_nextspace-core.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_nextspace-core.sh "$@" || abort_with_message # Raster graphics manipulation -`dirname $0`/build_libwraster.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_libwraster.sh "$@" || abort_with_message # GNUstep libraries -`dirname $0`/build_nextspace-gnustep.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_nextspace-gnustep.sh "$@" || abort_with_message print_OK " Build and install of NEXTSPACE Libraries SUCCEEDED!" diff --git a/Packaging/RedHat/1.build_frameworks.sh b/Packaging/RedHat/1.build_frameworks.sh index 2cedd05d2..b5ac6e937 100755 --- a/Packaging/RedHat/1.build_frameworks.sh +++ b/Packaging/RedHat/1.build_frameworks.sh @@ -7,11 +7,7 @@ BUILD_RPM=1 . `dirname $0`/../functions.sh . `dirname $0`/../environment.sh -prepare_redhat_environment -if [ $? -ne 0 ];then - print_ERR "Failed to setup building environment. Exiting..." - exit 1 -fi +prepare_redhat_environment || error_exit "Failed to setup building environment. Exiting..." LOG_FILE=${CWD}/frameworks_build.log SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/nextspace-frameworks.spec @@ -32,12 +28,12 @@ mv ${PROJECT_DIR}/nextspace-frameworks-${FRAMEWORKS_VERSION}.tar.gz ${RPM_SOURCE spectool -g -R ${SPEC_FILE} print_H2 "===== Building nextspace-frameworks package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of NEXTSPACE Frameworks RPM SUCCEEDED!" print_H2 "===== Installing nextspace-frameworks RPMs..." - FRAMEWORKS_VERSION=`rpm_version ${SPEC_FILE}` + FRAMEWORKS_VERSION=`rpm_version ${SPEC_FILE} "$@"` install_rpm nextspace-frameworks ${RPMS_DIR}/nextspace-frameworks-${FRAMEWORKS_VERSION}.rpm mv ${RPMS_DIR}/nextspace-frameworks-${FRAMEWORKS_VERSION}.rpm ${RELEASE_USR} diff --git a/Packaging/RedHat/2.build_applications.sh b/Packaging/RedHat/2.build_applications.sh index dea4a44e6..ab22ff6d4 100755 --- a/Packaging/RedHat/2.build_applications.sh +++ b/Packaging/RedHat/2.build_applications.sh @@ -7,11 +7,7 @@ BUILD_RPM=1 . `dirname $0`/../functions.sh . `dirname $0`/../environment.sh -prepare_redhat_environment -if [ $? -ne 0 ];then - print_ERR "Failed to setup building environment. Exiting..." - exit 1 -fi +prepare_redhat_environment || error_exit "Failed to setup building environment. Exiting..." LOG_FILE=/dev/null SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/nextspace-applications.spec @@ -36,12 +32,12 @@ mv ${PROJECT_DIR}/nextspace-applications-${APPLICATIONS_VERSION}.tar.gz ${RPM_SO spectool -g -R ${SPEC_FILE} print_H2 "===== Building nextspace-applications package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of NEXTSPACE Applications RPM SUCCEEDED!" print_H2 "===== Installing nextspace-applications RPMs..." - APPLICATIONS_VERSION=`rpm_version ${SPEC_FILE}` + APPLICATIONS_VERSION=`rpm_version ${SPEC_FILE} "$@"` install_rpm nextspace-applications ${RPMS_DIR}/nextspace-applications-${APPLICATIONS_VERSION}.rpm mv ${RPMS_DIR}/nextspace-applications-${APPLICATIONS_VERSION}.rpm ${RELEASE_USR} diff --git a/Packaging/RedHat/3.build_selinux.sh b/Packaging/RedHat/3.build_selinux.sh index 600c239df..7b6ddf84d 100755 --- a/Packaging/RedHat/3.build_selinux.sh +++ b/Packaging/RedHat/3.build_selinux.sh @@ -8,25 +8,10 @@ BUILD_RPM=1 . `dirname $0`/../functions.sh . `dirname $0`/../environment.sh -if [ $# -eq 0 ];then - print_help - exit 1 -fi - -prepare_redhat_environment -if [ $? -ne 0 ];then - print_ERR "Failed to setup building environment. Exiting..." - exit 1 -fi - -REPO_DIR=$1 +prepare_redhat_environment || error_exit "Failed to setup building environment. Exiting..." # NextSpace SELinux -`dirname $0`/build_nextspace-selinux.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/build_nextspace-selinux.sh "$@" || abort_with_message print_OK " Build and install of NEXTSPACE SELinux SUCCEEDED!" diff --git a/Packaging/RedHat/SPECS/libcorefoundation.spec b/Packaging/RedHat/SPECS/libcorefoundation.spec index 39a3e62f1..0a3728075 100644 --- a/Packaging/RedHat/SPECS/libcorefoundation.spec +++ b/Packaging/RedHat/SPECS/libcorefoundation.spec @@ -1,10 +1,11 @@ %global toolchain clang +%{!?release:%global release 1} %define CFNET_VERSION 129.20 Name: libcorefoundation Version: 5.9.2 Epoch: 0 -Release: 1%{?dist} +Release: %{release}%{?dist} Summary: Apple CoreFoundation framework. License: Apache 2.0 URL: https://github.com/trunkmaster/apple-corefoundation diff --git a/Packaging/RedHat/SPECS/libdispatch.spec b/Packaging/RedHat/SPECS/libdispatch.spec index c16dd4d00..c045e6df6 100644 --- a/Packaging/RedHat/SPECS/libdispatch.spec +++ b/Packaging/RedHat/SPECS/libdispatch.spec @@ -1,9 +1,10 @@ %global toolchain clang +%{!?release:%global release 1} Name: libdispatch Epoch: 1 Version: 5.9.2 -Release: 1%{?dist} +Release: %{release}%{?dist} Summary: Grand Central Dispatch (GCD or libdispatch). License: Apache 2.0 URL: https://github.com/apple/swift-corelibs-libdispatch diff --git a/Packaging/RedHat/SPECS/libobjc2.spec b/Packaging/RedHat/SPECS/libobjc2.spec index c848c8124..dc896d4a8 100644 --- a/Packaging/RedHat/SPECS/libobjc2.spec +++ b/Packaging/RedHat/SPECS/libobjc2.spec @@ -1,9 +1,10 @@ %global toolchain clang +%{!?release:%global release 0} %global _hardened_build 0 Name: libobjc2 Version: 2.2.1 -Release: 0%{?dist} +Release: %{release}%{?dist} Summary: GNUstep Objecttive-C runtime library. License: GPL v2.0 URL: https://github.com/gnustep/libobjc2 diff --git a/Packaging/RedHat/SPECS/libwraster.spec b/Packaging/RedHat/SPECS/libwraster.spec index 25b43875c..5373bb6c4 100644 --- a/Packaging/RedHat/SPECS/libwraster.spec +++ b/Packaging/RedHat/SPECS/libwraster.spec @@ -1,9 +1,10 @@ %global toolchain clang +%{!?release:%global release 0} %define WRASTER_VERSION 7.0.1 Name: libwraster Version: %{WRASTER_VERSION} -Release: 0%{?dist} +Release: %{release}%{?dist} Summary: Raster graphics library. Group: Libraries/NextSpace License: GPLv3 diff --git a/Packaging/RedHat/SPECS/nextspace-applications.spec b/Packaging/RedHat/SPECS/nextspace-applications.spec index 009e0f818..746f96c94 100644 --- a/Packaging/RedHat/SPECS/nextspace-applications.spec +++ b/Packaging/RedHat/SPECS/nextspace-applications.spec @@ -1,8 +1,9 @@ %global toolchain clang +%{!?release:%global release 0} Name: nextspace-applications Version: 0.95 -Release: 0%{?dist} +Release: %{release}%{?dist} Summary: NextSpace desktop core applications. Group: Libraries/NextSpace diff --git a/Packaging/RedHat/SPECS/nextspace-core.spec b/Packaging/RedHat/SPECS/nextspace-core.spec index dcf48c355..a48aa0db2 100644 --- a/Packaging/RedHat/SPECS/nextspace-core.spec +++ b/Packaging/RedHat/SPECS/nextspace-core.spec @@ -1,11 +1,12 @@ %global debug_package %{nil} +%{!?release:%global release 12} %global _hardened_build 0 %define MAKE_VERSION 2_9_2 Name: nextspace-core Version: 0.95 -Release: 12%{?dist} +Release: %{release}%{?dist} Summary: NextSpace filesystem hierarchy and system files. License: GPLv2 URL: http://github.com/trunkmaster/nextspace diff --git a/Packaging/RedHat/SPECS/nextspace-frameworks.spec b/Packaging/RedHat/SPECS/nextspace-frameworks.spec index 03918e287..1ffed6ec8 100644 --- a/Packaging/RedHat/SPECS/nextspace-frameworks.spec +++ b/Packaging/RedHat/SPECS/nextspace-frameworks.spec @@ -1,8 +1,9 @@ %global toolchain clang +%{!?release:%global release 0} Name: nextspace-frameworks Version: 0.95 -Release: 0%{?dist} +Release: %{release}%{?dist} Summary: NextSpace core libraries. Group: Libraries/NextSpace License: GPLv2 diff --git a/Packaging/RedHat/SPECS/nextspace-gnustep.spec b/Packaging/RedHat/SPECS/nextspace-gnustep.spec index 1b41c9fc5..86aa8bb57 100644 --- a/Packaging/RedHat/SPECS/nextspace-gnustep.spec +++ b/Packaging/RedHat/SPECS/nextspace-gnustep.spec @@ -1,4 +1,5 @@ %global toolchain clang +%{!?release:%global release 1} %global _hardened_build 0 %define GS_REPO https://github.com/gnustep @@ -12,7 +13,7 @@ Name: nextspace-gnustep Version: %{BASE_VERSION}_%{GUI_VERSION} -Release: 1%{?dist} +Release: %{release}%{?dist} Summary: GNUstep libraries. Group: Libraries/NextSpace diff --git a/Packaging/RedHat/SPECS/nextspace-selinux.spec b/Packaging/RedHat/SPECS/nextspace-selinux.spec index dc5468755..3a5f2dcea 100644 --- a/Packaging/RedHat/SPECS/nextspace-selinux.spec +++ b/Packaging/RedHat/SPECS/nextspace-selinux.spec @@ -1,9 +1,10 @@ %global selinux_variants mls targeted %global selinux_modules ns-core ns-gdomap ns-gpbs ns-gdnc ns-Login +%{!?release:%global release 0} Name: nextspace-selinux Version: 0.91 -Release: 0%{?dist} +Release: %{release}%{?dist} Summary: SELinux policies for NEXTSPACE components. Group: Libraries/NextSpace diff --git a/Packaging/RedHat/build_all.sh b/Packaging/RedHat/build_all.sh index 6abdcaf70..a9f546c5b 100755 --- a/Packaging/RedHat/build_all.sh +++ b/Packaging/RedHat/build_all.sh @@ -8,36 +8,18 @@ BUILD_RPM=1 . `dirname $0`/../functions.sh . `dirname $0`/../environment.sh -if [ $# -eq 0 ];then - print_help - exit 1 -fi +NEXTSPACE_DIR="$(cd "$(dirname "$0")/../.."; pwd)" -prepare_redhat_environment -if [ $? -ne 0 ];then - print_ERR "Failed to setup building environment. Exiting..." - exit 1 -fi +test -d "${NEXTSPACE_DIR}" || errorExit "Invalid NEXTSPACE directory: '${NEXTSPACE_DIR}'." +prepare_redhat_environment || error_exit "Failed to setup building environment. Exiting..." rm -rf ~/rpmbuild/SOURCES/* rm -rf ~/rpmbuild/BUILD/* rm -rf ~/rpmbuild/BUILDROOT/* -rm -rf $1/Packaging/RedHat/$OS_ID-$OS_VERSION/NSDeveloper/* -rm -rf $1/Packaging/RedHat/$OS_ID-$OS_VERSION/NSUser/* +rm -rf "${NEXTSPACE_DIR}/Packaging/RedHat/$OS_ID-$OS_VERSION/NSDeveloper"/* +rm -rf "${NEXTSPACE_DIR}/Packaging/RedHat/$OS_ID-$OS_VERSION/NSUser"/* -`dirname $0`/0.build_libraries.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi -`dirname $0`/1.build_frameworks.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi -`dirname $0`/2.build_applications.sh $1 -if [ $? -ne 0 ]; then - echo "Aborting..." - exit 1 -fi +`dirname $0`/0.build_libraries.sh "$@" || abort_with_message +`dirname $0`/1.build_frameworks.sh "$@" || abort_with_message +`dirname $0`/2.build_applications.sh "$@" || abort_with_message diff --git a/Packaging/RedHat/build_libcorefoundation.sh b/Packaging/RedHat/build_libcorefoundation.sh index 7573c1735..81039f4e3 100755 --- a/Packaging/RedHat/build_libcorefoundation.sh +++ b/Packaging/RedHat/build_libcorefoundation.sh @@ -6,7 +6,7 @@ BUILD_RPM=1 . `dirname $0`/../environment.sh SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/libcorefoundation.spec -CF_VERSION=`rpm_version ${SPEC_FILE}` +CF_VERSION=`rpm_version ${SPEC_FILE} "$@"` print_H1 " Building Core Foundation (libcorefoundation) package..." print_H2 "===== Install Core Foundation build dependencies..." @@ -20,7 +20,7 @@ curl -L https://github.com/trunkmaster/apple-corefoundation/archive/refs/tags/${ spectool -g -R ${SPEC_FILE} print_H2 "===== Building CoreFoundation package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of Core Foundation library RPM SUCCEEDED!" diff --git a/Packaging/RedHat/build_libdispatch.sh b/Packaging/RedHat/build_libdispatch.sh index a225de4a5..ebda019d5 100755 --- a/Packaging/RedHat/build_libdispatch.sh +++ b/Packaging/RedHat/build_libdispatch.sh @@ -12,7 +12,7 @@ if [ "${OS_ID}" = "fedora" ]; then fi SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/libdispatch.spec -DISPATCH_VERSION=`rpm_version ${SPEC_FILE}` +DISPATCH_VERSION=`rpm_version ${SPEC_FILE} "$@"` # libdispatch print_H1 " Building Grand Central Dispatch (libdispatch) package..." @@ -26,7 +26,7 @@ curl -L https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${VER} spectool -g -R ${SPEC_FILE} print_H2 "===== Building libdispatch package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of Grand Central Dispatch library RPM SUCCEEDED!" diff --git a/Packaging/RedHat/build_libobjc2.sh b/Packaging/RedHat/build_libobjc2.sh index dd3dc6911..abacdd9ec 100755 --- a/Packaging/RedHat/build_libobjc2.sh +++ b/Packaging/RedHat/build_libobjc2.sh @@ -6,7 +6,7 @@ BUILD_RPM=1 . `dirname $0`/../environment.sh SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/libobjc2.spec -OBJC2_VERSION=`rpm_version ${SPEC_FILE}` +OBJC2_VERSION=`rpm_version ${SPEC_FILE} "$@"` print_H1 " Building Objective-C Runtime(libobjc2) package..." print_H2 "===== Install libobjc2 build dependencies..." @@ -17,7 +17,7 @@ print_H2 "===== Downloading libobjc2 sources..." spectool -g -R ${SPEC_FILE} print_H2 "===== Building libobjc2 package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of Objective-C Runtime RPM SUCCEEDED!" diff --git a/Packaging/RedHat/build_libwraster.sh b/Packaging/RedHat/build_libwraster.sh index fbd0b177a..297631185 100755 --- a/Packaging/RedHat/build_libwraster.sh +++ b/Packaging/RedHat/build_libwraster.sh @@ -24,10 +24,10 @@ mv ${PROJECT_DIR}/Libraries/libwraster-${WRASTER_VERSION}.tar.gz ${RPM_SOURCES_D spectool -g -R ${SPEC_FILE} print_H2 "===== Building libwraster RPM..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then - WRASTER_VERSION=`rpm_version ${SPEC_FILE}` + WRASTER_VERSION=`rpm_version ${SPEC_FILE} "$@"` print_OK " Building libwraster RPM SUCCEEDED!" install_rpm libwraster ${RPMS_DIR}/libwraster-${WRASTER_VERSION}.rpm diff --git a/Packaging/RedHat/build_nextspace-core.sh b/Packaging/RedHat/build_nextspace-core.sh index d42fd0576..2c45adc04 100755 --- a/Packaging/RedHat/build_nextspace-core.sh +++ b/Packaging/RedHat/build_nextspace-core.sh @@ -22,12 +22,12 @@ rm ./nextspace-os_files-${CORE_VERSION}/GNUmakefile tar zcf ${RPM_SOURCES_DIR}/nextspace-os_files-${CORE_VERSION}.tar.gz nextspace-os_files-${CORE_VERSION} cd $CWD -CORE_VERSION=`rpm_version ${SPEC_FILE}` +CORE_VERSION=`rpm_version ${SPEC_FILE} "$@"` cp ${PROJECT_DIR}/Libraries/gnustep/nextspace.fsl ${RPM_SOURCES_DIR} spectool -g -R ${SPEC_FILE} print_H2 "===== Building NEXTSPACE core components (nextspace-core) RPM..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of NEXTSPACE Core RPM SUCCEEDED!" diff --git a/Packaging/RedHat/build_nextspace-gnustep.sh b/Packaging/RedHat/build_nextspace-gnustep.sh index 4c378531d..64a613a03 100755 --- a/Packaging/RedHat/build_nextspace-gnustep.sh +++ b/Packaging/RedHat/build_nextspace-gnustep.sh @@ -8,7 +8,7 @@ BUILD_RPM=1 . /etc/profile.d/nextspace.sh SPEC_FILE=${PROJECT_DIR}/Packaging/RedHat/SPECS/nextspace-gnustep.spec -GNUSTEP_VERSION=`rpm_version ${SPEC_FILE}` +GNUSTEP_VERSION=`rpm_version ${SPEC_FILE} "$@"` print_H1 " Building NEXTSPACE GNUstep (nextspace-gnustep) package..." cp ${PROJECT_DIR}/Libraries/gnustep/gdnc-local.service ${RPM_SOURCES_DIR} @@ -39,7 +39,7 @@ print_H2 "===== Downloading GNUstep sources..." spectool -g -R ${SPEC_FILE} print_H2 "===== Building GNUstep package..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of NEXTSPACE GNUstep RPM SUCCEEDED!" diff --git a/Packaging/RedHat/build_nextspace-selinux.sh b/Packaging/RedHat/build_nextspace-selinux.sh index 5a3c0c774..883145671 100755 --- a/Packaging/RedHat/build_nextspace-selinux.sh +++ b/Packaging/RedHat/build_nextspace-selinux.sh @@ -33,11 +33,11 @@ cp ${PROJECT_DIR}/Libraries/selinux/ns-gpbs.fc ${RPM_SOURCES_DIR} cp ${PROJECT_DIR}/Libraries/selinux/ns-gpbs.if ${RPM_SOURCES_DIR} cp ${PROJECT_DIR}/Libraries/selinux/ns-gpbs.te ${RPM_SOURCES_DIR} -SELINUX_VERSION=`rpm_version ${SPEC_FILE}` +SELINUX_VERSION=`rpm_version ${SPEC_FILE} "$@"` spectool -g -R ${SPEC_FILE} print_H2 "===== Building NEXTSPACE SELinux components (nextspace-selinux) RPM..." -rpmbuild -bb ${SPEC_FILE} +run_rpmbuild ${SPEC_FILE} "$@" STATUS=$? if [ $STATUS -eq 0 ]; then print_OK " Building of NEXTSPACE SELinux RPM SUCCEEDED!" diff --git a/Packaging/functions.sh b/Packaging/functions.sh index c52720f5e..f17bf6e8f 100644 --- a/Packaging/functions.sh +++ b/Packaging/functions.sh @@ -30,7 +30,21 @@ uninstall_packages() { rpm_version() { - echo `rpmspec -q --qf "%{version}-%{release}.%{arch}:" $1 | awk -F: '{print $1}'` + SPEC_FILE=$1 + shift + RELEASE="" + while [ $# -gt 0 ]; do + case "$1" in + --release) shift; RELEASE="$1"; test -n "$RELEASE" || error_exit "Missing argument to '--release'.";; + *) error_exit "Unsupported argument: '$1'.";; + esac + shift + done + if [ -n "$RELEASE" ]; then + rpmspec --define "release $RELEASE" -q --qf "%{version}-%{release}.%{arch}:" ${SPEC_FILE} | awk -F: '{print $1}' + else + rpmspec -q --qf "%{version}-%{release}.%{arch}:" ${SPEC_FILE} | awk -F: '{print $1}' + fi } # $1 - path to spec file @@ -40,7 +54,29 @@ build_rpm() spectool -g -R ${SPEC_FILE} DEPS=`rpmspec -q --buildrequires ${SPEC_FILE} | awk -c '{print $1}'` sudo yum -y install ${DEPS} - rpmbuild -bb ${SPEC_FILE} + run_rpmbuild ${SPEC_FILE} +} + +# $1 - path to spec file, optional: $2, $3, ... - rpm build flags +run_rpmbuild() +{ + SPEC_FILE=$1 + shift + RELEASE="" + while [ $# -gt 0 ]; do + case "$1" in + --release) shift; RELEASE="$1"; test -n "$RELEASE" || error_exit "Missing argument to '--release'.";; + *) error_exit "Unsupported argument: '$1'.";; + esac + shift + done + if [ -n "$RELEASE" ]; then + echo "rpmbuild --define \"release $RELEASE\" -bb ${SPEC_FILE}" + rpmbuild --define "release $RELEASE" -bb ${SPEC_FILE} + else + echo "rpmbuild -bb ${SPEC_FILE}" + rpmbuild -bb ${SPEC_FILE} + fi } # $1 - package name, $2 - rpm file path @@ -99,20 +135,6 @@ print_ERR() echo -e -n "\e[0m" } -print_help() -{ - SCRIPT_NAME=`basename $0` - print_ERR " ERROR: No NEXTSPACE directory specified." - printf "\n" - print_H2 "You have to specify directory where NEXTSPACE git clone resides." - print_H2 "For example, consider this scenario:" - printf "\n" - print_H2 "$ git clone https://github.com/trunkmaster/nextspace" - print_H2 "$ cd nextspace" - print_H2 "$ ./scripts/$SCRIPT_NAME ~/nextspace" - printf "\n" -} - prepare_redhat_environment() { print_H1 " Prepare build environment" @@ -146,3 +168,13 @@ prepare_redhat_environment() sudo dnf -y install ${BUILD_TOOLS} fi } + +error_exit() { + print_ERR "*** $*" + exit 1 +} + +abort_with_message() { + echo "Aborting..." + exit 1 +}