Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo Linux Update Script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
FelixPetzold
n00b
n00b


Joined: 10 May 2010
Posts: 24
Location: Paderborn/Germany

PostPosted: Mon May 10, 2010 3:57 pm    Post subject: Gentoo Linux Update Script Reply with quote

I have updated my script to version 2.1. It comes with an installer/updater now. It uses >=portage-2.2_rc67 and needs this for installation. But this dependency will be managed by the installer using autounmask.
Original documentation under: http://www.felixpetzold.de/Gentoo/update/GentooLinuxUpdateScript.html

What has changed?
A run without emerges is now only 8 minutes. Before it was 40 (on my Acer Aspire 7738G). This is achieved by outsourcing functions and executing them not so often. The "gentoo_ebuild_update_check_by_maggu2810" is now executed once a week and "gentoo-decruft" by bell is executed once a month.

New is, that there is a program version watcher that reacts on updates for Firefox, Thunderbird and xorg-server. If Firefox (or Firefox-bin) is updated, adobe-flash, swfdec and swfdec-mozilla will be reinstalled. If Thunderbird (or Thunderbird-bin) is updated, "emerge -1 enigmail" is executed. And if xorg-server is updated, "emerge -1 $(qlist -I -C x11-drivers/)" will be executed. If one or many watched programs are not installed on your system, this will be recognized and nothing is done for them, as you can see in the sample down at the end. I have no Thunderbird installed and watching Thunderbird is skipped on my system.

Explanation what is done:
update_sources - This function updates layman, portage und eix
get_old_versions - save versions of watched programs
update_system - update the system. If there is an error "emerge --resume --skipfirst" will be executed until there is nothing to do any more
get_new_versions - save new versions of watched programs
react_on_version_differences - if updated do what described above
emerge_depclean - executes "emerge --depclean"
lafilefixer_fixit - executes lafilefixer
preserved_rebuild - executes "emerge @preserved-rebuild"
pearl_cleaner - executes pearl cleaner
check_broken_librarys - executes "revdep-rebuild"
cfg_update - "cfg-update -ua" updates all configs marked automatic (-a) so you only have to deal with the rest
clean_system - executes "eclean packages" and "eclean distfiles"
exit_update - if there was an error a notice to the user will be given

Also will be installed:

"gentoo-decruft" by bell can be executed from the shell and will be executed by a cron job every month. Duration: ~1h
"gentoo_ebuild_update_check_by_maggu2810" can also be executed from the shell and is executed by a jron job weekly
"updateScriptVersionChecker" is my installer / updater and will be executed by a cron job weekly but can be run from the shell as well


Installation:
Things you already have installed / configured on your system can be skipped

local overlay:
A local overlay is used to add software to the portage tree.

Code:
mkdir -p /usr/local/portage/overlay # path to your local overlay
mkdir -p /usr/local/portage/overlay/profiles/ # profiles folder in your local overlay
echo "local overlay" >> /usr/local/portage/overlay/profiles/repo_name # give your local overlay the name "local overlay"
chown -R portage:portage /usr/local/portage/overlay # this is how it should be ;-)


Now you have a local overlay with the name "local overlay". If you want portage to use it, you have to set this up in /etc/make.conf

Code:
echo "PORTDIR_OVERLAY=\"/usr/local/portage/overlay\"" >> /etc/make.conf


Now you have your local overlay configured. It may be empty, but portage and my installer will use the path configured in /etc/make.conf to find it. This local overlay is where the source code of the script will be after you have run the installer. There you can take it and configure it to your needs.


elogv and portage elog messages:
elogv is a tool used to read elog messages saved by portage if you configured portage this way. We will do that now. Elog messages are the outputs running through the shell when you emerge something. And there is a lot running through what we do not want to read. We will set up a filter so make portage save all messages with the status "warn" and "error". Status "error" means that there was an error when building a package and the message will contain what you need to know about that. Status "warn" means that there is something that a package wants you to do after is was installed. A typical warning comes from xorg-server:

Quote:
* You must rebuild all drivers if upgrading from xorg-server 1.X
* or earlier, because the ABI changed. If you cannot start X because
* of module version mismatch errors, this is your problem.

