Accept a name for dl and include starter script file
[khome.git] / Makefile
index 02522ba..7a32ec4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,39 @@
 MAKEFLAGS := --no-builtin-rules
+SHELL     := /bin/bash
 
 DEPS := $(wildcard deps/*)
 
+ifeq ($(shell uname),Darwin)
+       GREP := ggrep
+       SED := gsed
+       DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1)
+else
+       GREP := grep
+       SED  := sed
+       DIFF := diff
+endif
+
 .PHONY: \
     default \
     clean \
     $(DEPS) \
     deps \
     home \
-    mpdconf \
+    diff \
+    pull \
+    push \
+    dirs \
+    pkgs_void \
+    pkgs_void_update \
     pkgs_brew_cask_install \
     pkgs_brew_install \
+    pkgs_cargo \
     pkgs_deb_install \
     pkgs_deb_purge \
     pkgs_debian \
     pkgs_mac \
-    pkgs_pip \
+    pkgs_pip_install \
+    pkgs_pip_upgrade \
     pkgs_snap_classic \
     pkgs_snap_strict
 
@@ -25,25 +43,13 @@ default:
        @echo '================================================================================'
        @exit 1
 
-home: mpdconf compiled
-       @cp  -Rp       bin           $(HOME)/
-       @cp  -Rp  home/bin           $(HOME)/
-       @cp  -Rp  home/lib           $(HOME)/
-       @cp       home/.compton.conf $(HOME)/
-       @cp  -Rp  home/.config/      $(HOME)/
-       @cp  -Rp  home/.newsboat/    $(HOME)/
-       @cp       home/.profile      $(HOME)/
-       @cp       home/.fonts.conf   $(HOME)/
-       @cp       home/.Rprofile     $(HOME)/
-       @cp       home/.tmux.conf    $(HOME)/
-       @cp       home/.xbindkeysrc  $(HOME)/
-
-mpdconf:
-       @mkdir -p ~/Archives/Audio
-       @mkdir -p ~/var/lib/mpd/playlists
-       @mkdir -p ~/var/log/mpd
-       @mkdir -p ~/var/run/mpd
-       @cp home/.mpdconf $(HOME)/
+home: compiled dirs
+       cp -Rp bin $(HOME)/
+       $(MAKE) push
+       xdg-user-dirs-update
+
+dirs:
+       mkdir -p $(shell ./list dirs)
 
 compiled:
        mkdir -p bin
@@ -51,13 +57,32 @@ compiled:
        mv src/clockloop bin/
 
 font_cache:
-       @fc-cache -fv
+       fc-cache -fv
+
+#
+# Void Linux
+#
+
+pkgs_void:
+       sudo xbps-install $(shell ./list pkgs-void.list)
+
+# Mark $pkg as manually-installed:
+#
+#     sudo xbps-pkgdb -m manual $pkg
+#
+# List manually-installed packages:
+#
+#     xbps-query -m
+#
+pkgs_void_update:
+       xbps-query -m | awk -F - '{sub("-" $$NF "$$", ""); print}' | sort -fu | grep -vf <(./list -v sep='\n' -v end='\n' pkgs-void-src.list) > pkgs-void.list
+       (echo '#'; ./patch-comments pkgs-void.list.comments pkgs-void.list) | sponge pkgs-void.list
 
 #
 # Golang
 #
 pkgs_golang: list pkgs-golang.list
-       go get $(shell ./list pkgs-golang.list)
+       go install $(shell ./list pkgs-golang.list)
 
 #
 # Ubuntu
@@ -71,8 +96,18 @@ pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list
 #
 # PIP
 #
-pkgs_pip:
-       sudo pip3 install $(shell ./list pkgs-pip.list)
+pkgs_pip_install:
+       pip install --user $(shell ./list pkgs-pip.list)
+
+pkgs_pip_upgrade:
+       pip install --user --upgrade $(shell ./list pkgs-pip.list)
+
+#
+# Rust (cargo)
+#
+
+pkgs_cargo: list pkgs-cargo.list
+       cargo install $(shell ./list pkgs-cargo.list)
 
 #
 # Homebrew/Mac
@@ -127,8 +162,28 @@ $(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d))))
 
 diff:
        find home -type f -print0 \
-       | sed -z 's/^home\///g' \
-       | xargs -0 -I% sh -c 'echo %; diff --color=always ~/% home/%'
+       | $(SED) -z 's/^home\///g' \
+       | sort -zr \
+       | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=auto ~/% home/%'
+
+.PHONY: diff_bins_untracked
+diff_bins_untracked:
+       ls -1 ~/bin | sort | grep -vf <(ls -1 home/bin | sort)
+
+pull:
+       find home -type f -print0 \
+       | $(SED) -z 's/^home\///g' \
+       | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%'
+
+push:
+       # TODO Backup files before replacing.
+       #      But - recursive copy is not a good strategy for this.
+       #      Need to do a file by file pass, like the diff recipe.
+       #
+       # Limit depth because directories are copied recursively:
+       find home -maxdepth 1 -print0 \
+       | $(GREP) -zv '^home$$' \
+       | xargs -0 -I% cp -Rp % ~
 
 clean:
        rm -rf ./debfiles
This page took 0.032591 seconds and 4 git commands to generate.