dot

packages and services management
Log | Files | Refs | README

commit 99ecbd16f59ef2e9cf389ab3bb80dfaff0fb30fe
parent c57ca6e9714c1960adbc813a1f3fdb986f72968d
Author: josuah <mail@josuah.net>
Date:   Thu, 15 Dec 2016 19:10:41 +0000

Simplified and improved build

Diffstat:
M.local/bin/build | 67+++++++++++++++++++++++++++++--------------------------------------
M.profile | 2+-
MREADME | 45++++++++++++++++++++++++++++++++++++++++-----
Dinstall | 79-------------------------------------------------------------------------------
4 files changed, 70 insertions(+), 123 deletions(-)

diff --git a/.local/bin/build b/.local/bin/build @@ -2,7 +2,7 @@ PROGRAMS="$HOME/Programs" -PREFIX="$HOME/.local" +LOCAL="$HOME/.local" CONFIG="$HOME/.config" @@ -17,7 +17,7 @@ d[ownload] Download PACKAGE's sources i[nstall] Download then install PACKAGE r[emove] Remove build PACKAGE and its sources u[pdate] Delete, then download and install PACKAGE again -l[ink] Update links from ~${PROGRAMS#$HOME} to ~${PREFIX#$HOME} +l[inks] Update links from ~${PROGRAMS#$HOME} to ~${LOCAL#$HOME} v[iew] View the list of available packages" exit 0 @@ -26,28 +26,25 @@ v[iew] View the list of available packages" view() { - find -L "$PREFIX/share/build" -type f | while IFS='' read -r path + find -L "$LOCAL/share/build" -type f | while IFS='' read -r f do - IFS='' read -r description < "$path" - printf '\t%-12s %s\n' \ - "${path#$PREFIX/share/build/}" \ - "${description#\#}" + read -r comment description < "$f" + printf ' %-12s %s\n' "${f#$LOCAL/share/build/}" "$description" done | sort | more - exit 0 } error() { - printf '\033[1;31merror\033[0;1m %s\033[m: %s\n' "$1" "$2" 1>&2 + printf '\033[1;31merror\033[0;1m %-12s\033[m %s\n' "$1" "$2" 1>&2 exit 1 } info() { - printf '\033[1;36minfo\033[0;1m %s\033[m: %s\n' "$1" "$2" 1>&2 + printf '\033[1;36minfo\033[0;1m %-12s\033[m %s\n' "$1" "$2" 1>&2 } @@ -56,10 +53,7 @@ info() # build() { - for patch in $(find "$CONFIG/$1" -name '*.diff') - do - patch -p1 < "$patch" - done + find "$CONFIG/$1" -name '*.diff' -exec patch -N -p 1 -i {} \; for file in "$CONFIG/$1/config.mk" "$CONFIG/$1/config.h" do @@ -68,7 +62,7 @@ build() [ -f ./autogen.sh ] && ./autogen.sh [ -f ./configure ] && ./configure --prefix="$PREFIX" - + make && make PREFIX="$PREFIX" install clean } @@ -76,7 +70,8 @@ build() compile() { local name="$1" tar="$2" - local PREFIX="$PROGRAMS/$name" script="$PREFIX/share/build/$name" + local PREFIX="$PROGRAMS/$name" script="$LOCAL/share/build/$name" + export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 export CFLAGS="-I $LOCAL/include -L$LOCAL/lib" @@ -87,7 +82,7 @@ compile() info "$name" "installing" cd "$PREFIX" && mkdir -p bin doc etc include lib libexec share man - cd src && build "$name" + cd src && build "$name" cd "$PREFIX" && rmdir -p * 2> /dev/null } @@ -95,7 +90,7 @@ compile() download() { local name="$1" tar="$2" - local tmp="$(mktemp -u)" script="$PREFIX/share/build/$name" + local script="$LOCAL/share/build/$name" [ -d "$PROGRAMS/$name/src" ] && error "$name" "already in $PROGRAMS" [ -f "$script" -o -h "$script" ] || error "$name" "no build script" @@ -108,23 +103,20 @@ download() *.tbz2 | *.tar.bz2 ) opt='j' ;; *.tgz | *.tar.gz ) opt='z' ;; *.txz | *.tar.xz ) opt='J' ;; - *) error "$name" 'not a known tar extension' ;; + * ) error "$name" 'not a known tar extension' ;; esac - mkdir -p "$tmp" "$PROGRAMS/$name" - wget -O - "$tar" | tar -xv"$opt" -f - -C "$tmp" 1> /dev/null + mkdir -p "$PROGRAMS/$name" + wget -O - "$tar" | tar -xv"$opt" -f - -C "$PROGRAMS/$name" 1> /dev/null - mv "$tmp/"* "$PROGRAMS/$name/src" - rm -rf "$tmp" + mv "$PROGRAMS/$name/"* "$PROGRAMS/$name/src" } remove() { - local name="$1" - - info "$name" "removing" - rm -rf "$PROGRAMS/$name" + info "$1" "removing" + rm -rf "$PROGRAMS/$1" } @@ -132,14 +124,10 @@ index() { local name="$1" - info "$name" "updating index in $PREFIX" - - find "$PROGRAMS/$name" -mindepth 2 -type f -o -type l ! -path "*/src/*" | - while read path - do - mkdir -p "$(dirname "$PREFIX/${path#$PROGRAMS/*/}")" - ln -sf "$path" "$PREFIX/${path#$PROGRAMS/*/}" - done + info "$name" "updating index in ~${LOCAL#$HOME}" + cd "$PROGRAMS/$name" || exit 1 + find -type d ! -path "*/src/*" -exec mkdir -p "$LOCAL/{}" \; + find ! -type d ! -path "*/src/*" -exec ln -sf "$PWD/{}" "$LOCAL/{}" \; } @@ -167,7 +155,10 @@ main() index "$2" ;; l | link ) - index '' + ls "$PROGRAMS" | while IFS='' read -r name + do + index "$name" + done ;; v | view ) view @@ -177,8 +168,8 @@ main() ;; esac - info "all" "removing broken links from $PREFIX" - find -L "$PREFIX" -type l -exec rm {} \; + info '' "removing broken links from ~${LOCAL#$HOME}" + find -L "$LOCAL" -type l -exec rm {} \; } main $@ diff --git a/.profile b/.profile @@ -16,7 +16,7 @@ #_______________________________________________________________________________ export ENV="$HOME/.profile" -export TERM='linux' +export TERM='screen' # mail export NAME='Josuah Demangeon' diff --git a/README b/README @@ -1,8 +1,7 @@ -Config 2016-12-11 - _ _ - / _ __ /_ . _ - \_ (_) | | | | (_| - _| +: '_ _ + / _ __ /_ . _ + \_ (_) | | | | (_| + _| ________________________________________________________________________________ Configuration files for all UNIX distros, mostly shell agnostic. @@ -15,3 +14,39 @@ ________________________________________________________________________________ symlinks to .local/ as a local root directory. This is similar to the GoboLinux file hierarchy. + + You can run this file, it is the install script.' + + +mkdir -p ~/Projects +mkdir -p "$MAIL/cur" "$MAIL/new" "$MAIL/tmp" + +cd "${0%/*}" || exit 1 +find -type d ! -path './.git*' -path './.*' -exec mkdir -p ~/{} \; +find -type f ! -path './.git*' -path './.*' -exec ln -sf "$PWD/{}" ~/{} \; +find -L ~ -type l -exec rm {} \; + +case "$1" in +g | git ) + cd ~/Projects && while read url + do git clone $url & done << REPOS + ssh://repo.or.cz/iomenu.git + http://github.com/josuah/iode + http://github.com/josuah/josuah.github.io + http://github.com/josuah/cgr + http://github.com/josuah/barkdown + http://github.com/josuah/notes + http://github.com/josuah/fungus-vs-pathogen + http://github.com/josuah/miniwi + http://github.com/josuah/drawille +REPOS + wait + ;; + +m | mail ) + read -p '<address@mail.net> <imap.host.net> <password>:' a h p + printf 'machine %s\nlogin %s\npassword "%s"' "$h" "$a" "$p" > ~/.netrc + chmod 400 "$HOME/.netrc" + printf '\033[A\r\033[K' + ;; +esac diff --git a/install b/install @@ -1,79 +0,0 @@ -CONFIG="$(cd "${0%/*}"; pwd)" - - -usage() -{ - printf %s " -Usage: ${0##*/} COMMAND - -l link the dotfiles to $HOME -g clone git repos listed in ~/.config/git/projects -m setup mail credentials -" - - exit 0 -} - - -link() -{ - # Link all dotfiles - find "$CONFIG" -type f -path "$CONFIG/.*" ! -path "*/.git*" | - while IFS='' read -r file - do - destination="$HOME/${file#$CONFIG/}" - - printf '%s\n' "$destination" - mkdir -p "${destination%/*}" - ln -sf "$file" "$destination" - done - - # Delete dead links - find -L "$HOME" -type l -exec rm {} \; -} - - -git_repos() -{ - local projects="$HOME/Projects" - - mkdir -p "$projects" && cd "$projects" && while read url dir - do - git clone "$url" & - done < ~/.config/git/projects - - wait -} - - -netrc() -{ - mkdir -p "$MAIL/cur" "$MAIL/new" "$MAIL/tmp" - - read -p 'address: ' address - read -p 'host: ' host - read -p 'password: ' password - - printf 'machine %s\nlogin %s\npassword "%s"' \ - "$host" "$address" "$password" > ~/.netrc - chmod 400 "$HOME/.netrc" - - printf '\033[A\r\033[K' -} - - -main() -{ - [ $# -eq 0 ] && usage - - case "$1" in - l ) link ;; - g ) git_repos ;; - m ) netrc ;; - v ) vim_plugins ;; - * ) usage ;; - esac -} - - -main $@