Re: good patch vs. sed fixes

"Bruce Dubbs" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On 11/20/24 20:40, Uwe Düffert ([email protected] via blfs-dev Mailing List) 
wrote:
> Hi all,
> 
> I'm not sure it is worth the effort, but from time to time I stumble across the 
> "problem" that certain sed or patch commands would apply multiple times although they 
> should not. I'm fully aware this is unsupported "deviating from the book" but it 
> happens. I'm trying to build some not-yet-in-the-book new version, something fails, I 
> fix the problem and try again, then some unexpected "double sed" or "double patch" 
> silently breaks stuff. Sure, I should have done it cleanly from scratch, but the 
> nature of the fixed problem suggested I could just repeat the build...
> 
> Current example: I was upgrading to icu-76.1 . icu is an ugly package that usually 
> triggers having to rebuild quite a number of others. firefox is one of those, at 
> least when using system-icu. I'm aware the book stays with firefox ESR versions for a 
> reason, however, if I'm rebuilding it anyway, I (try to) use the most recent release 
> version. The ICU74+ sed for firefox in the book fixes the build problem just fine, 
> BUT it would apply arbitrarily often. Took me quite some time to understand that my 
> firefox-132 problem is NOT icu-76.1 but applying the system-icu sed multiple times.
> 
> My personal solution for that is protecting my build script like this:
> grep -q "CLASS_CHARACTER,CLASS_CHARACTER" intl/lwbrk/LineBreaker.cpp || for i in 
> {43..47}; do
>     sed '/ZWJ/s/}/,CLASS_CHARACTER&/' -i intl/lwbrk/LineBreaker.cpp
> done
> 
> I do like the idea to fix stuff with a simple sed if it helps avoiding a patch, BUT 
> only if it does the job similarily well. I kind of appreciate the educational value 
> of a sophisticated sed, but in my experience a unified patch is less likely to 
> "doubly apply" (though it happened to me before) and sometimes makes clearer what 
> actually needs to be changed.
> 
> I'm not proposing using some more official patch such as https://gitweb.gentoo.org/ 
> repo/gentoo.git/commit/?id=d9712b1358dc1b64933c3090d72153aae3270f25 in this case, I'd 
> just like to mention that this patch 1) makes the idea more clear (there are not just 
> 5 more CLASS_CHARACTERs but they do have names) and it does not apply multiple times...

To avoid the problem, add this to your scripts

DIR=`pwd`
rm -rf <build location>
mkdir  <build location>
cd     <build location>
tar -xf $DIR/<tarball>
cd <extracted directory>

continue with build instructions.

That way you are always working from a clean directory and any seds or patches are 
only applied as specified in the book.

Note that the primary advantage of our use of seds in BLFS is to allow you to see 
simple changes without downloading an extra file and looking inside it to see what it 
is doing.  Of course more complicated changes still require a patch.

   -- Bruce

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.