dot

packages and services management
Log | Files | Refs | README

commit 97a108e5d489540129c61d6a3eb0cd2789505822
parent 0d07ed3cbc30b81cf4ca93d825a1808d454d65b7
Author: josuah <mail@josuah.net>
Date:   Mon, 10 Oct 2016 09:57:57 -0400

Preparing a very clean way to manage configuration

Diffstat:
MREADME | 64+++++-----------------------------------------------------------
Dbuild.sh | 180-------------------------------------------------------------------------------
Dinstall.sh | 72------------------------------------------------------------------------
Ainstall/build.sh | 156+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ainstall/cron.sh | 10++++++++++
Ainstall/git.sh | 14++++++++++++++
Rlink.sh -> install/link.sh | 0
Ainstall/mail.sh | 14++++++++++++++
Ainstall/sync.sh | 16++++++++++++++++
Ainstall/vim.sh | 19+++++++++++++++++++
Avim/vim/plugins | 7+++++++
Rvim/vimrc -> vim/vim/vimrc | 0
12 files changed, 241 insertions(+), 311 deletions(-)

diff --git a/README b/README @@ -1,10 +1,8 @@ -http://josuah.net mail@josuah.net - __ /\ - \/ ____ ____ __ /\ _____ / /_ - /\ / __ \ / __// / / /.'__ // __ \ - / // /_/ /_\ \ / /_/ // /_/ // / / / -_,-' / \____/\___/ \____/ \____/ \/ \/ 's dotfiles 2016-09-27 -\_,-'=========================================================================== + ,--. ,-- * | * + | ,--. ---. |- , ,--, , , .,-- ,--. |-- , ,--. ---. + | | | | | | | | | | | | ,--| | | | | | | + `--' `--' ' ' ' ' `--| `--` ' `--` ' ' `--' ' ' 2016-10-10 +--------------------- `--' ----------------------------------------------------- This downloads, compiles, installs locall, and configures my tools for me. @@ -15,55 +13,3 @@ INSTALL on most systems: wget -qO- http://github.com/josuah/Config/tarball/master | tar -xvz -f- - - Then you can link the files, clone my repos (-g), install vim - plugins (-v) by running the 'install.sh' script. - - -SHELL SCRIPTS -------------------------------------------------------------------------------- - - You can see each files header, there are sometimes more detailled - explainations of what they do and how to use them. - - I try to make them POSIX and busybox compatible: should run in - every UNIX. - - src Download, patch, install, sources from git repos or archives. - www A <pre>text</pre> based static website generator. - irc A whole irc client in sh script. - peax Prompt user to select a line through stdin, like slmenu. - feeds RSS/ATOM reader based on peax. - drawk Drawille in awk that use ImageMagick and images. - blawk Like drawk but use block characters instead of braille. - dna Ascii art DNA generator, with colors. - fig Single-font Figlet implementations. - agenda Terminal agenda viewer that can import ical files. - lsync Sync two directories both ways keeping the latest versions. - piano Terminal piano! Dvorak layout by default. |TT|TTT|TT|TTT| - - -VIM --------------------------------------------------------------------------------- - - undotree http://github.com/mbbill/undotree - surround http://github.com/tpope/vim-surround - lion http://github.com/tommcdo/vim-lion - fzf http://github.com/junegunn/fzf-vim - gitgutter http://github.com/airblade/vim-gitgutter - racket http://github.com/wlangstroth/vim-racket - auto-pairs http://github.com/jiangmiao/auto-pairs - - -PROJECTS --------------------------------------------------------------------------------- - - cgr Chaos Game plot http://github.com/josuah/cgr - drawille Elisp drawille http://github.com/josuah/drawille - miniwi Tiny bitmap font http://github.com/josuah/miniwi - notes Biology notes http://github.com/josuah/notes - website Website source http://github.com/josuah/website - www Website build http://github.com/josuah/josuah.github.io - barkdown Not a text markup http://github.com/josuah/barkdown - vir WIP editor http://github.com/josuah/vir - complete Completion engine http://github.com/josuah/complete diff --git a/build.sh b/build.sh @@ -1,180 +0,0 @@ -# ---. * | | -# |__/ , , , | .--| -# | \ | | | | | | -# ---' `--` ' ' `--` 2016-10-08 -#------------------------------------------------------------------------------- -# Install sources using crux-like package declaration. - -PROGRAMS="${PROGRAMS:-$HOME/Programs}" -PREFIX="${LOCAL:-$HOME/.local}" -CONFIG="${CONFIG:-$HOME/Config}" - - -# FUNCTIONS -#------------------------------------------------------------------------------- - -help() -{ - printf '%s\n' " -NAME - build - Download and install source code from tar archives. - -SYNTAX - build [COMMAND] PACKAGE PACKAGE ... - -DESCRIPTION - d download PACKAGE(s) into $PROGRAMS - i install PACKAGE(s) into $PREFIX - r remove PACKAGE(s) from $PROGRAMS - -FILES - \$PREFIX: $PREFIX - Path where sources will be installed. - - \$PROGRAMS: $PROGRAMS - Path to the sources with one subdirectory per project. - - \$CONFIG: $CONFIG - One subdirectory per project. In each, \"build.sh\", with: - - A comment on the first line describing the package. - - \"tar\" variable with the url of a tar archive. - - Optionnaly a \"build\" function building it in \$PREFIX. - -PACKAGES" - find "$CONFIG/build" -type f | while read file - do - name="${file#$CONFIG/build/}" - name="${name%.sh}" - - printf '\t%-14s ' "$name" - sed '1 {s/^# //; q}' "$file" - done | sort - exit 0 -} - -error() -{ - printf '%s: \033[1;31m%s\033[0m\n' "$(basename "$0")" "$1" 1>&2 -} - -info() -{ - printf '%s: \033[1m%s\033[0m\n' "$(basename "$0")" "$1" 1>&2 -} - -compile() -{ - local name="$1" - local tar="$2" - - [ ! -d "$PROGRAMS/$name/src" ] && download "$name" "$tar" - - info "Installing $name" - - local PREFIX="$PROGRAMS/$name" - local dirs='bin doc etc include lib libexec man share' - cd "$PREFIX"; mkdir -p $dirs - cd src; build "$name" - cd "$PREFIX"; rmdir -p --ignore-fail-on-non-empty * -} - -download() -{ - local name="$1" - local tar="$2" - - if [ -d "$PROGRAMS/$name/src" ] - then error "'$name/src' already in $PROGRAMS" - else info "Downloading $tar" - - case "$tar" in - *.tar ) opt='' ;; - *.tbz2 | *.tar.bz2 ) opt='j' ;; - *.tgz | *.tar.gz ) opt='z' ;; - *.txz | *.tar.xz ) opt='J' ;; - *) error 'not a known tar extension' ;; - esac - - tmp="$(mktemp -d)" - - wget -O - "$tar" | tar -xv"$opt" -f - -C "$tmp" &> /dev/null - - mkdir -p "$PROGRAMS/$name" - mv "$tmp/"* "$PROGRAMS/$name/src" - rm -r "$tmp" - fi -} - -remove() -{ - local name="$1" - - info "Removing $name" - rm -rf "$PROGRAMS/$name" -} - -index() -{ - local name="$1" - - info "Updating index in $PREFIX" - - find "$PROGRAMS/$name" -mindepth 2 -type f ! -path "*/src/*" \ - | while read path - do - mkdir -p "$(dirname "$PREFIX/${path#$PROGRAMS/*/}")" - ln -sf "$path" "$PREFIX/${path#$PROGRAMS/*/}" - done -} - - -# ALGORYTHM -#------------------------------------------------------------------------------- - -[ $# -le 1 ] && help - -mkdir -p "$PROGRAMS" - -opt="$1" -while shift && [ $# -gt 0 ] -do - if [ ! -f "$CONFIG/build/$1.sh" ] - then error "$1 has no build.sh script" - exit 1 - fi - - tar='' - - # - # Default build function - # - build() - { - local build="$CONFIG/$1/build" - - for patch in $(find "$CONFIG/$1" -name '*.diff') - do patch -Np1 < "$patch" - done - - [ -f "$build/config.mk" ] && cp -f "$build/config.mk" . - [ -f "$build/config.h" ] && cp -f "$build/config.h" . - [ -f ./autogen.sh ] && ./autogen.sh - [ -f ./configure ] && ./configure --prefix="$PREFIX" - - make - make prefix="$PREFIX" PREFIX="$PREFIX" install clean - return 0 - } - - . "$CONFIG/build/$1.sh" # Specific build script - - case "$opt" in - d ) download "$1" "$tar"; index "$1" ;; - i ) compile "$1" "$tar"; index "$1" ;; - r ) remove "$1" ;; - * ) error "unknown option: $opt"; help ;; - esac -done - -# Remove broken links from the index -find -L ~/.local -type l -exec rm {} \; diff --git a/install.sh b/install.sh @@ -1,72 +0,0 @@ -#!/bin/sh - -pwd="$(cd "$(dirname "$0")" && pwd)" - -help=" -SYNTAX - ~${pwd#$HOME}/install.sh OPTION - -OPTIONS - -g Clone git repositories as listed in the README file. - -m Prompt for e-mail password to save in a unsafe text file. - -s Link the sub-sub-directories of: ~/Sync. - -v Install asyncronously the vim plugins. - -c Activates the crontab. -" -NL=' -' - -case "$1" in --g) - git="$HOME/Projects" - - mkdir -p "$git" - cd "$git" - - sed '/^[ \t-]*$/ d; 1,/^PROJECTS$/ d' "$pwd/README" | while read line - do git clone --recursive "${line##* }" "${line%% *}" - done - ;; --m) - mail='mail@josuah.net' - host='mail.gandi.net' - - mkdir -p "$HOME/Mail" "$HOME/.cache/mail" - read -p 'password: ' p - printf 'machine %s\nlogin %s\npassword "%s"' "$host" "$mail" "$p" > ~/.netrc - chmod 700 "$HOME/.netrc" - printf '\033[A\r\033[K' - ;; --s) - Sync="$HOME/Sync" - - find "$Sync" -maxdepth 1 -type d -path "$Sync/*" -exec ln -sf {} ~ \; - find "$pwd" -path "$pwd/[^.]*/.*" | while read path - do - if [ -d "$path" ] - then mkdir -p "$HOME/${path#$pwd/*/}" - else ln -sf "$path" "$HOME/${path#$pwd/*/}" - fi - done - ;; --v ) - b=~/.vim/bundle - - [ -d "$b" ] && rm -r "$b" ~/.vim/autoload/pathogen.vim - mkdir -p "$b" ~/.vim/autoload - wget -qO ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim - - for p in $(sed '/^[ \t-]*$/ d; 1,/^VIM/ d; /^PROJ/,$ d' "$pwd/README") - do wget -O- "${p##* }/archive/master.tar.gz" | tar -xvz -f- -C "$b" & - done - - wait - ;; --c ) - c=~/.config/cron/tab - - crontab "$c" - crontab -l - ;; -* ) printf '%s\n' "$help" ;; -esac diff --git a/install/build.sh b/install/build.sh @@ -0,0 +1,156 @@ +# ---. * | | +# |__/ , , , | .--| +# | \ | | | | | | +# ---' `--` ' ' `--` 2016-10-08 +#------------------------------------------------------------------------------- +# Install sources using crux-like package declaration. + +PROGRAMS="${PROGRAMS:-$HOME/Programs}" +PREFIX="${LOCAL:-$HOME/.local}" +CONFIG="${CONFIG:-$HOME/Config}" + + +# FUNCTIONS +#------------------------------------------------------------------------------- + +help() +{ + printf '%s\n' " +USAGE + [d|download] [i|install] [r|remove] PACKAGES... + +PACKAGES" + find "$CONFIG/build" -type f | while read file + do + name="${file#$CONFIG/build/}" + name="${name%.sh}" + + printf '\t%-12s ' "$name" + sed 's/^# //; q' "$file" + done | sort | more +} + +error() +{ + printf '%s: \033[1;31m%s\033[0m\n' "$(basename "$0")" "$1" 1>&2 +} + +info() +{ + printf '%s: \033[1m%s\033[0m\n' "$(basename "$0")" "$1" 1>&2 +} + +compile() +{ + local name="$1" tar="$2" + + [ ! -d "$PROGRAMS/$name/src" ] && download "$name" "$tar" + + info "Installing $name" + + local PREFIX="$PROGRAMS/$name" + local dirs='bin doc etc include lib libexec man share' + cd "$PREFIX" && mkdir -p $dirs + cd src && build "$name" + cd "$PREFIX" && rmdir -p --ignore-fail-on-non-empty * +} + +download() +{ + local name="$1" tar="$2" + + if [ -d "$PROGRAMS/$name/src" ] + then error "'$name/src' already in $PROGRAMS" + else info "Downloading $tar" + + case "$tar" in + *.tar ) opt='' ;; + *.tbz2 | *.tar.bz2 ) opt='j' ;; + *.tgz | *.tar.gz ) opt='z' ;; + *.txz | *.tar.xz ) opt='J' ;; + *) error 'not a known tar extension' ;; + esac + + tmp="$(mktemp -d)" + + wget -O - "$tar" | tar -xv"$opt" -f - -C "$tmp" &> /dev/null + + mkdir -p "$PROGRAMS/$name" + mv "$tmp/"* "$PROGRAMS/$name/src" + rm -r "$tmp" + fi +} + +remove() +{ + local name="$1" + + info "Removing $name" + rm -rf "$PROGRAMS/$name" +} + +index() +{ + local name="$1" + + info "Updating index in $PREFIX" + + find "$PROGRAMS/$name" -mindepth 2 -type f ! -path "*/src/*" \ + | while read path + do + mkdir -p "$(dirname "$PREFIX/${path#$PROGRAMS/*/}")" + ln -sf "$path" "$PREFIX/${path#$PROGRAMS/*/}" + done +} + + +# ALGORYTHM +#------------------------------------------------------------------------------- + +[ $# -le 1 ] && help && exit 0 + +mkdir -p "$PROGRAMS" + +opt="$1" +while shift && [ $# -gt 0 ] +do + if [ ! -f "$CONFIG/build/$1.sh" ] + then error "$1 has no build.sh script" + exit 1 + fi + + tar='' + + # + # Default build function + # + build() + { + local build="$CONFIG/$1/build" + + for patch in $(find "$CONFIG/$1" -name '*.diff') + do patch -Np1 < "$patch" + done + + [ -f "$build/config.mk" ] && cp -f "$build/config.mk" . + [ -f "$build/config.h" ] && cp -f "$build/config.h" . + [ -f ./autogen.sh ] && ./autogen.sh + [ -f ./configure ] && ./configure --prefix="$PREFIX" + + make + make prefix="$PREFIX" PREFIX="$PREFIX" install clean + return 0 + } + + . "$CONFIG/build/$1.sh" # Specific build script + + case "$opt" in + d | download ) download "$1" "$tar"; index "$1" ;; + i | compile ) compile "$1" "$tar"; index "$1" ;; + r | remove ) remove "$1" ;; + * ) error "unknown option: $opt"; help ;; + esac +done + +# Remove broken links from the index +find -L "$PREFIX" -type l -exec rm {} \; diff --git a/install/cron.sh b/install/cron.sh @@ -0,0 +1,10 @@ +# ,--. | | +# | .,-- ,--. ---. |-- ,--. |--. +# | | | | | | | ,--| | | +# `--' ' `--' ' ' ' `--` '--' 2016-10-10 +#------------------------------------------------------------------------------- + +c=~/.config/cron/tab + +crontab "$c" +crontab -l diff --git a/install/git.sh b/install/git.sh @@ -0,0 +1,14 @@ +# ,--. * | +# | , |-- +# | -. | | +# `--' ' ' 2016-10-10 +#------------------------------------------------------------------------------- + +git="$HOME/Projects" + +mkdir -p "$git" +cd "$git" + +sed '/^[ \t-]*$/ d; 1,/^PROJECTS$/ d' "$pwd/README" | while read line +do git clone --recursive "${line##* }" "${line%% *}" +done diff --git a/link.sh b/install/link.sh diff --git a/install/mail.sh b/install/mail.sh @@ -0,0 +1,14 @@ +# . . * | +# |\ /| ,--. , | ,--- +# | | | ,--| | | `--. +# ' ' `--` ' ' ---' 2016-10-10 +#------------------------------------------------------------------------------- + +mail='mail@josuah.net' +host='mail.gandi.net' + +mkdir -p "$HOME/Mail" "$HOME/.cache/mail" +read -p 'password: ' p +printf 'machine %s\nlogin %s\npassword "%s"' "$host" "$mail" "$p" > ~/.netrc +chmod 700 "$HOME/.netrc" +printf '\033[A\r\033[K' diff --git a/install/sync.sh b/install/sync.sh @@ -0,0 +1,16 @@ +# ,--. * | * +# `. , , ---. ,--. .,-- ,--. ---. , ---, ,--. |-- , ,--. ---. +# `. | | | | | | | | | | | ,' ,--| | | | | | | +# `--' `--| ' ' `--' ' `--' ' ' ' '--- `--` ' ' `--' ' ' 2016-10-10 +#----- `--' -------------------------------------------------------------------- + +Sync="$HOME/Sync" + +find "$Sync" -maxdepth 1 -type d -path "$Sync/*" -exec ln -sf {} ~ \; +find "$pwd" -path "$pwd/[^.]*/.*" | while read path +do + if [ -d "$path" ] + then mkdir -p "$HOME/${path#$pwd/*/}" + else ln -sf "$path" "$HOME/${path#$pwd/*/}" + fi +done diff --git a/install/vim.sh b/install/vim.sh @@ -0,0 +1,19 @@ +# . . * ---. | * . . +# | / , --.-. |__' | , , ,--, , ---. |\ /| ,--. ---. ,--. ,--, ,--. .,-- +# |/ | | | | | | | | | | | | | | | | ,--| | | ,--| | | |--' | +# ' ' ' ' ' ' ' `--` `--| ' ' ' ' ' `--` ' ' `--` `--| `--' ' +#--------------------------- `--' ----------------------------- `--' ----------- + +bundle=~/.vim/bundle + +[ -d "$bundle" ] && rm -r "$bundle" ~/.vim/autoload/pathogen.vim +mkdir -p "$bundle" ~/.vim/autoload +wget -qO ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + +sed '/^[[:space:]]*$/ d; /^[[:space:]]*#/d;' | while read plugin +do + wget -O- "http://github.com/$plugin/archive/master.tar.gz" \ + | tar -xvz -f- -C "$bundle" &> /dev/null & +done + +wait diff --git a/vim/vim/plugins b/vim/vim/plugins @@ -0,0 +1,7 @@ +mbbill/undotree +tpope/vim-surround +tommcdo/vim-lion +junegunn/fzf-vim +airblade/vim-gitgutter +wlangstroth/vim-racket +jiangmiao/auto-pairs diff --git a/vim/vimrc b/vim/vim/vimrc