Patch for gsbuild_base.prep
Pierre Labastie
diy-linux-dev@diy-linux.org
Fri, 24 Nov 2006 14:24:38 +0100
Hello,
I do not know if this list is for Greg's "gsbuild" implementation of
automatic build.
I made some mods which could be of interest to others using this
implementation.
If this is not the right place to do this, please let me know.
here is the issue that I tried to solve :
To taylor the scriptlets for use in an automatic build, gsbuild.sh calls
a script named gsbuild_base.prep, which applies various seds to the
scriptlets. It works fine on the first time, but not if you reapply it
to the same scriptlets. Of course in normal operation it cannot be
applied twice since gsbuild.sh touches prep-base.done which prevents it.
But what if an error occur before the prep-base.done file is touched ?
(this happened to me...).
So a patch follows :
I tested that The old and the new version give exactly the same results
(as measured by a diff on the scriptlets directory), and the new version
does not change anything when applied a second time, (as measured by
diff again), while the old one does.
Regards
Pierre
---------------------------------------
Date: 2006-11-24
Author: Pierre Labastie <lnimbus@club-internet.fr>
Origin: See Author
Description: Guards against applying the same modifications to a file twice
(or more)
diff -Nau gsbuild_base.prep{.old,}
--- gsbuild_base.prep.old 2006-11-24 11:15:51.000000000 +0100
+++ gsbuild_base.prep 2006-11-24 14:07:50.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 '/RUN_TESTS/{:a ; /^fi/n ; N ; ba}' \
-e '/NON_ROOT/i if [ "$RUN_TESTS" = Y ]; then' \
-e '/RUN_EXP/a fi' \
-e '/NON_ROOT/,/RUN_EXP/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