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.
This commit is contained in:
dyoung 2003-11-25 07:19:46 +00:00
parent a7742656be
commit 17b5668ccd
8 changed files with 61 additions and 57 deletions

View File

@ -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 @@ usage() {
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 @@ exit 1
while : ; do
case $1 in
-a*)
arch=$2; shift
machine_arch=$2; shift
;;
-m*)
machine=$2; shift
@ -56,13 +55,13 @@ else
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

View File

@ -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 @@ while : ; do
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*)

View File

@ -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 @@ while : ; do
-x*)
lists=$xlists;;
-a*)
arch=$2; shift
machine_arch=$2; shift
;;
-m*)
machine=$2; shift
@ -43,7 +40,7 @@ while : ; do
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 @@ if [ -n "$1" ]; then
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 @@ for setname in $lists; do
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}

View File

@ -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`

View File

@ -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 @@ prog=${0##*/}
: ${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"

24
distrib/sets/sets.defaults Executable file
View File

@ -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

View File

@ -42,7 +42,7 @@ list_set_files () {
# 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 @@ list_set_lists () {
fi
}
arch_to_cpu () {
MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOF
.include <bsd.own.mk>
all:
@echo \${MACHINE_CPU}
EOF
}

View File

@ -14,6 +14,8 @@ DB="db -q"
#
# set defaults and import setlist subroutines
#
. ./sets.defaults
. ./sets.subr
setd=$(pwd)
prefix=/
@ -35,8 +37,8 @@ exit 1
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*)