diff options
author | papajoker | 2015-10-04 20:13:14 +0200 |
---|---|---|
committer | papajoker | 2015-10-04 20:13:14 +0200 |
commit | b8740bf721468dc0fa803bb3824f4e0dbc271389 (patch) | |
tree | 7bbebd1975925537167577bbaad9230768c7843f | |
parent | 3e13c4d7e7c43df835347b2f649d11d2e29ebec8 (diff) | |
download | aur-b8740bf721468dc0fa803bb3824f4e0dbc271389.tar.gz |
plugins
-rw-r--r-- | .SRCINFO | 9 | ||||
-rw-r--r-- | PKGBUILD | 10 | ||||
-rwxr-xr-x | pacman-diffs | 205 |
3 files changed, 12 insertions, 212 deletions
@@ -1,7 +1,8 @@ pkgbase = pacman-diffs - pkgdesc = finding .pacnew files and compare, and archive + pkgdesc = finding .pacnew files, compare and archive pkgver = 1.1.0 - pkgrel = 2 + pkgrel = 4 + url = https://github.com/papajoker/pacman-diffs arch = any license = GPL depends = findutils @@ -9,8 +10,8 @@ pkgbase = pacman-diffs optdepends = diffuse: graphical editor[community] optdepends = kompare: kde editor [extra] optdepends = gksu: gnome gui for su - optdepends = kdesu: kde gui for su - source = pacman-diffs + optdepends = kde-cli-tools: kde gui for su + source = pacman-diffs::git+http://github.com/papajoker/pacman-diffs#branch=master md5sums = SKIP pkgname = pacman-diffs @@ -1,8 +1,9 @@ # Maintainer: Papajoker <papajoker [at] archlinux [dot] info> pkgname=pacman-diffs pkgver=1.1.0 -pkgrel=2 -pkgdesc="finding .pacnew files and compare, and archive" +pkgrel=4 +url=(https://github.com/papajoker/pacman-diffs) +pkgdesc="finding .pacnew files, compare and archive" arch=('any') license=('GPL') depends=('findutils' 'diffutils') @@ -10,10 +11,13 @@ optdepends=('diffuse: graphical editor[community]' 'kompare: kde editor [extra]' 'gksu: gnome gui for su' 'kde-cli-tools: kde gui for su') -source=("pacman-diffs") +source=("$pkgname::git+http://github.com/papajoker/$pkgname#branch=master") md5sums=('SKIP') package() { + cd "$srcdir/$pkgname" install -Dm755 ./${pkgname} ${pkgdir}/usr/bin/${pkgname} install -dm755 ${pkgdir}/var/cache/pacman/pacnew/ + install -Dm644 ./${pkgname}.fr ${pkgdir}/usr/share/locale/fr/LC_MESSAGES/${pkgname} + install -Dm644 ./${pkgname}.plugins ${pkgdir}/etc/${pkgname}.plugins } diff --git a/pacman-diffs b/pacman-diffs deleted file mode 100755 index e6dbb614cec8..000000000000 --- a/pacman-diffs +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env bash -# finding .pacnew files and compare -# v1.1.0 - - -AGE=360 # ne rechercher que ceux qui ont moins de 360 jours -EXT='pacnew' -ARCCHIVEDIR='/var/cache/pacman/pacnew' - -c_red='\033[0m\033[31m' -c_green='\033[0m\033[32m' -c_yellow='\033[0m\033[33m' -c_end='\033[0m' -bold='\033[1m' - -## default string constants {{{ - declare -A txt=( - ['label']='differences of' - ['error']='Error' - ['notfound']='file not found' - ['root']='This script must be run as root' - ['files']='files' - ['noarchive']='not in archives' - ['erase']='You can erase this file' - ['archiver']='archive in' - ) -lg=$(locale 2>/dev/null | awk -F'=' '/^LANG/ {print $2}') -if [ 'fr' == "${lg:0:2}" ]; then - declare -A txt=( - ['label']='les différences de' - ['error']='Erreur' - ['notfound']="fichier n'existe pas" - ['root']='Vous devez avoir des droits administrateur' - ['files']='fichiers' - ['noarchive']='non archivés' - ['erase']='Vous pouvez supprimer ce fichier' - ['archiver']='archivé dans' - ) -fi -#}}} - -function error() -{ - echo -e "\033[41m${txt[error]}:\033[0m $1" >&2 -} -function test_sudo() { - if [[ $EUID -ne 0 ]]; then - error "${txt[root]}" - exit 1 - fi -} - -function get_su(){ - local mysu='' - if [ -f '/usr/bin/kdesu' ]; then - mysu='kdesu' - else - [ -f '/usr/bin/gksu' ] && mysu='gksu' - fi - echo -n "$mysu" -} - -function get_editor(){ - local ed='' - if [ -f '/usr/bin/diffuse' ]; then - ed='/usr/bin/diffuse' - else - [ -f '/usr/bin/kompare' ] && ed='/usr/bin/kompare' - fi - echo "$ed" -} - -function archive() -{ - test_sudo - local file="$1" - local name="$2" - file=$ARCCHIVEDIR${file/$name.$EXT/$(stat -c "%Y" "$1")-$name.$EXT} - install -D "$1" "$file" - echo "-- ${txt[archiver]} $file" - file=$(dirname $file) - # want only 2 last files - nb=$(ls $file/*$name.$EXT | wc -l) - if [ "$nb" -gt 2 ]; then - ls -v $file/*$name.$EXT | head -$(($nb-2)) | xargs rm - fi -} -function in_archive(){ - local file="$1" - local name="$2" - file=$ARCCHIVEDIR${file/$name.$EXT/*-$name.$EXT} - nb=$(ls $file | wc -l) - if [ "$nb" -gt "1" ]; then - echo $(ls -v $file) - else - return 1 - fi -} - -function make_diff() -#TODO : test permission et faire sudo si besoin ou test_sudo() ? -{ - local file1="$1" - local file2="$2" - local original="$3" - if [[ $(diff $file1 $file2|wc -l) -eq 0 ]]; then - # can remove etc/pacnew - echo -e "-- ${c_yellow}${txt[erase]}${c_end} : sudo rm $original" - else - IFS=$'\n' - # < : removed > : added - diff $file1 $file2| grep -E "^>|^<" | while read line ; do - if [ "${line::1}" = '<' ]; then c="$c_red-"; else c="$c_green+"; fi - echo -e "$c ${line:2}$c_end" - done - fi -} - -function history_pacman() -{ - local history="$1" - if [ "$history" -gt "0" ]; then - grep "pacnew$" /var/log/pacman.log | sed -e "s/\[ALPM\] warning: //" - else - grep "pacnew$" /var/log/pacman.log| awk '{print $8}' | sort | uniq - fi -} - -function usage() -{ - echo "usage: pacman-diffs [options]" - echo -e "\t -x extension (pacnew, pacsave...)" - echo -e "\t -d since x days" - echo -e "\t -l : list only - no diff" - echo -e "\t -e filename : edit files" - echo -e "\t -a archive pacnew in /var/cache/pacman/pacnew/" - echo -e "\t -c compare archives" - echo -e "\t -i pacman history" - echo -e "\t -j pacman history files" - exit -} - -############## RUN ############## - -while getopts "hd:x:le:acij" flags; do - case $flags in - h) usage;exit 0 ;; - d) AGE="${OPTARG}" ;; - x) EXT="${OPTARG}" ;; - l) listing=1 ;; - e) edit="${OPTARG}"; listing=1 ;; - a) archive=1; listing=1 ;; - c) archive=1; archivediff=1 ;; - i) history_pacman 1; exit ;; - j) history_pacman 0; exit ;; - :) error "Vous avez oublié un argument"; exit 1 ;; - ?) error "invalid Option"; exit 1 ;; - *) error "*"; exit 1 ;; - esac -done - -find '/etc' -name "*.$EXT" -mtime -$AGE -type f 2> /dev/null | while read file ; do - - fname=$(basename "$file") - fname="${fname%.$EXT}" - ofile="$(dirname ${file})/${fname}" - dfile=$(stat -c "%y" ${file} | awk '{print $1}') - echo -e "\n$bold${fname}$c_end\n-- ${txt[label]} $file\t(${dfile})" - - if [[ -f "$ofile" ]]; then - - if [[ $archive -eq 1 ]]; then - # cp in /var/cache/pacman/pacnew/ - archive ${file} ${fname} - fi - - - if [[ $listing -ne 1 ]]; then - - if [[ $archivediff -eq 1 ]]; then - files=$(in_archive ${file} ${fname}) - if [ "$?" -ne "1" ]; then - make_diff ${files} ${file} - continue - else - echo "2 ${txt[files]} \"${fname}\" ${txt[noarchive]}" - continue - fi - fi - - make_diff ${ofile} ${file} ${file} - fi - - if [ "$edit" == "$fname" ]; then - cmd="$(get_su) $(get_editor) $ofile $file &" - $cmd - fi - - else - echo -e "\t$bold ${txt[error]}:$c_end ${txt[notfound]} ? $ofile" - fi - -done - -exit 0
\ No newline at end of file |