# update.sh -- lisp source code downloading # # Part of clbuild by Luke Gorrie and contributors. count_systems() { n_asd=`ls -1 "$system_dir"/*.asd | wc -l` echo "$n_asd system definition files registered" } blank_line=" " tail_last() { if tty 0>&1 >/dev/null; then while read line; do echo -e '\r\c' echo -n "$blank_line" echo -e '\r\c' echo -n $line | cut -b 1-65 | tr -d '\n' done echo -e '\r\c' echo -n "$blank_line" echo -e '\r\c' else while read line; do echo $line done fi } dribble_get() { label="$1" name="$2" if test -d `echo ${name}*/ | awk '{print $1;}'`; then echo -n "UPDATE " else echo -n "NEW " fi echo "$label $name" } dry_run_ok() { if test -n "$dry_run"; then echo "OK: $1" fi } dry_run_missing() { if test -n "$dry_run"; then echo "MISSING: $1" fi } get_darcs() { name="$1" url="$2" if [ -d $name ]; then actual="`cat $name/_darcs/prefs/defaultrepo`" if test "x$actual" = "x$url"; then dry_run_ok $1 else echo "MISMATCH: $1 was installed from $actual, current is $url" fi else dry_run_missing $1 fi if test -n "$dry_run"; then exit 0 fi # don't use tail_last, since darcs already has this kind of progress bar if [ -d $name ]; then dribble_get "darcs pull" $name ( cd $name if ! test -d _darcs; then echo ERROR: not a darcs repository exit 1 fi darcs pull --all ) else dribble_get "darcs get" $name darcs get $url $name fi } get_git() { name="$1" url="$2" if [ -d $name ]; then actual="`cd $name && git config --get remote.origin.url`" if test "x$actual" = "x$url"; then dry_run_ok $1 else echo "MISMATCH: $1 was installed from $actual, current is $url" fi else dry_run_missing $1 fi if test -n "$dry_run"; then exit 0 fi if [ -d $name ]; then dribble_get "git pull" $name ( cd $name if ! test -d .git; then echo ERROR: not a git repository exit 1 fi git pull ) else dribble_get "git clone" $name git clone $url $name fi } get_svn() { name="$1" url="$2" if [ -d $name ]; then actual="`cd $name && svn info | grep ^URL: | awk '{print $2;}'`" if test "x$actual" = "x$url"; then dry_run_ok $1 else echo "MISMATCH: $1 was installed from $actual, current is $url" fi else dry_run_missing $1 fi if test -n "$dry_run"; then exit 0 fi dribble_get "svn co" $name svn co $url $name | tail_last } get_cvs_aux() { module="$1" repository="$2" target_directory="$3" if [ -d $module ]; then actual="`cat $module/CVS/Root`" if test "x$actual" = "x$repository"; then dry_run_ok $1 else echo "MISMATCH: $1 was installed from $actual, current is $repository" fi else dry_run_missing $1 fi if test -n "$dry_run"; then exit 0 fi dribble_get "cvs co" $module cvs -d $repository co ${3+-d "$3"} $module | tail_last } get_cvs_full() { get_cvs_aux $3 $2 $1 } get_svn_clnet() { name="$1" path="$2" get_svn $name svn://common-lisp.net/project/$name/svn/$2 } get_cvs_clnet() { module="$1" project="${2:-$1}" get_cvs_aux $module ${CLNET_USER}@common-lisp.net:/project/$project/cvsroot } get_cvs_sfnet() { module="$1" project="${2:-$1}" get_cvs_aux $module ${SF_USER}@$project.cvs.sourceforge.net:/cvsroot/$project } get_ediware() { get_darcs $1 http://common-lisp.net/~loliveira/ediware/$1 } get_clbuild_mirror() { get_darcs $1 http://common-lisp.net/project/clbuild/mirror/$1 } get_lichteblau_com() { get_git $1 http://www.lichteblau.com/git/$1.git } get_b9_com() { get_git $1 http://git.b9.com/$1.git } get_xach_com() { get_git $1 http://git.xach.com/$1.git } update_project() { if test x$1 = x--dry-run; then shift dry_run=1 else unset dry_run fi export dry_run if test $# -ne 1; then exec 1>&2 echo error: invalid number of arguments echo usage: ... update [--dry-run] PROJECT_NAME exit 1 fi if ! grep -h "^$1 " "$BASE/projects" "$BASE/wnpp-projects" >/dev/null; then echo Error: cannot download unknown project $1 rm "$BASE/.clbuild-resume" exit 1 fi found=`grep -h "^$1 " "$BASE/projects" "$BASE/wnpp-projects" | cut -d\# -f1` update_project_2 $found } update_project_2() { name="$1" action="$2" shift shift ( $action $name "$@" ) } update() { if test -n "$clbuild_resume"; then if test $# -gt 0; then echo "error: --resume conflicts with arguments" 1>&2 exit 1 fi previous=`cat "$BASE/.clbuild-resume"` CLBUILD_DEPENDENCIES=no update_1 $previous else rm -f $source_dir/*/.clbuild-skip-update if test $# -gt 0; then update_1 $* else update_1 $main_projects fi fi } update_1() { touch "$BASE"/.core-is-stale TMPDIR=`mktemp -d /tmp/clbuild.XXXXXXXXXX` export TMPDIR cleanup() { if test -f "$BASE/.clbuild-resume"; then exec 1>&2 echo echo error: update was interrupted. echo 'Use "clbuild update --resume" to retry. (See also "clbuild skip PROJECT").' fi rm -rf $TMPDIR } trap cleanup exit cd "$source_dir" touch $TMPDIR/dependencies0 while test $# -ge 1; do echo $1 >>$TMPDIR/arguments0 if grep "^$1 " ../dependencies >/dev/null; then found=`grep "^$1 " ../dependencies` for x in $found; do echo $x >>$TMPDIR/dependencies0 done else echo $1 >>$TMPDIR/dependencies0 echo "warning: no dependencies for $1 found" 1>&2 fi shift done sort <$TMPDIR/arguments0 | uniq >$TMPDIR/arguments sort <$TMPDIR/dependencies0 | uniq >$TMPDIR/dependencies if ! cmp $TMPDIR/arguments $TMPDIR/dependencies >/dev/null; then case "$CLBUILD_DEPENDENCIES" in ask) extra=`diff $TMPDIR/arguments $TMPDIR/dependencies | grep '^>' | cut -d' ' -f2 | xargs echo` echo "The following extra dependencies were found: $extra" echo -n "include dependencies in update? (Y/n)" read reply case _"$reply" in _Y|_y|_) ;; _n) mv $TMPDIR/arguments $TMPDIR/dependencies ;; *) echo Invalid reply exit 1 ;; esac ;; yes) ;; no) mv $TMPDIR/arguments $TMPDIR/dependencies ;; *) echo "error: invalid \$CLBUILD_DEPENDENCIES" 1>&2 exit 1 esac fi cp $TMPDIR/dependencies "$BASE/.clbuild-resume" for project in $(cat $TMPDIR/dependencies); do skipfile="$project"/.clbuild-skip-update if test -f "$skipfile" -a -n "$clbuild_resume"; then echo "resume: skipping update of $project" else ${UPDATE_SCRIPT} ${UPDATE_ARGS} $project ln -f -s $(pwd)/${project}*/*.asd "${system_dir}"/ touch "$skipfile" fi done link_extra_asds rm "$BASE/.clbuild-resume" echo "update complete" count_systems cd .. } link_extra_asds() { # some (buggy) projects try to hide their .asd files from us: ln -sf $source_dir/mcclim/Experimental/freetype/*.asd ${system_dir}/ ln -sf $source_dir/eclipse/system.lisp ${system_dir}/eclipse.asd ln -f -s $source_dir/graphic-forms/src/external-libraries/*/*/*.asd \ ${system_dir} ln -sf $source_dir/clg/*/*.asd ${system_dir} # also, override uffi: ln -sf $source_dir/cffi/uffi-compat/uffi.asd ${system_dir}/ } updatesbcl() { cd ${source_dir} $SBCL_DOWNLOAD_COMMAND # Enable threads if test -z "$windowsp"; then ctf=sbcl/customize-target-features.lisp if test -f $ctf; then echo $ctf already exists else echo creating $ctf echo '(lambda (list) (pushnew :sb-thread list) list)' >$ctf fi fi } list() { pattern="$1" TMPDIR=`mktemp -d /tmp/clbuild.XXXXXXXXXX` export TMPDIR cleanup() { rm -rf $TMPDIR } trap cleanup exit cat "$BASE/projects" "$BASE/wnpp-projects" | sort | grep -i -E "$pattern" | while read project rest; do if test -n "$project" -a x"$project" != 'x#'; then description=`echo $rest | cut -d\# -f2` case `cd $source_dir && ${UPDATE_SCRIPT} --dry-run $project | cut -d: -f1` in MISSING) status=u ;; MISMATCH) status="!" ;; OK) status="i" ;; *) echo "failed to check URL" 1>&2 ;; esac echo "$status $project" >>$TMPDIR/left echo $description >>$TMPDIR/right fi done paste $TMPDIR/left $TMPDIR/right | expand -t 25 exit 0 } scan_projects() { cat $1 | awk '{print $1;}' | while read name; do if test -n "$name" -a x"$name" != 'x#'; then echo -n "$name " fi done }