dot

packages and services management
Log | Files | Refs | README

commit 909880d75a2799a81919019dff30fcfe20aa0077
parent 6e6c5469f292f0b44e7d6f53c3ba58a986b3b7ab
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Fri,  2 Jun 2017 09:39:10 +0200

Managements scripts at the root of etc

Diffstat:
Dbin/build | 114-------------------------------------------------------------------------------
Abuild | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Minstall | 24+++++++++++-------------
Aplan9port/build | 1+
Aplan9port/profile | 4++++
Mplan9port/url | 1+
6 files changed, 121 insertions(+), 127 deletions(-)

diff --git a/bin/build b/bin/build @@ -1,114 +0,0 @@ -# Install sources from build receipes - - -usage() -{ - printf 'build [-d pkg] [-r pkg] [-i pkg] [-u pkg]\n' - exit 1 -} - - -build() -{ - find "$ETC/build/$1" -name '*.diff' -exec patch -N -p 1 -i {} \; - find "$ETC/build/$1" -name 'config.*' -exec cp -f {} . \; - - [ -f ./configure ] && ./configure --prefix="$PREFIX" - - make && make PREFIX="$PREFIX" DESTDIR="$PREFIX" install clean -} - - -compile() -{ - PREFIX="$OPT/$1" - export PREFIX - - cd "$PREFIX" || exit 1 - mkdir -p bin doc etc include lib libexec share man - ln -fs bin sbin - ln -fs ../man share/man - ln -fs . usr - cd "$SRC/$1" || exit 1 - - if [ -f "$ETC/build/$1/build" ] - then sh "$ETC/build/$1/build" - else build "$1" - fi - - rmdir "$PREFIX"/* 2> /dev/null -} - - -download() -{ - read url < "$ETC/build/$1/url" - - [ -e "$SRC/$1" ] && exit 1 - [ -e "$OPT/$1" ] && rm -r "$OPT/$1" - - case "$url" in - ( *.tar ) opt='' ;; - ( *.tbz2 | *.tar.bz2 ) opt='j' ;; - ( *.tgz | *.tar.gz ) opt='z' ;; - ( *.txz | *.tar.xz ) opt='J' ;; - ( * ) exit 1 ;; - esac - - mkdir -p "$OPT/$1" "$SRC" - - wget -qO - "$url" | tar -xv"$opt"f - -C "$OPT/$1" - - if [ "`ls "$OPT/$1" | wc -l`" -gt 1 ] - then - mv "$OPT/$1" "$SRC/$1" - mkdir -p "$OPT/$1" - else - mv "$OPT/$1"/* "$SRC/$1" - fi -} - - -remove() -{ - rm -rf "${OPT:?}/$1" "${SRC:?}/$1" - find -L "$ROOT" -type l -exec rm {} + -} - - -index() -{ - find "$OPT/$1" | while IFS='' read -r path - do - [ -d "$path" ] && mkdir -p "$ROOT/${path#$OPT/$1}" - [ -f "$path" ] && ln -sf "$path" "$ROOT/${path#$OPT/$1}" - done -} - - -main() -{ - mkdir -p "$OPT" "$SRC" - - case "$1" in - - -d ) [ $# = 2 ] || usage - download "$2"; index "$2" - ;; - -i ) [ $# = 2 ] || usage - [ ! -d "$OPT/$2" ] && download "$2" - compile "$2"; index "$2" - ;; - -r ) [ $# = 2 ] || usage - remove "$2" - ;; - -u ) [ $# = 2 ] || usage - remove "$2"; download "$2"; echo; compile "$2"; index "$2" - ;; - * | '' ) usage - ;; - esac -} - - -main "$@" diff --git a/build b/build @@ -0,0 +1,104 @@ +# Install sources from build receipes + + +usage() +{ + printf 'build [-d pkg] [-r pkg] [-i pkg] [-u pkg]\n' + exit 1 +} + + +build() +{ + find "$ETC/$1" -name '*.diff' -exec patch -N -p 1 -i {} \; + find "$ETC/$1" -name 'config.*' -exec cp -f {} . \; + + [ -f ./configure ] && ./configure --prefix="$PREFIX" + + make && make PREFIX="$PREFIX" DESTDIR="$PREFIX" install clean +} + + +compile() +{ + PREFIX="$OPT/$1" + export PREFIX + + cd "$PREFIX" || exit 1 + mkdir -p bin doc etc include lib libexec share man + ln -fs bin sbin + ln -fs ../man share/man + ln -fs . usr + cd "$SRC/$1" || exit 1 + + if [ -f "$ETC/$1/build" ] + then sh "$ETC/$1/build" + else build "$1" + fi + + rmdir "$PREFIX"/* 2> /dev/null +} + + +download() +{ + read url < "$ETC/$1/url" + + [ -e "$SRC/$1" ] && echo "'$1' already in $SRC" exit 1 + [ -e "$OPT/$1" ] && rm -r "$OPT/$1" + + case "$url" in + ( *.tar ) opt='' ;; + ( *.tbz2 | *.tar.bz2 ) opt='j' ;; + ( *.tgz | *.tar.gz ) opt='z' ;; + ( *.txz | *.tar.xz ) opt='J' ;; + ( * ) exit 1 ;; + esac + + mkdir -p "$OPT/$1" "$SRC" + wget -qO - "$url" | tar -xv"$opt"f - -C "$OPT/$1" + mv "$OPT/$1"/* "$SRC/$1" +} + + +remove() +{ + rm -rf "${OPT:?}/$1" "${SRC:?}/$1" + find -L "$ROOT" -type l -exec rm {} + +} + + +index() +{ + find "$OPT/$1" | while IFS='' read -r path + do + [ -d "$path" ] && mkdir -p "$ROOT/${path#$OPT/$1}" + [ -f "$path" ] && ln -sf "$path" "$ROOT/${path#$OPT/$1}" + done +} + + +main() +{ + case "$1" in + -d ) [ $# = 2 ] || usage + download "$2" && index "$2" + ;; + -i ) [ $# = 2 ] || usage + [ ! -d "$OPT/$2" ] && download "$2" + compile "$2" && index "$2" + ;; + -r ) [ $# = 2 ] || usage + remove "$2" + ;; + -u ) [ $# = 2 ] || usage + remove "$2" + download "$2" && compile "$2" && index "$2" + ;; + * | '' ) usage + ;; + esac +} + + +main "$@" diff --git a/install b/install @@ -1,3 +1,8 @@ +ETC=${0%/*} +GIT=$HOME/git +MAIL=$HOME/var/mail + + usage() { printf '%s [-l] [-g] [-m address host password] [-9]\n' "$0" @@ -8,19 +13,18 @@ usage() case "$1" in ( -l ) [ $# = 1 ] || usage - cd "${0%/*}" || exit 1 - find "$PWD" -path "$PWD/.*" ! -path '$PWD/.git*' | while read -r path + find "$ETC" -path "$ETC/*/.*" | while read -r path do - [ -d "$path" ] && mkdir -p "$HOME/${path#$PWD/}" - [ -f "$path" ] && ln -sf "$path" "$HOME/${path#$PWD/}" + [ -d "$path" ] && mkdir -p "$HOME/${path#$ETC/*/}" + [ -f "$path" ] && ln -sf "$path" "$HOME/${path#$ETC/*/}" done - find -L ~ -type l -exec rm {} \; + find -L "$HOME" -maxdepth 5 -type l -exec rm {} + ;; ( -g ) [ $# = 1 ] || usage - mkdir -p ~/git && cd ~/git || exit + mkdir -p "$GIT" && cd "$GIT" || exit 1 git clone http://github.com/josuah/www & git clone http://github.com/josuah/alphabet & @@ -48,12 +52,6 @@ case "$1" in chmod 400 ~/.netrc ;; -( -9 ) [ $# = 1 ] || usage - wget -O- http://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/plan9port/plan9port-20140306.tgz | - tar -xzf - -C "$HOME" && mv plan9port 9 && cd 9 || exit 1 - ./INSTALL - ;; - -( '' | * ) usage +( * ) usage ;; esac diff --git a/plan9port/build b/plan9port/build @@ -0,0 +1 @@ +./INSTALL diff --git a/plan9port/profile b/plan9port/profile @@ -0,0 +1,4 @@ +PLAN9=$OPT/plan9port +PATH=$PLAN9/bin:$PATH + +export PLAN9 PATH diff --git a/plan9port/url b/plan9port/url @@ -0,0 +1 @@ +http://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/plan9port/plan9port-20140306.tgz