I encountered the same problem. I found out that the script always dies when a line ends with an "escaped line feed" (don't know how it is called). Remove the line feed and put all the commands in one line.mirek wrote:I have got an errorCode: Select all
# sh genscript.sh Decoding attachment - please standby. genscript.sh: line 7: syntax error near unexpected token `||' genscript.sh: line 7: `|| die "I need openssl for base64 decoding!" '
Code: Select all
emerge --oneshot --update openssl \
|| die "I need openssl for base64 decoding!"
Code: Select all
emerge --oneshot --update openssl || die "I need openssl for base64 decoding!"

Thanks for that more accurate problem description!COMKEEN wrote:I encountered the same problem. I found out that the script always dies when a line ends with an "escaped line feed" (don't know how it is called).
Originally, this was exactly as the line looked! But as I never allow any line in one of my scripts to get longer than 79 characters, I inserted escaped line feeds in order to break long lines.COMKEEN wrote:Remove the line feed and put all the commands in one line.
Actually it is not the text editor's fault, but the browser's fault. I am using Konqueror and when I am copying/pasting your code snippet into a text editor (no matter whether I use a GUI editor like KWrite or a command line editor running in Konsole), there are additional whitespaces inserted at the beginning as well as at the end of each line. When I am copying the script from Firefox, everything seems alright.Guenther Brunthaler wrote:Thanks for that more accurate problem description!COMKEEN wrote:I encountered the same problem. I found out that the script always dies when a line ends with an "escaped line feed" (don't know how it is called).
I therefore conclude the origin of the problem must be the following: When copying/pasting the script, whitespace has somehow been added after the backslash which was not there in the original script.
In order to fix things, that white space must be manually removed: The backslash must be the very last character in the line! No spaces/tabs are allowed to follow.
Seems your editor somehow screwed up the pasted text by inserting some whitespace after the backslashes.
Code: Select all
$ cat genscript_with_spaces.sh | sed -e "s/^\ //g" | sed -e "s/\ $//g" > genscript.sh

Code: Select all
athlon ~ # emerge -pv lzo
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] dev-libs/lzo-2.02-r1 USE="examples" 0 kB
Total size of downloads: 0 kB
athlon ~ # emerge -pv =lzo-1.08-r1
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] dev-libs/lzo-1.08-r1 0 kB
Total size of downloads: 0 kBCode: Select all
athlon ~ # grep lzo recompile-remaining-packages
item 537 =dev-libs/lzo-2.02-r1
athlon ~ # 
Code: Select all
athlon ~ # ls /var/db/pkg/app-crypt/ | grep gnupg
gnupg-1.4.5/
gnupg-1.9.20-r3/
athlon ~ # cat recompile-remaining-packages | grep gnupg
item 140 =app-crypt/gnupg-1.4.5
item 141 =app-crypt/gnupg-1.9.20-r3
Code: Select all
athlon ~ # emerge -ep world | grep -e lzo -e gnupg
[ebuild N ] app-crypt/gnupg-1.4.5
[ebuild N ] app-crypt/gnupg-1.9.20-r3
[ebuild N ] dev-libs/lzo-2.02-r1Code: Select all
find /var/db/pkg -type d | sed "s/\/var\/db\/pkg\//=/" | grep / | sed "s/\/var\/db\/pkg//"|grep =


My script is based on the output of "emerge --emptytree". It re-orders that output and removes duplicate and unnecessary emerges, but will not add anything to that list.AssociateX wrote:But in this case both installed versions were found by your script. I wonder what I might have done wrong to mess up the other case.
Code: Select all
emerge -avuDN worldCode: Select all
emerge --ask --depcleanCode: Select all
revdep-rebuild
I like it!count_zero wrote:Guenther, great job!
Check out my script and how I've made it interface with yours for interruption-free compiling of the entire system (in the correct order).

Sounds good.Guenther Brunthaler wrote:I like it!count_zero wrote:Guenther, great job!
Check out my script and how I've made it interface with yours for interruption-free compiling of the entire system (in the correct order).
And I totally agree with your idea of an interruption-free rebuild.
I even think it would be the best to incorporate your great idea on next occasion directly into my script, so people won't have to mess around with different scripts for basically the same purpose.
Of course, your contribution will be honored accordingly in the updated version of the guide!
Until then, I recommend using your script for the purpose of interruption-free rebuilding the entire system in combination with my script.
I am also happy to see that my original guide has undergone several revision since then, adding significant improvements suggested by various people, making it even better.
It should be also clear from this, that it's no longer my guide - it's our guide! I'm just the original author and primary maintainer.


I have just updated the script and guide as of version 1.15. The script now features interruption-free operation, just as you suggested. Your contribution has been mentioned in the guide.count_zero wrote:Sounds good.

Code: Select all
find /var/db/pkg -type d|sed "s/\/var\/db\/pkg\//=/"|grep /|sed "s/\/var\/db\/pkg//"|grep =|sort>db.tmpCode: Select all
emerge -ep world|perl -ne 'if (/]/) { s{^\[[^\]]+\]\s+}{=}; print $_ }'|sort>emerge.tmpCode: Select all
perl -ne 'if (/item [1-9]/) { s{item \d{1,4} }{}; print $_ }' recompile-remaining-packages|sort>recompile.tmpCode: Select all
diff -bn emerge.tmp recompile.tmp|grep =Code: Select all
diff -bn emerge.tmp db.tmp|grep =Guenther, you are a starGuenther Brunthaler wrote:Hi all,
(You are reading version 1.15 of this guide.)
ABSTRACT: How to recompile your entire system / toolchain with MINIMUM PROCESSING TIME EFFORT.
If you plan to do a major compiler update for your Gentoo box, such as from GCC 3.3 to GCC 3.4, or from GCC 3.3/3.4 to GCC 4, then read on. (This will typically be the case when upgrading your Gentoo installation to the new 2006.1 profile.)

You are absolutely right. It's /var/lib/portage/world, not /var/portage/world.AssociateX wrote:Also, my world file is located at /var/lib/portage/world, not /var/portage/world as this howto has it.


Perhaps you might have been using a very old version of bash? My script assumes a moderately modern version of bash.steveL wrote:I get an error (unexpected token >) at line 62 of the recompile-remaining-packages script, which is `exec > >('
Code: Select all
exec > >(...)Code: Select all
exec > anonymous_pipeCode: Select all
#! /bin/bashCode: Select all
#! /bin/shYes and no. The problem is, my script assumes a working compiler and tools to be available when it starts its job.steveL wrote:Also, is it really necessary to emerge world newuse etc before running the script? Surely these are all going to be compiled anyway?
Code: Select all
emerge -avuDN worldCode: Select all
emerge --sync
Well, actually they are not really anonymous from the viewpoint of the kernel, but rather temporary: Bash uses mkfifo or something similar internally to create a pipe with a temporary name in /tmp (I guess), then runs the process substitution, and eventually removes the pipe automatically.steveL wrote:I didn't know about anonymous pipes.
My bash --version gives "3.1.16(1)-release (i686-pc-linux-gnu)", from which I conclude your bash should be good enough.steveL wrote:I am running bash-3.1_p17; while I don't know if this is old
Perhaps it might be easiest to run a few tests manually before going into details how my script works.steveL wrote:Is there anything else that could cause this?
Code: Select all
cat <( echo hello )The idea is very simple: emerge -avuDN world is intended to bring the system up-to-date, including any build tools.steveL wrote:On the second point, how does the emerge world guarantee a consistent toolchain; surely that's the point of the whole recompile everything metaphor?
That's OK, the script and the guide have different version numbers. I am referring always to the guide version.steveL wrote:Also (minor point) the version given in the generated script is "1.13".
Yes it does.Guenther Brunthaler wrote: My bash --version gives "3.1.16(1)-release (i686-pc-linux-gnu)", from which I conclude your bash should be good enough.
..
Perhaps it might be easiest to run a few tests manually before going into details how my script works.
First, let's check whether process substitution runs at all in your environment. Try this:
This should just print "hello". Note that there must not be a space between the "<" and the "(".Code: Select all
cat <( echo hello )
Ok, no biggy... the script and the guide have different version numbers. I am referring always to the guide version.
So far, the guide has been much more often updated than the script, and I'm incrementing the version number on each change for both of them independently.
But I realize this might be a cause for confusion; perhaps I'll change this in the future.
Understood. Thanks for responding!BTW: I'm going offline now (it's midnight where I live), so I'm not going to answer any more postings before tomorrow.

OK, so input redirection works. Now let's check output redirection.steveL wrote:Yes it does.
Code: Select all
#! /bin/bash
exec > >(
echo "starting output"
while read LINE; do
echo "OUTPUT: $LINE"
done
echo "stopping output"
)
echo "Hello, world!"
echo "Hello, universe!"
Code: Select all
starting output
OUTPUT: Hello, world!
OUTPUT: Hello, universe!
stopping output

I think now it must have something to do with you bash's settings.steveL wrote:Guess we've found the problem (and it's not your script.) Just wish I knew what the sol'n was!