This commit is contained in:
Nick Bebout 2011-03-12 02:44:22 +00:00
parent 475d7b9015
commit cdefaa6ccf
7 changed files with 70 additions and 49 deletions

View file

@ -1,17 +1,24 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.156 head: 1.158
branch: branch:
locks: strict locks: strict
gilles: 1.156
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 156; selected revisions: 156 total revisions: 158; selected revisions: 158
description: 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 date: 2006/03/02 03:14:12; author: gilles; state: Exp; lines: +6 -5
Added imap_tools link. Added imap_tools link.
---------------------------- ----------------------------

4
README
View file

@ -2,7 +2,7 @@ NAME
imapsync - IMAP synchronization, copy or migration tool. Synchronize imapsync - IMAP synchronization, copy or migration tool. Synchronize
mailboxes between two imap servers. Good at IMAP migration. mailboxes between two imap servers. Good at IMAP migration.
$Revision: 1.156 $ $Revision: 1.158 $
INSTALL INSTALL
imapsync works fine under any Unix OS. 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 teaching free open and gratis softwares. Don't hesitate to pay him for
that services. 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 $

8
TODO
View file

@ -7,8 +7,6 @@ problem is encountered.
Post on newsgroup comp.mail.imap when a new release comes. Post on newsgroup comp.mail.imap when a new release comes.
http://groups.google.fr/group/comp.mail.imap http://groups.google.fr/group/comp.mail.imap
Make --include --exclude options possibly be a list.
Add features from Herman (patch against 1.139) Add features from Herman (patch against 1.139)
- Support for authenticating as different (admin) user - Support for authenticating as different (admin) user
- Support for different auth mechanisms (we needed PLAIN) - 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 my amazon wishlist link.
Add an --exactsync option to remove target messages 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 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 Add cyrus link about INBOX. namespace
http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html http://asg.web.cmu.edu/cyrus/download/imapd/altnamespace.html
Look at http://freshmeat.net/projects/freshmeat-submit/
Explain expunge behavior. 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 : DONE in FAQ.Talk about :
"I think notes is right but MS Eudora is bad with dates. "I think notes is right but MS Eudora is bad with dates.

View file

@ -1 +1 @@
1.156 1.158

View file

@ -1,5 +1,5 @@
Project: imapsync Project: imapsync
Version: 1.155 Version: 1.156
Release-Focus: Major feature enhancements Release-Focus: Major feature enhancements
Hide: N Hide: N
Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Home-Page-URL: http://www.linux-france.org/prj/imapsync/

View file

