pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/54349: bootstrap with --prefix fails on Solaris 10
Revision 1.262 is OK.
Revision 1.263 introduced the problem.
The trouble maybe relate to the change introduce in checkarg_sane_absolute_path() or/and checkarg_no_symlink_path().
Hiroshi
> 2019/07/11 19:35、Hiroshi Hakoyama <hiroshi-hakoyama%nagano.ac.jp@localhost>のメール:
>
> The following reply was made to PR pkg/54349; it has been noted by GNATS.
>
> From: Hiroshi Hakoyama <hiroshi-hakoyama%nagano.ac.jp@localhost>
> To: gnats-bugs%netbsd.org@localhost
> Cc: pkg-manager%netbsd.org@localhost,
> gnats-admin%netbsd.org@localhost,
> pkgsrc-bugs%netbsd.org@localhost
> Subject: Re: pkg/54349: bootstrap with --prefix fails on Solaris 10
> Date: Thu, 11 Jul 2019 19:31:07 +0900
>
> Dear Benny,
>
> /bin/sh on Solaris 10 is Bourne Shell.
>
>> Do you happen to know where in the file this
>> happens, i.e. can you get a line number?
>
> line 501, probably.
>
>
> Hiroshi
>
> env CFLAGS=3D-O2 CC=3D/opt/csw/gcc4/bin/gcc GCCBASE=3D/opt/csw/gcc4 =
> ./bootstrap --prefix=3D/usr/pkg2 --varbase
> # $NetBSD: bootstrap,v 1.268 2019/07/08 19:44:08 sevan Exp $
> #
> # Copyright (c) 2001-2011 Alistair Crooks <agc%NetBSD.org@localhost>
> # All rights reserved.
> #
> # 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.
> #
> # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
> #
> #set -x
>
> # the following environment variables are honored:
> # compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS
> # tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS
>
>
> BOOTSTRAP_VERSION=3D20060721
>
> # Don't let the bootstrap program get confused by a pre-existing mk.conf
> # file.
> MAKECONF=3D/dev/null
> export MAKECONF
>
> # No vulnerability checks since there might be an incompatible checker =
> installed
> NO_PKGTOOLS_REQD_CHECK=3Dyes
> export NO_PKGTOOLS_REQD_CHECK
>
> unprivileged=3Dno
>
> preserve_path=3Dno
>
> # where the building takes place
> bootstrapdir=3D`dirname "$0"`
> bootstrapdir=3D`cd "${bootstrapdir}" && pwd`
> pkgsrcdir=3D`dirname "${bootstrapdir}"`
> wrkdir=3D"`pwd`/work"
>
> usage=3D"Usage: $0 "'
> [ --abi [32|64] ]
> [ --binary-kit <tarball> ]
> [ --binary-macpkg <pkg> ]
> [ --compiler <compiler> ]
> [ --cwrappers <auto|yes|no> ]
> [ --full ]
> [ --gzip-binary-kit <tarball> ]
> [ --help ]
> [ --make-jobs <num> ]
> [ --mk-fragment <mk.conf> ]
> [ --pkgdbdir <pkgdbdir> ]
> [ --pkginfodir <pkginfodir> ]
> [ --pkgmandir <pkgmandir> ]
> [ --prefer-pkgsrc <list|yes|no> ]
> [ --prefix <prefix> ]
> [ --preserve-path ]
> [ --quiet ]
> [ --sysconfdir <sysconfdir> ]
> [ --unprivileged | --ignore-user-check ]
> [ --varbase <varbase> ]
> [ --workdir <workdir> ]
> '
>
> # strip / for BSD/OS, strip - for HP-UX
> opsys=3D`uname -s | tr -d /-`
>
> mkbinarykit_macpkg()
> {
> local macdestdir
> macdestdir=3D${wrkdir}/macpkg-destdir
> rm -rf ${macdestdir} || die "cleanup destdir"
>
> mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix"
> rmdir ${macdestdir}${prefix} || die "rmdir destprefix"
> cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix"
>
> if [ ! -d ${macdestdir}${pkgdbdir} ]; then
> mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir =
> destdbdir"
> rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir"
> cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy =
> dbdir"
> fi
>
> ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \
> -e "s|%TARGETDIR%|${targetdir}|g" -e =
> "s|%DATE%|${date}|g" \
> < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj
> ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p =
> "${binary_macpkg}"
> }
>
> mkbinarykit_tar()
> {
> # in case tar was built by bootstrap
> PATH=3D"$prefix/bin:$PATH"; export PATH
> cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir =
> .$etc_mk_conf
> }
>
> mkbinarykit_tgz()
> {
> # in case tar was built by bootstrap
> PATH=3D"$prefix/bin:$PATH"; export PATH
> cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > =
> "${binary_gzip_kit}"
> }
>
> die()
> {
> echo >&2 "$@"
> exit 1
> }
>
> echo_msg()
> {
> echo "=3D=3D=3D> $@"
> }
>
> # see if we're using gcc. If so, set $compiler_is_gnu to '1'.
> get_compiler()
> {
> testcc=3D"${CC}"
> # normally, we'd just use 'cc', but certain configure tools look
> # for gcc specifically, so we have to see if that comes first
> if [ -z "${testcc}" ]; then
> save_IFS=3D"${IFS}"
> IFS=3D':'
> for dir in ${PATH}; do
> test -z "$dir" && dir=3D.
> if [ -x "$dir/gcc" ]; then
> testcc=3D"$dir/gcc"
> break
> fi
> done
> IFS=3D"${save_IFS}"
> fi
>
> # Clang compiler pretends to be GCC, so we have to check that
> cat >${wrkdir}/$$.c <<EOF
> #ifdef __clang__
> indeed
> #endif
> EOF
> compiler_is_clang=3D`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null =
> | grep -c indeed`
> rm -f ${wrkdir}/$$.c
>
> cat >${wrkdir}/$$.c <<EOF
> #ifdef __GNUC__
> #ifndef __clang__
> indeed
> #endif
> #endif
> EOF
> compiler_is_gnu=3D`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | =
> grep -c indeed`
> rm -f ${wrkdir}/$$.c
>
> }
> get_abi()
> {
> abi_opsys=3D$@
>
> if [ -n "$abi" ]; then
> case "$abi_opsys" in
> IRIX)
> die "ERROR: $abi_opsys has special ABI handling, =
> --abi not supported (yet)."
> ;;
> esac
> fi
>
> case "$abi_opsys" in
> IRIX)
> if [ `uname -r` -ge 6 ]; then
> abi=3D`sed -e 's/.*\(abi=3D\)\([on]*[36][24]\).*/\2/' =
> /etc/compiler.defaults`
> isa=3D`sed -e 's/.*\(isa=3Dmips\)\([1234]\).*/\2/' =
> /etc/compiler.defaults`
> case "$abi" in
> o32)
> imakeopts=3D"-DBuildO32 -DSgiISAo32=3D$isa"
> abi=3D""
> ;;
> n32) imakeopts=3D"-DBuildN32 -DSgiISA32=3D$isa"
> abi=3D"32"
> ;;
> 64 | n64)
> imakeopts=3D"-DBuild64bit -DSgiISA64=3D$isa"
> abi=3D"64"
> ;;
> esac
> else # IRIX before 6
> abi=3D32
> fi
> ;;
> esac
> }
>
> get_machine_arch_aix()
> {
> _cpuid=3D`/usr/sbin/lsdev -C -c processor -S available | sed 1q =
> | awk '{ print $1 }'`
> if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; =
> then
> echo rs6000
> else
> echo powerpc
> fi
> }
>
> get_machine_arch_darwin()
> {
> case `uname -p` in
> i386)
> # Returns "i386" or "x86_64" depending on CPU
> echo `uname -m`
> ;;
> powerpc)
> # sysctl mib exists on 64-bit hardware
> if [ -n "`sysctl -n hw.optional.64bitops 2>/dev/null`" =
> ]; then
> echo "powerpc64"
> else
> echo "powerpc"
> fi
> ;;
> esac
> }
>
> check_prog()
> {
> _var=3D"$1"; _name=3D"$2"
>
> eval _tmp=3D\"\$$_var\"
> if [ "x$_tmp" !=3D "x" ]; then
> # Variable is already set (by the user, for example)
> return 0
> fi
>
> for _d in `echo $PATH | tr ':' ' '`; do
> if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
> # Program found
> eval $_var=3D\""$_d/$_name"\"
> return 1
> fi
> done
>
> die "$_name not found in path."
> }
>
> opsys_finish()
> {
> case "$opsys" in
> IRIX)
> if [ -n "$imakeopts" ]; then
> echo "IMAKEOPTS+=3D $imakeopts" >> =
> ${TARGET_MKCONF}
> fi
> if [ `uname -r` -lt 6 ]; then
> echo_msg "Installing fake ldd script"
> run_cmd "$install_sh -c -o $user -g $group -m =
> 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
> need_extras=3Dyes
> echo "LDD=3D =
> $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
> fi
> ;;
> Haiku)
> need_extras=3Dyes
> echo "LDD=3D $prefix/sbin/fakeldd" =
>>> ${TARGET_MKCONF}
> ;;
> esac
> }
>
> is_root()
> {
> if [ `uname -s` =3D "IRIX" ]; then
> if [ `uname -r` -lt 6 -a -z "$ID" ]; then
> # older version of IRIX have an id command with limited features
> if [ "`$idprog`" !=3D "uid=3D0(root) gid=3D0(sys)"=
> ]; then
> return 1
> fi
> return 0
> fi
> fi
> if [ `$idprog -u` !=3D 0 ]; then
> return 1
> fi
> return 0
> }
>
> # run a command, abort if it fails
> run_cmd()
> {
> echo_msg "running: $@"
> eval "$@"
> ret=3D$?
> if [ $ret -ne 0 ]; then
> echo_msg "exited with status $ret"
> die "aborted."
> fi
> }
>
> # Some versions of mkdir (notably SunOS) bail out too easily, so use the
> # install-sh wrapper instead.
> mkdir_p()
> {
> for dir in $@; do
> run_cmd "$install_sh -d -o $user -g $group $dir"
> done
> }
>
> mkdir_p_early()
> {
> [ -d "$1" ] && return 0
> mkdir -p "$1" 2> /dev/null && return 0
> parent=3D`dirname "$1"`
> mkdir_p_early "$parent"
> if [ ! -d "$1" ] && mkdir "$1"; then
> echo_msg "mkdir $1 exited with status $?"
> die "aborted."
> fi
> return 0
> }
>
> copy_src()
> {
> _src=3D"$1"; _dst=3D"$2"
> if [ ! -d $wrkdir/$_dst ]; then
> mkdir_p $wrkdir/$_dst
> fi
> $cpprog -r $_src/* $wrkdir/$_dst
> if [ -f $wrkdir/$_dst/config.guess ]; then
> $cpprog $pkgsrcdir/mk/gnu-config/config.guess =
> $wrkdir/$_dst/
> fi
> if [ -f $wrkdir/$_dst/config.sub ]; then
> $cpprog $pkgsrcdir/mk/gnu-config/config.sub =
> $wrkdir/$_dst/
> fi
> }
>
> get_optarg()
> {
> expr "x$1" : "x[^=3D]*=3D\\(.*\\)"
> }
>
> checkarg_sane_absolute_path()
> {
> case "$1" in
> "") ;; # the default value will be used.
> *[!-A-Za-z0-9_./]*)
> die "ERROR: Invalid characters in path $1 (from $2)." ;;
> */) die "ERROR: The argument to $2 must not end in /." ;;
> *//* | */. | */./* | */.. | */../*)
> die "ERROR: The path $1 (from $2) must be canonical." ;;
> /*) [ "${3-}" =3D "may-be-symlink" ] \
> || checkarg_no_symlink_path "$1" "$2" ;;
> *) die "ERROR: The argument to $2 must be an absolute =
> path." ;;
> esac
> }
>
> checkarg_no_symlink_path()
> {
> _dir=3D$1
> while [ ! -d "$_dir" ]; do
> _dir=3D${_dir%/*}
> [ "$_dir" ] || _dir=3D"/"
> done
>
> _realdir=3D`cd "$_dir" && exec pwd`
> [ "$_realdir" =3D "$_dir" ] && return
>
> die "ERROR: The path $1 (from $2) must not contain symlinks.
>
> Given path : $1
> Resolved path: $_realdir${1##${_dir}}
>
> Several packages assume that the given path of $2 stays the same =
> when
> symlinks are resolved. When that assumption fails, they will:
>
> * not find some include files or libraries during the build =
> phase
> since the files from dependencies are not installed in
> \${WRKDIR}/.buildlink.
>
> * install their files into the wrong path inside =
> \${WRKDIR}/.destdir,
> which will fail the PLIST check during the install phase."
> }
>
> checkarg_sane_relative_path() {
> case "$1" in
> "") ;; # the default value will be used.
> *[!-A-Za-z0-9_./]*)
> die "ERROR: Invalid characters in path $1 (from $2)." ;;
> /*) die "ERROR: The argument to $2 must be a relative path." =
> ;;
> *) ;;
> esac
> }
>
> bootstrap_sh=3D${SH-/bin/sh}
> bootstrap_sh_set=3D${SH+set}
>
> case "$bootstrap_sh" in
> /*)
> ;;
> *)
> die "ERROR: The variable SH must contain an absolute path"
> ;;
> esac
>
> # On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
> # whose echo(1) is not BSD-compatible.
> # On all Debian GNU/kFreeBSD 7.0, /bin/sh is a symlink to /bin/dash, and
> # use /bin/bash. bootstrap forces /bin/bash is used.
> dash_echo_test=3D`$bootstrap_sh -c 'echo "\\100"'`
> if [ "$opsys" !=3D "GNUkFreeBSD" ] && [ "$dash_echo_test" =3D "@" ]; =
> then
> { echo "ERROR: Your shell's echo command is not BSD-compatible."
> echo "ERROR: Please select another shell by setting the =
> environment"
> echo "ERROR: variable SH."
> } 1>&2
> exit 1;
> fi
>
> if [ -n "$PKG_PATH" ]; then
> die "ERROR: Please unset PKG_PATH before running bootstrap."
> fi
>
> build_start=3D`date`
> echo_msg "bootstrap command: $0 $@"
> =3D=3D=3D> bootstrap command: ./bootstrap --prefix=3D/usr/pkg2 --varbase
> echo_msg "bootstrap started: $build_start"
> =3D=3D=3D> bootstrap started: Thu Jul 11 19:26:29 JST 2019
>
> # ensure system locations are empty; we will set them later when we know
> # whether they will be system wide or user specific
> prefix=3D
> pkgdbdir=3D
> pkginfodir=3D
> pkgmandir=3D
> sysconfdir=3D
> varbase=3D
>
> compiler=3D""
> cwrappers=3Dauto
> full=3Dno
> make_jobs=3D1
> mk_fragment=3D
> quiet=3Dno
>
> while [ $# -gt 0 ]; do
> case $1 in
> --workdir=3D*) wrkdir=3D`get_optarg "$1"` ;;
> --workdir) wrkdir=3D"$2"; shift ;;
> --prefix=3D*) prefix=3D`get_optarg "$1"` ;;
> --prefix) prefix=3D"$2"; shift ;;
> --pkgdbdir=3D*) pkgdbdir=3D`get_optarg "$1"` ;;
> --pkgdbdir) pkgdbdir=3D"$2"; shift ;;
> --pkginfodir=3D*) pkginfodir=3D`get_optarg "$1"` ;;
> --pkginfodir) pkginfodir=3D"$2"; shift ;;
> --pkgmandir=3D*) pkgmandir=3D`get_optarg "$1"` ;;
> --pkgmandir) pkgmandir=3D"$2"; shift ;;
> --sysconfdir=3D*) sysconfdir=3D`get_optarg "$1"` ;;
> --sysconfdir) sysconfdir=3D"$2"; shift ;;
> --varbase=3D*) varbase=3D`get_optarg "$1"` ;;
> --varbase) varbase=3D"$2"; shift ;;
> --compiler=3D*) compiler=3D`get_optarg "$1"` ;;
> --compiler) compiler=3D"$2"; shift ;;
> --abi=3D*) abi=3D`get_optarg "$1"` ;;
> --abi) abi=3D"$2"; shift ;;
> --cwrappers=3D*) cwrappers=3D`get_optarg "$1"` ;;
> --cwrappers) cwrappers=3D"$2"; shift ;;
> --unprivileged | --ignore-user-check) unprivileged=3Dyes ;;
> --prefer-pkgsrc=3D*)
> prefer_pkgsrc=3D`get_optarg "$1"` ;;
> --prefer-pkgsrc)
> prefer_pkgsrc=3D"$2"; shift ;;
> --preserve-path) preserve_path=3Dyes ;;
> --mk-fragment=3D*)
> mk_fragment=3D`get_optarg "$1"` ;;
> --mk-fragment)
> mk_fragment=3D"$2"; shift ;;
> --binary-kit=3D*)
> binary_kit=3D`get_optarg "$1"` ;;
> --binary-kit)
> binary_kit=3D"$2"; shift ;;
> --gzip-binary-kit=3D*)
> binary_gzip_kit=3D`get_optarg "$1"` ;;
> --gzip-binary-kit)
> binary_gzip_kit=3D"$2"; shift ;;
> --binary-macpkg=3D*)
> binary_macpkg=3D`get_optarg "$1"` ;;
> --binary-macpkg)
> binary_macpkg=3D"$2"; shift ;;
> --make-jobs=3D*) make_jobs=3D`get_optarg "$1"` ;;
> --make-jobs) make_jobs=3D"$2"; shift ;;
> --full) full=3Dyes ;;
> --quiet) quiet=3Dyes ;;
> --help) echo "$usage"; exit ;;
> -h) echo "$usage"; exit ;;
> -*) echo "${0##*/}: unknown option \"$1\"" 1>&2
> echo "$usage" 1>&2; exit 1 ;;
> esac
> shift
> done
> ./bootstrap: cannot shift
>
>
>
>> 2019/07/07 18:05=E3=80=81Benny Siegert =
> <bsiegert%gmail.com@localhost>=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB:
>> =20
>> The following reply was made to PR pkg/54349; it has been noted by =
> GNATS.
>> =20
>> From: Benny Siegert <bsiegert%gmail.com@localhost>
>> To: gnats-bugs%netbsd.org@localhost
>> Cc: pkg-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, =
> pkgsrc-bugs%netbsd.org@localhost
>> Subject: Re: pkg/54349: bootstrap with --prefix fails on Solaris 10
>> Date: Sun, 7 Jul 2019 11:01:16 +0200
>> =20
>> On Sun, Jul 7, 2019 at 8:49 AM <hiroshi-hakoyama%nagano.ac.jp@localhost> wrote:
>> =20
>>> =3D=3D=3D> bootstrap started: Sat Jul 6 18:58:16 JST 2019
>>> ./bootstrap: bad substitution
>> =20
>>>> Fix:
>>> a workaround:
>>> =20
>>> vi bootstrap
>>> #! /bin/sh -> #! /usr/bin/bash
>> =20
>> Thank you for the report! Do you happen to know where in the file this
>> happens, i.e. can you get a line number?
>> =20
>> =20
>> --=20
>> Benny
>> =20
>
Home |
Main Index |
Thread Index |
Old Index