summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2005-05-08 09:51:26 +0000
committerjlam <jlam@pkgsrc.org>2005-05-08 09:51:26 +0000
commit5a73de3af44dda49c6a1455b76f04da918ee8e26 (patch)
tree19f943e03e2d1cf3a20598253f7aa18f81d18628 /regress
parent8d21560eadc0bca597078503aea51c203db5054f (diff)
downloadpkgsrc-5a73de3af44dda49c6a1455b76f04da918ee8e26.tar.gz
Regression test for the bootstrap install-sh script which is a BSD install
replacement.
Diffstat (limited to 'regress')
-rw-r--r--regress/bootstrap-install-sh/Makefile137
-rwxr-xr-xregress/bootstrap-install-sh/files/install-sh284
-rw-r--r--regress/bootstrap-install-sh/spec9
3 files changed, 430 insertions, 0 deletions
diff --git a/regress/bootstrap-install-sh/Makefile b/regress/bootstrap-install-sh/Makefile
new file mode 100644
index 00000000000..2fbb014458f
--- /dev/null
+++ b/regress/bootstrap-install-sh/Makefile
@@ -0,0 +1,137 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/05/08 09:51:26 jlam Exp $
+
+DISTNAME= bootstrap-install-sh-0.0
+CATEGORIES= regress
+WRKSRC= ${WRKDIR}
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= jlam@NetBSD.org
+COMMENT= Test functionality of bootstrap install-sh
+
+EXTRACT_ONLY= # empty
+NO_CONFIGURE= yes
+NO_INSTALL= yes
+NO_PACKAGE= yes
+
+INSTALL_SH= ${WRKSRC}/install-sh
+
+regress: extract
+post-extract:
+ ${CP} ${FILESDIR}/install-sh ${INSTALL_SH}
+ ${CHMOD} +x ${INSTALL_SH}
+
+# create one directory using -d
+regress: test-d1
+test-d1:
+ ${INSTALL_SH} -d ${WRKSRC}/d1_dir
+ ${TEST} -d ${WRKSRC}/d1_dir || exit 1
+
+# create two directories using -d
+regress: test-d2
+test-d2:
+ ${INSTALL_SH} -d ${WRKSRC}/d2_dir1 ${WRKSRC}/d2_dir2
+ ( ${TEST} -d ${WRKSRC}/d2_dir1 && \
+ ${TEST} -d ${WRKSRC}/d2_dir2 ) || exit 1
+
+# create three directories using -d
+regress: test-d3
+test-d3:
+ ${INSTALL_SH} -d ${WRKSRC}/d3_dir1 ${WRKSRC}/d3_dir2 ${WRKSRC}/d3_dir3
+ ( ${TEST} -d ${WRKSRC}/d3_dir1 && \
+ ${TEST} -d ${WRKSRC}/d3_dir2 && \
+ ${TEST} -d ${WRKSRC}/d3_dir3 ) || exit 1
+
+# copy one existing file to nonexistent file
+regress: test-c1
+test-c1:
+ ${ECHO} "Test data" > ${WRKSRC}/c1_file1
+ ${INSTALL_SH} -c ${WRKSRC}/c1_file1 ${WRKSRC}/c1_file2
+ ${CMP} ${WRKSRC}/c1_file1 ${WRKSRC}/c1_file2 || exit 1
+
+# copy one existing file into existing directory
+regress: test-c2
+test-c2:
+ ${ECHO} "Test data" > ${WRKSRC}/c2_file
+ ${MKDIR} ${WRKSRC}/c2_dir
+ ${INSTALL_SH} -c ${WRKSRC}/c2_file ${WRKSRC}/c2_dir
+ ${CMP} -s ${WRKSRC}/c2_file ${WRKSRC}/c2_dir/c2_file || exit 1
+
+# copy two existing files into existing directory
+regress: test-c3
+test-c3:
+ ${ECHO} "Test data 1" > ${WRKSRC}/c3_file1
+ ${ECHO} "Test data 2" > ${WRKSRC}/c3_file2
+ ${MKDIR} ${WRKSRC}/c3_dir
+ ${INSTALL_SH} -c ${WRKSRC}/c3_file1 ${WRKSRC}/c3_file2 ${WRKSRC}/c3_dir
+ ( ${CMP} -s ${WRKSRC}/c3_file1 ${WRKSRC}/c3_dir/c3_file1 && \
+ ${CMP} -s ${WRKSRC}/c3_file2 ${WRKSRC}/c3_dir/c3_file2 ) || exit 1
+
+# copy three existing files into existing directory
+regress: test-c4
+test-c4:
+ ${ECHO} "Test data 1" > ${WRKSRC}/c4_file1
+ ${ECHO} "Test data 2" > ${WRKSRC}/c4_file2
+ ${ECHO} "Test data 3" > ${WRKSRC}/c4_file3
+ ${MKDIR} ${WRKSRC}/c4_dir
+ ${INSTALL_SH} -c ${WRKSRC}/c4_file1 ${WRKSRC}/c4_file2 \
+ ${WRKSRC}/c4_file3 ${WRKSRC}/c4_dir
+ ( ${CMP} -s ${WRKSRC}/c4_file1 ${WRKSRC}/c4_dir/c4_file1 && \
+ ${CMP} -s ${WRKSRC}/c4_file2 ${WRKSRC}/c4_dir/c4_file2 && \
+ ${CMP} -s ${WRKSRC}/c4_file3 ${WRKSRC}/c4_dir/c4_file3 ) || exit 1
+
+MODES= 0 1 2 3 4 5 6 7
+MODE_0= ---
+MODE_1= --x
+MODE_2= -w-
+MODE_3= -wx
+MODE_4= r--
+MODE_5= r-x
+MODE_6= rw-
+MODE_7= rwx
+
+# test mode permissions on installing file to nonexisting file
+regress: test-m1
+test-m1:
+.for _u_ in ${MODES}
+. for _g_ in ${MODES}
+. for _o_ in ${MODES}
+ ${ECHO} "Test data" > ${WRKSRC}/m${_u_}${_g_}${_o_}_file1
+ ${INSTALL_SH} -m ${_u_}${_g_}${_o_} ${WRKSRC}/m${_u_}${_g_}${_o_}_file1 ${WRKSRC}/m${_u_}${_g_}${_o_}_file2
+ ${LS} -l ${WRKSRC}/m${_u_}${_g_}${_o_}_file2 | \
+ while read a b; do \
+ case "$$a" in \
+ -${MODE_${_u_}}${MODE_${_g_}}${MODE_${_o_}}) \
+ exit 0 ;; \
+ *) exit 1 ;; \
+ esac; \
+ done
+. endfor
+. endfor
+.endfor
+
+# test mode permissions on creating directory
+regress: test-m2
+test-m2:
+.for _u_ in ${MODES}
+. for _g_ in ${MODES}
+. for _o_ in ${MODES}
+ ${INSTALL_SH} -m 357 -d ${WRKSRC}/m357_dir
+ ${INSTALL_SH} -m ${_u_}${_g_}${_o_} -d ${WRKSRC}/m${_u_}${_g_}${_o_}_dir
+ ${LS} -l ${WRKSRC}/m${_u_}${_g_}${_o_}_file2 | \
+ while read a b; do \
+ case "$$a" in \
+ -${MODE_${_u_}}${MODE_${_g_}}${MODE_${_o_}}) \
+ exit 0 ;; \
+ *) exit 1 ;; \
+ esac; \
+ done
+. endfor
+. endfor
+.endfor
+
+pre-clean:
+ ${TEST} "`${ECHO} ${WRKSRC}/*`" = "${WRKSRC}/*" || \
+ ${CHMOD} -R u+rwx ${WRKSRC}/*
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/regress/bootstrap-install-sh/files/install-sh b/regress/bootstrap-install-sh/files/install-sh
new file mode 100755
index 00000000000..89c1e37e3d4
--- /dev/null
+++ b/regress/bootstrap-install-sh/files/install-sh
@@ -0,0 +1,284 @@
+#!/bin/sh
+#
+# $NetBSD: install-sh,v 1.1.1.1 2005/05/08 09:51:26 jlam Exp $
+# This script now also installs multiple files, but might choke on installing
+# multiple files with spaces in the file names.
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+stripflags=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+msrc=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -S) stripcmd="$stripprog"
+ stripflags="-S $2 $stripflags"
+ shift
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo "$1" | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo "$1" | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$msrc" = x ]
+ then
+ msrc="$dst"
+ else
+ msrc="$msrc $dst"
+ fi
+ src="$dst"
+ dst="$1"
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$dir_arg" = x ]
+then
+ dstisfile=""
+ if [ ! -d "$dst" ]
+ then
+ if [ x"$msrc" = x"$src" ]
+ then
+ dstisfile=true
+ else
+ echo "install: destination is not a directory"
+ exit 1
+ fi
+ fi
+else
+ msrc="$msrc $dst"
+fi
+
+if [ x"$msrc" = x ]
+then
+ echo "install: no destination specified"
+ exit 1
+fi
+
+for srcarg in $msrc; do
+
+if [ x"$dir_arg" != x ]; then
+
+ dstarg="$srcarg"
+else
+ dstarg="$dst"
+
+# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$srcarg" ]
+ then
+ doinst="$instcmd"
+ elif [ -d "$srcarg" ]
+ then
+ echo "install: $srcarg: not a regular file"
+ exit 1
+ elif [ "$srcarg" = "/dev/null" ]
+ then
+ doinst="$cpprog"
+ else
+ echo "install: $srcarg does not exist"
+ exit 1
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dstarg" ]
+ then
+ dstarg="$dstarg"/`basename "$srcarg"`
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $doit $mkdirprog "${pathcomp}"
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "${pathcomp}"; else true ; fi
+
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+ if [ x"$dir_arg" != x ]
+ then
+ if [ -d "$dstarg" ]; then
+ true
+ else
+ $doit $mkdirprog "$dstarg" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi
+ fi
+ else
+
+# If we're going to rename the final file, determine the name now.
+
+ if [ x"$dstisfile" = x ]
+ then
+ file=$srcarg
+ else
+ file=$dst
+ fi
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename "$file"`
+ else
+ dstfile=`basename "$file" "$transformbasename" |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename "$file"`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $doinst $srcarg "$dsttmp" &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f "$dstdir/$dstfile" &&
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+ fi
+
+done &&
+
+
+exit 0
diff --git a/regress/bootstrap-install-sh/spec b/regress/bootstrap-install-sh/spec
new file mode 100644
index 00000000000..c746d6687f3
--- /dev/null
+++ b/regress/bootstrap-install-sh/spec
@@ -0,0 +1,9 @@
+# $NetBSD: spec,v 1.1.1.1 2005/05/08 09:51:26 jlam Exp $
+
+MAKEARGS_TEST=regress # target to invoke for regression tests
+MAKEARGS_CLEAN=clean # need to remove work directory afterwards
+
+check_result()
+{
+ exit_status 0
+}