updatoo is a bash script that performing a simple full (silent if you want) update in a Gentoo System.
By default updatoo will synchronize your portage tree with eix-sync, check if your system is update and for bad packages, create a pretend list of packages, try to install all the packages from the pretend list, clean up the system and run revdep-rebuild command.
If occur any problem updatoo will abort with code 1 so you can combine with && or || operator.
Everything is loged in /root/.updatoo/ where you can check anytime.
Please report any bug to ricardo.iramar@gmail.com or https://forums.gentoo.org/viewtopic-t-717092.html .

### Begin SubHelp ###
SubHelp()
{
echo "updatoo [ options ]
Options:
--help (-h) Print this help.
--ask (-a) Ask me to confirm each step.
--sync (-s) Synchronize the portage tree with eix-sync.
--prepare (-p) Don't emerge anything, only create the lists and check for bad packages.
--fetch (-f) Fetch the packages from the last list of the day in parallel.
--execute (-e) Don't create the lists, only update the system using the last lists of the day.
--clean (-c) Clean up the entire system.
--revdep (-r) Run revdep-rebuild command after all.
You can combine the options.
The default operation is the same that \"updatoo -spfecr\"."
}
### End SubHelp ###

The problem is if "emerge -uDNv @world" fail in the midle you can't continue. In my script every package(even deps) is installed even if the package before failed._________________Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.

The problem is if "emerge -uDNv @world" fail in the midle you can't continue. In my script every package(even deps) is installed even if the package before failed.

true... but there's also the fact that I can fix it the next day if there's a problem

simplicity is the way to go

That's the point. You will spent one day for each failed package. In my case in the end of the day I will know every failed package excluding rdeps of course. By the way I will include e-mail advise in my roadmap. _________________Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.

usually just updating packages may breaks things.
--buildpkgonly is my trick to prepare the packages for merging them later using emerge -K_________________Please stand by - The mailer daemon is busy burning your messages in hell...

usually just updating packages may breaks things.
--buildpkgonly is my trick to prepare the packages for merging them later using emerge -K

I'm not sure but I think the idea to create and install binary packages with emerge is to standardize which means you can install in a lot of machines and keep them up-to-date._________________Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.

NB: this works on POSIX sh too. (Bookmark that link if you value your time and that of your users. BASH is a lot more portable than sed -i at least as far as a shellscripter is concerned.)

Major shellscripting point (ie more important in the longer run) USE MORE QUOTES until you know when not to: in a nutshell foo=$bar is fine in bash and no quotes needed in [[ unless you're doing something you shouldn't. ;) Other than that, quote every parameter or variable expansion (or feel the wrath of greycat which is a terrible thing to behold..;p)

I've changed my script with your suggestions. Please take a look below the version 0.2.

OK first thing, this isn't Visual Basic. (Yes I used to code in it too, you're fine;) Every variable is a string. Even when you declare -i it. (That just means it can only ever be assigned a 64-bit integer.)
First place to check for anything is help, eg help declare or help test (you need to print that one out.)
Don't add Sub to the beginning of functions. You have complete control over what is and isn't in the script namespace. Just don't use the same name as a POSIX command (as in the link above) and if you want to be quick, use Kate as its syntax highlighting rocks (it has loads of standard Unix and Linux commands as well.)

Code:

StrVersion="v0.2"
declare -r version=0.2

StrHomeDir="$HOME/.updatoo"
declare -r homeDir=~/.updatoo # $HOME can be set in env. ~ can't afaik (it's in POSIX)
# Of course, sometimes you want the user to be able to override.
# A system update script isn't one of those times.

if [[ "$@" =~ ^-(f|-force)$ ]]
# If you want compatibility across bash 3 you need to use variables to hold regexen.
# This is _not_ the way to check parameters; I only do that in update for stuff I *have* to know before
# the main command processing function can be called.
# See: http://wooledge.org/mywiki/BashFAQ/035
ebegin "Starting in force mode"
# Again, no need to use " when you don't want any variable expansion.
StrForce="yes"
force=1

Thanks again steveL.
I know that every var is a string. The names of vars and functions its just for my control and turn the script more readable for the others n00bs like me. _________________Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.

The names of vars and functions its just for my control and turn the script more readable for the others n00bs like me. :D

I understand, but I'm trying to get you into good habits now, before it's too late ;) In your case, that means unlearning the VB habits you have so you can approach shell as a shellscripter would.

There's simply no need to indicate the type of a variable in its name, since they're all string. (Many people disagree with it even when you do have many types; I've used it in VB/A in the past but I prefer simple names nowadays. Maybe it's just age;) Remember that you have full control of all the variables in your script. You can use what's in the environment, or set your own values (and use defaults, alternatives etc) and make them read-only with declare -r or readonly (both builtin so accessible from help in terminal.) I recommend you read this as well: http://wooledge.org/mywiki/BashFAQ/073 wrt what you can do with variables.

WRT function naming, the whole point, in shellscript, is that they are used interchangeably with commands, and you can indeed 'decorate' an existing command (or make it nicer to use) by using a function with the same name. I recommend you do NOT do that in the general case, but it can be used, eg where the underlying implementation is not POSIX-compliant. It's better to be in the habit of knowing how the underlying commands work by using them as-is. This is the same argument against lots of custom aliases of an existing command: when you use another machine, in whatever context, you may well not have them available, but you will still be expected to get work done.

A much better reason for a function (apart from the standard coding ones of minimising code-duplication/maximising reuse) is to wrap a command (not using the same name as explained) to make it nicer to use. Here's a function which does just that, from update:

ed reads its commands from standard input, separated by newlines; the -s tells it to run in script mode. To get proper error messages (as opposed to a simple ?) we issue it the H command.
In console I might do:

Code:

printf '%s\n' H 'g/foo/s/bar/baz/g' w | ed -s someFile

Typing this same stuff over and over gets tiresome (even with alias print="printf '%s\n'" which I love to bits ;) and doesn't look nice in a script. By using the function (which stands for 'easy ed') in the script (it's in my bashrc as well;) the code is much more just about the stuff I'm interested in; eg to display the libErrCheck code to the user (update -h error), I use:

Code:

eed /sbin/update '/^# libErrCheck/;/^}/p'

I like having the filename upfront, and then being able to type in whatever I want; it's more natural and easier to maintain. The only thing I'm reading is stuff that's relevant to what I'm doing; the stuff I might want to edit.

I could use ed -s file <<< "blah" but it's BASH specific and the escaping required is very annoying; we already have to escape regexen. You can find 'eed' by searching for it as a (case-sensitive) 'whole word' in Kate; you'll see it's used more via another wrapper in update,eg deleteSearch or edit. The first is so I can escape a search term once and then reuse it, the second is for more convenience.

What I'm getting at, in my rambling manner, is that you need to get into the headspace of shellscripting, which will only happen after you've let go of VB. Other people starting out, who haven't coded anything but have used the terminal a lot (which practically any Gentoo user has) are actually in a better position, in that they're in that headspace already. (OFC they then need to learn the basics of coding..;)

Now you can help me to improve updatoo or download via svn.
Please take a look at http://code.google.com/p/updatoo/._________________Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.