Une place pour une véritable innovation. Partagez vos propres utilitaires créés avec la communauté Manjaro.
Questions et discussions sur la programmation et le codage.
Répondre

pacman-history

#1Messageil y a 8 ans

le script bash du dimanche :
retrouver l'historique d'un logiciel / paquet dans les logs de pacman

usage avec fichier:

pacman-history -o journalctl
-- systemd --  system and service manager
[2015-01-29 21:41]  installation de systemd (218-1)
[2015-02-17 06:55]  maj de systemd (218-1 -> 218-2)
[2015-04-19 21:03]  maj de systemd (218-2 -> 219-5)
[2015-04-24 00:53]  maj de systemd (219-5 -> 219-6)

pacman-history -o firefox-developer
-- firefox-developer-fr --  Standalone web browser from mozilla.org, developer build - French
[2015-01-29 07:27]  installation de firefox-developer-fr (37.0a2-1)
[2015-02-26 06:45]  maj de firefox-developer-fr (37.0a2-1 -> 38.0a2-1)
[2015-04-02 20:34]  maj de firefox-developer-fr (38.0a2-1 -> 39.0a2-1)
[2015-05-12 22:58]  maj de firefox-developer-fr (39.0a2-1 -> 40.0a2-1)

avec paquet

pacman-history linux        
[2015-01-29 21:41]  installation de linux (3.18.4-1)
[2015-02-02 08:16]  maj de linux (3.18.4-1 -> 3.18.5-1)
[2015-02-08 21:06]  maj de linux (3.18.5-1 -> 3.18.6-1)
[2015-03-23 23:28]  maj de linux (3.18.6-1 -> 3.19.2-1)
[2015-04-11 07:27]  maj de linux (3.19.2-1 -> 3.19.3-3)
[2015-05-01 07:09]  maj de linux (3.19.3-3 -> 4.0.1-1)
[2015-05-13 22:49]  maj de linux (4.0.1-1 -> 4.0.2-1)
[2015-05-17 23:12]  maj de linux (4.0.2-1 -> 4.0.3-1)



fichier pacman-history :

#!/usr/bin/env bash
#historique dans pacman
#grep "\[ALPM\]" /var/log/pacman.log | grep -i "kate"

function usage(){
   echo "pacman-history [-o] fichier"
   echo -e "\tfichier : paquet"   
   echo -e "\t-o fichier : fichier contenu dans un paquet"
   echo -e "equivalent: grep \"\[ALPM\]\" /var/log/pacman.log | grep -i \"kate\""
}

function get_paquet(){
   local fichier=$1
   local ret=$(pacman -Qoq $fichier 2>/dev/null)
   if [[ "$?" -ne 0 ]]; then
      echo ""
   else
      echo "$ret"
   fi
}

function run(){
   local paquage=$1
   #echo "-- grep \"\[ALPM\]\" /var/log/pacman.log | grep -i \"$paquage\""
    ret=$(grep "\[ALPM\]" /var/log/pacman.log | grep -i " $paquage ")
    ret=${ret//\[ALPM\]/}
                ret=${ret//upgraded /maj de }
              ret=${ret//installed /installation de }
    echo -e "$ret"
   #echo -e ${ret//\[/\/n\[}
}

if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
   usage
   exit 0
fi

if [ "$1" == '-o' ]; then
   paquage=$(get_paquet "$2")
   echo -ne "-- \033[0m\033[1;37m$paquage\033[0m -- \033[0m\033[1;37m"
   #ret=$(pacman -Qi "$paquage" | grep Description | awk -F':' '{print $2}') # version fr uniquement
   ret=$(pacman -Qi "$paquage" | head -n 3 | tail -n -1 | awk -F':' '{print $2}')
   echo -e "$ret\033[0m"
else
   paquage="$1"
fi

if [ "$paquage" == '' ]; then
   echo "Erreur : paramètre de recherche "$paquage" invalide" >&2
   usage
   exit 127
fi

run $paquage

exit 0


Je suis passé à l'étape suivante: mettre à disposition dans AUR

yaourt pacman-history

pacman-history

#2Messageil y a 8 ans

Merci, je prend. :bien
Répondre