summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorseb <seb>2001-11-30 12:16:07 +0000
committerseb <seb>2001-11-30 12:16:07 +0000
commite20ca40dfa3b65ecc0bac8874887cfff20d9e06c (patch)
treed44845fe8350f31550b16e20099da254e1689d25 /pkgtools
parent78bdaf783c78d7ad4ea706257aa44e683384e00f (diff)
downloadpkgsrc-e20ca40dfa3b65ecc0bac8874887cfff20d9e06c.tar.gz
Update to 0.2.
Nearly a complete rewrite in order to deal with the following situation: a package's Makefile include a Makefile fragment (like a buildlink.mk file) which does not exist, so `$MAKE show-depends-dirs' cannot be run. To resolve this pkgcvsupdate now try to figure out which package provide the missing file and update it first (and its dependencies), it will update a second time the crippled package in case the fragment - hopefully now in place - brings along new dependencies. Thanks to zuntum for this interesting case I overlooked!
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkgcvsupdate/Makefile6
-rw-r--r--pkgtools/pkgcvsupdate/files/pkgcvsupdate.17
-rwxr-xr-xpkgtools/pkgcvsupdate/files/pkgcvsupdate.sh167
3 files changed, 107 insertions, 73 deletions
diff --git a/pkgtools/pkgcvsupdate/Makefile b/pkgtools/pkgcvsupdate/Makefile
index 0b38d42d069..c5c4bc0b0e0 100644
--- a/pkgtools/pkgcvsupdate/Makefile
+++ b/pkgtools/pkgcvsupdate/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.1.1.1 2001/11/29 14:13:27 seb Exp $
+# $NetBSD: Makefile,v 1.2 2001/11/30 12:16:07 seb Exp $
-DISTNAME= pkgcvsupdate-0.1
+DISTNAME= pkgcvsupdate-0.2
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
@@ -28,11 +28,13 @@ DIFF?= diff
do-build:
${SED} \
+ -e 's|@AWK@|${AWK}|g' \
-e 's|@BASENAME@|${BASENAME}|g' \
-e 's|@DIRNAME@|${DIRNAME}|g' \
-e 's|@GREP@|${GREP}|g' \
-e 's|@LS@|${LS}|g' \
-e 's|@MAKE@|${MAKE}|g' \
+ -e 's|@SED@|${SED}|g' \
-e 's|@TEST@|${TEST}|g' \
< ${FILESDIR}/pkgcvsupdate.sh \
> ${WRKSRC}/pkgcvsupdate
diff --git a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1 b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
index f52f682948b..f8a5bf31e6e 100644
--- a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
+++ b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkgcvsupdate.1,v 1.1.1.1 2001/11/29 14:13:27 seb Exp $
+.\" $NetBSD: pkgcvsupdate.1,v 1.2 2001/11/30 12:16:08 seb Exp $
.\"
.\" Copyright (c) 2001 Stoned Elipot. All rights reserved.
.\"
@@ -50,6 +50,11 @@ depend on.
Any arguments of
.Nm
are passed down to the CVS's update command.
+.Sh ENVIRONMENT VARIABLES
+.Bl -tag -width CVS_OPTIONS
+.It Ev CVS_OPTIONS
+Specify options to pass to cvs.
+.El
.Sh SEE ALSO
.Xr cvs 1 ,
.Pa ${PKGSRCDIR}/Packages.txt
diff --git a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
index 0ad3e34ff7b..8be0ef2e98e 100755
--- a/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
+++ b/pkgtools/pkgcvsupdate/files/pkgcvsupdate.sh
@@ -1,96 +1,123 @@
#! /bin/sh -
-# $NetBSD: pkgcvsupdate.sh,v 1.1.1.1 2001/11/29 14:13:27 seb Exp $
+# $NetBSD: pkgcvsupdate.sh,v 1.2 2001/11/30 12:16:08 seb Exp $
+AWK=@AWK@
BASENAME=@BASENAME@
DIRNAME=@DIRNAME@
GREP=@GREP@
LS=@LS@
MAKE=@MAKE@
+SED=@SED@
TEST=@TEST@
args="$@"
cwd=`pwd`
+dirs_updated=":"
-# get packages to update for a start
-if $TEST -f ../../Packages.txt && $TEST -d ../../pkgtools/digest ; then
- # we are in a package directory: only one package to start with
- start_pkgs=`$MAKE show-var VARNAME=PKGPATH`
- if $TEST $? -ne 0 || $TEST x"$start_pkgs" = x ; then
- exit 1
+cvs_update()
+{
+_cwd=`pwd`
+case $dirs_updated in
+ *:$_cwd:*) return 0;; # already updated
+esac
+echo "==> $_cwd"
+cvs ${CVS_OPTIONS} update $args || return 1
+dirs_updated="$dirs_updated$_cwd:"
+}
+
+get_make_included_files()
+{
+$GREP '^\.include' Makefile | \
+$AWK '$2 !~ /mk\//{ gsub(/["<>]/, "", $2); print $2 }' || exit 1
+}
+
+recursive_cvs_update()
+{
+_dirs_toupdate="$*"
+while true ; do
+ # get the next package directory to update
+ set blah $_dirs_toupdate
+ shift
+ _dir=$1
+ if $TEST x"$_dir" = x ; then
+ break # all done
+ fi
+ shift
+ _dirs_toupdate="$*"
+ # cd into it and update...
+ if $TEST -d $_dir ; then
+ cd $_dir || exit 1
+ cvs_update
+ 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
+ cd $_dir || exit 1
fi
- pkgsrcdir=`$MAKE show-var VARNAME=PKGSRCDIR`
- if $TEST $? -ne 0 || $TEST x"$pkgsrcdir" = x ; then
- exit 1
+ _cwd=`pwd`
+ # get the dependencies...
+ _depends=`$MAKE show-depends-dirs`
+ if $TEST $? -ne 0; then
+ # ...it failed try to see if it's because included Makefile
+ # fragments are missing and queue up the packages providing
+ # them
+ _included_files=`get_make_included_files`
+ for _f in $_included_files ; do
+ case x$_f in
+ x../*)
+ _dirs_toupdate="$_cwd/`$DIRNAME $_f` $_dirs_toupdate";;
+ esac
+ done
+ # and we would like to visit again the current package
+ # directory in the end
+ dirs_updated=`echo $dirs_updated | $SED -e "s,:$_cwd:,:,"`
+ _dirs_toupdate="$_dirs_toupdate $_cwd"
+ else
+ # queue up the dependencies of the current package
+ for _p in $_depends ; do
+ _dirs_toupdate="$_cwd/../../$_p $_dirs_toupdate"
+ done
fi
+done
+}
+
+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
+
+ # update the current package directory and needed dependencies
+ recursive_cvs_update $cwd
+
elif $TEST -f Makefile && $TEST -f ../Packages.txt ; then
# we are in category directory: get the package list of this
# category
- pkg_list=`$MAKE -V SUBDIR`
- if $TEST $? -ne 0 || $TEST x"$start_pkgs" = x ; then
+
+ # update mk
+ cd ../mk && cvs_update && 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 ?)
- pkg_list=""
- for f in * ; do
- if $TEST -f $f/Makefile ; then
- pkg_list="$pkg_list $f"
+ _list=""
+ for _f in * ; do
+ if $TEST -f $_f/Makefile ; then
+ _list="$_list $_f"
fi
done
fi
- category=`$BASENAME $cwd`
- if $TEST $? -ne 0 || $TEST x"$category" = x ; then
- exit 1
- fi
- start_pkgs=""
- for p in $pkg_list ; do
- start_pkgs="$start_pkgs $category/$p"
+ _dirs=""
+ for _p in $_list ; do
+ _dirs="$_dirs $cwd/$_p"
done
- pkgsrcdir=`$DIRNAME $cwd`
- if $TEST $? -ne 0 || $TEST x"$pkgsrcdir" = x ; then
- exit 1
- fi
+
+ # update the category packages' directories and their dependencies
+ recursive_cvs_update $_dirs
else
echo "Not in a package or category directory" 1>&2
- exit
+ exit 1
fi
-
-# first update pkgsrc infrastructure...
-cd $pkgsrcdir/mk || exit 1
-echo "==> mk"
-cvs update $@ || exit 1
-
-# ... then needed packages
-pkg_toupdate=$start_pkgs
-pkg_updated=""
-while true; do
- # get next package to update
- set blah $pkg_toupdate
- shift
- pkg=$1
- if $TEST x"$pkg" = x ; then
- break # all done
- fi
- shift
- pkg_toupdate="$*"
- # check if we already updated it...
- case :$pkg_updated: in
- *:$pkg:*) continue ;; # ...yes: on to next one
- esac
- # ...no: updating it
- if cd $pkgsrcdir/$pkg ; then :; else
- # package directory is not there, this may be a new package:
- # try to check it out. This would also fail if it is
- # a brand new category! Oh well...
- cd $pkgsrcdir/`$BASENAME $pkg` || exit 1
- cvs checkout $args `$DIRNAME $pkg` || exit 1
- fi
- echo "==> $pkg"
- cvs update $args || exit 1
- # record we updated if
- pkg_updated="$pkg_updated:$pkg"
- # queue dependency packages
- pkg_depends=`$MAKE show-depends-dirs`
- if $TEST $? -ne 0 ; then
- exit 1
- fi
- pkg_toupdate="$pkg_toupdate $pkg_depends"
-done