* You can generate a list of all installed packages in the x11-drivers
* category using this command:
* emerge portage-utils; qlist -I -C x11-drivers/


If you don't follow this you will wake up without keyboard and mouse after reboot. And for that reason we want portage to make this message available to us. OK, in this case a bad example because my script watches for updates on xorg-server and does this for you, but there is a lot of programs that need things to be done after updating them.

OK, let set it up:
Code:
# install elogv
emerge -av elogv
# tell portage what to show (log,info,warn,error) and what to save (warn,error)
echo "PORTAGE_ELOG_CLASSES=\"log warn error info qa\"
PORTAGE_ELOG_SYSTEM=\"echo:log,info,warn,error  save:warn,error\"" >> /etc/make.conf 



There are a few configuration examples if you don't want to use what I recommended. This is how it has to look like in /etc/make.conf
Code:
Example 1 (only warn and error will be saved) (what we set up in my example)
PORTAGE_ELOG_CLASSES="log warn error info qa"
PORTAGE_ELOG_SYSTEM="echo:log,info,warn,error  save:warn,error"

Example 2 (+info messages)
PORTAGE_ELOG_CLASSES="log warn error info qa"
PORTAGE_ELOG_SYSTEM="echo:log,info,warn,error save:info,warn,error"

Example 3 (from elogv documentation)
PORTAGE_ELOG_SYSTEM="save"
and at least one out of
PORTAGE_ELOG_CLASSES="warn error info log qa"


OK, elogv is installed now and from now on portage is saving elog messages when something is emerged. If there is now message after you emerged something (or after my script has run) don't worry, everything is OK. There were only emerges that do not need to be taken care of after installation.

To start elogv you have to be root or in the group portage (gpasswd -a ${user} portage). Now type "elogv".

If there are messages you can do the following:

  • You can jump between messages with the arrow keys up and down
  • You can scroll inside messages with the space key
  • You can delete a message by hitting the key d twice "(dd")
  • You can close elogv with "q" but it closes itself when you deleted the last message



layman
Layman is a tool to add remote overlays into your portage tree. Here (http://gpo.zugaina.org/) you can search what overlays are available and what kind of packages is inside them.

Code:
echo "app-portage/layman git subversion
dev-util/subversion -dso" >> /etc/portage/package.use
emerge -av layman


Now you have to look into /etc/layman/layman.cfg to make sure you have a source configured following the new rules. It has to be "storage : /var/lib/layman" !!!
Code:
nano -w /etc/layman/layman.cfg

Now you can sync layman with "layman -S", see the overlays available with "layman -L", see what you added with "layman -l", add something with "layman -a foo" and see more with "layman --help"

Now you have to sync layman, add an overlay so layman creates a make.conf in his directory, delete the overlay again as we don't need it and make layman's make.conf available in /etc/make.conf
Code:
layman -S
layman -a maggu2810-overlay
layman -d maggu2810-overlay
echo "source /var/lib/layman/make.conf" >> /etc/make.conf


cfg-update
cfg-update is the tool I use to update all config files marked automatic by portage. With "cfg-update -ua" (update automatic) I make sure that you only have to deal with config files where you changed something when you run "etc-update or "dispatch-conf" or cfg-update -u" after my script finished. cfg-update needs a diff tool. Gnome users like me become dev-util/meld installed with cfg-update because of their USE-Flag gnome. Others have to install and setup something else from the list.

Code:
emerge -av cfg-update
nano -w /etc/cfg-update.conf


As I told you, I have meld configured as MERGE_TOOL in /etc/cfg-update.conf. Here you can see what else you can install and configure. But you have to configure one! If you start cfg-update without parameter "cfg-update" it shows you the help.
Quote:
# +----------+
# | MERGETOOL \
# +------------+-------------------------------------------------------------+
# | The recommended tool for merging is xxdiff but you can also use other |
# | tools if you don't like xxdiff. The Supported tools are listed below: |
# +----------+-----+--------------------------+------------------------------+
# | xxdiff | GUI | KDE (or Gnome with QT) | |
# | kdiff3 | GUI | KDE (or Gnome with QT) | |
# | meld | GUI | Gnome (or KDE with GTK) | |
# | gtkdiff | GUI | Gnome (or KDE with GTK) | STAGE 3 not supported! |
# | gvimdiff | GUI | Gnome (or KDE with GTK) | STAGE 3 not supported! |
# | tkdiff | GUI | Gnome (or KDE with TK) | |
# | vimdiff | CLI | Systems without X | STAGE 3 not supported! |
# | sdiff | CLI | Systems without X | STAGE 3 not supported! |
# | imediff2 | CLI | Systems without X | STAGE 3 not supported! |
# +----------+-----+--------------------------+------------------------------+
MERGE_TOOL = /usr/bin/meld



OK, everything is set up now. What you have to do after my script ran will be described later.
Code:
BitKiller ~ # emerge -pv update

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] app-admin/update-2.1_rc3  USE="X daily -weekly" 0 kB [1]

