packages: archivemail/archivemail.spec, archivemail/archivemail-add-archive...

glen glen at pld-linux.org
Wed Oct 28 10:28:43 CET 2009


Author: glen                         Date: Wed Oct 28 09:28:43 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- In python 2.5, mailbox objects evaluate to false when empty.
  Avoid an assertian when this happens. Closes Debian: #476806
- add more patches from debian, rel 2

---- Files affected:
packages/archivemail:
   archivemail.spec (1.22 -> 1.23) , archivemail-add-archive-all-switch.patch (NONE -> 1.1)  (NEW), archivemail-add-archive-name-switch.patch (NONE -> 1.1)  (NEW), archivemail-add-prefix-switch.patch (NONE -> 1.1)  (NEW), archivemail-empty-mailbox-objects-fix.patch (NONE -> 1.1)  (NEW), archivemail-fix-path-in-example.patch (NONE -> 1.1)  (NEW), archivemail-preserve-symlinks.patch (NONE -> 1.1)  (NEW), archivemail-relax-timestamps-test.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/archivemail/archivemail.spec
diff -u packages/archivemail/archivemail.spec:1.22 packages/archivemail/archivemail.spec:1.23
--- packages/archivemail/archivemail.spec:1.22	Tue May 20 22:15:41 2008
+++ packages/archivemail/archivemail.spec	Wed Oct 28 10:28:37 2009
@@ -3,11 +3,18 @@
 Summary(pl.UTF-8):	Archiwizowanie starej poczty
 Name:		archivemail
 Version:	0.7.2
-Release:	1
+Release:	2
 License:	GPL
 Group:		Applications/Mail
 Source0:	http://dl.sourceforge.net/archivemail/%{name}-%{version}.tar.gz
 # Source0-md5:	e444424688e6ec063e829176e4eb62e2
+Patch0:		%{name}-add-archive-name-switch.patch
+Patch1:		%{name}-empty-mailbox-objects-fix.patch
+Patch2:		%{name}-fix-path-in-example.patch
+Patch3:		%{name}-preserve-symlinks.patch
+Patch4:		%{name}-add-prefix-switch.patch
+Patch5:		%{name}-add-archive-all-switch.patch
+Patch6:		%{name}-relax-timestamps-test.patch
 URL:		http://archivemail.sourceforge.net/
 BuildRequires:	python-devel >= 2.0
 %pyrequires_eq	python
@@ -17,17 +24,17 @@
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
-Archivemail is a tool written in Python for archiving and
-compressing old email in mailboxes.
+Archivemail is a tool written in Python for archiving and compressing
+old email in mailboxes.
 
 It can move messages older than the specified number of days to a
 separate 'archive' mbox-format mailbox that is compressed with 'gzip'.
 
 For example, have you been subscribing to the 'linux-kernel' mailing
 list for the last 6 years and ended up with an 160-meg mailbox that
-Mutt is taking a long time to load? Archivemail can move all
-messages that are older than 6 months to a separate compressed
-mailbox, and leave you with just the most recent messages.
+Mutt is taking a long time to load? Archivemail can move all messages
+that are older than 6 months to a separate compressed mailbox, and
+leave you with just the most recent messages.
 
 It supports IMAP, Maildir, MH and mbox-format mailboxes.
 
@@ -50,29 +57,37 @@
 
 %prep
 %setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+
+%{__sed} -i -e 's,man/man1,%{_mandir}/man1,' setup.py
 
 %build
-# Nothing to be done here.
-./setup.py build
+%{__python} setup.py build
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d ${RPM_BUILD_ROOT}%{_mandir}
-./setup.py install \
+install -d $RPM_BUILD_ROOT%{_mandir}
+%{__python} setup.py install \
 	--prefix=%{_prefix} \
-	--root=${RPM_BUILD_ROOT}
+	--root=$RPM_BUILD_ROOT
 
