Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bash script for updating and mantaining gentoo install
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
InvisibleRasta
Tux's lil' helper
Tux's lil' helper


Joined: 30 Mar 2011
Posts: 112

PostPosted: Sat Nov 17, 2018 12:48 am    Post subject: Bash script for updating and mantaining gentoo install Reply with quote

Hello guys, i tend to forget the commands needed to mantain my system so i wrote a script for updating and such. I tought i could share it so you guys can use it to or perhaps give me some suggestions.

So here it is: :D

:arrow: https://gist.github.com/InvisibleRasta/fdb6607510a820628c693d8baad0f52c

A little description of what it does:
For each of these commands it will print a description of what they do.
You can press Yy or Enter for yes or Nn for no.
If you press no it will skip to the next option.
You can change the order of the commands if you would like. This is how i tend to run them.

eix-sync
revdep-rebuild -v
emerge -uDNqva @world
emerge -pac
etc-update
eclean-pkg
eclean-dist


EDIT: I also added a news read command at the end.
eslect news read
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 372
Location: France

PostPosted: Sun Nov 18, 2018 2:36 pm    Post subject: Reply with quote

Hello.

For my own I prefer command to be completed from history search, but I'll give you my 2 cents anyway.
What bothers me a little with your script is the necessity to pass the whole loop of Y/N, and where in the loop you placed the revdep-rebuild.
I would rather have each command wrapped in a function (sync -> eix-sync || exit $?) and loop through command line optionsusing[/list] a switch statement with each desired function mapped to an option, allowing command line options like 'sync update depclean', as well as any shortcut option you may want to define. For example, I would have:
- syncup: eix; update (I prefer dealing with etc-update first after an update, then no depclean in my shortcut)
- etc
- depclean
- revdep
- eclean: ecleanpkg; ecleandist
You may also add help and/or list options and functions as a self reminder.
Cherry on top of the cake, you avoid the use of eval command.

++
Gi)
Back to top
View user's profile Send private message
Dwosky
n00b
n00b


Joined: 07 Nov 2018
Posts: 55

PostPosted: Mon Nov 19, 2018 9:12 am    Post subject: Reply with quote

Hello,

First of all, thanks for sharing the script.

In my case I follow a different approach:
Code:
emerge --sync
emerge -avuDN world
emerge -Da --depclean
revdep-rebuild -i


Its been quite some time since I've checked it out, but from what I understand some time ago, isn't revdep better called last in order to check if the previous steps broke anything?
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 803

PostPosted: Mon Nov 19, 2018 1:29 pm    Post subject: Reply with quote

FWIW, my routine. I have a different way to effect the "ask" before proceeding.

First get a new portage tree. $(emerge --sync) hooks to eix via a small script /etc/portage/postsync.d/eix-update -- more on that later.

Code:
emerge --sync --quiet
emerge -p --update --deep --newuse --with-bdeps=y @world


At this point I am presented with news, reports of packages masked or to be masked b the maintainers, etc. In addition to reading the news, I may choose to adjust USE flags to modify what will be drawn in by a soon-to-come $(emerge --update), or in some cases, even add a mask myself to avoid an upgrade. I repeat the $(emerge -p --update --deep --newuse --with-bdeps=y @world) until it suits me. Repeated use of --pretend is my way of implementing "ask."

Now time to run the update. I use --quiet, all the building activity is logged anyway, in case of need to review.

Code:
emerge -q --update --deep --newuse --with-bdeps=y @world
emerge -q @preserved-rebuild
CLEAN_DELAY=0 emerge -q --depclean
revdep-rebuild --quiet --ignore


After this comes the $(etc-update), if necessary.

After that, I run $(lib_users) [from app-admin/lib_users] and restart services that are using updated programs or libraries.

As for keeping eix up to date ....

Code:
#!/bin/sh
# /etc/portage/postsync.d/eix-update

if [ -x /usr/bin/eix-update ] ; then
  printf " ** [/etc/portage/postsync.d/eix-update]\n ** Now running eix-update ...\n"
  cp -a /var/cache/eix/portage.eix /var/cache/eix/previous.eix
  NOSTATUSLINE=true eix-update -q
  printf " -------\n %(%c)T\n" -1
fi
:


The closing colon causes /etc/portage/postsync.d/eix-update to always return with an errorlevel of 0, even if /usr/bin/eix-update does not exist. Creating or keeping var/cache/eix/previous.eix facilitates the $(eix-diff) function. I use the output of eix-diff as an aid to maintain a list of packages that should be considered in conjunction with tripwire rule builder, mktwpol.

Edit to add - my method for pruning the distfiles directory is a monthly cronjob

Code:
#!/bin/sh
# report security notices
# check package management files for consistency
# clean Gentoo distribution directories

LINE="--------------------------------------------------------------------"
printf " \n[$0]\n\n"
printf " Run \`check-use\` to test for obsolete USE flags in package.use\n\n"

printf " glsa-check --nocolor --list --quiet\n"
printf " -----------------------------------\n\n"
glsa-check --nocolor --list --quiet

printf "\n"
printf " eix-test-obsolete brief\n"
printf " -----------------------\n\n"
eix-test-obsolete brief

for i in /public/distfiles /usr/portage/distfiles /home/portage/distfiles /home/portage/http-replicator; do
  [ -d $i ] && \
    {
    COMMAND="DISTDIR=$i/ eclean-dist --deep --nocolor"
    COMMANDLEN=${#COMMAND}
    printf "\n"
    printf " $COMMAND\n"
    printf " ${LINE:0:$COMMANDLEN}\n"
    DISTDIR=$i/ eclean-dist --deep --nocolor
    }
done

printf "\n"
printf " Running \`makewhatis -w\`\n"
printf " -----------------------\n"
makewhatis -w
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