Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/sets Factor duplicated code for setting variables su...



details:   https://anonhg.NetBSD.org/src/rev/12be317b5502
branches:  trunk
changeset: 555686:12be317b5502
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue Nov 25 07:19:46 2003 +0000

description:
Factor duplicated code for setting variables such as machine_cpu
and machine_arch to their defaults into sets.defaults, and source
it at the top of each script.

Also, to be consistent with variable naming, s/arch/machine_arch/.

sets.defaults introduces two new variables, krb and krb4, which
will affect whether Kerberos- or Kerberos IV-only files are put
into the set lists.

diffstat:

 distrib/sets/listpkgs      |  17 ++++++++---------
 distrib/sets/makeflist     |  16 +++++-----------
 distrib/sets/makeobsolete  |  17 +++++++----------
 distrib/sets/makeplist     |  21 +--------------------
 distrib/sets/maketars      |   7 +++----
 distrib/sets/sets.defaults |  24 ++++++++++++++++++++++++
 distrib/sets/sets.subr     |  10 +++++++++-
 distrib/sets/syspkgdeps    |   6 ++++--
 8 files changed, 61 insertions(+), 57 deletions(-)

diffs (290 lines):

diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/listpkgs
--- a/distrib/sets/listpkgs     Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/listpkgs     Tue Nov 25 07:19:46 2003 +0000
@@ -1,14 +1,13 @@
 #!/bin/sh
 #
-# $NetBSD: listpkgs,v 1.5 2003/06/23 09:20:55 dyoung Exp $
+# $NetBSD: listpkgs,v 1.6 2003/11/25 07:19:46 dyoung Exp $
 #
 # List all packages in the given pkgset by parsing the list files.
 #
 
 # set defaults
-MAKE="${MAKE:-make} -j 1"
-machine=${MACHINE:-`printf 'xxx:\n\techo ${MACHINE}' | ${MAKE} -s -f-`}
-arch=${MACHINE_ARCH:-`printf 'xxx:\n\techo ${MACHINE_ARCH}' | ${MAKE} -s -f-`}
+. ./sets.defaults
+
 setd=`dirname $0`
 prefix=/
 
@@ -18,7 +17,7 @@
 exec 1>&2
 
 echo "Usage: $0 [-a arch] [-m machine] [-s setsdir] [-p prefix] setname"
-echo " -a arch         set arch (e.g, m68k, mips, powerpc)     [$arch]"
+echo " -a arch         set arch (e.g, m68k, mips, powerpc)     [$machine_arch]"
 echo " -m machine      set machine (e.g, amiga, i386, macppc)  [$machine]"
 echo " -s setsdir      directory to find sets                  [$setd]"
 echo " setname set to list packages for"
@@ -30,7 +29,7 @@
 while : ; do
        case $1 in
        -a*)
-               arch=$2; shift
+               machine_arch=$2; shift
                ;;
        -m*)
                machine=$2; shift
@@ -56,13 +55,13 @@
 fi
 
 # Convert mipse[lb] to mips after processing command line arguments.
-arch=`echo $arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3,`
+machine_arch=`echo $machine_arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3,`
 
 # Compute toolchain  used on target cpu.
-if [ "$arch" = "mips" -o "$machine" = "alpha" -o "$arch" = "powerpc" -o "$arch" = "sparc" -o "$arch" = "sparc64" -o "$arch" = "i386" -o "$arch" = "arm" -o "$machine" = "mvme68k" -o "$machine" = 
"hp300" ]; then
+if [ "$machine_arch" = "mips" -o "$machine" = "alpha" -o "$machine_arch" = "powerpc" -o "$machine_arch" = "sparc" -o "$machine_arch" = "sparc64" -o "$machine_arch" = "i386" -o "$machine_arch" = 
"arm" -o "$machine" = "mvme68k" -o "$machine" = "hp300" ]; then
        shlib=elf
 else
-       if [ "$arch" = "sh3" ]; then
+       if [ "$machine_arch" = "sh3" ]; then
                shlib=
        else
                shlib=aout
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/makeflist
--- a/distrib/sets/makeflist    Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/makeflist    Tue Nov 25 07:19:46 2003 +0000
@@ -1,20 +1,14 @@
 #!/bin/sh
 #
