GNU stow linking all files instead of only binary

stow

What must I do to have stow only linking the binaries (and maybe the man pages) correctly?

I want to use GNU stow to manage local installs on my machine. However, stow does not simply symlinks the binary, but all files in the program folder.
What I did so far:

  • created an extended stow-ignore file
  • use a subfolder src/ where all files except the binary go and manually change the Makefile to create a bin/ subfolder. Then later delete the linked local/src/ folder

I guess there must be a better way and I am using stow wrong.

Example

Folder structure

~home/
 |~local/
   |+bin/     <-- binarys should go here
   |+share/   <-- man page
   |~stow/
     |-.stowrc
     |~dwm-6.0/
       |-Makefile
       |-dwm.c
       |-dwm.h
       |-dwm
       |-config.mk
       |-README
     |~hub-1.11/
       |~bin/
         |-hub
       |+etc/
       |+feature/
       |+githook/
       |+lib/
       |-Gemfile
       |-Rakefile
       |-hub.gemspec

From here I would go into the stow/ folder type

stow dwm-6.0

Then stow links all files into the local/ folder, instead of only the binary dwm into the local/bin/ folder. I can now change the Makefile so it creates a dwm-6.0/bin/ folder and moves the binary in there. Then stow at least will link dwm to local/bin/, but still all other files are linked to local/ as well.

The same goes for hub:

[9962]../stow:$stow hub-1.11.1
Loading defaults from .stowrc
stow dir is /home/myusername/local/stow
stow dir path relative to target /home/myusername/local is stow
Planning stow of package hub-1.11.1...
LINK: man => stow/hub-1.11.1/man
LINK: test => stow/hub-1.11.1/test
LINK: hub.gemspec => stow/hub-1.11.1/hub.gemspec
LINK: script => stow/hub-1.11.1/script
LINK: etc => stow/hub-1.11.1/etc
LINK: lib => stow/hub-1.11.1/lib
LINK: hub => stow/hub-1.11.1/hub
LINK: bin/hub => ../stow/hub-1.11.1/bin/hub
LINK: git-hooks => stow/hub-1.11.1/git-hooks
LINK: Rakefile => stow/hub-1.11.1/Rakefile
LINK: Gemfile => stow/hub-1.11.1/Gemfile
LINK: features => stow/hub-1.11.1/features
Planning stow of package hub-1.11.1... done
Processing tasks...
Processing tasks... done

Now stow even links the man files to a separate folder instead of using share/

===

.stow-global-ignore

# Comments and blank lines are allowed.

RCS
.+,v

CVS
\.\#.+       # CVS conflict files / emacs lock files
\.cvsignore

\.svn
_darcs
\.hg

\.git
\.gitignore


.+~          # emacs backup files
\#.*\#       # emacs autosave files
.*\.c        # c src files 
.*\.cc       # c++ src files 
#.*\.\d       # compile temporary files 
#.*\.\d\..*       # compile temporary files 
.*\.o        # object files
.*\.h        # include files
.*\.info
.*\.mk       # make configs
.*\.swp      # vim temp buffer file
.*\.lock     # vim temp buffer file
.*\.md       # mark down 
.*\.yml      # YAML
#.*\.gemspec  # gem file
#.*\.rb       # ruby file
#.*\.sh       # shell file
#.*\.feature  # shell file
README.*
LICENSE
FAQ
LEGACY
TODO
Makefile

.stowrc

--dir=/home/myusername/local/stow
--target=/home/myusername/local

Best Answer

One approach would be to use local ignore lists, one per package.

However, I believe your approach is fundamentally the wrong one which is making your life unnecessarily hard. The problem is that you are not distinguishing between files needed at build-time vs. files needed at run-time. Directories like ~/local/stow/dwm-6.0/ are package directories which are supposed to contain installation images, not source code or other resources only intended for use at build-time.

The correct workflow is as follows:

  1. Download the source code into a directory totally ignored by Stow (e.g. ~/src).
  2. Build and install from the source into ~/local/stow/dwm-6.0/ (the manual has lots of tips on how to achieve this)
  3. Verify that ~/local/stow/dwm-6.0/ only contains directories files required at runtime (files under bin/, man/ etc.)
  4. stow dwm-6.0