Total: 1 package (1 reinstall), Size of downloads: 0 kB
Portage tree and overlays:
[0] /usr/portage
[1] /overlay
BitKiller ~ #


As you can see there is 3 USE-Flags. The USE-Flag X is managed by your profile and is meant to disable the dependency x11-misc/xdialog and its functionality so systems without graphical user interface can use this script as well.

Interesting for you are the USE-Flags "daily" and "weekly". I recomend and use "daily". OK, what happens, when you chose daily or weekly?

daily:

  • the update script will be executed daily
  • the ebuild check will be executed weekly
  • gentoo-cruft will be executed monthly
  • the update check will be executed weekly


weekly:

  • gentoo-cruft will be executed monthly (as before)
  • the update check will be executed weekly (as before)
  • the update script will be executed weekly
  • the ebuild check will be executed monthly


I recomend setting up:
Code:
echo "app-admin/update daily" >> /etc/portage/package.use


My install script finds your local overlay be looking into /etc/make.conf. Therefore you can start the installer where ever you want. It created app-admin/update inside your local overlay, changes into this directoy, get latest-version.txt from my website, downloads latest version of app-admin/update, decompresses it, creates the manifest for you, installs autounmask, unmasks all dependencies for app-admin/update and installs app-admin/update.

Code:
wget http://www.felixpetzold.de/Gentoo/update/InstallUpdateScript
chmod +x InstallUpdateScript
./InstallUpdateScript
rm InstallUpdateScript


Now you have to set up your user name in /etc/conf.d/update
Code:
nano -w /etc/conf.d/update


Quote:
USER_NAME="felix

This is the user that gets a message on his Desktop when there was an error. I know that elogv is doing the same and will make the config file optional soon.

Now everything is installed. When root you can execute now the following commands

  • update - The update script that will be executed by cron daily
  • updateScriptVersionChecker - the update script that is executed weeky
  • gentoo_ebuild_update_check_by_maggu2810 - the ebuild check maggu2810 wrote, will be executed once a week
  • gentoo-decruft - the decruft script bell wrote, will be executed every month


How does it work with cron and automatic and so on? Is there nothing I have to do?

  • When you (or cron) run the script it will be finished some time. Nice, everything updated. But there is a few programs that need special treatment when being updated. They write that in elog messages when the are emerged and portage is saving them for you. So first thing you execute after my script is "elogv" and follow the messages. If there is no message, fine.
  • Second thing you have to do is updating you config files. You can use "cfg-update -u" or "dispatch-conf" or "etc-update" to do this.


And that is it. You only have to run 2 commands (elogv + cfg-update -u) after my script finished!

Sample run:
Code:
Update-Script v2.1 for Gentoo Linux by Felix Petzold
----------------------------------------------------
Syncing Portage, Eix & Layman.
Finished

Saving installed version-nr of firefox, thunderbird and xorg-server
Found www-client/firefox-3.6.8-r1
Found x11-base/xorg-server-1.8.2
Finished

Updating System.
Finished

Getting new version-nr of firefox, thunderbird and xorg-server
Found www-client/firefox-3.6.8-r1
Found x11-base/xorg-server-1.8.2
Finished

Checking version differences to react on updates
Finished

Running emerge --depclean.
Finished

Running lafilefixer --justfixit
Finished.

Running emerge @preserved-rebuild.
Finished

