tuXXX n00b
Joined: 01 Apr 2005 Posts: 32 Location: France/Brest
|
Posted: Sat Apr 02, 2005 12:24 am Post subject: A bash script to update only one categorie |
|
|
This is a bash script that allow the upgrade of only one categorie (like media-video, sys-dev, but also "sys-*" for example )
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` |
|
|