-# $NetBSD: makeflist,v 1.64 2003/09/21 19:33:59 tron Exp $
+# $NetBSD: makeflist,v 1.65 2003/11/25 07:19:46 dyoung Exp $
 #
 # Print out the files in some or all lists.
 # Usage: makeflist [-b] [-x] [-a arch] [-m machine] [-s setsdir] [setname ...]
 #
 
 # set defaults
-make="${MAKE:-make} -j 1 -f `dirname $0`/Makefile"
-machine=`${make} print_machine`
-machine_arch=`${make} print_machine_arch`
-machine_cpu=`${make} print_machine_cpu`
-object_fmt=`${make} print_object_fmt`
-toolchain_missing=`${make} print_toolchain_missing`
-use_tools_toolchain=`${make} print_use_tools_toolchain`
-x11_version=`${make} print_x11_version`
+. ./sets.defaults
+
 setd=`pwd`
 nlists="base comp etc games man misc text"
 xlists="xbase xcomp xcontrib xfont xserver xmisc"
@@ -32,8 +26,8 @@
                lists=$xlists
                ;;
        -a*)
-               machine_arch=`MACHINE_ARCH=${2} ${make} print_machine_arch`
-               machine_cpu=`MACHINE_ARCH=${2} ${make} print_machine_cpu`
+               machine_arch=${2}
+               machine_cpu=$(arch_to_cpu ${2})
                shift
                ;;
        -m*)
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/makeobsolete
--- a/distrib/sets/makeobsolete Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/makeobsolete Tue Nov 25 07:19:46 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: makeobsolete,v 1.18 2003/09/21 19:26:05 tron Exp $
+# $NetBSD: makeobsolete,v 1.19 2003/11/25 07:19:46 dyoung Exp $
 #
 # Print out the obsolete files for a set
 # Usage: makeobsolete [-b] [-x] [-a arch] [-m machine] [-s setsdir] \
@@ -8,15 +8,12 @@
 #
 
 # set defaults
-make="${MAKE:-make} -j 1 -f `dirname $0`/Makefile"
-machine=`${make} print_machine`
-arch=`${make} print_machine_arch`
+. $(dirname $0)/sets.defaults
 setd=`pwd`
 nlists="base comp etc games man misc text"
 xlists="xbase xcomp xcontrib xfont xserver xmisc"
 lists=$nlists
 target=./dist
-have_gcc3="`${make} print_have_gcc3`"
 
 # handle args
 while : ; do
@@ -27,7 +24,7 @@
        -x*)
                lists=$xlists;;
        -a*)
-               arch=$2; shift
+               machine_arch=$2; shift
                ;;
        -m*)
                machine=$2; shift
@@ -43,7 +40,7 @@
 Usage: $0 [-a arch] [-m machine] [-s setsdir] [setname ...]
        -b              make netbsd + x11 lists
        -x              only make x11 lists
-       -a arch         set arch (e.g, m68k, mips, powerpc)     [$arch]
+       -a arch         set arch (e.g, m68k, mips, powerpc)     [$machine_arch]
        -m machine      set machine (e.g, amiga, i386, macppc)  [$machine]
        -s setsdir      directory to find sets  [$setd]
        -t target       target directory [$target]
@@ -62,7 +59,7 @@
 fi
 
 # Convert mipse[lb] to mips after processing command line arguments.
-arch=`echo $arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3e,`
+machine_arch=`echo $machine_arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3e,`
 
 if [ ! -d $target ] ; then
        echo "target directory [$target] doesn't exist"
@@ -93,8 +90,8 @@
                awk -- '{print $1}' $setd/lists/$setname/obsolete.mi
        fi
        if [ "$machine" != "$cpu" -a \
-           -f $setd/lists/$setname/obsolete.${arch} ]; then
-               awk -- '{print $1}' $setd/lists/$setname/obsolete.${arch}
+           -f $setd/lists/$setname/obsolete.${machine_arch} ]; then
+               awk -- '{print $1}' $setd/lists/$setname/obsolete.${machine_arch}
        fi
        if [ -f $setd/lists/$setname/obsolete.${machine} ]; then
                awk -- '{print $1}' $setd/lists/$setname/obsolete.${machine}
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/makeplist
--- a/distrib/sets/makeplist    Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/makeplist    Tue Nov 25 07:19:46 2003 +0000
@@ -5,26 +5,7 @@
 #
 
 # set defaults
