[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Strange abort of rpm-build with exit code 1 in brp-nobuildrootpath



Hi,


While creating an RPM package for libmusicbrainz 2.1.2 I got the
following strange result:

Bad exit status from /var/tmp/rpm-tmp.13863 (%install)

Hunting this one done I found that /usr/lib/rpm/brp-nobuildrootpath
had an exit code of '1'.

I think the problem is the code in the 'brp-nobuildrootpath':

grep "${RPM_BUILD_ROOT}\/" "$f" 2>&1 > /dev/null && \
  sed -e "s|${RPM_BUILD_ROOT}/|/|g" "$f" 2>/dev/null > "$f.out" && \
  mv "$f.out" "$f"

(grep exits with '0' if something is found, '1' if not, '2' if another
errors occurred, at least on Linux).

If the grep fails because there is nothing to substitute in a .pc or .la
file (ok, we could argue, that maybe the package has a problem in this case), then the exit code of 'grep' gets '1' which gets propagated
upwards in the call chain making the build of the package fail which is
probably not the desired result.

The following patch seems to solve the problem:

--- rpm-4.4.4/scripts/brp-nobuildrootpath 2005-11-06 16:24:53.000000000 +0100 +++ rpm-4.4.4-brp-nobuildrootpath-exit-code/scripts/brp-nobuildrootpath 2006-01-31 21:25:17.000000000 +0100
@@ -9,9 +9,15 @@
 for f in `find $RPM_BUILD_ROOT -type f` ; do
     case "$f" in
     *.la|*.pc)
-       grep "${RPM_BUILD_ROOT}\/" "$f" 2>&1 > /dev/null && \
-       sed -e "s|${RPM_BUILD_ROOT}/|/|g" "$f" 2>/dev/null > "$f.out" && \
-       mv "$f.out" "$f"
+       grep "${RPM_BUILD_ROOT}\/" "$f" 2>&1 > /dev/null
+       if test $? -eq 0; then
+ sed -e "s|${RPM_BUILD_ROOT}/|/|g" "$f" 2>/dev/null > "$f.out" && \
+          mv "$f.out" "$f"
+        else
+ # not finding something to replace with 'grep' causes this script to
+           # fail unless we react here!
+           true
+        fi
        ;;
     esac
 done

Feedback welcome...


With kind regards

Andreas


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]