summaryrefslogtreecommitdiff
path: root/pkgtools/pkgcvsupdate
diff options
context:
space:
mode:
authorseb <seb>2002-01-07 12:39:24 +0000
committerseb <seb>2002-01-07 12:39:24 +0000
commitc8ba5ed1af7be3d7ae79a7d97733209b8caa85f2 (patch)
treecdec64578783756ea26b9002b0ec384d059c3850 /pkgtools/pkgcvsupdate
parente7b9ced370ddbdec04c37ba6f4c85d5bce99644a (diff)
downloadpkgsrc-c8ba5ed1af7be3d7ae79a7d97733209b8caa85f2.tar.gz
Update to version 0.3
New feature: Somewhat rewritten to support run from top-level pkgsrc directory. When run from there pkgcvsupdate launchs a separate cvs update for each caterory directory. This is believed to be faster than a single cvs run. Thanks to Simon Burge for this! Bugfix: First update a category Makefile (by way of a non-recursive update in the category directory) before finding out which packages are included in it.
Diffstat (limited to 'pkgtools/pkgcvsupdate')
-rw-r--r--pkgtools/pkgcvsupdate/Makefile4
-rw-r--r--pkgtools/pkgcvsupdate/files/pkgcvsupdate.111
-rwxr-xr-xpkgtools/pkgcvsupdate/files/pkgcvsupdate.sh100
3 files changed, 78 insertions, 37 deletions
diff --git a/pkgtools/pkgcvsupdate/Makefile b/pkgtools/pkgcvsupdate/Makefile
index c5c4bc0b0e0..2df71b2b653 100644
--- a/pkgtools/pkgcvsupdate/Makefile
+++ b/pkgtools/pkgcvsupdate/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.2 2001/11/30 12:16:07 seb Exp $
+# $NetBSD: Makefile,v 1.3 2002/01/07 12:39:24 seb Exp $
-DISTNAME= pkgcvsupdate-0.2
+DISTNAME= pkgcvsupdate-0.3
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1 b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
index f8a5bf31e6e..a75864ff05b 100644
--- a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
+++ b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkgcvsupdate.1,v 1.2 2001/11/30 12:16:08 seb Exp $
+.\" $NetBSD: pkgcvsupdate.1,v 1.3 2002/01/07 12:39:25 seb Exp $
.\"
.\" Copyright (c) 2001 Stoned Elipot. All rights reserved.
.\"
@@ -41,11 +41,14 @@
.Sh DESCRIPTION
The
.Nm
-utility should be run from a package's main directory or a package category
-directory. It first updates the pkgsrc infrastructure in
+utility should be run from a package's main directory, a package category
+directory or the top-level pkgsrc directory. It first updates the pkgsrc
+infrastructure in
.Pa ${PKGSRCDIR}/mk ,
then the package's files and recursively all the packages' files it
-depend on.
+depend. When run from the top-level pkgsrc directory it run a separate CVS
+update for each category directory, this is believed to be faster than
+a single CVS invocation.
.Pp
Any arguments of
.Nm
diff --git a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
index 8be0ef2e98e..81aeac63c49 100755
--- a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
+++ b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
@@ -1,5 +1,5 @@
#! /bin/sh -
-# $NetBSD: pkgcvsupdate.sh,v 1.2 2001/11/30 12:16:08 seb Exp $
+# $NetBSD: pkgcvsupdate.sh,v 1.3 2002/01/07 12:39:25 seb Exp $
AWK=@AWK@
BASENAME=@BASENAME@
@@ -10,28 +10,64 @@ MAKE=@MAKE@
SED=@SED@
TEST=@TEST@
-args="$@"
+cvs_cmd_args="$@"
cwd=`pwd`
dirs_updated=":"
+# low-level cvs update
cvs_update()
{
_cwd=`pwd`
+if $TEST "x$1" = x. ; then
+ echo "==> $_cwd"
+else
+ echo "==> $_cwd/$1"
+fi
+cvs ${CVS_OPTIONS} update $cvs_cmd_args $1 || return 1
+}
+
+# update a directory tree
+cvs_update_dir()
+{
+_cwd=`pwd`
case $dirs_updated in
*:$_cwd:*) return 0;; # already updated
esac
-echo "==> $_cwd"
-cvs ${CVS_OPTIONS} update $args || return 1
+cvs_update . || return 1
dirs_updated="$dirs_updated$_cwd:"
}
+# get the file included in ./Makefile
get_make_included_files()
{
$GREP '^\.include' Makefile | \
$AWK '$2 !~ /mk\//{ gsub(/["<>]/, "", $2); print $2 }' || exit 1
}
-recursive_cvs_update()
+# get the "make sub-directory"
+get_subdirs()
+{
+# update local files first
+_oldcvs_cmd_args="$cvs_cmd_args"
+cvs_cmd_args="-l $cvs_cmd_args"
+cvs_update . || return 1
+cvs_cmd_args="$oldcvs_cmd_args"
+subdirs=`$MAKE -V SUBDIR`
+if $TEST $? -ne 0 || $TEST x"$subdirs" = x ; then
+ # perhaps we don't have the -V flags to make (pre NetBSD 1.3
+ # make ?)
+ # XXX FIXME: we could miss a new directory here
+ subdirs=""
+ for _f in * ; do
+ if $TEST -f $_f/Makefile ; then
+ subdirs="$subdirs $_f"
+ fi
+ done
+fi
+}
+
+# update a list of package directories and their dependencies
+recursive_cvs_update_pkgdir()
{
_dirs_toupdate="$*"
while true ; do
@@ -47,12 +83,12 @@ while true ; do
# cd into it and update...
if $TEST -d $_dir ; then
cd $_dir || exit 1
- cvs_update
+ cvs_update_dir
else
# ...the directory does not exist, that would be a brand new
# package we try to check it out instead
cd `$DIRNAME $_dir` || exit 1
- cvs ${CVS_OPTIONS} checkout $args `$BASENAME $_dir` || exit 1
+ cvs ${CVS_OPTIONS} checkout $cvs_cmd_args `$BASENAME $_dir` || exit 1
cd $_dir || exit 1
fi
_cwd=`pwd`
@@ -86,38 +122,40 @@ if $TEST -f ../../Packages.txt && $TEST -d ../../pkgtools/digest ; then
# we are in a package directory...
# update mk
- cd ../../mk && cvs_update && cd $cwd || exit 1
+ cd ../../mk && cvs_update_dir && cd $cwd || exit 1
# update the current package directory and needed dependencies
- recursive_cvs_update $cwd
+ recursive_cvs_update_pkgdir $cwd
-elif $TEST -f Makefile && $TEST -f ../Packages.txt ; then
- # we are in category directory: get the package list of this
- # category
+elif $TEST -f Makefile && \
+ ( $TEST -f ../Packages.txt || $TEST -f Packages.txt) ; then
+ # we are in category directory or in the top-level pkgsrc directory
# update mk
- cd ../mk && cvs_update && cd $cwd || exit 1
+ $TEST -d ../mk && cd ../mk || cd mk || exit 1
+ cvs_update_dir && cd $cwd || exit 1
- # get the packages in this category
- _list=`$MAKE -V SUBDIR`
- if $TEST $? -ne 0 || $TEST x"$_list" = x ; then
- # perhaps we don't have the -V flags to make (pre NetBSD 1.3
- # make ?)
- _list=""
- for _f in * ; do
- if $TEST -f $_f/Makefile ; then
- _list="$_list $_f"
- fi
- done
+ # get the packages in this category or all the categories
+ get_subdirs
+ if $TEST $? -ne 0 || $TEST x"$subdirs" = x ; then
+ echo "could not get the sub-directories in $cwd" 1>&2
+ exit 1
fi
- _dirs=""
- for _p in $_list ; do
- _dirs="$_dirs $cwd/$_p"
- done
- # update the category packages' directories and their dependencies
- recursive_cvs_update $_dirs
+ if $TEST -f ../Packages.txt ; then
+ # update the category packages' directories and their
+ # dependencies
+ _dirs=""
+ for _p in $subdirs ; do
+ _dirs="$_dirs $cwd/$_p"
+ done
+ recursive_cvs_update_pkgdir $_dirs
+ else
+ for _p in $subdirs ; do
+ cvs_update $_p || exit 1
+ done
+ fi
else
- echo "Not in a package or category directory" 1>&2
+ echo "Not in a package, category or toplevel directory" 1>&2
exit 1
fi