1 |
Gregg wrote: |
2 |
> Also, as per my last email with the other script that was being worked on. |
3 |
> Ive noticed that the find in that one is faster because of the min and |
4 |
> max depth settings. These 2 seem to be perfect for merging together then |
5 |
> having exactly what we want, with it being quick and easy. |
6 |
|
7 |
Ok. I'm merging the two. I've already implemented the "remove" feture. |
8 |
It outputs in red, for consistency, but I don't know if it makes sense. |
9 |
|
10 |
For the -maxdepth -mindepth: |
11 |
I'm working to implement the |
12 |
EXCLUDE="distfiles:files:eclass:licenses:profiles:scripts:metadata:packages" |
13 |
feature, but if -maxdepth 2-mindepth 2 is used it is useless because |
14 |
at this directory level all we have is *.ebuild directories. |
15 |
But if the portage system will be extended to have more than two levels |
16 |
of directories (instead of the "-" trik, like in "x11-libs") we'll |
17 |
have to switch back. |
18 |
Ok. so I drop the EXCLUDE feature. |
19 |
|
20 |
However the performance gain is ridiculous 0.3 seconds with recursive |
21 |
vs 0.03 sec with maxdepth 2, given that rsync often takes much much longer. |
22 |
|
23 |
What about /var/cache for script output ? |
24 |
Or should I leave /root as default ? |
25 |
|
26 |
I thought it could be called "emerge-rsync", at least until |
27 |
we integrate it in emerge itself :-) ok? |
28 |
|
29 |
I've added command line passing to emerge rysnc (for --clean) |
30 |
Tell me if you like it. |
31 |
I will make an ebuild for it, but I cannot provide hosting. Where should |
32 |
I put it? |
33 |
|
34 |
So here is the script: |
35 |
<snip> |
36 |
#!/bin/sh |
37 |
BASE=/var/cache |
38 |
USE_COLORS=yes |
39 |
|
40 |
# end user configuration section |
41 |
. /etc/make.globals |
42 |
BEFORE=$BASE/ebuild-rsync.before |
43 |
AFTER=$BASE/ebuild-rsync.after |
44 |
NEW=$BASE/ebuild-rsync.new |
45 |
REMOVED=$BASE/ebuild-rsync.removed |
46 |
|
47 |
if [ "$USE_COLORS" == "yes" ]; then |
48 |
RED="\033[;31m" |
49 |
GREEN="\033[;32m" |
50 |
NORMAL="\033[m" |
51 |
fi |
52 |
|
53 |
function portagetree () { |
54 |
find $PORTDIR -type d -mindepth 2 -maxdepth 2 |
55 |
} |
56 |
|
57 |
# do it |
58 |
portagetree >$BEFORE |
59 |
emerge $@ rsync |
60 |
portagetree >$AFTER |
61 |
diff $BEFORE $AFTER | grep ">" | sed "s/> //g" > $NEW |
62 |
diff $BEFORE $AFTER | grep "<" | sed "s/< //g" > $REMOVED |
63 |
|
64 |
# cleanup |
65 |
rm $BEFORE $AFTER |
66 |
|
67 |
# display new ebuilds |
68 |
if ! diff -q $NEW /dev/null >/dev/null; then |
69 |
echo |
70 |
echo New ebuilds: |
71 |
for i in $(cat $NEW); do |
72 |
. $(ls $i/*.ebuild --sort=time | head -n 1) |
73 |
echo -e $GREEN${i##$PORTDIR/}$NORMAL: $DESCRIPTION |
74 |
done |
75 |
fi |
76 |
|
77 |
# display removed ebuilds |
78 |
if ! diff -q $REMOVED /dev/null >/dev/null; then |
79 |
echo |
80 |
echo Removed ebuilds: |
81 |
for i in $(cat $REMOVED); do |
82 |
echo -e $RED${i##$PORTDIR/}$NORMAL |
83 |
done |
84 |
fi |
85 |
</snip> |