Running perl-cleaner --all
Finished.

Running revdep-rebuild.
Finished

Running cfg-update -ua
Finished

Running eclean packages.
Finished

Running eclean distfiles.
Finished

Exiting update script


Last edited by FelixPetzold on Mon Aug 30, 2010 11:39 am; edited 14 times in total
Back to top
View user's profile Send private message
XQYZ
Apprentice
Apprentice


Joined: 19 Jul 2009
Posts: 231
Location: Europe

PostPosted: Mon May 10, 2010 5:51 pm    Post subject: Re: Gentoo Linux Update Script Reply with quote

FelixPetzold wrote:
The USE-Flags GentooForum and GentooFreunde are not optional. You have to choose one of it. These USE-Flags manage the output ("Relesed for www.GentooForum.de" or "Released for www.GentooFreunde.org").


Ok, how is that important enough to a) be put on-screen every time and b) get two different USE Flags?
Back to top
View user's profile Send private message
FelixPetzold
n00b
n00b


Joined: 10 May 2010
Posts: 24
Location: Paderborn/Germany

PostPosted: Mon May 10, 2010 6:02 pm    Post subject: Reply with quote

If the script is run by cron, you don't see this. And of course, this is open source. Change it, if you don't like it, but please notify me about changes, maybe I like them 8)

edit:
This started as "I wanna learn something about Linux". Maybe you could strip some "features", but I think this script is worth being put here. It helped German beginners to read their elog messages, take care of their system on their own and learn. Problems like x11-drivers after an update on xorg-server can be found by following my tutorial above. And if the beginners remove my script and are now able to take care of their system on their own? Perfect. Never said, my script is the best.
Back to top
View user's profile Send private message
FelixPetzold
n00b
n00b


Joined: 10 May 2010
Posts: 24
Location: Paderborn/Germany

PostPosted: Wed May 12, 2010 1:58 am    Post subject: Re: Gentoo Linux Update Script Reply with quote

Updated the script because I use portage-2.2 now. This part was striped:

XQYZ wrote:
FelixPetzold wrote:
The USE-Flags GentooForum and GentooFreunde are not optional. You have to choose one of it. These USE-Flags manage the output ("Relesed for www.GentooForum.de" or "Released for www.GentooFreunde.org").


Ok, how is that important enough to a) be put on-screen every time and b) get two different USE Flags?
Back to top
View user's profile Send private message
FelixPetzold
n00b
n00b


Joined: 10 May 2010
Posts: 24
Location: Paderborn/Germany

PostPosted: Sun May 23, 2010 10:34 pm    Post subject: Reply with quote

Updated to 2.0-r2. Link to my homepage does not work today because of maintenance work. Use the other one
Back to top
View user's profile Send private message
Amity88
Apprentice
Apprentice


Joined: 03 Jul 2010
Posts: 260
Location: Third planet from the Sun

PostPosted: Tue Aug 10, 2010 3:17 pm    Post subject: Reply with quote

I made an attempt at automation too. check this out :)
_________________
Ant P. wrote:
The enterprise distros sell their binaries. Canonical sells their users.


Also... Be ignorant... Be happy! :)
Back to top
View user's profile Send private message
FelixPetzold
n00b
n00b


Joined: 10 May 2010
Posts: 24
Location: Paderborn/Germany

PostPosted: Sat Aug 28, 2010 2:05 pm    Post subject: Reply with quote

Updated it to version 2.1. If you liked it before, try it, you will love it. If you only wanna see the code, download the installer, open it in an editor and execute download part only.
Back to top
View user's profile Send private message
Marlo
Veteran
Veteran


Joined: 26 Jul 2003
Posts: 1591

PostPosted: Sat Mar 19, 2011 3:49 pm    Post subject: Reply with quote

Hello Felix,

many thanks for your Script. But it seems I did not understand your instructions.
I use Layman and for the first installation your UpdateScript oscillate between my two overlays
but not to the correct place in /usr/local/portage/overlay.

Thus I deinstall my layman/mozilla and layman/vmware and now your script works well. After the first
installation of UpdateScript I installed layman again and it seem to work.

thanks again
Ma
_________________
------------------------------------------------------------------
http://radio.garden/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum