7/01/2008

GmailFS with MacPorts

Hi everyone!

I've been using MacPorts for quite some time, and I have been very pleased with its simplicity, specially since I am much more used to FreeBSD's amazing ports system. For those who don't know, MacPorts is basically a system of tools that makes it easier for you and everyone to keep a great collection of UNIX software applications up-to-date, without the annoying task of managing all the dependencies or patching some software project (hence the word "port") that was intended to run on Linux or other platform, and that could easily run on a Mac just by changing a line in some file (I'm not exagerating).

These days I've become interested in GMailFS, a software package that allows you to see (technically "mount") a directory in your filesystem (inside your home directory for example) in user space (i.e., outside the kernel space), so you can mount it without any privileges. GMailFS sits on top of FUSE (Filesystem in Userspace), more specifically on top of MacFUSE which in turn was ported by Google, and allows you to see your GMail account as a set of files and directories so you can actually download and upload files to your account with a couple of drag-n-drops with Finder :)

Since I was having problems installing this on my Mac, I've seen many forums with discussions regarding the installation procedures. In the end it all involved a lot of tricks and hacks, and never worked for the latest software versions of the packages that are required to set up GMailFS.

For these reasons I decided to stick with MacPorts (which I believe is a much cleaner and elegant way to manage sofware). Since there was no GMailFS port in MacPorts, not even support for most dependencies, I got in contact with the development team (thanks Raim), and provided feedback enough so a port with all the dependencies for GMailFS was created :)

For those who might be wondering how to get GMailFS working with MacPorts:


  • Download a fresh copy of MacPorts from here

  • Update your MacPorts tree of ports by opening a terminal and issuing the command sudo port sync

  • Install GMailFS by issuing the command sudo port install gmailfs



Please make sure you have python2.5 selected by default, if you don't know or don't have, you can try the following:

  • Install python_select by issuing the command sudo port install python_select

  • Select python2.5 as the default python interpreter sudo python_select python25



Along the way you will be asked for your password in your Terminal, after you issue a sudo command. This is equivalent to MacOS X's GUI prompt for a password every time you install an application with some installer.

Then you can just create a hidden GMailFS configuration file in your home directory as ~/.gmailfs with a content similar to:


[connection]
# The proxy URL
#proxy = http://user:pass@proxyhost:port
# or just
#proxy = http://proxyhost:port

# The number or retries for the proxy connection.
#retries = 3

[account]
username = your_username
password = your_password_in_plaintext

[filesystem]
fsname = zOlRRaXPTOzOlRRa

[references]
# reference = filesystem:username:password

[logs]
# Change this to DEBUG for verbose output (useful for debugging)
level = INFO

# if you'd like logs to go to stdout, comment out this variable.
# For logging to, say, stderr, use /dev/stderr of your system's
# equivalent for it
logfile = /dev/stderr


After this, you can mount your GMailFS issuing a command like:

mount -ovolname=gmail,ping_diskarb -t gmailfs /opt/local/share/gmailfs/gmailfs.py path_for_the_directory_where_you_want_to_mount_your_gmailfs


After you have mounted the filesystem, you can copy files from and to it, and you will see your gmail account populated with "weird" emails. That's where the string zOlRRaXPTOzOlRRa I used in the sample configuration file above comes in (by the way, you can change this string to anything else): GMailFS will keep emails in your account with subjects containing the word zOlRRaXPTOzOlRRa. Since such emails in your Inbox can become distracting, you can filter them out by archiving them with a GMail filter like the following:



Please note that I added __g__zOlRRaXPTOzOlRRa__h__ instead of just zOlRRaXPTOzOlRRa, since the real email in your inbox will contain a word with a prefix and suffix, making the word become like this.

Have fun!

6 comments:

Moze said...

Hi, I allways was windwos user and used gmaildrive. Recently i bought a macbook and now i'm totaly mac :). I was very happy when i found this post, because i was lacking of gmaildrive.

I'm having problem at moment, when i'm trying to mount drive "$ mount -ovolname=gmail,ping_diskarb -t gmailfs /opt/local/share/gmailfs/gmailfs.py /" i get this: "Ignored option :ping_diskarb
Traceback (most recent call last):
File "/sbin/mount_gmailfs", line 159, in [module>
import gmailfs
File "/opt/local/share/gmailfs/gmailfs.py", line 20, in [module>
import fuse
File "/opt/local/lib/python2.5/site-packages/fuse.py", line 26, in [module>
from fuseparts._fuse import main, FuseGetContext, FuseInvalidate
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/fuseparts/_fusemodule.so, 2): Symbol not found: _iconv
Referenced from: /opt/local/lib/libfuse.0.dylib
Expected in: flat namespace
"
I'm new to macs and programing so it says nothing to me. Can you help me with it?

imkira said...

Hi Moze, thanks for the input. Actually I have not been dealing much lately with gmailfs but it sounds like you're having a problem with libiconv. Try temporarily disabling libiconv by issuing the command sudo port deactivate libiconv on a terminal.

I believe a fix for this is already in progress, but for the meantime I think you can use this workaroud.

Best regards

Moze said...

Well now i get other problem. But it looks like gmailfs connects to gmail, because after each try i find 2 messages in mailbox. Here is log from terminal:

Mozes-MacBook:~ Moze$ mount -ovolname=gmail,ping_diskarb -t gmailfs /opt/local/share/gmailfs/gmailfs.py ~
Ignored option :update
01/15/09 20:11:51 ERROR OpenSSLProxy is missing. Can't use HTTPS proxy!
01/15/09 20:11:51 INFO waiting for / to become a mountpoint
01/15/09 20:11:51 INFO / is now a mountpoint
01/15/09 20:11:51 INFO Starting gmailfs in child process (PID 260)
01/15/09 20:11:51 INFO Mountpoint: /
01/15/09 20:11:51 INFO Named mount options: {'password': '********'}
01/15/09 20:11:51 WARNING mount: warning, should mount with username=gmailuser option, using default
01/15/09 20:11:51 WARNING mount: warning, should mount with password=gmailpass option, using default
01/15/09 20:11:51 WARNING mount: warning, should mount with fsname=name option, using default
Mozes-MacBook:~ Moze$ The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
.
.
rpeats for ±100 lines more
.
.
__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
01/15/09 20:11:54 INFO Connected to gmail
kextload: /Library/Filesystems/fusefs.fs/Support/fusefs.kext loaded successfully
01/15/09 20:11:54 ERROR gmailfs child died, exiting...

After this nothing works and i have to restart my mac.

imkira said...

You should not use ~ or / as the destination mount point. You should pass something like ~/Desktop/gmailfs or something else so that it does not conflict with existing directories and files. For instance, try
mkdir ~/Desktop/gmailfs
mount -ovolname=gmail -t gmailfs /opt/local/share/gmailfs/gmailfs.py ~/Desktop/gmailfs/

This is probably the reason why your system is unusable after you try mounting your gmail filesystem. Nevertheless, I have been able to "apparently" mount it. but gmailfs immediately dies after that:

01/16/09 12:55:05 INFO Connected to gmail
01/16/09 12:55:05 ERROR gmailfs child died, exiting...

Like I told you I have not been dealing lately with gmailfs so I don't know if there is a fix for this already. If there is none, the developers or someone else should be already working on this... If you get to know how to fix this, please let me know.

Best regards.

Moze said...

Thanks for all help. I will inform you if i'll find a solution.

Unknown said...

hey moze, i'm at the same point you are. let me know if you find anything out and i'll do the same!
cheers,
k