-for x in $(
-${MAKE:-make} -f- all <<EOF
-.include <bsd.own.mk>
-all:
-       @echo machine=\${MACHINE}
-       @echo machine_arch=\${MACHINE_ARCH}
-       @echo machine_cpu=\${MACHINE_CPU}
-       @echo object_fmt=\${OBJECT_FMT}
-       @echo toolchain_missing=\${TOOLCHAIN_MISSING}
-       @echo use_tools_toolchain=\${USE_TOOLS_TOOLCHAIN}
-.if defined(USE_XF86_4) && (\${USE_XF86_4} != no)
-       @echo x11_version=4
-.else
-       @echo x11_version=3
-.endif
-
-EOF
-); do
-       eval $x
-done
+. ./sets.defaults
 
 . ./sets.subr
 setd=`dirname $0`
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/maketars
--- a/distrib/sets/maketars     Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/maketars     Tue Nov 25 07:19:46 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: maketars,v 1.44 2003/10/16 14:20:20 dsl Exp $
+# $NetBSD: maketars,v 1.45 2003/11/25 07:19:46 dyoung Exp $
 #
 # Make release tar files for some or all lists.  Usage:
 # maketars [-b] [-x] [-i installdir] [-a arch] [-m machine] [-s setsdir]
@@ -19,10 +19,9 @@
 : ${PAX=pax}
 : ${MKTEMP=mktemp}
 : ${MTREE=mtree}
-make="${MAKE:-make} -j 1 -f $(dirname $0)/Makefile"
 
-machine=$(${make} print_machine)
-machine_arch=$(${make} print_machine_arch)
+. $(dirname $0)/sets.defaults
+
 setd=$(pwd)
 nlists="base comp etc games man misc text"
 xlists="xbase xcomp xcontrib xfont xserver xmisc"
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/sets.defaults
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/sets.defaults        Tue Nov 25 07:19:46 2003 +0000
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+for x in $(
+${MAKE:-make} -f- all <<EOF
+.include <bsd.own.mk>
+all:
+       @echo krb=\${MKKERBEROS}
+       @echo krb4=\${MKKERBEROS4}
+       @echo machine=\${MACHINE}
+       @echo machine_arch=\${MACHINE_ARCH}
+       @echo machine_cpu=\${MACHINE_CPU}
+       @echo object_fmt=\${OBJECT_FMT}
+       @echo toolchain_missing=\${TOOLCHAIN_MISSING}
+       @echo have_gcc3=\${HAVE_GCC3}
+.if defined(USE_XF86_4) && (\${USE_XF86_4} != no)
+       @echo x11_version=4
+.else
+       @echo x11_version=3
+.endif
+
+EOF
+); do
+       eval $x
+done
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/sets.subr
--- a/distrib/sets/sets.subr    Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/sets.subr    Tue Nov 25 07:19:46 2003 +0000
@@ -42,7 +42,7 @@
 # In each file, a record consists of a path and a System Package name,
 # separated by whitespace. E.g.,
 #
-#      # $NetBSD: sets.subr,v 1.4 2003/10/29 23:05:55 dyoung Exp $
+#      # $NetBSD: sets.subr,v 1.5 2003/11/25 07:19:46 dyoung Exp $
 #      .                       base-sys-root
 #      ./altroot               base-sys-root
 #      ./bin                   base-sys-root
@@ -159,3 +159,11 @@
        fi
 }
 
+arch_to_cpu () {
+MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOF
+.include <bsd.own.mk>
+all:
+       @echo \${MACHINE_CPU}
+EOF
+}
+
diff -r 124e919f7c62 -r 12be317b5502 distrib/sets/syspkgdeps
--- a/distrib/sets/syspkgdeps   Tue Nov 25 06:28:54 2003 +0000
+++ b/distrib/sets/syspkgdeps   Tue Nov 25 07:19:46 2003 +0000
@@ -14,6 +14,8 @@
 #
 # set defaults and import setlist subroutines
 #
+. ./sets.defaults
+
 . ./sets.subr
 setd=$(pwd)
 prefix=/
@@ -35,8 +37,8 @@
 while : ; do
        case $1 in
        -a*)
-               machine_arch=`MACHINE_ARCH=${2} ${make} print_machine_arch`
-               machine_cpu=`MACHINE_ARCH=${2} ${make} print_machine_cpu`
+               machine_arch=${2}
+               machine_cpu=$(arch_to_cpu ${2})
                shift
                ;;
        -m*)



Home | Main Index | Thread Index | Old Index