Si vous avez testé archlinux, vous avez sans doute apprécié ce programme, qui simplifie la ligne de commande. Voici quelque chose qui y ressemble. J'espère qu'il vous plaira. Ce qui serait super, c'est que chacun contribue un peu à l'améliorer
!
#!/bin/sh
#
#// Petit script simplifiant l'utilisation d'apt
#// à la façon de yaourt pour pacman dans archlinux
#// yapt.sh
#//
#// Copyright 2010 xavier <arrakispice@gmail.com>
#//
#// This program is free software; you can redistribute it and/or modify
#// it under the terms of the GNU General Public License as published by
#// the Free Software Foundation; either version 2 of the License, or
#// (at your option) any later version.
#//
#// This program is distributed in the hope that it will be useful,
#// but WITHOUT ANY WARRANTY; without even the implied warranty of
#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#// GNU General Public License for more details.
#//
#// You should have received a copy of the GNU General Public License
#// along with this program; if not, write to the Free Software
#// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#// MA 02110-1301, USA.
LIST=/tmp/yapt-get_research
ROUGE="\033[31m"
VERT="\033[0;33;32m"
NORMAL="\033[1;0m"
CYAN="\033[0;33;36m"
usage_ () {
echo "Usage :"
echo " yapt-get <nom du paquet> <nom d'un autre paquet> <...>"
echo " yapt-get -update : mise à jour de la base de données"
echo " yapt-get -upgrade : mise à jour du système "
echo " yapt-get -source <nom du/des paquets> : téléchargement des sources"
}
install_ () {
for i in $@; do
PACKAGE=$(sed -n ${i}p $LIST | awk '{print $1}')
echo " *** Installation de "$ROUGE" $PACKAGE "$NORMAL" *** \n "
su --shell=/bin/bash --command "apt-get install $PACKAGE"
done
}
searching_ () {
echo "Choix\tNom - Description (séparer par des espaces)"
echo "--------------------------------------------------------------"
apt-cache search $1 > $LIST
sed = $LIST | sed 'N;s/\n/\t/' | awk -F"\t" '{print "'$VERT'"$1 "\t" "'$CYAN'"$2"'$NORMAL'"}'
read CHOICE
install_ $CHOICE
}
#Pour commencer, on regarde le nombre d'arguments entrés. Ensuite \
#on effectue la recherche pour chacuns d'eux.
if [ "$#" = 0 ]; then
usage_
fi
case $1 in
"-update" )
su --shell=/bin/bash --command "apt-get update"
;;
"-upgrade" )
su --shell=/bin/bash --command "apt-get upgrade"
;;
"-source" )
apt-get source $(echo $@ | cut -d" " -f2-)
;;
* )
for i in $@; do
searching_ $i
done
esac
exit 0