Linux standalone: Improved process names of linker shimmed programs.

This commit is contained in:
Joey Hess 2015-02-16 19:36:26 -04:00
parent f4c677feeb
commit 88fbb13ee3
5 changed files with 37 additions and 14 deletions

View file

@ -44,31 +44,40 @@ mklibs top = do
-- Various files used by runshell to set up env vars used by the -- Various files used by runshell to set up env vars used by the
-- linker shims. -- linker shims.
writeFile (top </> "libdirs") (unlines libdirs) writeFile (top </> "libdirs") (unlines libdirs)
writeFile (top </> "linker")
(Prelude.head $ filter ("ld-linux" `isInfixOf`) libs')
writeFile (top </> "gconvdir") writeFile (top </> "gconvdir")
(parentDir $ Prelude.head $ filter ("/gconv/" `isInfixOf`) glibclibs) (parentDir $ Prelude.head $ filter ("/gconv/" `isInfixOf`) glibclibs)
mapM_ (installLinkerShim top) exes let linker = Prelude.head $ filter ("ld-linux" `isInfixOf`) libs'
mapM_ (installLinkerShim top linker) exes
{- Installs a linker shim script around a binary. {- Installs a linker shim script around a binary.
- -
- Note that each binary is put into its own separate directory, - Note that each binary is put into its own separate directory,
- to avoid eg git looking for binaries in its directory rather - to avoid eg git looking for binaries in its directory rather
- than in PATH.-} - than in PATH.
installLinkerShim :: FilePath -> FilePath -> IO () -
installLinkerShim top exe = do - The linker is symlinked to a file with the same basename as the binary,
createDirectoryIfMissing True shimdir - since that looks better in ps than "ld-linux.so".
-}
installLinkerShim :: FilePath -> FilePath -> FilePath -> IO ()
installLinkerShim top linker exe = do
createDirectoryIfMissing True (top </> shimdir)
createDirectoryIfMissing True (top </> exedir)
renameFile exe exedest renameFile exe exedest
link <- relPathDirToFile (top </> exedir) (top ++ linker)
unlessM (doesFileExist (top </> exelink)) $
createSymbolicLink link (top </> exelink)
writeFile exe $ unlines writeFile exe $ unlines
[ "#!/bin/sh" [ "#!/bin/sh"
, "exec \"$GIT_ANNEX_LINKER\" --library-path \"$GIT_ANNEX_LD_LIBRARY_PATH\" \"$GIT_ANNEX_SHIMMED/" ++ base ++ "/" ++ base ++ "\" \"$@\"" , "exec \"$GIT_ANNEX_DIR/" ++ exelink ++ "\" --library-path \"$GIT_ANNEX_LD_LIBRARY_PATH\" \"$GIT_ANNEX_DIR/shimmed/" ++ base ++ "/" ++ base ++ "\" \"$@\""
] ]
modifyFileMode exe $ addModes executeModes modifyFileMode exe $ addModes executeModes
where where
base = takeFileName exe base = takeFileName exe
shimdir = top </> "shimmed" </> base shimdir = "shimmed" </> base
exedest = shimdir </> base exedir = "exe"
exedest = top </> shimdir </> base
exelink = exedir </> base
{- Converting symlinks to hard links simplifies the binary shimming {- Converting symlinks to hard links simplifies the binary shimming
- process. -} - process. -}

1
debian/changelog vendored
View file

@ -31,6 +31,7 @@ git-annex (5.20150206) UNRELEASED; urgency=medium
* sync, assistant: Use the ssh-options git config when doing git pull * sync, assistant: Use the ssh-options git config when doing git pull
and push. and push.
* remotedaemon: Use the ssh-options git config. * remotedaemon: Use the ssh-options git config.
* Linux standalone: Improved process names of linker shimmed programs.
-- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400 -- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400

View file

@ -37,3 +37,5 @@ root@koumbit-mp-test:/var/isuma/media/video# ps axf | grep annex
"""]] """]]
couldn't it alter its process name to make this a little more intuitive? This is especially problematic because i am trying to hook git-annex into Puppet and Facter, which require me to guess where the various git-annex repos are on the server. The way i was doing that so far was with `lsof -c 'git-annex' -F0tn`, which is obviously failing under those circumstances.... Unless there's a better way to find those repos across the system? I assume there's a git-annex assistant running here... --[[anarcat]] couldn't it alter its process name to make this a little more intuitive? This is especially problematic because i am trying to hook git-annex into Puppet and Facter, which require me to guess where the various git-annex repos are on the server. The way i was doing that so far was with `lsof -c 'git-annex' -F0tn`, which is obviously failing under those circumstances.... Unless there's a better way to find those repos across the system? I assume there's a git-annex assistant running here... --[[anarcat]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,13 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2015-02-16T23:35:08Z"
content="""
Haskell programs actually cannot alter their process name. I've had a bug
open on ghc for a year about that.
However, I can make a nicer symlink name than ld-linux.so, and use that,
and it will then be clear what program is being run, although the
parameters to it will still be unusual due to the shimming used in the
standalone build.
"""]]

View file

@ -66,10 +66,8 @@ for lib in $(cat $base/libdirs); do
GIT_ANNEX_LD_LIBRARY_PATH="$base/$lib:$GIT_ANNEX_LD_LIBRARY_PATH" GIT_ANNEX_LD_LIBRARY_PATH="$base/$lib:$GIT_ANNEX_LD_LIBRARY_PATH"
done done
export GIT_ANNEX_LD_LIBRARY_PATH export GIT_ANNEX_LD_LIBRARY_PATH
GIT_ANNEX_LINKER="$base/$(cat $base/linker)" GIT_ANNEX_DIR="$base"
export GIT_ANNEX_LINKER export GIT_ANNEX_DIR
GIT_ANNEX_SHIMMED="$base/shimmed"
export GIT_ANNEX_SHIMMED
ORIG_GCONV_PATH="$GCONV_PATH" ORIG_GCONV_PATH="$GCONV_PATH"
export ORIG_GCONV_PATH export ORIG_GCONV_PATH