From 285a138691b40d6d20931676cc9f2fdb52fe6737 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 21 Apr 2008 12:26:43 +0100 Subject: [PATCH] Repository reorganization. * Remove version numbers from the packages to be downloaded. Updating the setup script just because some package has changed versions is silly; we'll just mess with symlinks appropriately instead. * Move the small scripts into the profile repository, so that they live a sensible version-controlled life. --- lesspipe.sh | 27 +++++++++++++++++++++ setup | 50 ++++++++++---------------------------- start-ssh-agent | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ svnwrap | 23 ++++++++++++++++++ 4 files changed, 137 insertions(+), 37 deletions(-) create mode 100755 lesspipe.sh create mode 100755 start-ssh-agent create mode 100755 svnwrap diff --git a/lesspipe.sh b/lesspipe.sh new file mode 100755 index 0000000..70d76d3 --- /dev/null +++ b/lesspipe.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# This is a preprocessor for 'less'. It is used when this environment +# variable is set: LESSOPEN="|lesspipe.sh %s" + +lesspipe() { + case "$1" in + *.tar) tar tvvf $1 2>/dev/null ;; # View contents of .tar and .tgz files + *.tgz|*.tar.gz|*.tar.Z|*.tar.z) gzip -dc $1 | tar tvvf - 2>/dev/null ;; + *.tar.bz2) bzip2 -dc $1 | tar tvvf - 2>/dev/null ;; + *.zip) unzip -l $1 2>/dev/null ;; + *.[1-9n]|*.man) + groff -te -Tascii -mandoc $1 ;; + *.[1-9].gz|*.man.gz) + gzip -dc $1 | groff -te -Tascii -mandoc ;; + *.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly + *.bz2) bzip2 -dc $1 2>/dev/null ;; # View compressed files correctly +# *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings' +# FILE1=`echo $FILE | cut -d ' ' -f 2` +# FILE2=`echo $FILE | cut -d ' ' -f 3` +# if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \ +# -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then +# strings $1 +# fi ;; + esac +} + +lesspipe $1 diff --git a/setup b/setup index 2eeb274..ce31afc 100755 --- a/setup +++ b/setup @@ -75,47 +75,19 @@ done echo " all done." ###-------------------------------------------------------------------------- -### Install necessary things. - -echo "Installing useful scripts..." - -scripts=" - lesspipe.sh start-ssh-agent svnwrap" -for script in $scripts; do - $echon " $script:$echoc" - found= - for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do - if $false [ -x $p/$script ]; then - found=t - break - fi - done - if [ "$found" ]; then - echo " already installed." - else - $echon " downloading$echoc" - $GETURL $HOME$sub/bin/$script $REPO/$script - chmod +x $HOME$sub/bin/$script - echo " done." - fi -done - -echo " all done." - -###-------------------------------------------------------------------------- ### Install some more complicated programs. echo "Installing packages..." systems=" - mlib:2.0.4:crc-mktab - chkpath:1.1.0:tmpdir + mlib:crc-mktab + checkpath:tmpdir " [ "$xstuff" ] && systems="$systems - xtoys:1.4.0:xatom + xtoys:xatom " for system in $systems; do set -- $(echo $system | tr : ' ') - sys=$1 ver=$2 prog=$3 + sys=$1 prog=$2 $echon " $sys:$echoc" if $false $prog >/dev/null 2>&1 --version; then echo " already installed." @@ -123,12 +95,13 @@ for system in $systems; do ( set -e $echon " downloading$echoc" cd $HOME$sub/src - rm -rf $sys-$ver.tar.gz $sys-$ver - $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz + rm -rf $sys.tar.gz $sys-$ver + $GETURL $sys.tar.gz $REPO/$sys.tar.gz $echon " unpacking$echoc" - gzip -cd $sys-$ver.tar.gz | tar xf - + dir=$(gzip -cd $sys.tar.gz | tar tf - | head -1) + gzip -cd $sys.tar.gz | tar xf - $echon " configuring$echoc" - cd $sys-$ver + cd $dir mkdir build cd build ../configure --prefix=$HOME$sub >>buildlog 2>&1 @@ -215,7 +188,10 @@ scripts=" mdw-editor mdw-conf movemail-hack - emerge-hack" + emerge-hack + lesspipe.sh + start-ssh-agent + svnwrap" [ "$xstuff" ] && scripts="$scripts xrun xshutdown" diff --git a/start-ssh-agent b/start-ssh-agent new file mode 100755 index 0000000..3515579 --- /dev/null +++ b/start-ssh-agent @@ -0,0 +1,74 @@ +#! /bin/sh + +set -e +usage="Usage: $0 [-bc] [COMMAND [ARGS...]]" + +### Parse options +case "${SHELL-/bin/sh}" in + *csh*) style=csh;; + *) style=sh;; +esac +force= chosen= commands= +while [ $# -gt 0 ]; do + case "$1" in + -h | --help) echo "$usage"; exit 0;; + -c | --cshell | --tcsh) style=csh chosen=t;; + -b | --bourne | --bash | --zsh) style=sh chosen=t;; + -f | --force) force=t;; + --) shift; break;; + -*) echo >&2 "$usage"; exit 1;; + *) break;; + esac + shift +done +[ $# -gt 0 ] && style=commands +case $chosen,$style in + t,commands) + echo >&2 "$0: output style and commands? you're odd" + exit 1 + ;; +esac + +### Should I start a new agent? +case "$force,$SSH_AUTH_SOCK" in + t,* | ,) + start=t + ;; + *) + start= + set +e; ssh-add -l >/dev/null 2>&1; rc=$?; set -e + [ $rc -ge 2 ] && start=t + ;; +esac + +### If so, do that +if [ "$start" ]; then + hostname=${HOST-$(hostname)} + user=${USER-${LOGNAME-$(whoami)}} + dir=$TMPDIR/.ssh-agent.$hostname.$user socket=$dir/sock pid=$dir/pid + mkdir -p -m700 "$dir" + SSH_AUTH_SOCK=$socket; export SSH_AUTH_SOCK + set +e; ssh-add -l >/dev/null 2>&1; rc=$?; set -e + if [ $rc -ge 2 ]; then + if [ -f "$pid" ]; then + kill $(cat "$pid") >/dev/null 2>&1 || : + fi + rm -f "$socket" "$pid" + (cd /; exec ssh-agent -d -a "$socket" >/dev/null 2>&1)& + echo $! >"$pid" + SSH_AUTH_SOCK=$socket; export SSH_AUTH_SOCK + fi +fi + +### Run a program, or export the details +case $style in + sh) + echo "SSH_AUTH_SOCK='$SSH_AUTH_SOCK'; export SSH_AUTH_SOCK" + ;; + csh) + echo "setenv SSH_AUTH_SOCK '$SSH_AUTH_SOCK'" + ;; + commands) + exec "$@" + ;; +esac diff --git a/svnwrap b/svnwrap new file mode 100755 index 0000000..525872f --- /dev/null +++ b/svnwrap @@ -0,0 +1,23 @@ +#! /bin/bash + +set -e +me=${0##*/} + +# --- Snarfle the arguments --- + +declare -a cmd +declare -i i seq + +i=1 seq=0 +for j; do + file=$1; shift + case "$file" in + :*) file=$SVNROOT/${file#:};; + esac + cmd[i]=$file + i=i+1 +done + +# --- Run the program --- + +exec svn "${cmd[@]}" -- 2.11.0