Makefile: Added install-home target which installs git-annex into the HOME directory

This commit is contained in:
Joey Hess 2019-03-18 12:33:56 -04:00
parent 95e94b9d00
commit 6491b62614
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 83 additions and 17 deletions

View file

@ -29,12 +29,12 @@ import Prelude
systemwideInstall :: IO Bool systemwideInstall :: IO Bool
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
systemwideInstall = isroot <||> destdirset systemwideInstall = isroot <||> (not <$> userdirset)
where where
isroot = do isroot = do
uid <- fromIntegral <$> getRealUserID uid <- fromIntegral <$> getRealUserID
return $ uid == (0 :: Int) return $ uid == (0 :: Int)
destdirset = isJust <$> catchMaybeIO (getEnv "DESTDIR") userdirset = isJust <$> catchMaybeIO (getEnv "USERDIR")
#else #else
systemwideInstall = return False systemwideInstall = return False
#endif #endif

View file

@ -21,6 +21,8 @@ git-annex (7.20190220) UNRELEASED; urgency=medium
* S3: Support enabling bucket versioning when built with aws-0.21.1. * S3: Support enabling bucket versioning when built with aws-0.21.1.
* stack.yaml: Build with aws-0.21.1 * stack.yaml: Build with aws-0.21.1
* Fix cleanup of git-annex:export.log after git-annex forget --drop-dead. * Fix cleanup of git-annex:export.log after git-annex forget --drop-dead.
* Makefile: Added install-home target which installs git-annex into
the HOME directory.
-- Joey Hess <id@joeyh.name> Wed, 20 Feb 2019 14:20:59 -0400 -- Joey Hess <id@joeyh.name> Wed, 20 Feb 2019 14:20:59 -0400

View file

@ -56,7 +56,7 @@ removeAutoStartFile path = do
modifyAutoStartFile $ modifyAutoStartFile $
filter (not . equalFilePath path') filter (not . equalFilePath path')
{- The path to git-annex is written here; which is useful when cabal {- The path to git-annex is written here; which is useful when something
- has installed it to some awful non-PATH location. -} - has installed it to some awful non-PATH location. -}
programFile :: IO FilePath programFile :: IO FilePath
programFile = userConfigFile "program" programFile = userConfigFile "program"

View file

@ -18,6 +18,16 @@ endif
build: $(all) build: $(all)
# install system-wide
# Set PREFIX and DESTDIR to configure where it is installed
install: install-bins install-docs install-desktop
# installs into your home directory
install-home:
$(MAKE) install-bins PREFIX=$(HOME)/.local
$(MAKE) install-mans PREFIX=$(HOME)/.local
$(MAKE) install-desktop PREFIX=$(HOME)/.local USERDIR=1
tmp/configure-stamp: Build/TestConfig.hs Build/Configure.hs tmp/configure-stamp: Build/TestConfig.hs Build/Configure.hs
if [ "$(BUILDER)" = ./Setup ]; then ghc --make Setup; fi if [ "$(BUILDER)" = ./Setup ]; then ghc --make Setup; fi
if [ "$(BUILDER)" != stack ]; then \ if [ "$(BUILDER)" != stack ]; then \
@ -61,8 +71,10 @@ install-bins: build
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-tor-annex ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-tor-annex
install-misc: build Build/InstallDesktopFile install-desktop: build Build/InstallDesktopFile
./Build/InstallDesktopFile $(PREFIX)/bin/git-annex || true ./Build/InstallDesktopFile $(PREFIX)/bin/git-annex || true
install-completions:
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions
install -m 0644 bash-completion.bash $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions/git-annex install -m 0644 bash-completion.bash $(DESTDIR)$(PREFIX)/$(SHAREDIR)/bash-completion/completions/git-annex
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/zsh/vendor-completions install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/zsh/vendor-completions
@ -72,8 +84,6 @@ install-misc: build Build/InstallDesktopFile
@./git-annex --fish-completion-script git-annex 2>/dev/null > $(DESTDIR)$(PREFIX)/$(SHAREDIR)/fish/completions/git-annex.fish || \ @./git-annex --fish-completion-script git-annex 2>/dev/null > $(DESTDIR)$(PREFIX)/$(SHAREDIR)/fish/completions/git-annex.fish || \
echo "** fish completions not installed; built with too old version of optparse-applicative" echo "** fish completions not installed; built with too old version of optparse-applicative"
install: install-bins install-docs install-misc
test: git-annex git-annex-shell test: git-annex git-annex-shell
./git-annex test ./git-annex test

View file

@ -1,3 +1,6 @@
git-annex uses copyHook in Setup.hs to create/install man pages, .desktop file and etc. git-annex uses copyHook in Setup.hs to create/install man pages, .desktop file and etc.
I'm using cabal new-build/new-install to install it, and these copyHooks don't get called. I reported it to Cabal, but they replied that this should be fixed on git-annex side: https://github.com/haskell/cabal/issues/5933 I'm using cabal new-build/new-install to install it, and these copyHooks don't get called. I reported it to Cabal, but they replied that this should be fixed on git-annex side: https://github.com/haskell/cabal/issues/5933
> [[done]], make install-home. Can't be done in Setup.hs for new-build so
> this is the best that can be done. --[[Joey]]

