X-Git-Url: https://git.xandkar.net/?p=khome.git;a=blobdiff_plain;f=Makefile;h=563f6f4ac688506a17f6cf378b22e5e6da513eb1;hp=71b1ea41e1de23973fb7b517d168b75ccc0643b2;hb=HEAD;hpb=7acf9b505b5d9b3e2656aa4ffca938075ff7b79d diff --git a/Makefile b/Makefile index 71b1ea4..7a32ec4 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,39 @@ MAKEFLAGS := --no-builtin-rules +SHELL := /bin/bash -DIFF := diff --color=always 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 @@ -26,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 @@ -52,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 @@ -72,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,24 +161,29 @@ endef $(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d)))) diff: - $(DIFF) $(HOME)/.Rprofile home/.Rprofile || true - $(DIFF) $(HOME)/.compton.conf home/.compton.conf || true - $(DIFF) $(HOME)/.config/dunst/dunstrc home/.config/dunst/dunstrc || true - $(DIFF) $(HOME)/.config/mimeapps.list home/.config/mimeapps.list || true - $(DIFF) $(HOME)/.config/neofetch/config.conf home/.config/neofetch/config.conf || true - $(DIFF) $(HOME)/.config/ranger/rc.conf home/.config/ranger/rc.conf || true - $(DIFF) $(HOME)/.config/screengrab/screengrab.conf home/.config/screengrab/screengrab.conf || true - $(DIFF) $(HOME)/.fonts.conf home/.fonts.conf || true - $(DIFF) $(HOME)/.mpdconf home/.mpdconf || true - $(DIFF) $(HOME)/.newsboat/config home/.newsboat/config || true - $(DIFF) $(HOME)/.profile home/.profile || true - $(DIFF) $(HOME)/.tmux.conf home/.tmux.conf || true - $(DIFF) $(HOME)/.xbindkeysrc home/.xbindkeysrc || true - $(DIFF) $(HOME)/lib/login_aliases.sh home/lib/login_aliases.sh || true - $(DIFF) $(HOME)/lib/login_functions.sh home/lib/login_functions.sh || true - $(DIFF) $(HOME)/lib/login_variables.sh home/lib/login_variables.sh || true - $(DIFF) $(HOME)/lib/login_variables_dpi_high.sh home/lib/login_variables_dpi_high.sh || true - $(DIFF) $(HOME)/lib/login_variables_dpi_norm.sh home/lib/login_variables_dpi_norm.sh || true + find home -type f -print0 \ + | $(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