cookutils diff cooker @ rev 965
Tiny edits
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Fri Sep 01 19:57:10 2017 +0100 (2017-09-01) |
parents | 48b237fbb760 |
children | 9c835beabf65 |
line diff
1.1 --- a/cooker Thu Jul 20 05:07:33 2017 +0300 1.2 +++ b/cooker Fri Sep 01 19:57:10 2017 +0100 1.3 @@ -44,6 +44,7 @@ 1.4 -a | all Find and cook all unbuilt packages. 1.5 -T | tasks List existing cooker tasks. 1.6 -t | task <task> Executing specified task. 1.7 + -o | outgoing Find changes in wok that we can move to wok-hg. 1.8 1.9 EOT 1.10 exit 0 1.11 @@ -303,6 +304,59 @@ 1.12 } 1.13 1.14 1.15 +# Compare wok and wok-hg file $1, display signs: 1.16 +# '+' file added, '-' file removed, '~' file changed, '=' file not changed 1.17 + 1.18 +compare_wok_file() { 1.19 + local f1='n' f2='n' # n: not exists, e: exists 1.20 + [ -e "$wok/$1" ] && f1='e' 1.21 + [ -e "$wok-hg/$1" ] && f2='e' 1.22 + case "$f1$f2" in 1.23 + en) echo "+ $1";; 1.24 + ne) [ -n "$del" ] && echo "- $1";; 1.25 + ee) 1.26 + if cmp -s "$wok/$1" "$wok-hg/$1"; then 1.27 + [ -n "$eq" ] && echo "= $1" 1.28 + else 1.29 + echo "~ $1" 1.30 + fi 1.31 + ;; 1.32 + esac 1.33 +} 1.34 + 1.35 + 1.36 +# Compare wok and wok-hg folder $1; process only: 1.37 +# receipt, description.*txt, all files in the stuff folder 1.38 + 1.39 +compare_wok_folder() { 1.40 + IFS=$'\n' 1.41 + { 1.42 + for i in $wok $wok-hg; do 1.43 + ls $i/$1/receipt 2>/dev/null 1.44 + ls $i/$1/description.*txt 2>/dev/null 1.45 + [ -d $i/$1/stuff ] && find $i/$1/stuff -type f 1.46 + done 1.47 + } | sed "s|$wok/$1/||; s|$wok-hg/$1/||" | sort -u | \ 1.48 + while read file; do 1.49 + compare_wok_file "$1/$file" 1.50 + done 1.51 +} 1.52 + 1.53 + 1.54 +# Compare entire wok 1.55 + 1.56 +compare_wok() { 1.57 + { 1.58 + cd $wok; ls 1.59 + cd $wok-hg; ls 1.60 + } | sort -u | \ 1.61 + while read folder; do 1.62 + result="$(compare_wok_folder $folder)" 1.63 + [ -n "$result" ] && echo -e "$result\n" 1.64 + done 1.65 +} 1.66 + 1.67 + 1.68 # 1.69 # Commands 1.70 # 1.71 @@ -524,6 +578,11 @@ 1.72 . $tasks/$task; task 1.73 footer "Task $task finished" ;; 1.74 1.75 + outgoing|-o) 1.76 + # Find changes in wok that we can move to wok-hg 1.77 + compare_wok 1.78 + ;; 1.79 + 1.80 *) 1.81 # Default is to cook all commits if not yet running. 1.82 [ -n "$1" ] && usage