Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A bash script to update only one categorie
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
tuXXX
n00b
n00b


Joined: 01 Apr 2005
Posts: 32
Location: France/Brest

PostPosted: Sat Apr 02, 2005 12:24 am    Post subject: A bash script to update only one categorie Reply with quote

This is a bash script that allow the upgrade of only one categorie (like media-video, sys-dev, but also "sys-*" for example :wink: )
The comments/outputs are yet in french, but the code is so small that it is easy to translate if someone wanted it...

licence is GNU GPLv2

UpdCateg.sh :
Code:
#!/bin/bash

#
# UpdCateg
# Lists packages that have to be updated in a category
# For Gentoo@PC INpact
#
# By tuXXX and Duke98
# http://www.pcinpact.com/forum/rubrique_20.htm
# Released under GNU-GPL v2
#

function packageName
{
  LIST=`echo $1 | tr '-' ' '`
  OUT=""
  for i in $LIST
  do
     if [ `echo $i | cut -c 1 | tr -d '[:digit:]'` ]
     then OUT="$OUT-$i"
     else break
     fi
  done
  echo $OUT | cut -c 2-
}

if [ "$1" ]
then echo -n "";
else
  echo "Usage : $0 categorie"
  echo ""
  echo "categorie examples :"
  echo "    media-plugins"
  echo "    \"sys-*\""
  exit 0
fi

cat=`echo $1 | awk -F "/" '{print $1}'`
if ! ls -d /var/db/pkg/$cat 1>/dev/null 2>/dev/null
then
  echo "Erreur : mauvaise catégorie !" 1>&2
  exit 1
fi

PACKAGES=`emerge -puD world | cut -c 16- | grep $1 | awk {'print $1'}`
if [ ! "$PACKAGES" ]
then
  echo "Rien a mettre à jour" 1>&2
  exit 2
fi

EMERGE_LIST=""
for pack in $PACKAGES
do
  EMERGE_LIST="$EMERGE_LIST "`packageName $pack`
done

echo $EMERGE_LIST


A sample use is like this :
Quote:
$ emerge `UpdCateg.sh sys-apps`
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software 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