vitalif / grive2

Google Drive client with support for new Drive REST API and partial sync
http://yourcmc.ru/wiki/Grive2
GNU General Public License v2.0
1.52k stars 141 forks source link

Produce a static binary #375

Open jankatins opened 1 year ago

jankatins commented 1 year ago

I came to love the static binaries produced by go/rust apps. You can download them directly from GitHub releases and put them into your local path and be done. It would be nice to have this for grive, too.

Currently I have to rebuild grive (debian packages) a lot because some of the dependencies on debian unstable has an api change and so changes the soname version and grive is not in debian and therefore not automatically rebuild in such transitions.

I can build github pipelines to produce binaries for different platform, but I have no idea how to change the build pipeline to produce a static binary instead of a dynamically linked one.

jumoog commented 1 year ago

I have been working on this a little bit. You have to build almost all dependencies yourself so they are not dynamic. I have given up on it.

hubyhuby commented 1 year ago

Dear @jumoog Do you have a binary for the current grive2 installation o Ubuntu 22 AMD ? Thanks for your help, for now I am strungeling with compilation : https://github.com/vitalif/grive2/issues/374

jankatins commented 1 year ago

This is a very quick and dirty way to build an appimage for grive, which includes all relevant libraries (debian unstable)...

# Prepare dependencies and tools
λ  wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
λ  chmod +x linuxdeploy*.AppImage
λ  sudo apt install --mark-auto cmake pkg-config zlib1g-dev libcurl4-openssl-dev  libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-regex-dev libexpat1-dev libgcrypt-dev libyajl-dev

# Install into ./AppDir
λ  cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DHAVE_SYSTEMD=1
λ  make -j`nproc`  install DESTDIR=AppDir

# Create necessary desktop file -> AppImages do not work without, for whatever reason
λ  printf "[Desktop Entry]\nName=grive\nExec=grive\nIcon=grive\nType=Application\nTerminal=true\nCategories=Utility;\n" > grive.desktop

# xterm icon chosen at random... :-/
# For some reason the version cannot be computed 
λ  VERSION=0.5.3 ./linuxdeploy-x86_64.AppImage --appdir AppDir -e AppDir/usr/bin/grive -d ./grive.desktop -i /usr/share/icons/hicolor/48x48/apps/xterm.png --output appimage

# Just to see if it works
λ  ./grive-0.5.3-x86_64.AppImage --help

grive-0.5.3-x86_64.AppImage is 23MB compared to the 1.5MB of the grive binary itself.

I haven't tested this further, but I really like this... The only problem is that I would have to manually get the systemd/script files to run it as a service.