diff --git a/installJRMC b/installJRMC index 712c6bc..9475317 100755 --- a/installJRMC +++ b/installJRMC @@ -589,10 +589,17 @@ acquireDeb() { buildRPM() { debug "Running: ${FUNCNAME[0]}" + declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm" + + # skip rebuilding the rpm if it already exists + if [[ -f "$_mcrpm" ]]; then + echo "$_mcrpm already exists. Skipping build step." + return 0 + fi + # install build dependencies installPackage "wget" "dpkg" "rpm-build" - # If necessary, make build directories [[ ! -d "$_outputdir/SPECS" ]] && mkdir -p "$_outputdir/SPECS" # rpmbuild uses rpm to check for build dependencies @@ -677,14 +684,6 @@ buildRPM() { /etc/security/limits.d/* EOF - declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm" - - # skip rebuilding the rpm if it already exists - if [[ -f "$_mcrpm" ]]; then - echo "$_mcrpm already exists. Skipping build step." - return 0 - fi - # Run rpmbuild echo "Building version $_mcversion, please wait..." if debug; then @@ -692,8 +691,6 @@ buildRPM() { else rpmbuild --quiet --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec" > /dev/null 2>&1 fi - - return $? } @@ -1306,12 +1303,15 @@ main() { # Build RPM from source deb package if [[ -v _build ]]; then acquireDeb - if ! buildRPM || [[ ! -f "$_mcrpm" ]] ; then + if buildRPM; then + echo "Build Successful." + echo "The RPM file is located at: $_mcrpm" + else err "Build failed." + # In case this is automated, let's remove the source DEB and reaquire + # it on next run in case it is corrupted or buggy [[ -f "$DEBFILENAME" ]] && echo "Removing source DEB" && rm -f "$DEBFILENAME" exit 1 - else - echo "Build successful. The RPM file is located at: $_mcrpm" fi fi