diff --git a/ChangeLog b/ChangeLog index 5ffea64..2114dce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,17 +1,24 @@ RCS file: RCS/imapsync,v Working file: imapsync -head: 1.156 +head: 1.158 branch: locks: strict - gilles: 1.156 access list: symbolic names: keyword substitution: kv -total revisions: 156; selected revisions: 156 +total revisions: 158; selected revisions: 158 description: ---------------------------- -revision 1.156 locked by: gilles; +revision 1.158 +date: 2006/03/02 06:28:30; author: gilles; state: Exp; lines: +38 -29 +Made acls_sync() to_folder_name() +---------------------------- +revision 1.157 +date: 2006/03/02 04:32:01; author: gilles; state: Exp; lines: +15 -11 +Made --include --exclude options possibly be a list. +---------------------------- +revision 1.156 date: 2006/03/02 03:14:12; author: gilles; state: Exp; lines: +6 -5 Added imap_tools link. ---------------------------- diff --git a/README b/README index 3aa97d6..ff6ae28 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME imapsync - IMAP synchronization, copy or migration tool. Synchronize mailboxes between two imap servers. Good at IMAP migration. - $Revision: 1.156 $ + $Revision: 1.158 $ INSTALL imapsync works fine under any Unix OS. @@ -274,5 +274,5 @@ AUTHOR teaching free open and gratis softwares. Don't hesitate to pay him for that services. - $Id: imapsync,v 1.156 2006/03/02 03:14:12 gilles Exp gilles $ + $Id: imapsync,v 1.158 2006/03/02 06:28:30 gilles Exp $ diff --git a/TODO b/TODO index 5def2c2..b85486d 100644 --- a/TODO +++ b/TODO @@ -7,8 +7,6 @@ problem is encountered. Post on newsgroup comp.mail.imap when a new release comes. http://groups.google.fr/group/comp.mail.imap -Make --include --exclude options possibly be a list. - Add features from Herman (patch against 1.139) - Support for authenticating as different (admin) user - Support for different auth mechanisms (we needed PLAIN) @@ -16,7 +14,7 @@ Add features from Herman (patch against 1.139) Add my amazon wishlist link. Add an --exactsync option to remove target messages -that are not on source. +that are not on source. Maybe --delete2 is a better name. Read the IMAP RFC http://www.faqs.org/rfcs/rfc3501.html @@ -34,10 +32,12 @@ http://www.washington.edu/imap/documentation/commndmt.txt.html Add cyrus link about INBOX. namespace http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html -Look at http://freshmeat.net/projects/freshmeat-submit/ Explain expunge behavior. +DONE. Make --include --exclude options possibly be a list. + +DONE. Look at http://freshmeat.net/projects/freshmeat-submit/ DONE in FAQ.Talk about : "I think notes is right but MS Eudora is bad with dates. diff --git a/VERSION b/VERSION index 6149232..3c5303c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.156 +1.158 diff --git a/freshmeat_submition2 b/freshmeat_submition2 index 99626c0..ac497cb 100644 --- a/freshmeat_submition2 +++ b/freshmeat_submition2 @@ -1,5 +1,5 @@ Project: imapsync -Version: 1.155 +Version: 1.156 Release-Focus: Major feature enhancements Hide: N Home-Page-URL: http://www.linux-france.org/prj/imapsync/ diff --git a/imapsync b/imapsync index ee25cd8..bfc7e03 100755 --- a/imapsync +++ b/imapsync @@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration tool. Synchronize mailboxes between two imap servers. Good at IMAP migration. -$Revision: 1.156 $ +$Revision: 1.158 $ =head1 INSTALL @@ -322,7 +322,7 @@ Gilles LAMIRAL earn his living writing, installing, configuring and teaching free open and gratis softwares. Don't hesitate to pay him for that services. -$Id: imapsync,v 1.156 2006/03/02 03:14:12 gilles Exp gilles $ +$Id: imapsync,v 1.158 2006/03/02 06:28:30 gilles Exp $ =cut @@ -342,7 +342,7 @@ my( $rcs, $debug, $debugimap, $error, $host1, $host2, $port1, $port2, $user1, $user2, $password1, $password2, $passfile1, $passfile2, - @folder, $include, $exclude, + @folder, @include, @exclude, $prefix1, $prefix2, @regextrans2, @regexmess, $sep1, $sep2, @@ -370,7 +370,7 @@ my( use vars qw ($opt_G); # missing code for this will be option. -$rcs = ' $Id: imapsync,v 1.156 2006/03/02 03:14:12 gilles Exp gilles $ '; +$rcs = ' $Id: imapsync,v 1.158 2006/03/02 06:28:30 gilles Exp $ '; $rcs =~ m/,v (\d+\.\d+)/; $VERSION = ($1) ? $1 : "UNKNOWN"; @@ -407,8 +407,8 @@ $error=0; my $banner = join("", '$RCSfile: imapsync,v $ ', - '$Revision: 1.156 $ ', - '$Date: 2006/03/02 03:14:12 $ ', + '$Revision: 1.158 $ ', + '$Date: 2006/03/02 06:28:30 $ ', "\n", "Mail::IMAPClient version used here is ", $VERSION_IMAPClient,"\n" @@ -603,11 +603,11 @@ if (scalar(@folder)) { # no option, all folders @f_folders = sort $from->folders(); # consider (optional) includes and excludes - if ($include) { + foreach my $include (@include) { @f_folders = grep /$include/,@f_folders; print "Only including folders matching pattern '$include'\n"; } - if ($exclude) { + foreach my $exclude (@exclude) { @f_folders = grep !/$exclude/,@f_folders; print "Excluding folders matching pattern '$exclude'\n"; } @@ -776,11 +776,9 @@ sub separator_invert { return($t_fold); } -FOLDER: foreach my $f_fold (@f_folders) { - my $t_fold; - print "From Folder [$f_fold]\n"; - - my $x_fold = $f_fold; +sub to_folder_name { + my ($t_fold); + my ($x_fold) = @_; # first we remove the prefix $x_fold =~ s/^$f_prefix//; $debug and print "removed source prefix : [$x_fold]\n"; @@ -795,7 +793,35 @@ FOLDER: foreach my $f_fold (@f_folders) { $debug and print "eval \$t_fold =~ $regextrans2\n"; eval("\$t_fold =~ $regextrans2"); } + return($t_fold); +} +sub acls_sync { + my($f_fold, $t_fold) = @_; + if ($syncacls) { + my $f_hash = $from->getacl($f_fold) + or warn "Could not getacl for $f_fold: $@\n"; + my $t_hash = $to->getacl($t_fold) + or warn "Could not getacl for $t_fold: $@\n"; + my %users = map({ ($_, 1) } (keys(%$f_hash), keys(%$t_hash))); + foreach my $user (sort(keys(%users))) { + my $acl = $f_hash->{$user} || "none"; + print "acl $user : [$acl]\n"; + next if ($f_hash->{$user} && $t_hash->{$user} && + $f_hash->{$user} eq $t_hash->{$user}); + unless ($dry) { + print "setting acl $t_fold $user $acl\n"; + $to->setacl($t_fold, $user, $acl) + or warn "Could not set acl: $@\n"; + } + } + } +} + +FOLDER: foreach my $f_fold (@f_folders) { + my $t_fold; + print "From Folder [$f_fold]\n"; + $t_fold = to_folder_name($f_fold); print "To Folder [$t_fold]\n"; unless ($from->select($f_fold)) { @@ -821,25 +847,8 @@ FOLDER: foreach my $f_fold (@f_folders) { } } - if ($syncacls) { - my $f_hash = $from->getacl($f_fold) - or warn "Could not getacl for $f_fold: $@\n"; - my $t_hash = $to->getacl($t_fold) - or warn "Could not getacl for $t_fold: $@\n"; - my %users = map({ ($_, 1) } (keys(%$f_hash), keys(%$t_hash))); - foreach my $user (sort(keys(%users))) { - my $acl = $f_hash->{$user} || "none"; - print "acl $user : [$acl]\n"; - next if ($f_hash->{$user} && $t_hash->{$user} && - $f_hash->{$user} eq $t_hash->{$user}); - unless ($dry) { - print "setting acl $t_fold $user $acl\n"; - $to->setacl($t_fold, $user, $acl) - or warn "Could not set acl: $@\n"; - } - } - } - + acls_sync($f_fold, $t_fold); + unless ($to->select($t_fold)) { warn "To Folder $t_fold : Could not select ", @@ -1130,8 +1139,8 @@ sub get_options "sep1=s" => \$sep1, "sep2=s" => \$sep2, "folder=s" => \@folder, - "include=s" => \$include, - "exclude=s" => \$exclude, + "include=s" => \@include, + "exclude=s" => \@exclude, "prefix1=s" => \$prefix1, "prefix2=s" => \$prefix2, "regextrans2=s" => \@regextrans2, @@ -1262,11 +1271,15 @@ Several options are mandatory. --folder : and this one, etc. --include : only sync folders matching this regular expression (only effective if neither --folder nor --subscribed - is specified). + is specified). +--include : and this one, etc. + in case both --include --exclude options are + use, include is done before. --exclude : skips folders matching this regular expression (only effective if neither --folder nor --subscribed is specified). Several folders to avoid: --exclude 'fold1|fold2|f3' skips fold1, fold2 and f3. +--exclude : and this one, etc. --prefix1 : remove prefix to all destination folders (usually INBOX. for cyrus imap servers) use --prefix1 if your source imap server does not diff --git a/memo b/memo index 257944f..41cb5d8 100644 --- a/memo +++ b/memo @@ -44,12 +44,13 @@ else cat > $NEWS_FILE_FM << EOF Project: imapsync Version: $VERSION -Release-Focus: Major feature enhancements -Hide: N +Release-Focus: Minor feature enhancements +Hide: Y Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/ EOF +freshmeat-submit < $NEWS_FILE_FM fi }