@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration
tool. Synchronize mailboxes between two imap servers. Good tool. Synchronize mailboxes between two imap servers. Good
at IMAP migration. at IMAP migration.
$Revision: 1.156 $ $Revision: 1.158 $
=head1 INSTALL =head1 INSTALL
@ -322,7 +322,7 @@ Gilles LAMIRAL earn his living writing, installing,
configuring and teaching free open and gratis configuring and teaching free open and gratis
softwares. Don't hesitate to pay him for that services. 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 =cut
@ -342,7 +342,7 @@ my(
$rcs, $debug, $debugimap, $error, $rcs, $debug, $debugimap, $error,
$host1, $host2, $port1, $port2, $host1, $host2, $port1, $port2,
$user1, $user2, $password1, $password2, $passfile1, $passfile2, $user1, $user2, $password1, $password2, $passfile1, $passfile2,
@folder, $include, $exclude, @folder, @include, @exclude,
$prefix1, $prefix2, $prefix1, $prefix2,
@regextrans2, @regexmess, @regextrans2, @regexmess,
$sep1, $sep2, $sep1, $sep2,
@ -370,7 +370,7 @@ my(
use vars qw ($opt_G); # missing code for this will be option. 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+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
@ -407,8 +407,8 @@ $error=0;
my $banner = join("", my $banner = join("",
'$RCSfile: imapsync,v $ ', '$RCSfile: imapsync,v $ ',
'$Revision: 1.156 $ ', '$Revision: 1.158 $ ',
'$Date: 2006/03/02 03:14:12 $ ', '$Date: 2006/03/02 06:28:30 $ ',
"\n", "\n",
"Mail::IMAPClient version used here is ", "Mail::IMAPClient version used here is ",
$VERSION_IMAPClient,"\n" $VERSION_IMAPClient,"\n"
@ -603,11 +603,11 @@ if (scalar(@folder)) {
# no option, all folders # no option, all folders
@f_folders = sort $from->folders(); @f_folders = sort $from->folders();
# consider (optional) includes and excludes # consider (optional) includes and excludes
if ($include) { foreach my $include (@include) {
@f_folders = grep /$include/,@f_folders; @f_folders = grep /$include/,@f_folders;
print "Only including folders matching pattern '$include'\n"; print "Only including folders matching pattern '$include'\n";
} }
if ($exclude) { foreach my $exclude (@exclude) {
@f_folders = grep !/$exclude/,@f_folders; @f_folders = grep !/$exclude/,@f_folders;
print "Excluding folders matching pattern '$exclude'\n"; print "Excluding folders matching pattern '$exclude'\n";
} }
@ -776,11 +776,9 @@ sub separator_invert {
return($t_fold); return($t_fold);
} }
FOLDER: foreach my $f_fold (@f_folders) { sub to_folder_name {
my $t_fold; my ($t_fold);
print "From Folder [$f_fold]\n"; my ($x_fold) = @_;
my $x_fold = $f_fold;
# first we remove the prefix # first we remove the prefix
$x_fold =~ s/^$f_prefix//; $x_fold =~ s/^$f_prefix//;
$debug and print "removed source prefix : [$x_fold]\n"; $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"; $debug and print "eval \$t_fold =~ $regextrans2\n";
eval("\$t_fold =~ $regextrans2"); 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"; print "To Folder [$t_fold]\n";
unless ($from->select($f_fold)) { unless ($from->select($f_fold)) {
@ -821,25 +847,8 @@ FOLDER: foreach my $f_fold (@f_folders) {
} }
} }
if ($syncacls) { acls_sync($f_fold, $t_fold);
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";
}
}
}
unless ($to->select($t_fold)) { unless ($to->select($t_fold)) {
warn warn
"To Folder $t_fold : Could not select ", "To Folder $t_fold : Could not select ",
@ -1130,8 +1139,8 @@ sub get_options
"sep1=s" => \$sep1, "sep1=s" => \$sep1,
"sep2=s" => \$sep2, "sep2=s" => \$sep2,
"folder=s" => \@folder, "folder=s" => \@folder,
"include=s" => \$include, "include=s" => \@include,
"exclude=s" => \$exclude, "exclude=s" => \@exclude,
"prefix1=s" => \$prefix1, "prefix1=s" => \$prefix1,
"prefix2=s" => \$prefix2, "prefix2=s" => \$prefix2,
"regextrans2=s" => \@regextrans2, "regextrans2=s" => \@regextrans2,
@ -1262,11 +1271,15 @@ Several options are mandatory.
--folder <string> : and this one, etc. --folder <string> : and this one, etc.
--include <regex> : only sync folders matching this regular expression --include <regex> : only sync folders matching this regular expression
(only effective if neither --folder nor --subscribed (only effective if neither --folder nor --subscribed
is specified). is specified).
--include <regex> : and this one, etc.
in case both --include --exclude options are
use, include is done before.
--exclude <regex> : skips folders matching this regular expression --exclude <regex> : skips folders matching this regular expression
(only effective if neither --folder nor --subscribed (only effective if neither --folder nor --subscribed
is specified). Several folders to avoid: is specified). Several folders to avoid:
--exclude 'fold1|fold2|f3' skips fold1, fold2 and f3. --exclude 'fold1|fold2|f3' skips fold1, fold2 and f3.
--exclude <regex> : and this one, etc.
--prefix1 <string> : remove prefix to all destination folders --prefix1 <string> : remove prefix to all destination folders
(usually INBOX. for cyrus imap servers) (usually INBOX. for cyrus imap servers)
use --prefix1 if your source imap server does not use --prefix1 if your source imap server does not

5
memo
View file

@ -44,12 +44,13 @@ else
cat > $NEWS_FILE_FM << EOF cat > $NEWS_FILE_FM << EOF
Project: imapsync Project: imapsync
Version: $VERSION Version: $VERSION
Release-Focus: Major feature enhancements Release-Focus: Minor feature enhancements
Hide: N Hide: Y
Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Home-Page-URL: http://www.linux-france.org/prj/imapsync/
Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/ Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/
EOF EOF
freshmeat-submit < $NEWS_FILE_FM
fi fi
} }