-# This one is ugly.
-mv ${RPM_BUILD_ROOT}%{_prefix}/man/man1 ${RPM_BUILD_ROOT}%{_mandir}
+# Not a Python module, so drop the egg.
+rm -f $RPM_BUILD_ROOT%{py_sitescriptdir}/*.egg-info
 
 %clean
-rm -rf ${RPM_BUILD_ROOT}
+rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
 %doc CHANGELOG FAQ README TODO
-%attr(755,root,root) %{_bindir}/*
-%{_mandir}/man1/*
+%attr(755,root,root) %{_bindir}/archivemail
+%{_mandir}/man1/archivemail.1*
 
 %define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
 %changelog
@@ -80,6 +95,11 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.23  2009/10/28 09:28:37  glen
+- In python 2.5, mailbox objects evaluate to false when empty.
+  Avoid an assertian when this happens. Closes Debian: #476806
+- add more patches from debian, rel 2
+
 Revision 1.22  2008/05/20 20:15:41  adamg
 - updated to 0.7.2
 
@@ -118,7 +138,7 @@
 - typo
 
 Revision 1.10  2004/07/28 08:03:13  troll
-- removed %%include /usr/lib/rpm/macros.python
+- removed %include /usr/lib/rpm/macros.python
 
 Revision 1.9  2003/08/13 20:58:10  adamg
 - aieee, previous BR wasn't really needed, thanks wrobell
@@ -142,7 +162,7 @@
 - summaries and descriptions fixes
 
 Revision 1.2  2003/02/12 23:09:36  ankry
-- added %%doc
+- added %doc
 
 Revision 1.1  2003/02/12 22:46:38  grzegol
 - spec by Adam Gołębiowski <adamg at biomerieux.pl>

================================================================
Index: packages/archivemail/archivemail-add-archive-all-switch.patch
diff -u /dev/null packages/archivemail/archivemail-add-archive-all-switch.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-add-archive-all-switch.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,139 @@
+# Description: add, document and test --all option
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470675
+# Author: Serafeim Zanikolas <serzan at hellug.gr>
+# Last-Update: 2009-02-22
+Index: archivemail/archivemail
+===================================================================
+--- archivemail.orig/archivemail	2008-09-06 15:11:32.000000000 +0100
++++ archivemail/archivemail	2008-09-06 15:14:23.000000000 +0100
+@@ -179,6 +179,7 @@
+     delete_old_mail      = 0
+     dry_run              = 0
+     filter_append        = None
++    archive_all          = 0
+     include_flagged      = 0
+     lockfile_attempts    = 5  
+     lockfile_extension   = ".lock"
+@@ -209,14 +210,14 @@
+ 
+         """
+         try:
+-            opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uvp:', 
++            opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uvp:',
+                              ["date=", "days=", "delete", "dry-run", "help",
+                              "include-flagged", "no-compress", "output-dir=",
+                              "archive-name=",
+                              "filter-append=", "pwfile=", "dont-mangle",
+                              "preserve-unread", "quiet", "size=", "suffix=",
+                              "verbose", "version", "warn-duplicate", "copy",
+-                             "prefix="])
++                             "prefix=", "all"])
+         except getopt.error, msg:
+             user_error(msg)
+ 
+@@ -227,6 +228,8 @@
+                 if self.copy_old_mail: 
+                     user_error("found conflicting options --copy and --delete")
+                 self.delete_old_mail = 1
++            if o == ('--all'):
++                self.archive_all = 1
+             if o == '--include-flagged':
+                 self.include_flagged = 1
+             if o == '--no-compress':
+@@ -277,6 +280,9 @@
+             if o in ('-V', '--version'):
+                 print __version__ + "\n\n" + __copyright__
+                 sys.exit(0)
++        if self.archive_all and archive_by:
++            user_error("--all must not be used with other " +
++                       "filtering options")
+         return args
+ 
+     def sanity_check(self):
+@@ -681,6 +687,8 @@
+ mailbox compressed with gzip. 
+ 
+ Options are as follows:
++      --all             archive all messages (not to be used along with other
++                        filter switches; use with caution)
+   -d, --days=NUM        archive messages older than NUM days (default: %d)
+   -D, --date=DATE       archive messages older than DATE
+   -o, --output-dir=DIR  directory to store archives (default: same as original)
+@@ -1009,6 +1017,8 @@
+ 
+ def should_archive(message):
+     """Return true if we should archive the message, false otherwise"""
++    if options.archive_all:
++        return 1
+     old = 0
+     time_message = guess_delivery_time(message)
+     if options.date_old_max == None:
+Index: archivemail/archivemail.sgml
+===================================================================
+--- archivemail.orig/archivemail.sgml	2008-09-06 15:11:32.000000000 +0100
++++ archivemail/archivemail.sgml	2008-09-06 15:16:25.000000000 +0100
+@@ -119,6 +119,15 @@
+ 
+ <VarListEntry>
+ <Term>
++    <Option>--all</Option>
++</Term>
++<ListItem><Para>
++Archive _all_ messages. Not to be combined with other filter switches.
++</Para></ListItem>
++</VarListEntry>
++
++<VarListEntry>
++<Term>
+     <Option>-d <Replaceable/NUM/, --days=<Replaceable/NUM/</Option>
+ </Term>
+ <ListItem><Para>Archive messages older than <Replaceable/NUM/ days.  
+Index: archivemail/test_archivemail.py
+===================================================================
+--- archivemail.orig/test_archivemail.py	2008-09-06 15:13:17.000000000 +0100
++++ archivemail/test_archivemail.py	2008-09-06 19:58:49.000000000 +0100
+@@ -974,6 +974,44 @@
+         super(TestArchiveDryRun, self).tearDown()
+ 
+ 
++class TestArchiveAll(TestCaseInTempdir):
++    """make sure the 'all' option works"""
++    def setUp(self):
++        super(TestArchiveAll, self).setUp()
++        archivemail.options.quiet = 1
++
++    def testValidUse(self):
++        """test that it works when used without any other archive_by option"""
++        for execute in ("package", "system_long"):
++            self.setUp()
++            self.mbox_name = make_mbox(messages=3, hours_old=(24 * 12))
++            self.mbox = archivemail.Mbox(self.mbox_name)
++            if execute == "package":
++                archivemail.options.archive_all = 1
++                archivemail.archive(self.mbox_name)
++            elif execute == "system_long":
++                run = "./archivemail.py --all --quiet "\
++                        + "%s 2>&1 >/dev/null" % self.mbox_name
++                self.assertEqual(os.system(run), 0)
++            else:
++                sys.exit(1)
++            assert(os.path.exists(self.mbox_name))
++            self.assertTrue(self.mbox.is_empty())
++            self.tearDown()
++
++    def testInvalidUses(self):
++        """test that it gives up with invoked with either -d or -D"""
++        for arg in ["-d 30", "--days=30",\
++                    "-D 2008-07-30", "--date=2008-07-30"]:
++            run = ("./archivemail.py --all %s --quiet "\
++                    + "whatever >/dev/null 2>&1") % arg
++            self.assertEqual(os.system(run), 256)
++
++    def tearDown(self):
++        archivemail.options.archive_all = 0
++        archivemail.options.quiet = 0
++        super(TestArchiveAll, self).tearDown()
++
+ class TestArchiveDays(TestCaseInTempdir):
+     """make sure the 'days' option works"""
+     def setUp(self):

================================================================
Index: packages/archivemail/archivemail-add-archive-name-switch.patch
diff -u /dev/null packages/archivemail/archivemail-add-archive-name-switch.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-add-archive-name-switch.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,71 @@
+# Description: add and document --archive-name option
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=247340
+# Author: Serafeim Zanikolas <serzan at hellug.gr>
+# Last-Update: 2008-08-15
+Index: archivemail/archivemail
+===================================================================
+--- archivemail.orig/archivemail	2008-08-15 20:38:03.000000000 +0100
++++ archivemail/archivemail	2008-08-15 21:39:57.000000000 +0100
+@@ -172,6 +172,7 @@
+ class Options:
+     """Class to store runtime options, including defaults"""
+     archive_suffix       = "_archive"
++    archive_name         = None
+     days_old_max         = 180
+     date_old_max         = None
+     delete_old_mail      = 0
+@@ -210,6 +211,7 @@
+             opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uv', 
+                              ["date=", "days=", "delete", "dry-run", "help",
+                              "include-flagged", "no-compress", "output-dir=",
++			     "archive-name=",
+                              "filter-append=", "pwfile=", "dont-mangle",
+                              "preserve-unread", "quiet", "size=", "suffix=",
+                              "verbose", "version", "warn-duplicate", "copy"])
+@@ -262,6 +264,8 @@
+                 self.mangle_from = 0
+             if o in ('-v', '--verbose'):
+                 self.verbose = 1
++            if o in ('--archive-name'):
++                self.archive_name = os.path.expanduser(a)
+             if o == '--copy':
+                 if self.delete_old_mail: 
+                     user_error("found conflicting options --copy and --delete")
+@@ -663,6 +667,8 @@
+   -P, --pwfile=FILE     file to read imap password from (default: None)
+   -F, --filter-append=STRING  append arbitrary string to the IMAP filter string
+   -s, --suffix=NAME     suffix for archive filename (default: '%s')
++      --archive-name=NAME  specify whole archive filename, overrides prefix
++                           and suffix
+   -S, --size=NUM        only archive messages NUM bytes or larger
+   -n, --dry-run         don't write to anything - just show what would be done
+   -u, --preserve-unread never archive unread messages
+@@ -1102,6 +1108,8 @@
+         final_archive_name = mailbox_name.split('/')[-1] + parsed_suffix
+     else:
+         final_archive_name = mailbox_name + parsed_suffix
++    if options.archive_name:
++	final_archive_name = options.archive_name
+     if options.output_dir:
+         final_archive_name = os.path.join(options.output_dir, 
+                 os.path.basename(final_archive_name))
+Index: archivemail/archivemail.sgml
+===================================================================
+--- archivemail.orig/archivemail.sgml	2008-08-15 20:38:03.000000000 +0100
++++ archivemail/archivemail.sgml	2008-08-15 21:38:49.000000000 +0100
+@@ -238,6 +238,15 @@
+ 
+ <VarListEntry>
+ <Term>
++    <Option>--archive-name</Option>
++</Term>
++<ListItem><Para>
++Specify whole archive filename, overrides prefix and suffix.
++</Para></ListItem>
++</VarListEntry>
++
++<VarListEntry>
++<Term>
+     <Option>-S <Replaceable/NUM/, --size=<Replaceable/NUM/</Option>
+ </Term>
+ <ListItem><Para>Only archive messages that are <Replaceable/NUM/ bytes or

================================================================
Index: packages/archivemail/archivemail-add-prefix-switch.patch
diff -u /dev/null packages/archivemail/archivemail-add-prefix-switch.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-add-prefix-switch.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,142 @@
+# Description: add, document and test --prefix option for archive name
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=247340
+# Author: Serafeim Zanikolas <serzan at hellug.gr>
+# Last-Update: 2009-02-22
+Index: archivemail/archivemail
+===================================================================
+--- archivemail.orig/archivemail	2008-08-15 21:40:17.000000000 +0100
++++ archivemail/archivemail	2008-08-15 21:40:17.000000000 +0100
+@@ -171,6 +171,7 @@
+ 
+ class Options:
+     """Class to store runtime options, including defaults"""
++    archive_prefix       = None
+     archive_suffix       = "_archive"
+     archive_name         = None
+     days_old_max         = 180
+@@ -208,13 +209,14 @@
+ 
+         """
+         try:
+-            opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uv', 
++            opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uvp:', 
+                              ["date=", "days=", "delete", "dry-run", "help",
+                              "include-flagged", "no-compress", "output-dir=",
+-			     "archive-name=",
++                             "archive-name=",
+                              "filter-append=", "pwfile=", "dont-mangle",
+                              "preserve-unread", "quiet", "size=", "suffix=",
+-                             "verbose", "version", "warn-duplicate", "copy"])
++                             "verbose", "version", "warn-duplicate", "copy",
++                             "prefix="])
+         except getopt.error, msg:
+             user_error(msg)
+ 
+@@ -254,6 +256,8 @@
+                 self.dry_run = 1
+             if o in ('-q', '--quiet'):
+                 self.quiet = 1
++            if o in ('-p', '--prefix'):
++                self.archive_prefix = a
+             if o in ('-s', '--suffix'):
+                 self.archive_suffix = a
+             if o in ('-S', '--size'):
+@@ -682,6 +686,7 @@
+   -o, --output-dir=DIR  directory to store archives (default: same as original)
+   -P, --pwfile=FILE     file to read imap password from (default: None)
+   -F, --filter-append=STRING  append arbitrary string to the IMAP filter string
++  -p, --prefix=NAME     prefix for archive filename (default: none)
+   -s, --suffix=NAME     suffix for archive filename (default: '%s')
+       --archive-name=NAME  specify whole archive filename, overrides prefix
+                            and suffix
+@@ -1124,8 +1129,11 @@
+         final_archive_name = mailbox_name.split('/')[-1] + parsed_suffix
+     else:
+         final_archive_name = mailbox_name + parsed_suffix
++    if options.archive_prefix:
++        final_archive_name = os.path.join(os.path.dirname(final_archive_name),\
++                options.archive_prefix + os.path.basename(final_archive_name))
+     if options.archive_name:
+-	final_archive_name = options.archive_name
++        final_archive_name = options.archive_name
+     if options.output_dir:
+         final_archive_name = os.path.join(options.output_dir, 
+                 os.path.basename(final_archive_name))
+Index: archivemail/test_archivemail.py
+===================================================================
+--- archivemail.orig/test_archivemail.py	2008-08-15 21:40:17.000000000 +0100
++++ archivemail/test_archivemail.py	2008-08-15 21:40:17.000000000 +0100
+@@ -889,6 +889,54 @@
+         archivemail.options.archive_suffix = "_archive"
+         super(TestArchiveMboxSuffix, self).tearDown()
+ 
++class TestArchiveMboxPrefix(TestCaseInTempdir):
++    """make sure the 'prefix' option works"""
++    def setUp(self):
++        super(TestArchiveMboxPrefix, self).setUp()
++        archivemail.options.quiet = 1
++
++    def testPrefix(self):
++        """archiving with specified --prefix arguments"""
++        for prefix in ["blah-"]:
++            for execute in ("system_long", "system_short", "package"):
++                self.setUp()
++                days_old_max = 180
++                self.mbox_name = make_mbox(messages=3, 
++                    hours_old=(24 * (days_old_max+1)))
++                self.copy_name = tempfile.mkstemp()[1]
++                shutil.copyfile(self.mbox_name, self.copy_name)
++                if execute == "system_long":
++                    run = "./archivemail.py --quiet --prefix='%s' %s" % \
++                        (prefix, self.mbox_name)
++                    self.assertEqual(os.system(run), 0)
++                elif execute == "system_short":
++                    run = "./archivemail.py --quiet -p'%s' %s" % \
++                        (prefix, self.mbox_name)
++                    self.assertEqual(os.system(run), 0)
++                elif execute == "package":
++                    archivemail.options.archive_prefix = prefix
++                    archivemail.archive(self.mbox_name)
++                else:
++                    sys.exit(1)
++                assert(os.path.exists(self.mbox_name))
++                self.assertEqual(os.path.getsize(self.mbox_name), 0)
++
++                archive_name = os.path.join(os.path.dirname(self.mbox_name),\
++                        prefix + os.path.basename(self.mbox_name) +\
++                        "_archive.gz")
++                assert(os.path.exists(archive_name))
++                self.assertEqual(os.system("gzip -d %s" % archive_name), 0)
++                archive_name = re.sub("\.gz$", "", archive_name)
++                assert(os.path.exists(archive_name))
++                assert(filecmp.cmp(archive_name, self.copy_name, shallow=0))
++                os.remove(archive_name)
++                self.tearDown()
++
++    def tearDown(self):
++        archivemail.options.quiet = 0
++        archivemail.options.archive_prefix = None
++        super(TestArchiveMboxPrefix, self).tearDown()
++
+ 
+ class TestArchiveDryRun(TestCaseInTempdir):
+     """make sure the 'dry-run' option works"""
+Index: archivemail/archivemail.sgml
+===================================================================
+--- archivemail.orig/archivemail.sgml	2008-08-15 21:38:49.000000000 +0100
++++ archivemail/archivemail.sgml	2008-08-15 21:40:34.000000000 +0100
+@@ -170,6 +170,14 @@
+ 
+ <VarListEntry>
+ <Term>
++    <Option>-p <Replaceable/NAME/, --prefix=<Replaceable/NAME/</Option>
++</Term>
++<ListItem><Para>Prefix <Replaceable/NAME/ to the archive name.
++</Para></ListItem>
++</VarListEntry>
++
++<VarListEntry>
++<Term>
+     <Option>-s <Replaceable/NAME/, --suffix=<Replaceable/NAME/</Option>
+ </Term>
+ <ListItem><Para>

================================================================
Index: packages/archivemail/archivemail-empty-mailbox-objects-fix.patch
diff -u /dev/null packages/archivemail/archivemail-empty-mailbox-objects-fix.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-empty-mailbox-objects-fix.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,17 @@
+# Description: add, document and test --all option
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476806
+# Author: Joey Hess <joeyh at debian.org>
+# Last-Update: 2008-08-14
+Index: archivemail/archivemail
+===================================================================
+--- archivemail.orig/archivemail	2008-08-14 21:24:03.000000000 +0100
++++ archivemail/archivemail	2008-08-14 21:24:12.000000000 +0100
+@@ -1278,7 +1278,7 @@
+         original = mailbox.MHMailbox(mailbox_name)
+     else:
+         unexpected_error("unknown type: %s" % type)        
+-    assert(original)
++    #assert(original)
+ 
+     cache = IdentityCache(mailbox_name)
+ 

================================================================
Index: packages/archivemail/archivemail-fix-path-in-example.patch
diff -u /dev/null packages/archivemail/archivemail-fix-path-in-example.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-fix-path-in-example.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,13 @@
+# Description: correct example invocation
+# Author: Serafeim Zanikolas <serzan at hellug.gr>
+--- archivemail-0.7.2.orig/examples/archivemail_all
++++ archivemail-0.7.2/examples/archivemail_all
+@@ -10,7 +10,7 @@
+ #
+ set -e
+ 
+-ARCMAIL="/usr/local/bin/archivemail --quiet --output-dir=$HOME/Mail/Archive/ "
++ARCMAIL="archivemail --quiet --output-dir=$HOME/Mail/Archive/ "
+ 
+ $ARCMAIL --days 14 $HOME/Mail/debian-user \
+                    $HOME/Mail/linux-kernel \

================================================================
Index: packages/archivemail/archivemail-preserve-symlinks.patch
diff -u /dev/null packages/archivemail/archivemail-preserve-symlinks.patch:1.1
--- /dev/null	Wed Oct 28 10:28:43 2009
+++ packages/archivemail/archivemail-preserve-symlinks.patch	Wed Oct 28 10:28:37 2009
@@ -0,0 +1,97 @@
+# Description: do not overwrite <mailbox>_archive.gz when it is a symbolic link
+# Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=349068
+# Author: Serafeim Zanikolas <serzan at hellug.gr>
+# Last-Update: 2009-02-22
+Index: archivemail/archivemail
+===================================================================
+--- archivemail.orig/archivemail	2008-08-15 21:41:37.000000000 +0100
++++ archivemail/archivemail	2008-08-15 22:00:20.000000000 +0100
+@@ -487,6 +487,20 @@
+         """Return the current size of the mbox file"""
+         return os.path.getsize(self.mbox_file_name)
+ 
++    def get_link_target(self, file_name):
++        """Return the supplied file name if not a link; else its target."""
++        if not os.path.islink(file_name):
++            return file_name
++        orig_file_name = prev = file_name
++        while os.path.islink(file_name):
++            prev = file_name
++            file_name = os.readlink(file_name)
++        if not os.path.isabs(file_name):
++            file_name = os.path.abspath(os.path.join(os.path.dirname(prev),
++                                                     file_name))
++        if not os.path.exists(file_name):
++            unexpected_error("%s is a broken symbolic link" % orig_file_name)
++        return file_name
+ 
+ class RetainMbox(Mbox):
+     """Class for holding messages that will be retained from the original
+@@ -525,6 +539,7 @@
+         mode =  os.stat(self.__final_name)[stat.ST_MODE]
+         os.chmod(self.mbox_file_name, mode)
+ 
++        self.__final_name = self.get_link_target(self.__final_name)
+         vprint("renaming '%s' to '%s'" % (self.mbox_file_name, self.__final_name))
+         try:
+             os.rename(self.mbox_file_name, self.__final_name)
+@@ -615,6 +630,7 @@
+         final_name = self.__final_name
+         if not options.no_compress:
+             final_name = final_name + ".gz"
++        final_name = self.get_link_target(final_name)
+         vprint("renaming '%s' to '%s'" % (self.mbox_file_name, 
+             final_name))
+         try:
+@@ -1145,9 +1161,6 @@
+         tempfile.tempdir = new_temp_dir
+         vprint("set tempfile directory to '%s'" % new_temp_dir)
+ 
+-        if os.path.islink(mailbox_name):
+-            unexpected_error("'%s' is a symbolic link -- I feel nervous!" % 
+-                mailbox_name)
+         if imap_scheme == 'imap' or imap_scheme == 'imaps':
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/archivemail/archivemail.spec?r1=1.22&r2=1.23&f=u



More information about the pld-cvs-commit mailing list