diff options
| author | tv <tv> | 2006-06-07 15:25:38 +0000 |
|---|---|---|
| committer | tv <tv> | 2006-06-07 15:25:38 +0000 |
| commit | 9f8f8b56853fbb6010afc3995ea972f81cfd5f3d (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /mk/scripts | |
| parent | 78fd8ab75e985cdaa025217d055b5691eb2bef70 (diff) | |
| download | pkgsrc-tv_derecurse.tar.gz | |
EOL the tv-derecurse branch; it has become too outdated. The last livetv_derecurse
revision can be fetched at the tv-derecurse-eol tag.
Diffstat (limited to 'mk/scripts')
| -rwxr-xr-x | mk/scripts/chkdatabase.awk | 115 | ||||
| -rwxr-xr-x | mk/scripts/genindex.awk | 389 | ||||
| -rwxr-xr-x | mk/scripts/genreadme.awk | 770 | ||||
| -rwxr-xr-x | mk/scripts/mkdatabase | 212 | ||||
| -rwxr-xr-x | mk/scripts/mkreadme | 488 | ||||
| -rwxr-xr-x | mk/scripts/print-la-libnames | 77 | ||||
| -rw-r--r-- | mk/scripts/shell-lib | 385 |
7 files changed, 0 insertions, 2436 deletions
diff --git a/mk/scripts/chkdatabase.awk b/mk/scripts/chkdatabase.awk deleted file mode 100755 index c751f9201bc..00000000000 --- a/mk/scripts/chkdatabase.awk +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/awk -f -# -# $NetBSD: chkdatabase.awk,v 1.2 2003/05/06 17:42:04 jmmv Exp $ -# -# Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Dan McMahill. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# This script reads a pkgsrc database created with the 'print-summary-data' -# target and returns a lists of packages which are listed as DEPENDS and/or -# BUILD_DEPENDS but do not have their own dependencies recorded yet. -# This can be used as part of a loop which makes several passes to record -# the complete dependency tree for a package in the database -# - -BEGIN { - if(debug) { - printf("Reading database file\n") > "/dev/stderr"; - fflush("/dev/stderr"); - } -} - -/^(build_)?depends / { -# -# Read in the entire depends tree -# These lines look like: -# -#depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 -#build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base -# - pkg = $2; - -# mark this package as having its depencencies listed - depended_pkgs[pkg] = 1; - -# now go through the dependency lists and pull out all pkg directories that -# we will need to examine to ensure they have been depended. - for(i=3; i<=NF; i++) { - split($i,a,":"); - pkgpat=a[1]; - pkgdir=a[2]; - sub(/[\.\/]*/,"",pkgdir); - if(pkgdir !~ /\//) { - pkgcat=pkg; - gsub(/\/.*/,"",pkgcat); - pkgdir=pkgcat "/" pkgdir; - if(debug) printf("Corrected missing category directory to get \"%s\"\n",pkgdir) > "/dev/stderr"; - } - if(debug){ - printf("package in directory %s %s on:\n",pkg,deptype) > "/dev/stderr"; - printf("\tpkgpat = %s\n",pkgpat) > "/dev/stderr"; - printf("\tpkgdir = %s\n",pkgdir) > "/dev/stderr"; - } - -# mark this package directory as being one which is depended upon - depended_on_pkgs[pkgdir] = 1; - - } - next; -} - - -END { - i=0; - for(pkg in depended_on_pkgs) { - if(pkg in depended_pkgs) { - if(debug) printf("Package: %s is already depended\n",pkg) > "/dev/stderr"; - } - else { - if(debug)printf("Package: %s is NOT depended\n",pkg) > "/dev/stderr"; - not_depended[i]=pkg; - i++; - } - } - - i=0; - while(i in not_depended) { - printf("%s\n",not_depended[i]); - i++; - } - close("/dev/stderr"); - - exit(0); -} diff --git a/mk/scripts/genindex.awk b/mk/scripts/genindex.awk deleted file mode 100755 index 0e109955939..00000000000 --- a/mk/scripts/genindex.awk +++ /dev/null @@ -1,389 +0,0 @@ -#!/usr/bin/awk -f -# $NetBSD: genindex.awk,v 1.4 2003/09/02 07:00:08 jlam Exp $ -# -# Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Dan McMahill. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - - -# Global variables -#----------------- -# The following associative arrays are used for storing the dependency -# information and other information for the packages -# -# topdepends[] : index=pkgdir (math/scilab) -# List of explicitly listed depencencies by name. -# I.e. "xless-[0-9]* pvm-3.4.3" -# -# alldepends[] : index=pkgdir (math/scilab) -# Flattened dependency list by name. -# -# - - -BEGIN { - debug = 0; - printf("Reading database file\n"); -} - -#conflicts /usr/pkgsrc/math/scilab -#depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 -# - -/^(build_)?depends / { -# -# Read in the entire depends tree -# These lines look like: -# -#depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 -#build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base -# - deptype=$1; -# pkg=fulldir2pkgdir($2); - pkg = $2; - if (pkg in topdepends) {} - else {topdepends[pkg] = "";} - if (pkg in topbuilddepends) {} - else {topbuilddepends[pkg] = "";} - - for (i = 3; i <= NF; i++) { - split($i, a,":"); - pkgpat = a[1]; - pkgdir = a[2]; - sub(/[\.\/]*/, "", pkgdir); - if (pkgdir !~ /\//) { - pkgcat = pkg; - gsub(/\/.*/, "", pkgcat); - pkgdir=pkgcat "/" pkgdir; - if (debug) - printf("Corrected missing category directory to get \"%s\"\n", - pkgdir); - } - if (debug){ - printf("package in directory %s %s on:\n", - pkg, deptype); - printf("\tpkgpat = %s\n", pkgpat); - printf("\tpkgdir = %s\n", pkgdir); - } - - -# -# store the package directory in a associative array with the wildcard -# pattern as the index since we will need to be able to look this up later -# - pat2dir[pkgpat] = pkgdir; - - if (deptype == "depends") { - topdepends[pkg] = topdepends[pkg] " " pkgpat " " ; - if (debug) { - printf("Appending %s to topdepends[%s] (%s)\n", - pkgpat, pkg, topdepends[pkg]); - } - } - else { - if (debug) { - printf("Appending %s to topbuilddepends[%s] (%s)\n", - pkgpat, pkg, topbuilddepends[pkg]); - } - topbuilddepends[pkg] = topbuilddepends[pkg] " " pkgpat " " ; - } - } - - next; -} - -/^categories /{ - # note: we pick out the categories slightly differently than the comment - # and homepage because the category name will be included in the directory - # name and hence the index() call points to the wrong location - categories[$2] = $3; - for(i = 4; i <= NF; i = i + 1) { - categories[$2] = categories[$2] " " $i; - } - next; -} - -/^comment /{ - comment[$2] = substr($0, index($0, $3)); - next; -} - -/^descr /{ - descr[$2] = substr($0, index($0, $3)); - next; -} - -/^homepage /{ - if( NF>=3 ) { - homepage[$2] = substr($0, index($0, $3)); - } else { - homepage[$2] = ""; - } - next; -} - -/^index / { -# -# read lines like: -#index /usr/pkgsrc/math/scilab scilab-2.6nb3 -# and store the directory name in a associative array where the index -# is the package name and in a associative array that lets us lookup -# name from directory. We use fuldir2pkgdir to get "math/scilab" -# and drop the /usr/pkgsrc part. -# -# pkgname2dir[$3] = fulldir2pkgdir($2); -# pkgdir2name[fulldir2pkgdir($2)] = $3; - pkgname2dir[$3] = $2; - pkgdir2name[$2] = $3; - next; -} - -/^license /{ - license[$2] = substr($0, index($0, $3)); - next; -} - -/^maintainer /{ - maintainer[$2] = substr($0, index($0, $3)); - next; -} - -/^notfor /{ - notfor[$2] = substr($0, index($0, $3)); - next; -} - -/^onlyfor /{ - onlyfor[$2] = substr($0, index($0, $3)); - next; -} - -/^prefix /{ - prefix[$2] = substr($0, index($0, $3)); - next; -} - -/^wildcard /{ - wildcard[$2] = substr($0, index($0, $3)); - next; -} - -# -# Now recurse the tree to give a flattened depends list for each pkg -# - -END { - if( SORT == "" ) { SORT = "sort"; } - indexf = SORT " > INDEX"; - if ( dependsfile == "" ) dependsfile = "/dev/null"; - if ( builddependsfile == "" ) builddependsfile = "/dev/null"; - - printf("Flattening dependencies\n"); - printf("") > dependsfile; - for (toppkg in topdepends){ - if (debug) printf("calling find_all_depends(%s, run)\n", toppkg); - find_all_depends(toppkg, "run"); - if (debug) printf("%s depends on: %s, topdepends on %s\n", - toppkg, alldepends[toppkg], - topdepends[toppkg]); - printf("%s depends on: %s\n", - toppkg, alldepends[toppkg]) >> dependsfile; - flatdepends[toppkg] = alldepends[toppkg]; - } - close(dependsfile); - - -# clear out the flattened depends list and repeat for the build depends - for( pkg in alldepends) { - delete alldepends[pkg]; - } - - printf("Flattening build dependencies\n"); - printf("") > builddependsfile; - for (toppkg in topbuilddepends){ - find_all_depends(toppkg, "build"); - printf("%s build_depends on: %s\n", - toppkg, alldepends[toppkg]) >> builddependsfile; - } - close(builddependsfile); - - printf("Generating INDEX file\n"); - -# Output format: -# package-name|package-path|installation-prefix|comment| \ -# description-file|maintainer|categories|build deps|run deps|for arch| \ -# not for opsys|homepage - - pkgcnt = 0; - for (toppkg in topdepends){ - pkgcnt++; - printf("%s|", pkgdir2name[toppkg]) | indexf; - printf("%s|", toppkg) | indexf; - printf("%s|", prefix[toppkg]) | indexf; - printf("%s|", comment[toppkg]) | indexf; - printf("%s|", descr[toppkg]) | indexf; - printf("%s|", maintainer[toppkg]) | indexf; - printf("%s|", categories[toppkg]) | indexf; - gsub(/^ /, "", alldepends[toppkg]); - gsub(/ $/, "", alldepends[toppkg]); - printf("%s|", alldepends[toppkg]) | indexf; - gsub(/^ /, "", flatdepends[toppkg]); - gsub(/ $/, "", flatdepends[toppkg]); - printf("%s|", flatdepends[toppkg]) | indexf; - printf("%s|", onlyfor[toppkg]) | indexf; - printf("%s|", notfor[toppkg]) | indexf; - printf("%s", homepage[toppkg]) | indexf; - printf("\n") | indexf; - } - close(indexf); - printf("Indexed %d packages\n", pkgcnt); - exit 0; -} - -function find_all_depends(pkg, type, pkgreg, i, deps, depdir, topdep){ -# pkg is the package directory, like math/scilab - -# printf("find_all_depends(%s, %s)\n", pkg, type); -# if we find the package already has been fully depended -# then return the depends list - if (pkg in alldepends){ - if (debug) printf("\t%s is allready depended. Returning %s\n", - pkg, alldepends[pkg]); - return(alldepends[pkg]); - } - -# if this package has no top dependencies, enter an empty flat dependency -# list for it. - if( type == "run" ) { -# we only want DEPENDS - topdep = topdepends[pkg]; - } else { -# we want BUILD_DEPENDS and DEPENDS - topdep = topdepends[pkg] " " topbuilddepends[pkg]; - } - if (topdep ~ "^[ \t]*$") { - alldepends[pkg] = " "; - if (debug) printf("\t%s has no depends(%s). Returning %s\n", - pkg, topdep, alldepends[pkg]); - return(alldepends[pkg]); - } - -# recursively gather depends that each of the depends has - pkgreg = reg2str(pkg); - split(topdep, deps); - i = 1; - alldepends[pkg] = " "; - while ( i in deps ) { - -# figure out the directory name associated with the package hame -# in (wild card/dewey) version form - depdir = pat2dir[deps[i]]; - if (debug) printf("\tadding dependency #%d on \"%s\" (%s)\n", - i, deps[i], depdir); - -# do not add ourselves to the list (should not happen, but -# we would like to not get stuck in a loop if one exists) -# if (" "deps[i]" " !~ pkgreg){ - -# if we do not already have this dependency (deps[i]) listed, then add -# it. However, we may have already added it because another package -# we depend on may also have depended on -# deps[i]. - if (alldepends[pkg] !~ reg2str(deps[i])){ - alldepends[pkg] = alldepends[pkg] " " deps[i] " " find_all_depends(depdir, type); - } - else { - if (debug) printf("\t%s is already listed in %s\n", - deps[i], alldepends[pkg]); - } - - i = i + 1; - } # while i - - if (debug) printf("\tcalling uniq() on alldepends[%s] = %s\n", - pkg, alldepends[pkg]); - alldepends[pkg] = uniq(alldepends[pkg]); - if (debug) printf("\tuniq() output alldepends[%s] = %s\n", - pkg, alldepends[pkg]); - return(alldepends[pkg]); -} - -# -# take a string which has special characters like '+' in it and -# escape them. Also put a space before and after since that's how -# we'll distinguish things like gnome from gnome-libs -# -function reg2str(reg){ - gsub(/\./, "\\\.", reg); - gsub(/\+/, "\\\+", reg); - gsub(/\*/, "\\\*", reg); - gsub(/\?/, "\\\?", reg); - gsub(/\[/, "\\\[", reg); - gsub(/\]/, "\\\]", reg); - reg = " "reg" "; - return(reg); -} - -# -# accepts a full path to a package directory, like "/usr/pkgsrc/math/scilab" -# and returns just the last 2 directories, like "math/scilab" -# -function fulldir2pkgdir(d, i){ - i = match(d, /\/[^\/]+\/[^\/]+$/); - return substr(d, i + 1); -} - -# -# take the depends lists and uniq them. -# -function uniq(list, deps, i, ulist){ - -# split out the depends - split(list, deps); - - i = 1; - ulist = " "; - while (i in deps){ -# printf("uniq(): Checking \"%s\"\n", ulist); -# printf(" for \"%s\"\n", reg2str(deps[i])); - if (ulist !~reg2str(deps[i])){ - ulist = ulist deps[i]" "; - } - i++; - } - return(ulist); -} - - - diff --git a/mk/scripts/genreadme.awk b/mk/scripts/genreadme.awk deleted file mode 100755 index a653f592511..00000000000 --- a/mk/scripts/genreadme.awk +++ /dev/null @@ -1,770 +0,0 @@ -#!/usr/bin/awk -f -# $NetBSD: genreadme.awk,v 1.12 2004/07/06 22:49:18 wiz Exp $ -# -# Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Dan McMahill. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - - -# Global variables -#----------------- -# The following associative arrays are used for storing the dependency -# information and other information for the packages -# -# topdepends[] : index=pkgdir (math/scilab) -# List of explicitly listed depencencies by name. -# I.e. "xless-[0-9]* pvm-3.4.3" -# -# alldepends[] : index=pkgdir (math/scilab) -# Flattened dependency list by name. -# -BEGIN { - do_pkg_readme=1; -# set to 1 to use "README-new.html" as the name - use_readme_new=0; - printf("Reading database file\n"); - fflush("/dev/stdout"); -} - -#conflicts /usr/pkgsrc/math/scilab -#depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 -# - -/^(build_)?depends / { -# -# Read in the entire depends tree -# These lines look like: -# -#depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 -#build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base -# - deptype=$1; -# pkg=fulldir2pkgdir($2); - pkg = $2; - if (pkg in topdepends) {} - else {topdepends[pkg] = "";} - if (pkg in topbuilddepends) {} - else {topbuilddepends[pkg] = "";} - - for (i = 3; i <= NF; i++) { - split($i, a,":"); - pkgpat = a[1]; - pkgdir = a[2]; - sub(/[\.\/]*/, "", pkgdir); - if (pkgdir !~ /\//) { - pkgcat = pkg; - gsub(/\/.*/, "", pkgcat); - pkgdir=pkgcat "/" pkgdir; - if (debug) - printf("Corrected missing category directory to get \"%s\"\n", - pkgdir); - } - if (debug){ - printf("package in directory %s %s on:\n", - pkg, deptype); - printf("\tpkgpat = %s\n", pkgpat); - printf("\tpkgdir = %s\n", pkgdir); - } - - -# -# store the package directory in a associative array with the wildcard -# pattern as the index since we will need to be able to look this up later -# - pat2dir[pkgpat] = pkgdir; - - if (deptype == "depends") { - topdepends[pkg] = topdepends[pkg] " " pkgpat " " ; - if (debug) { - printf("Appending %s to topdepends[%s] (%s)\n", - pkgpat, pkg, topdepends[pkg]); - } - } - else { - if (debug) { - printf("Appending %s to topbuilddepends[%s] (%s)\n", - pkgpat, pkg, topbuilddepends[pkg]); - } - topbuilddepends[pkg] = topbuilddepends[pkg] " " pkgpat " " ; - } - } - - next; -} - -/^comment /{ - dir = $2; - gsub(/^comment[ \t]*/, ""); - tmp = substr($0, length($1) + 1); - gsub(/^[ \t]*/, "", tmp); - gsub(/&/, "\\\\\\&", tmp); - comment[dir] = tmp; - next; -} - -/^homepage /{ - homepage[$2] = $3; - gsub(/&/, "\\\\&", homepage[$2]); - next; -} - - -/^htmlname / { -# -# read lines like: -# htmlname /usr/pkgsrc/archivers/arc <a href=../../archivers/arc/README.html>arc-5.21e</A> -# -# dir=fulldir2pkgdir($2); - dir = $2; - htmlname = $3; - for (i = 4; i <= NF; i++){ - htmlname = htmlname " " $i; - } - dir2htmlname[dir] = htmlname; - if (debug) printf("added dir2htmlname[%s]=%s\n", dir, htmlname); - next; -} - -/^index / { -# -# read lines like: -#index /usr/pkgsrc/math/scilab scilab-2.6nb3 -# and store the directory name in a associative array where the index -# is the package name and in a associative array that lets us lookup -# name from directory. We use fuldir2pkgdir to get "math/scilab" -# and drop the /usr/pkgsrc part. -# -# pkgname2dir[$3] = fulldir2pkgdir($2); -# pkgdir2name[fulldir2pkgdir($2)] = $3; - pkgname2dir[$3] = $2; - pkgdir2name[$2] = $3; - next; -} - -/^license /{ - license[$2] = $3; - next; -} - -/^wildcard /{ - wildcard[$2] = $3; -} - -# -# Now recurse the tree to give a flattened depends list for each pkg -# - -END { - if (use_readme_new) { - readme_name = "README-new.html"; - } - else { - readme_name = "README.html"; - } - readme = TMPDIR "/" readme_name; - - if ( dependsfile == "" ) dependsfile = "/dev/stdout"; - if ( builddependsfile == "" ) builddependsfile = "/dev/stdout"; - - printf("Flattening dependencies\n"); - fflush("/dev/stdout"); - printf("") > dependsfile; - for (toppkg in topdepends){ - if (debug) printf("calling find_all_depends(%s, run)\n", toppkg); - find_all_depends(toppkg, "run"); - if (debug) printf("%s depends on: %s, topdepends on %s\n", - toppkg, alldepends[toppkg], - topdepends[toppkg]); - printf("%s depends on: %s\n", - toppkg, alldepends[toppkg]) >> dependsfile; - flatdepends[toppkg] = alldepends[toppkg]; - } - close(dependsfile); - - -# clear out the flattened depends list and repeat for the build depends - delete alldepends; - printf("Flattening build dependencies\n"); - fflush("/dev/stdout"); - printf("") > builddependsfile; - for (toppkg in topbuilddepends){ - find_all_depends(toppkg, "build"); - printf("%s build_depends on: %s\n", - toppkg, alldepends[toppkg]) >> builddependsfile; - } - close(builddependsfile); - - vfile = DISTDIR "/pkg-vulnerabilities"; - -# extract date for vulnerabilities file - cmd = "ls -l " vfile; - if ((cmd | getline) > 0) { - vuldate = sprintf("at %s %s %s\n",$6,$7,$8); -# read the vulnerabilities file - printf("Reading vulnerability file \"%s\"\n which was updated %s\n", - vfile, vuldate); - fflush("/dev/stdout"); - i = 1; - while((getline < vfile) > 0) { - if ($0 !~ /^\#/) { - vulpkg[i] = $1; - vultype[i] = $2; - vulref[i] = $3; - i = i + 1; - } - } - printf(" Loaded %d vulnerabilities\n", i - 1); - close(vfile); - have_vfile = 1; - } else { - vuldate="<TR><TD><I>(no vulnerabilities list available)</I>"; - printf("No vulnerability file found (%s).\n", vfile); - have_vfile = 0; - } - close(cmd); - fflush("/dev/stdout"); - - if (SINGLEPKG != "" ) { - printf("Only creating README for %s\n",SINGLEPKG); - delete topdepends; - topdepends[SINGLEPKG] = "yes"; - } - - printf("Generating README.html files\n"); - fflush("/dev/stdout"); - pkgcnt = 0; - if (do_pkg_readme) { - templatefile = PKGSRCDIR "/templates/README.pkg"; - fatal_check_file(templatefile); - for (toppkg in topdepends){ - pkgcnt++; - pkgdir = PKGSRCDIR "/" toppkg; - readmenew=pkgdir "/" readme_name; - - if (debug) printf("Creating %s for %s\n", - readme, readmenew); - printf("."); - if ((pkgcnt % 100) == 0) { - printf("\n%d\n", pkgcnt); - } - fflush("/dev/stdout"); - printf("") > readme; - htmldeps = ""; - delete dpkgs; - split(alldepends[toppkg], dpkgs); - i = 1; - while(i in dpkgs){ - if (debug) { - printf("\tdpkg=%s, pat2dir[%s] = %s\n", - dpkgs[i], - dpkgs[i], - pat2dir[dpkgs[i]]); - } - nm=dpkgs[i]; - -# we need a zillion escapes here because we need to end up -# with \\< in 'htmldeps' so that when -# we gsub htmldeps into the output file, we end up with < - - gsub(/&/, "\\\\\\&", nm); - gsub(/</, "\\\\\\<", nm); - gsub(/>/, "\\\\\\>", nm); - htmldeps=sprintf("%s<a href=\"../../%s/%s\">%s</a>\n", - htmldeps, - pat2dir[dpkgs[i]], - readme_name, nm); - i = i + 1; - } - if ( htmldeps == "" ) { - htmldeps = "<EM>none</EM>"; - } - if (debug) printf("htmldeps = \"%s\"\n", htmldeps); - - vul = ""; - if (have_vfile) { - i = 1; - pkgbase = pkgdir2name[toppkg]; - gsub(/-[^-]*$/, "", pkgbase); - if (debug) { - printf("Checking for %s (%s) vulnerabilities\n", - toppkg, pkgbase); - } - while(i in vulpkg) { - nm = vulpkg[i]; - gsub(/&/, "\\\\\\&", nm); - gsub(/</, "\\\\\\<", nm); - gsub(/>/, "\\\\\\>", nm); - url = vulref[i]; - gsub(/&/, "\\\\\\&", url); - printurl = vulref[i]; - gsub(/&/, "\\\\\\&", printurl); - gsub(/</, "\\\\\\<", printurl); - gsub(/>/, "\\\\\\>", printurl); - if (vulpkg[i] ~ "^" pkgbase"[-<>=]+[0-9]") { - vul = sprintf("%s<LI><STRONG> %s has a %s exploit (see <a href=\"%s\">%s</a> for more details)</STRONG></LI>\n", - vul, nm, - vultype[i], - url, printurl); - } - i = i + 1; - } - if ( vul == "" ){ - vul="<I>(no vulnerabilities known)</I>"; - } - } - - if (MULTIARCH == "no"){ - cmd="ls -1 "PACKAGES "/" PKGREPOSITORYSUBDIR "/" wildcard[toppkg] PKG_SUFX " 2>/dev/null"; - if (debug) { - printf("Checking for binary package with %s\n", - cmd); - } - binpkgs = ""; - while((cmd | getline) > 0) { - pkgfile = $0; - gsub(/.*\//, "", pkgfile); - pkgnm = pkgfile; - gsub(/\.tgz$/, "", pkgnm); - binpkgs = sprintf("%s\n<TR><TD>%s:<TD><a href=\"%s/%s\">%s</a><TD>(%s %s)", - binpkgs, - MACHINE_ARCH, - PKG_URL, - pkgfile, - pkgnm, - OPSYS, - OS_VERSION); - } - close(cmd); - } - else { - cmd = "ls -1 -d "PACKAGES"/[0-9].*/*/" PKGREPOSITORYSUBDIR "/" wildcard[toppkg] PKG_SUFX " 2>/dev/null"; - oldfs = FS; - FS = "[/]"; - binpkgs = ""; - while((cmd | getline) > 0) { - release = $(NF-3); - arch = $(NF-2); - pkg = $NF; - pkgnm = pkg; - gsub(PKG_SUFX "$", "", pkgnm) - if (debug) { - printf("%s:%s:%s (%s)\n", - release, - arch, - pkg, - pkgnm); - } - binpkgs = sprintf("%s\n<TR><TD>%s:<TD><a href=\"%s/%s/%s/%s/%s\">%s</a><TD>(%s-%s)", - binpkgs, arch, - PKG_URL, release, - arch, - PKGREPOSITORYSUBDIR, - pkg, pkgnm, - OPSYS, release); - } - FS = oldfs; - close(cmd); - } - -# sort the binary pkgs (XXX would be nice to implement in memory in awk) - sfile = TMPDIR "/sorted"; - spipe = "sort > " sfile; - printf("%s",binpkgs) | spipe; - close(spipe); - binpkgs = ""; - while((getline < sfile) > 0) { - binpkgs = sprintf("%s\n%s", binpkgs, $0); - } - close(sfile); - - if (debug) printf("binary packages: \n%s\n\n", - binpkgs); - - if ( flatdepends[toppkg] ~ /^[ \t]*$/ ) { - rundeps = "<EM>none</EM>"; - } else { - rundeps = flatdepends[toppkg]; - } - - while((getline < templatefile) > 0){ - gsub(/%%PORT%%/, toppkg); - gsub(/%%PKG%%/, pkgdir2name[toppkg]); - gsub(/%%COMMENT%%/, comment[toppkg]); - if (homepage[toppkg] == "") { - gsub(/%%HOMEPAGE%%/, ""); - } else { - gsub(/%%HOMEPAGE%%/, - "<p>This package has a home page at <a HREF=\"" homepage[toppkg] "\">" homepage[toppkg] "</a>.</p>"); - } - if (license[toppkg] == "") { - gsub(/%%LICENSE%%/, ""); - } else { - gsub(/%%LICENSE%%/, - "<p>Please note that this package has a " license[toppkg] " license.</p>"); - } - gsub(/%%VULNERABILITIES%%/, ""vul""); - gsub(/%%VULDATE%%/, ""vuldate""); - gsub(/%%BUILD_DEPENDS%%/, ""htmldeps""); - gsub(/%%RUN_DEPENDS%%/, ""rundeps""); - gsub(/%%BIN_PKGS%%/, ""binpkgs""); - gsub(/README.html/, readme_name); - print >> readme; - } - close(readme); - close(templatefile); - cmd = "if [ ! -d " pkgdir " ]; then exit 1 ; fi"; - if (debug) printf("Execute: %s\n",cmd); - rc = system(cmd); - if (rc != 0) { - printf("\n**** WARNING ****\nPackage directory %s\n", - pkgdir) > "/dev/stderr"; - printf("Does not exist. This is probably ") > "/dev/stderr"; - printf("due to an incorrect DEPENDS line.\n") > "/dev/stderr"; - printf("Try running: grep %s */*/Makefile\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; - printf("or: grep %s */*/buildlink3.mk\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; - printf("to find the problem\n", pkgdir) > "/dev/stderr"; - printf("**** ------- ****\n") > "/dev/stderr"; - } else { - copy_readme(readmenew, readme); - } - } - printf("\n"); - } # if (do_pkg_readme) - printf("\n"); - if (SINGLEPKG != "" ) { - close("/dev/stderr"); - exit 0; - } - printf("Generating category readmes\n"); - templatefile = PKGSRCDIR "/templates/README.category"; - fatal_check_file(templatefile); - -# string with URLs for all categories (used by the top README.html) - allcat = ""; -# string with URLs for all pkgs (used by the top README-all.html) - tot_numpkg = 0; - top_make = PKGSRCDIR"/Makefile"; - while((getline < top_make) > 0){ - if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { - category = $0; - gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", category); - catdir = PKGSRCDIR"/"category; - readmenew = catdir"/"readme_name; - printf("Category = %s\n", category); - cat_make = catdir"/Makefile"; - pkgs = ""; - numpkg = 0; - print "" > readme; - while((getline < cat_make) > 0){ - if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { - pkg = $0; - gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", - pkg); - dir = category"/"pkg; - numpkg++; - tot_numpkg++; - if (debug) { - printf("\tAdding %s (%s : %s)\n", - dir, - pkgdir2name[dir], - comment[dir]); - } - pkgs = sprintf("%s<TR><TD VALIGN=TOP><a href=\"%s/%s\">%s</a>: %s<TD>\n", - pkgs, pkg, readme_name, - pkgdir2name[dir], - comment[dir]); - allpkg[tot_numpkg] = sprintf("<!-- %s (for sorting) --><TR VALIGN=TOP><TD><a href=\"%s/%s/%s\">%s</a>: <TD>(<a href=\"%s/%s\">%s</a>) <td>%s\n", - pkgdir2name[dir], - category, pkg, - readme_name, - pkgdir2name[dir], - category, - readme_name, - category, - comment[dir]); -# we need slightly fewer escapes here since we are not gsub()-ing -# allpkg[] into the output files but just printf()-ing it. - gsub(/\\&/, "\\&", allpkg[tot_numpkg]); - } else if ($0 ~ /^[ \t]*COMMENT/) { - descr = $0; - gsub(/^[ \t]*COMMENT.*=[ \t]*/, "", - descr); - } - } - while ((getline < templatefile) > 0){ - gsub(/%%CATEGORY%%/, category); - gsub(/%%NUMITEMS%%/, numpkg); - gsub(/%%DESCR%%/, descr); - gsub(/%%SUBDIR%%/, pkgs); - gsub(/README.html/, readme_name); - print >> readme; - } - close(readme); - close(templatefile); - copy_readme(readmenew, readme); - - gsub(/href=\"/, "href=\""category"/", pkgs); - allcat = sprintf("%s<TR><TD VALIGN=TOP><a href=\"%s/%s\">%s</a>: %s<TD>\n", - allcat, category, readme_name, - category, descr); - close(cat_make); - } - } - close(top_make); - - printf("Generating toplevel readmes:\n"); - templatefile = PKGSRCDIR "/templates/README.top"; - fatal_check_file(templatefile); - readmenew = PKGSRCDIR "/"readme_name; - printf("\t%s\n", readmenew); - print "" > readme; - while((getline < templatefile) > 0){ - gsub(/%%DESCR%%/, ""); - gsub(/%%SUBDIR%%/, allcat); - gsub(/README.html/, readme_name); - print >> readme; - } - close(readme); - close(templatefile); - copy_readme(readmenew, readme); - - templatefile = PKGSRCDIR "/templates/README.all"; - fatal_check_file(templatefile); - readmenew = PKGSRCDIR "/README-all.html"; - printf("\t%s\n", readmenew); -# sort the pkgs - sfile = TMPDIR"/unsorted"; - spipe = "sort " sfile; - i = 1; - print "" >sfile; - while(i in allpkg) { - printf("%s",allpkg[i]) >> sfile; - i++; - } - close(sfile); - - print "" > readme; - while((getline < templatefile) > 0){ - line = $0; - if ($0 ~ /%%PKGS%%/) { - while((spipe | getline) > 0) { - print >> readme; - } - close(spipe); - } else { - gsub(/%%DESCR%%/, "", line); - gsub(/%%NPKGS%%/, tot_numpkg, line); - gsub(/README.html/, readme_name, line); - print line >> readme; - } - } - close(readme); - close(templatefile); - copy_readme(readmenew, readme); - - close("/dev/stderr"); - exit 0; -} - -function find_all_depends(pkg, type, pkgreg, i, deps, depdir, topdep){ -# pkg is the package directory, like math/scilab - -# printf("find_all_depends(%s, %s)\n", pkg, type); -# if we find the package already has been fully depended -# then return the depends list - if (pkg in alldepends){ - if (debug) printf("\t%s is allready depended. Returning %s\n", - pkg, alldepends[pkg]); - return(alldepends[pkg]); - } - -# if this package has no top dependencies, enter an empty flat dependency -# list for it. - if( type == "run" ) { -# we only want DEPENDS - topdep = topdepends[pkg]; - } else { -# we want BUILD_DEPENDS and DEPENDS - topdep = topdepends[pkg] " " topbuilddepends[pkg]; - } - if (topdep ~ "^[ \t]*$") { - alldepends[pkg] = " "; - if (debug) printf("\t%s has no depends(%s). Returning %s\n", - pkg, topdep, alldepends[pkg]); - return(alldepends[pkg]); - } - -# recursively gather depends that each of the depends has - pkgreg = reg2str(pkg); - split(topdep, deps); - i = 1; - alldepends[pkg] = " "; - while ( i in deps ) { - -# figure out the directory name associated with the package hame -# in (wild card/dewey) version form - depdir = pat2dir[deps[i]]; - if (debug) printf("\tadding dependency #%d on \"%s\" (%s)\n", - i, deps[i], depdir); - -# do not add ourselves to the list (should not happen, but -# we would like to not get stuck in a loop if one exists) -# if (" "deps[i]" " !~ pkgreg){ - -# if we do not already have this dependency (deps[i]) listed, then add -# it. However, we may have already added it because another package -# we depend on may also have depended on -# deps[i]. - if (alldepends[pkg] !~ reg2str(deps[i])){ - alldepends[pkg] = alldepends[pkg] " " deps[i] " " find_all_depends(depdir, type); - } - else { - if (debug) printf("\t%s is already listed in %s\n", - deps[i], alldepends[pkg]); - } - - i = i + 1; - } # while i - - if (debug) printf("\tcalling uniq() on alldepends[%s] = %s\n", - pkg, alldepends[pkg]); - alldepends[pkg] = uniq(alldepends[pkg]); - if (debug) printf("\tuniq() output alldepends[%s] = %s\n", - pkg, alldepends[pkg]); - return(alldepends[pkg]); -} - -# -# take a string which has special characters like '+' in it and -# escape them. Also put a space before and after since that's how -# we'll distinguish things like gnome from gnome-libs -# -function reg2str(reg){ - gsub(/\./, "\\\.", reg); - gsub(/\+/, "\\\+", reg); - gsub(/\*/, "\\\*", reg); - gsub(/\?/, "\\\?", reg); - gsub(/\[/, "\\\[", reg); - gsub(/\]/, "\\\]", reg); - reg = " "reg" "; - return(reg); -} - -# -# accepts a full path to a package directory, like "/usr/pkgsrc/math/scilab" -# and returns just the last 2 directories, like "math/scilab" -# -function fulldir2pkgdir(d, i){ - i = match(d, /\/[^\/]+\/[^\/]+$/); - return substr(d, i + 1); -} - -# -# take the depends lists and uniq them. -# -function uniq(list, deps, i, ulist){ - -# split out the depends - split(list, deps); - - i = 1; - ulist = " "; - while (i in deps){ -# printf("uniq(): Checking \"%s\"\n", ulist); -# printf(" for \"%s\"\n", reg2str(deps[i])); - if (ulist !~reg2str(deps[i])){ - ulist = ulist deps[i]" "; - } - i++; - } - return(ulist); -} - -function fatal_check_file(file, cmd){ - cmd="test -f "file ; - if (debug) printf("Execute: %s\n",cmd); - if (system(cmd) != 0) { - printf("**** FATAL ****\nRequired file %s does not exist\n", - file) > "/dev/stderr"; - printf("**** ------- ****\n") > "/dev/stderr"; - close("/dev/stderr"); - exit(1); - } -} - -# 'new' is the newly created README.html file -# 'old' is the existing (possibly not present) README.html file -# -# This function copies over the 'new' file if the 'old' one does -# not exist or if they are different. In addition, the 'new' one -# which is a temporary file is removed at the end - -function copy_readme(old, new, cmd, rc) { - -# if the README.html file does not exist at all then copy over -# the one we created - - cmd = "if [ ! -f "old" ]; then cp " new " " old " ; fi"; - if (debug) printf("copy_readme() execute: %s\n",cmd); - rc = system(cmd); - if (rc != 0) { - printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; - printf("failed with result code %d\n", rc) > "/dev/stderr"; - printf("**** ------- ****\n") > "/dev/stderr"; - } - -# Compare the existing README.html file to the one we created. If they are -# not the same, then copy over the one we created - - cmd = " if ! cmp -s "new" "old" ; then mv -f " new " " old " ; fi"; - if (debug) printf("copy_readme() execute: %s\n",cmd); - rc = system(cmd); - if (rc != 0) { - printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; - printf("failed with result code %d\n", rc) > "/dev/stderr"; - printf("**** ------- ****\n") > "/dev/stderr"; - } - -# If the temp file still exists, then delete it - cmd = " if [ -f "new" ]; then rm -f "new" ; fi"; - if (debug) printf("copy_readme() execute: %s\n",cmd); - rc = system(cmd); - if (rc != 0) { - printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; - printf("failed with result code %d\n", rc) > "/dev/stderr"; - printf("**** ------- ****\n") > "/dev/stderr"; - } - -} - diff --git a/mk/scripts/mkdatabase b/mk/scripts/mkdatabase deleted file mode 100755 index 739464e8e7b..00000000000 --- a/mk/scripts/mkdatabase +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh -# $NetBSD: mkdatabase,v 1.4 2003/05/06 17:42:05 jmmv Exp $ -# -# Script for generating a database with complete dependency information -# for a particular package -# -# Copyright (c) 2003 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Dan McMahill. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - - -TMPDIR=${TMPDIR:-/tmp} -BMAKE=${BMAKE:-make} -AWK=${AWK:-/usr/bin/awk} -DATABASE=${DATABASE:-${TMPDIR}/pkgdb.$$} -EXPR=${EXPR:-expr} - -# as of 2003-01-04, metapkgs/gnome gets to pass #6 so -# it is very likely that if you reach 25, something is broken -MAX_PASS=${MAX_PASS:-25} - -prog=$0 - -usage(){ - echo "$prog - Generates a complete dependency tree for a particular package" - echo "Usage: $prog [-a|--append] [-d|--debug] [-f|--database database]" - echo " " - echo " $prog -h|--help" - echo " " - echo " $prog -v|--version" - echo " " - echo "The options supported by $prog are: " - echo " " - echo " -a|--append Append to the database rather than overwriting it" - echo " " - echo " -d|--debug Enables debugging output" - echo " " - echo " -f|--database <file> Writes the database into file specified by <file>" - echo " " - echo " -h|--help Displays this help message" - echo " " - echo " -v|--version Displays the version of this script and exits." - echo " " - echo "Example: cd /usr/pkgsrc/graphics/gimp && $prog -d /tmp/gimp_database" - echo " " -} - -clean_and_exit(){ - exit 1 -} - - -###################################################################### -# -# Handle command line options -# -###################################################################### - -DEBUG= -append=no - -while - test -n "$1" -do - case "$1" - in - - # Append to the database - -a|--append) - append=yes - shift - ;; - - # Turn on debugging - -d|--debug) - DEBUG=yes - shift - ;; - - # Use the specified database file - -f|--database) - DATABASE=$2 - shift 2 - ;; - - # Help - -h|--help) - usage - exit 0 - ;; - - # Version - -v|--version) - ${AWK} '/^#[ \t]*\$NetBSD/ {gsub(/,v/,"",$3);printf("%s: Version %s, %s\n",$3,$4,$5); exit 0;}' $prog - exit 0 - ;; - - -*) echo "$prog: ERROR: $1 is not a valid option" - usage - clean_and_exit - ;; - - *) - break - ;; - - esac -done - -if [ "x$DEBUG" = "xyes" ]; then - set -v -fi - -if [ ! -d $TMPDIR ]; then - mkdir -p $TMPDIR -fi - -prompt="----> " - -case ${DATABASE} in - /*) - # we already have the absolute path to the database file - # so do nothing - ;; - - *) - # make sure we have the full path to the database file - DATABASE=`pwd`/${DATABASE} - ;; -esac - - -if [ "X$append" = "Xyes" ]; then - echo "$prompt Appending to database in ${DATABASE}" - if [ ! -f ${DATABASE} ]; then - touch ${DATABASE} - fi - # make sure we haven't already been listed before - # appending ourselves. - here=`pwd` - tmp1=`dirname $here` - pkgcat=`basename $tmp1` - pkg=`basename $here` - pkgpath=$pkgcat/$pkg - if [ "x$DEBUG" = "xyes" ]; then - echo "Looking for $pkgpath before appending" - fi - if grep "^index $pkgpath " ${DATABASE} >/dev/null 2>&1 ; then - echo "$prompt $pkgpath has already been depended. Skipping..." - exit 0 - else - ${BMAKE} print-summary-data >> ${DATABASE} || exit 1 - fi -else - echo "$prompt Creating new database in ${DATABASE}" - ${BMAKE} print-summary-data > ${DATABASE} || exit 1 -fi -here=`pwd` -echo "$prompt Depending in $here (pass #1)" -dirs=`${AWK} -f ../../mk/scripts/chkdatabase.awk debug=${DEBUG} ${DATABASE}` -pass=2 -while [ ! -z "$dirs" -a $pass -lt ${MAX_PASS} ]; do - for d in $dirs ; do - echo "$prompt Depending in ../../$d (pass #$pass)" ;\ - cd ../../$d && ${BMAKE} print-summary-data >> ${DATABASE} || exit 1 - cd $here - done - dirs=`${AWK} -f ../../mk/scripts/chkdatabase.awk debug=${DEBUG} ${DATABASE}` - pass=`${EXPR} $pass + 1` -done - -if [ $pass -eq ${MAX_PASS} ]; then - echo "ERROR: You have reached $pass times through the dependency tree" - echo " and _still_ not finished. This is probably due to a broken" - echo " set of dependencies. You may wish to examine the partial" - echo " database left in ${DATABASE}" - exit 1 -else - echo "Complete dependency database left in ${DATABASE}" -fi - diff --git a/mk/scripts/mkreadme b/mk/scripts/mkreadme deleted file mode 100755 index 231cdb36ee1..00000000000 --- a/mk/scripts/mkreadme +++ /dev/null @@ -1,488 +0,0 @@ -#!/bin/sh -# $NetBSD: mkreadme,v 1.4 2003/09/23 01:51:44 yyamano Exp $ -# -# Script for README.html generation -# -# Copyright (c) 2002 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Dan McMahill. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - - -TMPDIR=${TMPDIR:-/tmp/mkreadme} -PKGSRCDIR=${PKGSRCDIR:-/usr/pkgsrc} -BMAKE=${BMAKE:-make} -AWK=${AWK:-/usr/bin/awk} -EXPR=${EXPR:-expr} - -usage(){ - echo "$prog - Generates README.html files for a pkgsrc tree" - echo "Usage: $prog [-c|--cdrom] [-C|--prune] [-d|--debug] [-f|--ftp] " - echo " [-m|--multi-arch] [-p|--pkgsrc directory] " - echo " [-P|--packages directory] [-r|--restart] " - echo " [-s|--single-arch] [-S|--save-database]" - echo " " - echo " $prog -h|--help" - echo " " - echo " $prog -v|--version" - echo " " - echo "The options supported by $prog are: " - echo " " - echo " -C|--prune Prune unused README.html files which may exist in" - echo " pkg directories which have been removed from CVS." - echo " " - echo " -c|--cdrom Generates CD-ROM README.html files" - echo " " - echo " -d|--debug Enables (extremely verbose) debug output" - echo " " - echo " -f|--ftp Generates FTP README.html files" - echo " " - echo " -h|--help Displays this help message" - echo " " - echo " -m|--multi-arch Assumes a packages directory layout like:" - echo " OS_VERSION/MACHINE_ARCH/ for example:" - echo " 1.{5,6}/{alpha,i386,sparc,vax}" - echo " " - echo " -p|--pkgsrc dir Specifies the pkgsrc directory. Defaults to" - echo " The value of the PKGSRCDIR environment variable" - echo " if set or /usr/pkgsrc otherwise." - echo " " - echo " -P|--packages dir Specifies the packages directory." - echo " " - echo " -r|--restart Restart. This option assumes that the database file" - echo " from a previous run still exists and that the script" - echo " should use that instead of recreating the database." - echo " " - echo " -s|--single-arch Assumes a single OS release and MACHINE_ARCH binary" - echo " packages directory structure." - echo " " - echo " -S|--save-database Does not delete the database file after the run." - echo " This is useful for debugging or re-running this script" - echo " with the -r option." - echo " " - echo " -v|--version Displays the version of this script and exits." - echo " " - echo "Example: $prog -p /pub/NetBSD/packages/pkgsrc -P /pub/NetBSD/packages -m -f" - echo " " -} - -clean_and_exit(){ - if [ "x$DEBUG" = "xno" -a "x$restart" = "xno" -a "x$save" = "xno" ]; then - rm -fr $TMPDIR - else - echo "Debugging output left in $TMP" - fi - exit 1 -} - -prog=$0 - - -###################################################################### -# -# Handle command line options -# -###################################################################### - -ftp_readme=no -restart=no -prune=no -DEBUG=no -save=no - -while - test -n "$1" -do - case "$1" - in - - # We're generating README.html's for a CD-ROM - -c|--cdrom) - ftp_readme=no - shift - ;; - - # Prune old README.html files from pkgs which no longer exist - -C|--prune) - prune=yes - shift - ;; - - # Turn on debugging - -d|--debug) - DEBUG=yes - shift - ;; - - # We're generating README.html's for a CD-ROM - -f|--ftp) - ftp_readme=yes - shift - ;; - - - # Help - -h|--help) - usage - exit 0 - ;; - - # assume a OS_RELEASE/MACHINE_ARCH/ layout for the binary pkgs - -m|--multi-arch) - multiarch=yes - shift - ;; - - # Specify pkgsrc directory - -p|--pkgsrc) - PKGSRCDIR=$2 - shift 2 - ;; - - # Specify PACKAGES directory - -P|--packages) - PKGDIR=$2 - shift 2 - ;; - - # Restart (ie, don't re-generate the database file) - -r|--restart) - restart=yes - shift - ;; - - # assume a single directory structure layout for the binary pkgs - -s|--single-arch) - multiarch=no - shift - ;; - - # Save the database files - -S|--save-database) - save=yes - shift - ;; - - # Version - -v|--version) - ${AWK} '/^#[ \t]*\$NetBSD/ {gsub(/,v/,"",$3);printf("%s: Version %s, %s\n",$3,$4,$5); exit 0;}' $prog - exit 0 - ;; - - -*) echo "$prog: ERROR: $1 is not a valid option" - usage - clean_and_exit - ;; - - *) - break - ;; - - esac -done - -if [ "x$DEBUG" = "xyes" ]; then - set -v -fi - -if [ ! -d ${PKGSRCDIR} ]; then - echo "ERROR: package source directory ${PKGSRCDIR} does not exist" - echo "" - clean_and_exit -fi - -if [ ! -d $TMPDIR ]; then - mkdir -p $TMPDIR -fi - -DEPENDSTREEFILE=$TMPDIR/dependstree -export DEPENDSTREEFILE -DEPENDSFILE=$TMPDIR/depends -export DEPENDSFILE -SUPPORTSFILE=$TMPDIR/supports -export SUPPORTSFILE -INDEXFILE=$TMPDIR/index -export SUPPORTSFILE -ORDERFILE=$TMPDIR/order -export ORDERFILE -DATABASEFILE=$TMPDIR/database -export DATABASEFILE -BINPKGFILE=$TMPDIR/binpkglist - -echo "Starting README.html generation: `date`" - -###################################################################### -# -# Extract key pkgsrc configuration variables -# -###################################################################### - -echo " " -echo "Extracting configuration variables:" -echo " " -if [ -d ${PKGSRCDIR}/pkgtools/pkglint ]; then - cd ${PKGSRCDIR}/pkgtools/pkglint - - for v in DISTDIR PACKAGES PKGREPOSITORYSUBDIR PKG_SUFX MACHINE_ARCH PKG_URL OPSYS OS_VERSION FTP_PKG_URL_HOST FTP_PKG_URL_DIR CDROM_PKG_URL_HOST CDROM_PKG_URL_DIR - do - val=`${BMAKE} show-var VARNAME=${v}` - if [ $? != 0 ]; then - echo "Error: make show-var VARNAME=${v} in `pwd` " - echo "Failed. This is a fatal error" - clean_and_exit - fi - echo "$v=$val" - eval ${v}=${val} - done -else - echo "Error: ${PKGSRCDIR}/pkgtools/pkglint does not seem to exist" - exit 1 -fi - - -###################################################################### -# -# Decide on FTP vs CDROM README.html files -# -###################################################################### - -if [ "$ftp_readme" = "yes" ]; then - PKG_URL=${FTP_PKG_URL_HOST}${FTP_PKG_URL_DIR} - echo "Will generate FTP readme files with PKG_URL=$PKG_URL" -else - PKG_URL=${CDROM_PKG_URL_HOST}${CDROM_PKG_URL_DIR} - echo "Will generate CD-ROM readme files with PKG_URL=$PKG_URL" -fi - -###################################################################### -# -# Check for command line switch for packages directory -# -###################################################################### - -# we've been given the directory as a command line switch -if [ ! -z "$PKGDIR" ]; then - PACKAGES=$PKGDIR - echo "PACKAGES specified on command line to be $PKGDIR" -fi - -###################################################################### -# -# Decide in binary package directory layout -# -###################################################################### - - -# If PACKAGES is set to the default (../../pkgsrc/packages), the current -# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory -# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed. -# -# This is the logic from bsd.pkg.mk, but I think I'd like to change it to -# come from a command line switch - -if [ -z "$multiarch" -a -e ${PACKAGES} ]; then - cd ${PACKAGES} - case `pwd` in - */pkgsrc/packages) - multiarch=no - ;; - - *) - multiarch=yes - ;; - esac -fi - -if [ "x$multiarch" = "xyes" ]; then - echo "Will generate multi-release, multi-arch readme files" -else - echo "Will generate single-release, single-arch readme files" -fi - - -###################################################################### -# -# Extract Database for All Packages (longest step) -# -###################################################################### - -if [ "x$restart" = "xno" ] ; then - echo " " - echo "Extracting data. This could take a while" - echo " " - npkg=1 - - # make sure we don't have an old database lying around - rm -fr $DATABASEFILE - - cd ${PKGSRCDIR} - list=`grep '^[[:space:]]*'SUBDIR */Makefile | sed 's,/Makefile.*=[[:space:]]*,/,'` - for pkgdir in $list - do - if [ ! -d $pkgdir ]; then - echo " " - echo "WARNING: the package directory $pkgdir is listed in" > /dev/stderr - echo $pkgdir | sed 's;/.*;/Makefile;g' > /dev/stderr - echo "but the directory does not exist. Please fix this!" > /dev/stderr - else - cd $pkgdir - l=`${BMAKE} print-summary-data` - if [ $? != 0 ]; then - echo "WARNING (printdepends): the package in $pkgdir had problem with" \ - > /dev/stderr - echo " ${BMAKE} print-summary-data" > /dev/stderr - echo " database information for this package" > /dev/stderr - echo " will be dropped." > /dev/stderr - ${BMAKE} print-summary-data 2>&1 > /dev/stderr - else - echo "$l" >> $DATABASEFILE - fi - fi - echo -n "." - if [ `${EXPR} $npkg % 100 = 0` -eq 1 ]; then - echo " " - echo "$npkg" - fi - npkg=`${EXPR} $npkg + 1` - cd $PKGSRCDIR - done -else - echo " " - echo "Using existing database (are you sure you wanted the -r/--restart flag?)" - echo " " - if [ ! -f $DATABASEFILE ]; then - echo " " - echo "ERROR: You have use the -r/--restart flag but the database " - echo " file $DATABASEFILE does not exist" - echo " " - exit 1 - fi -fi - -###################################################################### -# -# Generate the package and category README.html files -# -###################################################################### - -echo " " -echo "Generating package README.html files" -echo " " -if [ "x$DEBUG" = "xyes" ]; then - debug=1; -else - debug=0; -fi - -${AWK} -f ${PKGSRCDIR}/mk/scripts/genreadme.awk \ - builddependsfile=${TMPDIR}/pkgsrc.builddepends.debug \ - debug=$debug \ - dependsfile=${TMPDIR}/pkgsrc.depends.debug \ - DISTDIR=$DISTDIR \ - MACHINE_ARCH=$MACHINE_ARCH \ - MULTIARCH=$multiarch \ - OPSYS=$OPSYS \ - OS_VERSION=$OS_VERSION \ - PACKAGES=$PACKAGES \ - PKG_SUFX=$PKG_SUFX \ - PKG_URL=$PKG_URL \ - PKGREPOSITORYSUBDIR=$PKGREPOSITORYSUBDIR \ - PKGSRCDIR=$PKGSRCDIR \ - TMPDIR=$TMPDIR \ - ${DATABASEFILE} - -if [ $? != 0 ]; then - echo "Error: genreadme.awk failed to create README.html files" - clean_and_exit -fi - -###################################################################### -# -# Generate the README-IPv6.html file -# -###################################################################### - -echo " " -echo "Generating the README-IPv6.html file" -echo " " -cd ${PKGSRCDIR} -ipv6=${TMPDIR}/ipv6pkgs -ipv6_entries=${TMPDIR}/ipv6_entries -grep -l '^BUILD_DEFS.*=.*USE_INET6' */*/Makefile | sed 's;Makefile;;g' > $ipv6 -fgrep -f $ipv6 README-all.html | sort -t/ +1 > $ipv6_entries -sed \ - -e "/%%TRS%%/r${ipv6_entries}" \ - -e '/%%TRS%%/d' \ - templates/README.ipv6 > ${TMPDIR}/README-IPv6.html -if [ $? != 0 ]; then - echo "Error: README-IPv6.html generation failed (on sed script)" - clean_and_exit -fi -if [ ! -f README-IPv6.html ] || ! cmp -s ${TMPDIR}/README-IPv6.html README-IPv6.html ; then - mv -f ${TMPDIR}/README-IPv6.html README-IPv6.html -else - echo "README-IPv6.html is unchanged (no changes were needed)" -fi - -###################################################################### -# -# Prune README.html files which are no longer needed -# -###################################################################### -if [ "x$prune" = "xyes" ]; then - echo " " - echo "Pruning unused README.html files" - echo " " - cd ${PKGSRCDIR} - for d in `ls -d */*` ; do - if [ -d $d -a ! -f ${d}/Makefile -a -f ${d}/README.html ]; then - echo "Pruning ${d}/README.html which is no longer used" - rm -f ${d}/README.html - fi - done -fi - -###################################################################### -# -# All done. Clean (if needed) and exit -# -###################################################################### -echo " " -echo "README.html generation finished: `date`" -echo " " -if [ "x$DEBUG" = "xno" -a "x$restart" = "xno" -a "x$save" = "xno" ]; then - rm -fr $TMPDIR -else - echo "Debugging output left in $TMPDIR" -fi - diff --git a/mk/scripts/print-la-libnames b/mk/scripts/print-la-libnames deleted file mode 100755 index a37a9459ead..00000000000 --- a/mk/scripts/print-la-libnames +++ /dev/null @@ -1,77 +0,0 @@ -# /bin/sh -# -# $NetBSD: print-la-libnames,v 1.4 2004/11/12 21:21:08 jlam Exp $ -# -# Copyright (c) 2004 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Todd Vierling. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -: ${ECHO=echo} -: ${GREP=grep} -: ${SORT=sort} - -for la -do - dir="${la%/*.la}" - library_names= - old_library= - - case $dir in - $la) dir= ;; - *) dir="$dir/" ;; - esac - case $la in - /*|./*) lapath="$la" ;; - *) lapath="./$la" ;; - esac - - if [ -r "$lapath" -a ! -h "$lapath" ]; then - if ${GREP} -q "libtool library file" "$lapath"; then - . "$lapath" - if [ "$installed" = "no" ]; then - ${ECHO} 1>&2 "$0: \`$lapath' was not properly installed" - exit 1 - fi - for lib in $library_names $old_library; do - libpath="$dir$lib" - if [ ! -f "$libpath" ]; then - ${ECHO} 1>&2 "$0: \`$libpath' was not found" - fi - ${ECHO} "$libpath" - done - fi - else - ${ECHO} 1>&2 "$0: cannot read libtool archive \`$lapath'" - fi -done | ${SORT} -u diff --git a/mk/scripts/shell-lib b/mk/scripts/shell-lib deleted file mode 100644 index 1d8cb95ac40..00000000000 --- a/mk/scripts/shell-lib +++ /dev/null @@ -1,385 +0,0 @@ -# $NetBSD: shell-lib,v 1.2 2004/09/21 15:14:08 jlam Exp $ -# -# Copyright (c) 2004 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Johnny C. Lam. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -###################################################################### -# msg_log logfile msg -# Output msg to logfile. If logfile is "stdout" or "stderr" -# then output to there instead. -###################################################################### -msg_log() -{ - : ${echo=echo} - - _msg_log="$1"; shift - case $_msg_log in - stdout) $echo "$@" ;; - stderr) $echo "$@" 1>&2 ;; - *) $echo "$@" >> $_msg_log ;; - esac -} - -###################################################################### -# die msg -# Output $msg to stderr, and exit with a positive error code. -###################################################################### -die() -{ - msg_log stderr "$@" - exit 1 -} - -###################################################################### -# check_prog var prog ... -# If $var is empty or unset, then set it to the path of one of -# the program names in the list. -###################################################################### -check_prog() -{ - : ${test=test} - - _ckp_var="$1"; shift - - eval _ckp_tmp=\"\$$_ckp_var\" - if $test "x$_ckp_tmp" != "x"; then - return 0 - fi - - for _ckp_prog do - _ckp_IFS="${IFS}"; IFS=":" - for _ckp_dir in ${PATH}; do - if $test -x "$_ckp_dir/$_ckp_prog"; then - eval $_ckp_var=\""$_ckp_dir/$_ckp_prog"\" - return 1 - fi - done - IFS="${_ckp_IFS}" - done - - die "$_ckp_var could not be set." -} - -###################################################################### -# shquote arg -# Returns a backslashed and quoted version of arg in $shquoted. -###################################################################### -shquote() -{ - : ${echo=echo} - : ${sed=sed} - - _shq_arg=$1 - _shq_sed="$sed -e 1s/^X//" - _shq_sed_quote_subst='s/\([\`\"$\\]\)/\\\1/g' - case $_shq_arg in - *[\`\"\$\\]*) - shquoted=`$echo "X$_shq_arg" | $_shq_sed -e "$_shq_sed_quote_subst"` - ;; - *) - shquoted="$_shq_arg" - ;; - esac - case $shquoted in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - shquoted="\"$shquoted\"" - ;; - esac -} - -###################################################################### -# lock_file -f path [-n token] -# Attempt to create a lockfile at $path. Any directories in the -# path should already exist. If $token is specified, then assume -# that it is unique between machines sharing an NFS mount. -# -# (1) Create globally-unique filename in the same filesystem as the -# lockfile. -# (2) Try to create a hard-link from this file to the lockfile, but -# ignoring any errors. -# (3) If the two files are the same file, then the lock was successfully -# obtained; otherwise, the lock attempt wasn't successful. -###################################################################### -lock_file() -{ - : ${dirname=dirname} - : ${echo=echo} - : ${link=link} - : ${mkdir=mkdir} - : ${mktemp=mktemp} - : ${rm=rm} - : ${test=test} - : ${touch=touch} - - _lf_lockfile= - _lf_nfs= - while $test $# -gt 0; do - case $1 in - -f) _lf_lockfile="$2"; shift ;; - -n) _lf_nfs="$2"; shift ;; - esac - shift - done - if $test -z "$_lf_lockfile"; then - $echo 1>&2 "$0: no lock file specified." - exit - fi - _lf_pid=$$ - _lf_lockdir=`$dirname $_lf_lockfile` - _lf_uniqfile=`$mktemp "$_lf_lockdir/.lock.$_lf_nfs.$_lf_pid.XXXXXX" 2>/dev/null` || return 1 - if $test -n "$_lf_nfs"; then - { $echo $_lf_pid; $echo $_lf_nfs; } > $_lf_uniqfile - else - $echo $_lf_pid > $_lf_uniqfile - fi - $link $_lf_uniqfile $_lf_lockfile 2>/dev/null - if $test $_lf_uniqfile -ef $_lf_lockfile; then - _lf_result=0 - else - _lf_result=1 - fi - $rm -f $_lf_uniqfile - return $_lf_result -} - -###################################################################### -###################################################################### -### -### Queue routines. The queue is implemented as a set of variables -### that is unique to each queue name, thus the use of multiple queues -### is allowed. -### -###################################################################### -###################################################################### - -###################################################################### -# init_queue name -# Initialize the named queue. -###################################################################### -init_queue() -{ - _qname="$1" - eval "_q${_qname}head=1111111111" - eval "_q${_qname}tail=1111111111" -} - -###################################################################### -# append_queue name item ... -# Append items onto the end of the named queue in FIFO order. -###################################################################### -append_queue() -{ - : ${test=test} - - _qname="$1"; shift - while $test $# -gt 0; do - eval "_qtail=\"\$_q${_qname}tail\"" - eval "_q${_qname}${_qtail}=\"\${1}\"" - case $_qtail in - *000000000) _qtail=${_qtail%000000000}1 ;; - *) _qtail=${_qtail}0 ;; - esac - eval "_q${_qname}tail=\"\${_qtail}\"" - shift - done -} - -###################################################################### -# prepend_queue name item ... -# Prepend items to the head of the named queue in LIFO order. -###################################################################### -prepend_queue() -{ - : ${test=test} - - _qname="$1"; shift - while $test $# -gt 0; do - eval "_qhead=\"\$_q${_qname}head\"" - case $_qhead in - *1) _qhead=${_qhead%1}000000000 ;; - *) _qhead=${_qhead%0} ;; - esac - eval "_q${_qname}${_qhead}=\"\${1}\"" - eval "_q${_qname}head=\"\${_qhead}\"" - shift - done -} - -###################################################################### -# head_queue name var -# Return the head of the named queue in $var. -###################################################################### -head_queue() -{ - _qname="$1"; shift - eval "_qhead=\"\$_q${_qname}head\"" - eval "${1}=\"\$_q${_qname}${_qhead}\"" -} - -###################################################################### -# pop_queue name var -# Pop off the head of the named queue and return it in $var. -###################################################################### -pop_queue() -{ - _qname="$1"; shift - head_queue $_qname $1 - case $_qhead in - *000000000) _qhead=${_qhead%000000000}1 ;; - *) _qhead=${_qhead}0 ;; - esac - eval "_q${_qname}head=\"\${_qhead}\"" -} - -###################################################################### -# queue_is_empty name -# Return 0 if the named queue is empty and 1 otherwise. -###################################################################### -queue_is_empty() -{ - : ${test=test} - - _qname="$1" - eval "_qhead=\"\$_q${_qname}head\"" - eval "_qtail=\"\$_q${_qname}tail\"" - $test "$_qhead" = "$_qtail" - return $? -} - -###################################################################### -###################################################################### -### -### File queue routines. The file queue is implemented as a file -### whose lines represent the queue elements. The file queue name -### is simply the file used for the queue, thus the use of multiple -### queues is allowed. -### -###################################################################### -###################################################################### - -###################################################################### -# init_fqueue name -# Initialize the named file queue. -###################################################################### -init_fqueue() -{ - _fqname="$1" - : > "$_fqname" -} - -###################################################################### -# append_fqueue name item ... -# Append items onto the end of the named file queue in FIFO order. -###################################################################### -append_fqueue() -{ - : ${echo=echo} - : ${test=test} - - _fqname="$1"; shift - while $test $# -gt 0; do - $echo "$1" >> "$_fqname" - shift - done -} - -###################################################################### -# prepend_fqueue name item ... -# Prepend items to the head of the named file queue in LIFO order. -###################################################################### -prepend_fqueue() -{ - : ${cat=cat} - : ${echo=echo} - : ${mv=mv} - - _fqname="$1"; shift - _fqtmpfile="$_fqname.$$" - init_queue _fqtmpqueue - prepend_queue _fqtmpqueue "$@" - while ! queue_is_empty _fqtmpqueue; do - pop_queue _fqtmpqueue _fqelt - $echo "$_fqelt" >> "$_fqtmpfile" - done - $cat "$_fqname" >> "$_fqtmpfile" - $mv -f "$_fqtmpfile" "$_fqname" -} - -###################################################################### -# head_fqueue name var -# Return the head of the named file queue in $var. -###################################################################### -head_fqueue() -{ - : ${head=head} - - _fqname="$1"; shift - _tmp=`$head -n 1 "$_fqname"` - eval "${1}=\"\$_tmp\"" -} - -###################################################################### -# pop_fqueue name var -# Pop off the head of the named file queue and return it in $var. -###################################################################### -pop_fqueue() -{ - : ${mv=mv} - : ${sed=sed} - - _fqname="$1"; shift - _fqtmpfile="$_fqname.$$" - head_fqueue "$_fqname" $1 - $sed "1,1d" "$_fqname" >> "$_fqtmpfile" - $mv -f "$_fqtmpfile" "$_fqname" -} - -###################################################################### -# fqueue_is_empty name -# Return 0 if the named file queue is empty and >0 otherwise. -###################################################################### -fqueue_is_empty() -{ - : ${test=test} - : ${wc=wc} - - _fqname="$1" - if $test -f "$_fqname"; then - _fqlines=`$wc -l < "$_fqname"` - return $_fqlines - else - return 1 - fi -} |
