Patch for gsbuild_base.prep

Pierre Labastie diy-linux-dev@diy-linux.org
Sat, 25 Nov 2006 20:00:01 +0100


Greg Schafer wrote:
> Thanks for the patch, Pierre. However, patches to gsbuild are probably best
> sent to me off list. The main focus here is on the Refbuild itself.
>   
Hello Greg,
Sorry for the misuse of the list. Here is a patch again. With the new 
commands in chroot/coreutils, gsbuild_base.prep (either before or after 
patching) is wrong. It is a patch to apply to the current cvs version of 
gsbuild_base.prep, which I suggest you to update anyway by changing at 
least the chroot/coreutils sed to:
---------------
sed -i\
    -e '/id -u/i if [ "$RUN_TESTS" = Y ]; then' \
    -e '/^fi/s/^/\tfi\n/' \
    -e '/id -u/,/^fi/{/fi/!s/^/\t/}' \
    scriptlets/chroot/coreutils
------------------------
or so. The current sed screws up completely the script.

Regards
Pierre
-----------------------------------------
--- gsbuild_base.prep.old    2006-11-25 18:55:50.000000000 +0100
+++ gsbuild_base.prep    2006-11-25 19:29:39.000000000 +0100
@@ -12,52 +12,64 @@
     scriptlets/chroot/{autoconf,automake,gettext,libtool,vim}
 
 sed -i \
+    -e '/^\tMYCC/n' \
     -e '/myspecs/i test "$ITER" = 1 && \\' \
     -e "/myspecs/s/^/\tMYCC='/" \
     -e "/myspecs/s/ \\\/'/" \
+    -e '/"$MYCC"/N; /"$MYCC"/n' \
     -e '/ure /i eval "$MYCC" \\' \
     scriptlets/chroot/gcc
 
 sed -i \
-    '0,/^sed/{/^sed/s/^/test "$ITER" = 1 \&\& /}' \
+    -e '/"$ITER"/{:a ; /^sed/n ; N ; ba}' \
+    -e '0,/^sed/{/^sed/s/^/test "$ITER" = 1 \&\& /}' \
     scriptlets/chroot/glibc
 
 sed -i \
-    -e '/NON_ROOT/i if [ "$RUN_TESTS" = Y ]; then' \
-    -e '/RUN_EXP/a fi' \
-    -e '/NON_ROOT/,/RUN_EXP/s/^/\t/' \
+    -e '/RUN_TESTS/{:a ; /fi\nfi/n ; N ; ba}' \
+    -e '/id -u/i if [ "$RUN_TESTS" = Y ]; then' \
+    -e '/^fi/s/^/\tfi\n/' \
+    -e '/id -u/,/^fi/{/fi/!s/^/\t/}' \
     scriptlets/chroot/coreutils
 
 sed -i \
+    -e '/RUN_TESTS/{:a ; /^fi/n ; N ; ba}' \
     -e '/^chown/i if [ "$RUN_TESTS" = Y ]; then' \
     -e '/^su/a fi' \
     -e '/^chown/,/^su/s/^/\t/' \
     scriptlets/chroot/bash
 
 sed -i \
-    '/CXX/a test "$NLS" = N && { test "${enable_nls+set}" = set || 
enable_nls=no; }' \
+    -e '/CXX/N' \
+        -e '/CXX.*test/n' \
+    -e '/CXX/s/\n/\ntest "$NLS" = N \&\& { test "${enable_nls+set}" = 
set || enable_nls=no; }\n/' \
     scriptlets/chroot/create_misc_files
 
 sed -i \
-    "/configure/a test \"\$NLS\" = N && { sed -i.bak '/NLS/d' 
defines.h; sed -i.bak '/^CATALOGS/d' po/Makefile; }" \
+    -e '/configure/N' \
+        -e '/configure.*test/n' \
+    -e "/configure/s@\n@\ntest \"\$NLS\" = N \&\& { sed -i.bak '/NLS/d' 
defines.h; sed -i.bak '/^CATALOGS/d' po/Makefile; }\n@" \
     scriptlets/chroot/kbd
 
 sed -i \
-    "/configure/i test \"\$NLS\" = N && sed -i.bak '/^D.*NLS/s/no/yes/' 
MCONFIG" \
+    -e '/"$NLS"/N ; /"$NLS"/n' \
+    -e "/configure/i test \"\$NLS\" = N && sed -i.bak 
'/^D.*NLS/s/no/yes/' MCONFIG" \
     scriptlets/chroot/util-linux
 
 sed -i \
-    "/check/i test \"\$NLS\" = N && sed -i.bak '/^SUBDIRS/d' 
doc/Makefile" \
+    -e '/"$NLS"/N ; /"$NLS"/n' \
+    -e "/check/i test \"\$NLS\" = N && sed -i.bak '/^SUBDIRS/d' 
doc/Makefile" \
     scriptlets/chroot/fakeroot
 
 for F in  
scriptlets/temptools/{sed-pass1,binutils-pass{1,2},gcc-pass{1,2},glibc,adjust-toolchain}; 
do
-    echo "log_debug" >> $F
+    grep "log_debug" $F >/dev/null 2>&1 || echo "log_debug" >> $F
 done
 
 for F in scriptlets/chroot/{man-pages,glibc,gcc,binutils}; do
-    echo 'if [ -z "$PKG_MGR" ]; then log_debug; fi' >> $F
+    grep "log_debug" $F >/dev/null 2>&1 || echo 'if [ -z "$PKG_MGR" ]; 
then log_debug; fi' >> $F
 done
 
+grep "log_debug" scriptlets/chroot/readjust-toolchain > /dev/null 2>&1 || \
 echo 'log_debug "gcc -specs=/tmp/myspecs -B/usr/lib/ -B/usr/bin/"' >> 
scriptlets/chroot/readjust-toolchain
 
 # These hacks are for Pacman's benefit.
@@ -71,6 +83,7 @@
 > scriptlets/chroot/coreutils.nofakeroot
 > scriptlets/chroot/bash.nofakeroot
 
+grep "PACMAN" scriptlets/chroot/create_dirs >/dev/null 2>&1 || \
 echo 'if [ "$PKG_MGR" = PACMAN ]; then mkdir -pv 
/var/{lib/pacman/local,cache/pacman/pkg}; fi' >> \
     scriptlets/chroot/create_dirs