diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-28 19:08:13 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-28 19:08:13 -0400 |
commit | edb563a78e51560e8f68d9d61a40f8c4a4963660 (patch) | |
tree | 0b0f3e2d5627728cbaa9040eca1e570167a48445 | |
parent | d70534eb5733e4669fb3b636397ee7acd76948a1 (diff) |
standalone linux app nearly ready
also made several fixes that apply to the OSX app
-rw-r--r-- | Assistant/Install.hs | 22 | ||||
-rw-r--r-- | Assistant/Install/AutoStart.hs | 24 | ||||
-rw-r--r-- | Build/InstallDesktopFile.hs | 2 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | standalone/licences.gz (renamed from doc/license/git-annex-osx.app-licences.gz) | bin | 55592 -> 55614 bytes | |||
-rw-r--r-- | standalone/linux/README | 23 | ||||
-rwxr-xr-x | standalone/linux/git-annex-webapp | 25 | ||||
-rw-r--r-- | standalone/linux/glibc-libs | 43 | ||||
-rwxr-xr-x | standalone/linux/runshell | 48 | ||||
-rwxr-xr-x | ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp | 10 |
10 files changed, 184 insertions, 17 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs index d2bd2c545..9b950ea4b 100644 --- a/Assistant/Install.hs +++ b/Assistant/Install.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.Install where import Assistant.Common @@ -12,14 +14,15 @@ import Assistant.Install.AutoStart import Assistant.Ssh import Locations.UserConfig import Utility.FileMode +import Utility.FreeDesktop import Utility.OSX import System.Posix.Env -standaloneOSXAppBase :: IO (Maybe FilePath) -standaloneOSXAppBase = getEnv "GIT_ANNEX_OSX_APP_BASE" +standaloneAppBase :: IO (Maybe FilePath) +standaloneAppBase = getEnv "GIT_ANNEX_APP_BASE" -{- The OSX git-annex.app does not have an installation process. +{- The standalone app does not have an installation process. - So when it's run, it needs to set up autostarting of the assistant - daemon, as well as writing the programFile, and putting a - git-annex-shell wrapper into ~/.ssh @@ -28,16 +31,21 @@ standaloneOSXAppBase = getEnv "GIT_ANNEX_OSX_APP_BASE" - it around, the paths this sets up won't break. -} ensureInstalled :: IO () -ensureInstalled = go =<< standaloneOSXAppBase +ensureInstalled = go =<< standaloneAppBase where go Nothing = noop go (Just base) = do - let program = base ++ "/bin/git-annex" + let program = base ++ "runshell git-annex" programfile <- programFile createDirectoryIfMissing True (parentDir programfile) writeFile programfile program - autostartfile <- userAutoStart autoStartLabel +#ifdef darwin_HOST_OS + autostartfile <- userAutoStart osxAutoStartLabel +#else + autostartfile <- autoStartPath "git-annex" + <$> userConfigDir +#endif installAutoStart program autostartfile {- This shim is only updated if it doesn't @@ -52,7 +60,7 @@ ensureInstalled = go =<< standaloneOSXAppBase , "exec", base </> "runshell" ++ " git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"" ] - curr <- catchDefaultIO "" $ readFile shim + curr <- catchDefaultIO "" $ readFileStrict shim when (curr /= content) $ do createDirectoryIfMissing True (parentDir shim) writeFile shim content diff --git a/Assistant/Install/AutoStart.hs b/Assistant/Install/AutoStart.hs index 692774939..85ce98287 100644 --- a/Assistant/Install/AutoStart.hs +++ b/Assistant/Install/AutoStart.hs @@ -1,23 +1,37 @@ -{- Assistant OSX autostart file installation +{- Assistant autostart file installation - - Copyright 2012 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.Install.AutoStart where +import Utility.FreeDesktop import Utility.OSX import Utility.Path import System.Directory -{- Installs an autostart plist file for OSX. -} installAutoStart :: FilePath -> FilePath -> IO () installAutoStart command file = do +#ifdef darwin_HOST_OS createDirectoryIfMissing True (parentDir file) - writeFile file $ genOSXAutoStartFile autoStartLabel command + writeFile file $ genOSXAutoStartFile osxAutoStartLabel command ["assistant", "--autostart"] +#else + writeDesktopMenuFile (fdoAutostart command) file +#endif + +osxAutoStartLabel :: String +osxAutoStartLabel = "com.branchable.git-annex.assistant" -autoStartLabel :: String -autoStartLabel = "com.branchable.git-annex.assistant" +fdoAutostart :: FilePath -> DesktopEntry +fdoAutostart command = genDesktopEntry + "Git Annex Assistant" + "Autostart" + False + (command ++ " assistant --autostart") + [] diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs index b4d9251e6..7bf97a0dd 100644 --- a/Build/InstallDesktopFile.hs +++ b/Build/InstallDesktopFile.hs @@ -64,7 +64,7 @@ writeFDODesktop command = do =<< inDestDir (desktopMenuFilePath "git-annex" datadir) configdir <- ifM systemwideInstall ( return systemConfigDir, userConfigDir ) - writeDesktopMenuFile (autostart command) + installAutoStart command =<< inDestDir (autoStartPath "git-annex" configdir) writeOSXDesktop :: FilePath -> IO () @@ -148,7 +148,7 @@ linuxstandalone: $(bins) cp git-annex "$(LINUXSTANDALONE_DEST)/bin/" strip "$(LINUXSTANDALONE_DEST)/bin/git-annex" ln -sf git-annex "$(LINUXSTANDALONE_DEST)/bin/git-annex-shell" - zcat doc/license/git-annex-osx.app-licences.gz > $(LINUXSTANDALONE_DEST)/LICENSE + zcat standalone/licences.gz > $(LINUXSTANDALONE_DEST)/LICENSE for bin in $(THIRDPARTY_BINS); do \ cp "$$(which "$$bin")" "$(LINUXSTANDALONE_DEST)/bin/" || echo "$$bin not available; skipping"; \ @@ -184,7 +184,7 @@ osxapp: $(bins) cp git-annex "$(OSXAPP_BASE)/bin/" strip "$(OSXAPP_BASE)/bin/git-annex" ln -sf git-annex "$(OSXAPP_BASE)/bin/git-annex-shell" - gzcat doc/license/git-annex-osx.app-licences.gz > $(OSXAPP_BASE)/LICENSE + gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE cp $(OSXAPP_BASE)/LICENSE $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/LICENSE.txt for bin in $(THIRDPARTY_BINS); do \ diff --git a/doc/license/git-annex-osx.app-licences.gz b/standalone/licences.gz Binary files differindex aa4923dd5..01b5d556e 100644 --- a/doc/license/git-annex-osx.app-licences.gz +++ b/standalone/licences.gz diff --git a/standalone/linux/README b/standalone/linux/README new file mode 100644 index 000000000..8ca68c901 --- /dev/null +++ b/standalone/linux/README @@ -0,0 +1,23 @@ +To start the git-annex webapp, run the git-annex-webapp script in this +directory. + +To enter an environment with git-annex in PATH, use runshell + +This should work on any Linux system of the appropriate architecture. +More or less. There are no external dependencies, except for glibc. +Any recent-ish version of glibc should work (2.13 is ok; so is 2.11). + + +How it works: This directory contains a lot of libraries and programs +that git-annex needs. But it's not a chroot. Instead, runshell sets +PATH and LD_LIBRARY_PATH to point to the stuff in this directory. + +The glibc libs are not included. Instead, it runs with the host system's +glibc. We trust that glibc's excellent backwards and forward compatability +is good enough to run binaries that were linked for a newer or older +version. Of course, this could fail. Particularly if the binaries try to +use some new glibc feature. But hopefully not. + +Why not bundle glibc too? I've not gotten it to work! The host system's +ld-linux.so will be used for sure, as that's hardcoded into the binaries. +When I tried including libraries from glibc in here, everything segfaulted. diff --git a/standalone/linux/git-annex-webapp b/standalone/linux/git-annex-webapp new file mode 100755 index 000000000..61a9bbbeb --- /dev/null +++ b/standalone/linux/git-annex-webapp @@ -0,0 +1,25 @@ +#!/bin/sh +base="$(dirname $0)" +if [ ! -d "$base" ]; then + echo "** cannot find base directory (I seem to be $0)" >&2 + exit 1 +fi +if [ ! -e "$base/runshell" ]; then + echo "** cannot find $base/runshell" >&2 + exit 1 +fi + +# Get absolute path to base, to avoid breakage when things change directories. +orig="$(pwd)" +cd "$base" +base="$(pwd)" +cd "$orig" + +# If this is a standalone app, set a variable that git-annex can use to +# install itself. +if [ -e "$base/bin/git-annex" ]; then + GIT_ANNEX_APP_BASE="$base" + export GIT_ANNEX_APP_BASE +fi + +"$base/runshell" git-annex webapp "$@" diff --git a/standalone/linux/glibc-libs b/standalone/linux/glibc-libs new file mode 100644 index 000000000..3f6e64112 --- /dev/null +++ b/standalone/linux/glibc-libs @@ -0,0 +1,43 @@ +libanl-.*.so +libutil-.*.so +libnss_hesiod-.*.so +libcrypt-.*.so +libnss_compat-.*.so +libm-.*.so +libr.so +libpcprofile.so +libnss_nis-.*.so +libSegFault.so +libpthread-.*.so +librt-.*.so +libnss_dns-.*.so +libdl-.*.so +libBrokenLocale-.*.so +libnss_nisplus-.*.so +libthread_db-1.0.so +libmemusage.so +libcidn-.*.so +libnss_files-.*.so +libnsl-.*.so +libc-.*.so +ld-.*.so +libnss_nis.so +libthread_db.so +libanl.so +libr.so +libnss_compat.so +libm.so +libnss_dns.so +libpthread.so +libc.so +librt.so +libcidn.so +libnss_nisplus.so +libnsl.so +libutil.so +libBrokenLocale.so +ld-linux.so +libnss_files.so +libdl.so +libnss_hesiod.so +libcrypt.so diff --git a/standalone/linux/runshell b/standalone/linux/runshell new file mode 100755 index 000000000..da26cd3ba --- /dev/null +++ b/standalone/linux/runshell @@ -0,0 +1,48 @@ +#!/bin/sh +# Runs a shell command (or interactive shell) using the binaries and +# libraries bundled with this app. + +set -e + +base="$(dirname $0)" + +if [ ! -d "$base" ]; then + echo "** cannot find base directory (I seem to be $0)" >&2 + exit 1 +fi + +if [ ! -e "$base/bin/git-annex" ]; then + echo "** base directory $base does not contain bin/git-annex" >&2 + exit 1 +fi +if [ ! -e "$base/bin/git" ]; then + echo "** base directory $base does not contain bin/git" >&2 + exit 1 +fi + +# Get absolute path to base, to avoid breakage when things change directories. +orig="$(pwd)" +cd "$base" +base="$(pwd)" +cd "$orig" + +# Put our binaries first, to avoid issues with out of date or incompatable +# system binaries. +PATH=$base/bin:$PATH +export PATH + +for lib in $(cat $base/libdirs); do + LD_LIBRARY_PATH="$base/$lib:$LD_LIBRARY_PATH" +done +export LD_LIBRARY_PATH + +GIT_EXEC_PATH=$base/git-core +export GIT_EXEC_PATH + +if [ "$1" ]; then + cmd="$1" + shift 1 + exec "$cmd" "$@" +else + $SHELL +fi diff --git a/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp b/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp index 565c3d1cb..61a9bbbeb 100755 --- a/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp +++ b/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp @@ -9,11 +9,17 @@ if [ ! -e "$base/runshell" ]; then exit 1 fi +# Get absolute path to base, to avoid breakage when things change directories. +orig="$(pwd)" +cd "$base" +base="$(pwd)" +cd "$orig" + # If this is a standalone app, set a variable that git-annex can use to # install itself. if [ -e "$base/bin/git-annex" ]; then - GIT_ANNEX_OSX_APP_BASE="$base" - export GIT_ANNEX_OSX_APP_BASE + GIT_ANNEX_APP_BASE="$base" + export GIT_ANNEX_APP_BASE fi "$base/runshell" git-annex webapp "$@" |