View file

@ -0,0 +1,16 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2019-03-18T15:22:46Z"
content="""
stack install also bypasses the custom postCopy. It's not been much of a
problem. git-annex's Makefile can use either system to build, and does a
much better job of installing all needed files.
I've updated the install/fromsource page to point the user toward
`make install` more. Also added a `make install-home` target.
But I've kept support for using cabal install because users may be relying
on that installation method. If cabal switches to new-build by default
and it stops working, it can be removed then.
"""]]

View file

@ -3,6 +3,9 @@ users with experience building code from source. But the build may
require some care and feeding. This page will start with the easy require some care and feeding. This page will start with the easy
methods and work up to the harder ones. methods and work up to the harder ones.
This page also covers installing git-annex from source, but in many
cases it's better to install it using your OS's package manager.
## downloading the source code ## downloading the source code
The easiest way is using git; see [[download]] or just run: The easiest way is using git; see [[download]] or just run:
@ -18,8 +21,17 @@ First, install everything git-annex needs to build:
sudo apt-get build-dep git-annex sudo apt-get build-dep git-annex
Now you can build git-annex by running either `make` or `cabal build` Now you can build git-annex by running `make` inside the source tree.
inside the source tree.
Then, to install the program and associated files system-wide in `/usr/local`,
run:
sudo make install PREFIX=/usr/local
Or, to install the program into $HOME/.local/bin, and associated files
into other parts of your HOME directory, run:
make install-home
## building from source with stack ## building from source with stack
@ -34,21 +46,28 @@ On Debian:
Get the git-annex source code, and inside the source tree run: Get the git-annex source code, and inside the source tree run:
stack setup stack setup
stack install stack build
Move git-annex into some directory that is in your PATH: To install the program and all associated files system-wide
in `/usr/local`, run:
mv ~/.local/bin/git-annex ~/bin # or /usr/local/bin/ or whatever sudo make install BUILDER=stack PREFIX=/usr/local
Or, to install the program into $HOME/.local/bin, and associated files
into other parts of your HOME directory, run:
make install-home BUILDER=stack
(Why not run `stack install git-annex`? Because that causes stack to (Why not run `stack install git-annex`? Because that causes stack to
[ignore git-annex's stack.yaml file](https://github.com/commercialhaskell/stack/issues/2371), [ignore git-annex's stack.yaml file](https://github.com/commercialhaskell/stack/issues/2371),
yielding a less reliable build.) yielding a less reliable build. Stack also only installs the binary,
and not other files.)
Note that this build produces a git-annex without the build flags Note that this build produces a git-annex without the build flags
XMPP, DBUS, and MagicMime. XMPP, DBUS, and MagicMime.
These optional features require installing additional C libraries. These optional features require installing additional C libraries.
To try to build with these features To try to build with these features
enabled, pass extra parameters when running stack install: enabled, pass extra parameters when running `stack build`:
`--flag git-annex:XMPP --flag git-annex:DBUS --flag git-annex:MagicMime` `--flag git-annex:XMPP --flag git-annex:DBUS --flag git-annex:MagicMime`
## minimal build from source with cabal ## minimal build from source with cabal
@ -67,8 +86,16 @@ Get the git-annex source code, and inside the source tree, run:
cabal install -j -f"-assistant -webapp -webdav -pairing -dbus -magicmime" --only-dependencies cabal install -j -f"-assistant -webapp -webdav -pairing -dbus -magicmime" --only-dependencies
cabal configure -f"-assistant -webapp -webdav -pairing -dbus -magicmime" cabal configure -f"-assistant -webapp -webdav -pairing -dbus -magicmime"
cabal build -j cabal build -j
PATH=$HOME/bin:$PATH
cabal install --bindir=$HOME/bin To install the program and all associated files system-wide
in `/usr/local`, run:
sudo make install BUILDER=cabal PREFIX=/usr/local
Or, to install the program into $HOME/.local/bin, and associated files
into other parts of your HOME directory, run:
make install-home BUILDER=cabal
## full build from source with cabal ## full build from source with cabal
@ -82,5 +109,13 @@ Once the C libraries are installed, run inside the source tree:
cabal install -j --only-dependencies cabal install -j --only-dependencies
cabal configure cabal configure
cabal build -j cabal build -j
PATH=$HOME/bin:$PATH
cabal install --bindir=$HOME/bin To install the program and all associated files system-wide
in `/usr/local`, run:
sudo make install BUILDER=cabal PREFIX=/usr/local
Or, to install the program into $HOME/.local/bin, and associated files
into other parts of your HOME directory, run:
make install-home BUILDER=cabal