[Installation] A substitute solution to using Google Drive in Ubuntu

Grive2

Get dependencies

You need to get the dependency libraries along with their development (-dev or -devel) packages:

  • yajl 2.x
  • libcurl
  • STL (libstdc++)
  • libgcrypt
  • Boost (filesystem, program_options, regex, unit_test_framework and system)
  • expat

There are also some optional dependencies:

  • CppUnit (for unit tests)
  • libbfd (for backtrace)
  • binutils (for libiberty, required for compilation in OpenSUSE, Ubuntu, Arch and etc)

And tools:

  • Git
  • CMake
  • C++ compiler (g++ or clang)

On a Debian/Ubuntu/Linux Mint machine just install the following packages:

sudo apt-get install git cmake build-essential libgcrypt11-dev libyajl-dev libboost-all-dev libcurl4-openssl-dev libexpat1-dev libcppunit-dev binutils-dev

Download sources

CMake

Now that you are in the source code's “grive2” subdirectory (after 'cd /path/to/yourGriveSourceCodeDir/grive2'), at the prompt type:

mkdir build
cd build
cmake ..
  • note the double period (..) as the argument to cmake, to denote the parent directory.
  • You should get a success message like: ”– Build files have been written to: /your/dir”
  • Don't run it with sudo - root access is not needed for building.

Make and install

At the prompt type:

make -j4

You'll get lots of messages & hopefully a success message: ”[100%] Built target grive_executable”. The executable file itself (called “grive”) will be placed in the “grive” subdirectory.

Then install it to the system binary directory (/usr/local/bin by default) by running:

sudo make install

Updates

For subsequent updates, you'll run `git pull` to get the latest source and then just rebuild and re-install it:

cd /path/to/yourGriveSourceCodeDir/grive2
git pull
cd build
cmake ..
make -j4
sudo make install

Usage

Backup

Since grive is still «beta» or «alpha» you should better keep a backup copy of your google directory.

First run

Change to your google drive sync directory, and run grive -a:

cd /home/you/yourGoogleDrive/
grive -a

 The «-a» option is only needed the very first time you run grive.

Visit the URL that comes up, then post the auth code given (you must have been logged into Google). You should get some messages including «Synchronizing files» … now you are running.

Syncs

To sync, you must run the program manually (there is no «real-time watching» yet). At the prompt, type:

cd /home/you/yourGoogleDrive/
grive

You can set up a cron job, if you want this done on a regular basis.

Command line options

Short optionLong optionDescription
-h --help Produce help message
-v --version Display Grive version
-a --auth Request authorization token
-p arg --path arg Root directory to sync
-s arg --dir arg Single subdirectory to sync (remembered for next runs)
-V --verbose Verbose mode. Enable more messages than normal.
  --log-http arg Log all HTTP responses in this file for debugging.
  --new-rev Create new revisions in server for updated files.
-d --debug Enable debug level messages. Implies -v.
-l arg --log arg Set log output filename.
-f --force Force grive to always download a file from Google Drive instead of uploading it.
  --dry-run Only detect which files need to be uploaded/downloaded, without actually performing them.
  --ignore arg Perl RegExp to ignore files (matched against relative paths, remembered for next runs).

原文地址:https://www.cnblogs.com/casperwin/p/6209762.html