From a25dc638eae1a78ec60ec291c5f83c68c1cdbd0d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 7 Feb 2010 16:47:02 +0100 Subject: Move bootstrap and pkglist to examples/ --- examples/bootstrap | 118 ++++++++++++++++++++++++++++++++++++++++++++++ examples/pkglist | 34 +++++++++++++ include/bootstrap | 118 ---------------------------------------------- include/pkglist | 34 ------------- man/7/caretaker-setup.pod | 4 +- man/7/caretaker.pod | 8 +--- test/main | 2 +- test/setup | 2 +- 8 files changed, 158 insertions(+), 162 deletions(-) create mode 100755 examples/bootstrap create mode 100755 examples/pkglist delete mode 100755 include/bootstrap delete mode 100755 include/pkglist diff --git a/examples/bootstrap b/examples/bootstrap new file mode 100755 index 0000000..6d4013e --- /dev/null +++ b/examples/bootstrap @@ -0,0 +1,118 @@ +#!/usr/bin/env zsh +# bootstrap - populate a home with the most necessary scripts +# After running this, other packages can be installed using 'ct' +# Note: Since caretaker is written in zsh, this script also is. +# This way, I don't have to check for zsh somewhere in the script, +# and also have an excuse for using zsh here :P + +setopt err_exit +trap "print -P '\n%N:%i: bootstrap failed ($?)'" ZERR +typeset -i rcempty=0 pkglist_cgi=0 +typeset PKG_ROOT PKG_DIR default_path='~/packages' +: ${XDG_CONFIG_HOME=$HOME/.config} + +while [[ $1 == --* ]] { + case $1 in + --pkglist-cgi) + pkglist_cgi=1 + pkglist_cgi_url=$2 + shift + ;; + esac + shift +} + +if [[ -n $1 ]] { + PKG_ROOT=$1 + PKG_DIR=${~${2-$default_path}} +} else { + cat <<- meow + Usage: ./bootstrap [options] PKG_ROOT [PKG_DIR] + PKG_ROOT is an URI, either of the form proto://host/path, or just /path + Note: The path must be absolute, it may not contain a literal ~ + PKG_DIR is the path where caretaker and all further packages will be installed, + by default $default_path + + Options: + + --pkglist-cgi URL + Get the package list from URL - most useful with a git:// PKG_ROOT + meow + exit 100 +} + +# zsh keeps complaining about not having a configuration, +# so let's be kind and give it an empty one. +if ! [[ -e ~/.zshrc ]] { + echo 'Creating empty zshrc' + rcempty=1 + touch ~/.zshrc +} + +echo 'Creating the basic directory structure' +mkdir -p ~/bin +path=(~/bin $path) +mkdir -p $PKG_DIR/.collected/man/man{1..8} + +if ! which git &> /dev/null; then + echo 'It appears that git is not available on this system.' + echo '-Installation aborted-' + exit 200 +fi + +echo 'Fetching the caretaker package...' +cd $PKG_DIR +git clone $PKG_ROOT/caretaker caretaker +cd caretaker + +echo "Writing $XDG_CONFIG_HOME/caretaker/caretaker.conf" +mkdir -p $XDG_CONFIG_HOME/caretaker + +cat > $XDG_CONFIG_HOME/caretaker/caretaker.conf <<- flurbl + PKG_ROOT=($PKG_ROOT) + PKG_DIR="${PKG_DIR/$HOME/\$HOME}" +flurbl + +if (( pkglist_cgi )) { + + if which curl &> /dev/null; then + getcmd='curl -s' + elif which wget &> /dev/null; then + getcmd='wget -q -O -' + else + print STDERR "Unable to find a proper download program, fix $PKG_DIR/.pkglist\n" + getcmd='echo fixme >&2; exit 1;' + fi + + cat >> $XDG_CONFIG_HOME/caretaker/caretaker.conf <<-flurbl + PKGLIST_LOCAL=1 + PKGLIST_PATH=$PKG_DIR/.pkglist + flurbl + + cat > $PKG_DIR/.pkglist <<-flurbl + #!/bin/sh + $getcmd $pkglist_cgi_url + flurbl + + chmod +x $PKG_DIR/.pkglist +} + +echo 'Installing caretaker package' +rehash + +bin/checklinks +bin/ct eval update_collected caretaker +bin/ct eval exec_hook caretaker post-add +bin/ct update + +if (( rcempty )) { + echo 'Removing empty zshrc' + rm ~/.zshrc +} + +if [[ $PATH != *$HOME/bin* ]] { + cat <<- tac + Note: You may need to change your PATH to include ~/bin, + otherwise certain parts of caretaker will not work. + tac +} diff --git a/examples/pkglist b/examples/pkglist new file mode 100755 index 0000000..95696a2 --- /dev/null +++ b/examples/pkglist @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh +## on the PKG_HOST: list available packages +## used by ct update remote +## the PKG_PATH (package root path) is given as first argument ($1) + +if [[ ! -d $1 ]] { + echo "$0: package root directory '$1' does not exist!" >&2 + exit 1 +} + +setopt err_exit + +cd $1 +shift + +for i in *(-/); { + + # git repo + if [[ -d $i/.git ]] { + echo -n "$i git " + echo -n ${$(git --git-dir=$i/.git log -n 1)[2]} + echo " $*" + + # bare git repo + } elif [[ -d $i/objects && -d $i/refs ]] { + echo -n "$i git " + echo -n ${$(git --git-dir=$i log -n 1)[2]} + echo " $*" + + # unknown + } else { + echo "$i: Unsupported or no repository" >&2 + } +} diff --git a/include/bootstrap b/include/bootstrap deleted file mode 100755 index 6d4013e..0000000 --- a/include/bootstrap +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env zsh -# bootstrap - populate a home with the most necessary scripts -# After running this, other packages can be installed using 'ct' -# Note: Since caretaker is written in zsh, this script also is. -# This way, I don't have to check for zsh somewhere in the script, -# and also have an excuse for using zsh here :P - -setopt err_exit -trap "print -P '\n%N:%i: bootstrap failed ($?)'" ZERR -typeset -i rcempty=0 pkglist_cgi=0 -typeset PKG_ROOT PKG_DIR default_path='~/packages' -: ${XDG_CONFIG_HOME=$HOME/.config} - -while [[ $1 == --* ]] { - case $1 in - --pkglist-cgi) - pkglist_cgi=1 - pkglist_cgi_url=$2 - shift - ;; - esac - shift -} - -if [[ -n $1 ]] { - PKG_ROOT=$1 - PKG_DIR=${~${2-$default_path}} -} else { - cat <<- meow - Usage: ./bootstrap [options] PKG_ROOT [PKG_DIR] - PKG_ROOT is an URI, either of the form proto://host/path, or just /path - Note: The path must be absolute, it may not contain a literal ~ - PKG_DIR is the path where caretaker and all further packages will be installed, - by default $default_path - - Options: - - --pkglist-cgi URL - Get the package list from URL - most useful with a git:// PKG_ROOT - meow - exit 100 -} - -# zsh keeps complaining about not having a configuration, -# so let's be kind and give it an empty one. -if ! [[ -e ~/.zshrc ]] { - echo 'Creating empty zshrc' - rcempty=1 - touch ~/.zshrc -} - -echo 'Creating the basic directory structure' -mkdir -p ~/bin -path=(~/bin $path) -mkdir -p $PKG_DIR/.collected/man/man{1..8} - -if ! which git &> /dev/null; then - echo 'It appears that git is not available on this system.' - echo '-Installation aborted-' - exit 200 -fi - -echo 'Fetching the caretaker package...' -cd $PKG_DIR -git clone $PKG_ROOT/caretaker caretaker -cd caretaker - -echo "Writing $XDG_CONFIG_HOME/caretaker/caretaker.conf" -mkdir -p $XDG_CONFIG_HOME/caretaker - -cat > $XDG_CONFIG_HOME/caretaker/caretaker.conf <<- flurbl - PKG_ROOT=($PKG_ROOT) - PKG_DIR="${PKG_DIR/$HOME/\$HOME}" -flurbl - -if (( pkglist_cgi )) { - - if which curl &> /dev/null; then - getcmd='curl -s' - elif which wget &> /dev/null; then - getcmd='wget -q -O -' - else - print STDERR "Unable to find a proper download program, fix $PKG_DIR/.pkglist\n" - getcmd='echo fixme >&2; exit 1;' - fi - - cat >> $XDG_CONFIG_HOME/caretaker/caretaker.conf <<-flurbl - PKGLIST_LOCAL=1 - PKGLIST_PATH=$PKG_DIR/.pkglist - flurbl - - cat > $PKG_DIR/.pkglist <<-flurbl - #!/bin/sh - $getcmd $pkglist_cgi_url - flurbl - - chmod +x $PKG_DIR/.pkglist -} - -echo 'Installing caretaker package' -rehash - -bin/checklinks -bin/ct eval update_collected caretaker -bin/ct eval exec_hook caretaker post-add -bin/ct update - -if (( rcempty )) { - echo 'Removing empty zshrc' - rm ~/.zshrc -} - -if [[ $PATH != *$HOME/bin* ]] { - cat <<- tac - Note: You may need to change your PATH to include ~/bin, - otherwise certain parts of caretaker will not work. - tac -} diff --git a/include/pkglist b/include/pkglist deleted file mode 100755 index 95696a2..0000000 --- a/include/pkglist +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env zsh -## on the PKG_HOST: list available packages -## used by ct update remote -## the PKG_PATH (package root path) is given as first argument ($1) - -if [[ ! -d $1 ]] { - echo "$0: package root directory '$1' does not exist!" >&2 - exit 1 -} - -setopt err_exit - -cd $1 -shift - -for i in *(-/); { - - # git repo - if [[ -d $i/.git ]] { - echo -n "$i git " - echo -n ${$(git --git-dir=$i/.git log -n 1)[2]} - echo " $*" - - # bare git repo - } elif [[ -d $i/objects && -d $i/refs ]] { - echo -n "$i git " - echo -n ${$(git --git-dir=$i log -n 1)[2]} - echo " $*" - - # unknown - } else { - echo "$i: Unsupported or no repository" >&2 - } -} diff --git a/man/7/caretaker-setup.pod b/man/7/caretaker-setup.pod index 00196d1..1ce71b8 100644 --- a/man/7/caretaker-setup.pod +++ b/man/7/caretaker-setup.pod @@ -9,12 +9,12 @@ server which shall from now on host all your packages. Then you need to put the caretaker git repository into F - it's recommended to do this via git clone --bare. -Copy the pkglist script (include/pkglist) to F. +Copy the pkglist script (examples/pkglist) to F. Now you can add your own packages as git repos in PKG_ROOT. To use caretaker with your packages on a machine, download and execute -the bootstrap script (include/bootstrap). +the bootstrap script (examples/bootstrap). =head1 CREATING A PACKAGE diff --git a/man/7/caretaker.pod b/man/7/caretaker.pod index 37ad1ac..488a870 100644 --- a/man/7/caretaker.pod +++ b/man/7/caretaker.pod @@ -52,7 +52,7 @@ the package directory $PKG_DIR, except that it neither contains .list nor .list-remote. It is the central point where caretaker fetches packages from and pushes packages to. -It should contain the pkglist script shipped in include/. +It should contain the pkglist script shipped in examples/. If it doesn't, PKGLIST_PATH in .caretaker.conf must be set to the appropiate location on the package root host. @@ -72,7 +72,7 @@ is the package root to which this package belongs. Example: caretaker git 82d716d01dee0329af7df5e67b55558fe3ff1466 git://git.tabularazor.org/~derf The package list is generated by the script set in the config var $PKGLIST_PATH, -by default F. Depending on $PKGLIST_LOCAL and $PKG_ROOT, it +by default F. Depending on $PKGLIST_LOCAL and $PKG_ROOT, it is either executed on the local host or on the remote host containing the package root. The script is always called with $PKG_PATH as the first argument. Its output must only contain valid pkglist lines (see the example above). @@ -111,10 +111,6 @@ Configuration files, not treated specially though Package hooks, see L -=item include/ - -Scripts used by the package that don't belong into B. Not treated specially - =item man/ Manual files, separated by section (like man/7/caretaker.pod). diff --git a/test/main b/test/main index 3544ed0..e78d090 100755 --- a/test/main +++ b/test/main @@ -31,7 +31,7 @@ source $tests/checklinks (source $tests/setup) echo "# bootstrapping PKG_DIR" -$test_proot/caretaker/include/bootstrap $test_proot $test_pdir +$test_proot/caretaker/examples/bootstrap $test_proot $test_pdir echo "# checking for success" [[ -e $test_home/.config/caretaker/caretaker.conf ]] diff --git a/test/setup b/test/setup index 14cfd7b..41db801 100644 --- a/test/setup +++ b/test/setup @@ -2,7 +2,7 @@ echo "# setting up PKG_ROOT" cd $test_proot git clone --quiet ${1-git://git.tabularazor.org/~derf/caretaker} caretaker -cp caretaker/include/pkglist pkglist +cp caretaker/examples/pkglist pkglist for repo in ra rb rc; ( mkdir $repo cd $repo -- cgit v1.2.3