pkgsrc-Bugs archive

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

Re: pkg/47427: pkgsrc pkgtools/pkg_comp fixes / enhancements (proposing update: 1.37 -> 1.38) [patch included]



The following reply was made to PR pkg/47427; it has been noted by GNATS.

From: Bug Hunting <bughunting%xs4all.nl@localhost>
To: NetBSD GNATS <gnats-bugs%NetBSD.org@localhost>
Cc: 
Subject: Re: pkg/47427: pkgsrc pkgtools/pkg_comp fixes / enhancements
 (proposing update: 1.37 -> 1.38) [patch included]
Date: Wed, 9 Jan 2013 22:43:33 +0100

 --DIOMP1UsTsWJauNi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 
 In update to the patch already given, there's an extra line that
 could be added to the pkg_comp.sh script, to do some sanity checking
 for when using `-C':
 
    [ -d `dirname "$conffile"` -a ! -d "$conffile" ] || err "invalid 
configuration file path."
 
 This will error out in case one specifies a path out of which
 intermediate directories are missing, or when the last part of the
 path (i.e., the configuration file name) exists and is a directory;
 currently (i.e., with the current script, but also with my patch
 of before applied), these situations output a lot of
 ``cannot create dir: is a directory''
 or
 ``directory nonexistent''
 errors but, still, end up with outputting
 ``pkg_comp: <conffile> created.  Edit the file by hand now.''
 (which of course has not been done).
 
 The patch attached overcomes there situations using encompassing
 the line above; note that it _only_ holds an updated part for
 pkg_comp.sh though, not the other three files that were in the
 previous patch as well.
 
 Thanks,
 
 Bug Hunting
 
 --DIOMP1UsTsWJauNi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="pkg_comp.sh_1.41.patch"
 
 Index: pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh,v
 retrieving revision 1.41
 diff -u -r1.41 pkg_comp.sh
 --- pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh 19 May 2012 10:54:40 -0000      
1.41
 +++ pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh 9 Jan 2013 21:30:56 -0000
 @@ -37,11 +37,10 @@
  # Default environment values and functions
  # ----------------------------------------------------------------------
  
 -# USE_GCC3, CFLAGS, CPPFLAGS and CXXFLAGS are ommited from _MKCONF_VARS
 -# as they require special handling.
 +# USE_GCC3 is omitted from _MKCONF_VARS, as it requires special handling.
  _MKCONF_VARS="WRKDIR_BASENAME MKOBJDIRS BSDSRCDIR WRKOBJDIR DISTDIR PACKAGES \
                PKG_DEVELOPER CLEANDEPENDS LOCALBASE PKG_SYSCONFBASE \
 -              CFLAGS CPPFLAGS CXXFLAGS USE_AUDIT_PACKAGES PKGVULNDIR \
 +              CFLAGS CPPFLAGS CXXFLAGS COPY_PKG_VULNERABILITIES PKGVULNDIR \
                USE_XPKGWEDGE PKGSRC_COMPILER \
                LIBKVER_STANDALONE_PREFIX PKG_DBDIR"
  
 @@ -95,19 +94,19 @@
      : ${CPPFLAGS:=}
      : ${CXXFLAGS:=}
      : ${USE_GCC3:=no}
 -    : ${USE_AUDIT_PACKAGES:=yes}
 -    : ${PKGVULNDIR:=/usr/pkg/share}
 +    : ${COPY_PKG_VULNERABILITIES:=yes}
 +    : ${PKGVULNDIR:=/var/db/pkg}
 +    : ${PKG_DBDIR:=/var/db/pkg}
      : ${USE_XPKGWEDGE:=yes}
      : ${PKGSRC_COMPILER:=gcc}
 -    : ${PKG_DBDIR:=/var/db/pkg}
  
      # Default values for global variables used in the script.
      : ${DESTDIR:=/var/chroot/pkg_comp/default}
 -    : ${ROOTSHELL:=/bin/ksh}
 +    : ${ROOTSHELL:=/bin/sh}
      : ${COPYROOTCFG:=no}
      : ${AUTO_TARGET:=package}
      : ${BUILD_TARGET:=package}
 -    : ${DISTRIBDIR:=/var/pub/NetBSD}
 +    : ${DISTRIBDIR:=/usr/INSTALL}
      : ${SETS:=base.tgz comp.tgz etc.tgz kern-GENERIC.tgz text.tgz}
      : ${SETS_X11:=xbase.tgz xcomp.tgz xetc.tgz xfont.tgz xserver.tgz}
      : ${REAL_SRC:=/usr/src}
 @@ -118,7 +117,7 @@
      : ${REAL_DISTFILES_OPTS:=-t null -o rw}
      : ${REAL_PACKAGES:=/usr/pkgsrc/packages}
      : ${REAL_PACKAGES_OPTS:=-t null -o rw}
 -    : ${REAL_PKGVULNDIR:=/usr/pkgsrc/distfiles}
 +    : ${REAL_PKGVULNDIR:=/var/db/pkg}
      : ${NETBSD_RELEASE:=no}
      : ${LIBKVER_STANDALONE_PREFIX:=/libkver}
      : ${MAKEROOT_HOOKS:=}
 @@ -129,7 +128,7 @@
      : ${GENERATE_PKG_SUMMARY:=yes}
  
      if [ -n "${MAKE_PACKAGES}" ]; then
 -        warn "MAKE_PACKAGES is deprecated; use {AUTO,BUILD}_PACKAGES instead."
 +        warn "MAKE_PACKAGES is deprecated; use AUTO_PACKAGES/BUILD_PACKAGES 
instead."
          : ${AUTO_PACKAGES:=${MAKE_PACKAGES}}
          : ${BUILD_PACKAGES:=${MAKE_PACKAGES}}
      fi
 @@ -143,6 +142,11 @@
          warn "UMOUNT_SCRIPT is deprecated; use UMOUNT_HOOKS instead."
          : ${UMOUNT_HOOKS:=${UMOUNT_SCRIPT}}
      fi
 +
 +    if [ -n "${USE_AUDIT_PACKAGES}" ]; then
 +        warn "USE_AUDIT_PACKAGES is deprecated; use COPY_PKG_VULNERABILITIES 
instead."
 +        : ${COPY_PKG_VULNERABILITIES:=${USE_AUDIT_PACKAGES}}
 +    fi
  }
  
  # ----------------------------------------------------------------------
 @@ -170,22 +174,22 @@
  
  # usage
  #
 -#   Shows an usage message and exits.
 +#   Shows a usage message and exits.
  #
  usage()
  {
 -    echo "usage: $ProgName [-(c|C) conf_file] [-Nn] target [pkg_names]" 1>&2
 +    echo "usage: $ProgName [-Nn] [-(C|c) conffile] target [operand ...]" 1>&2
      exit 1
  }
  
 -# copy_vulnerabilities
 +# copy_pkg_vulnerabilities
  #
 -#   If USE_AUDIT_PACKAGES is set to 'yes', this function copies the
 +#   If COPY_PKG_VULNERABILITIES is set to 'yes', this function copies the
  #   system-wide pkg-vulnerabilities file inside the sandbox.
  #
 -copy_vulnerabilities()
 +copy_pkg_vulnerabilities()
  {
 -    if [ "$USE_AUDIT_PACKAGES" = "yes" ]; then
 +    if [ "$COPY_PKG_VULNERABILITIES" = "yes" ]; then
          echo "PKG_COMP ==> Installing new \`pkg-vulnerabilities' file"
          if [ ! -f "$REAL_PKGVULNDIR/pkg-vulnerabilities" ]; then
              echo "$REAL_PKGVULNDIR/pkg-vulnerabilities not found."
 @@ -216,16 +220,16 @@
  }
  
  # ----------------------------------------------------------------------
 -# Filesystem functions
 +# File system functions
  # ----------------------------------------------------------------------
  
  # fsmount
  #
 -#   Mounts all sandboxed filesystems, if they are not mounted yet.
 +#   Mounts all sandboxed file systems, if they are not mounted yet.
  #
  fsmount()
  {
 -    echo "PKG_COMP ==> Mounting sandboxed filesystems"
 +    echo "PKG_COMP ==> Mounting sandboxed file systems"
      if [ -f $fsstate ]; then
          count=`cat $fsstate`
          count=$(($count + 1))
 @@ -240,7 +244,7 @@
          if [ ! -d "$REAL_SRC" ]; then
              echo " failed."
              fsumount
 -            err "REAL_SRC $REAL_SRC disappeared"
 +            err "REAL_SRC $REAL_SRC disappeared."
          fi
          mount $REAL_SRC_OPTS $REAL_SRC $DESTDIR/usr/src
      fi
 @@ -249,7 +253,7 @@
          if [ ! -d "$REAL_PKGSRC" ]; then
              echo " failed."
              fsumount
 -            err "REAL_PKGSRC $REAL_PKGSRC disappeared"
 +            err "REAL_PKGSRC $REAL_PKGSRC disappeared."
          fi
          mount $REAL_PKGSRC_OPTS $REAL_PKGSRC $DESTDIR/usr/pkgsrc
      fi
 @@ -258,7 +262,7 @@
          if [ ! -d "$REAL_DISTFILES" ]; then
              echo " failed."
              fsumount
 -            err "REAL_DISTFILES $REAL_DISTFILES disappeared"
 +            err "REAL_DISTFILES $REAL_DISTFILES disappeared."
          fi
          mount $REAL_DISTFILES_OPTS $REAL_DISTFILES $DESTDIR/pkg_comp/distfiles
      fi
 @@ -267,7 +271,7 @@
          if [ ! -d "$REAL_PACKAGES" ]; then
              echo " failed."
              fsumount
 -            err "REAL_PACKAGES $REAL_PACKAGES disappeared"
 +            err "REAL_PACKAGES $REAL_PACKAGES disappeared."
          fi
          mount $REAL_PACKAGES_OPTS $REAL_PACKAGES $DESTDIR/pkg_comp/packages
      fi
 @@ -276,7 +280,7 @@
          if [ ! -d "${REAL_CCACHE}" ]; then
              echo " failed."
              fsumount
 -            err "REAL_CCACHE ${REAL_CCACHE} disappeared"
 +            err "REAL_CCACHE ${REAL_CCACHE} disappeared."
          fi
          mount -t null -o rw ${REAL_CCACHE} ${DESTDIR}/pkg_comp/ccache
      fi
 @@ -293,11 +297,11 @@
  
  # fsumount
  #
 -#   Unmounts all sandboxed filesystems, if they are not in use any more.
 +#   Unmounts all sandboxed file systems, if they are not in use any more.
  #
  fsumount()
  {
 -    echo "PKG_COMP ==> Unmounting sandboxed filesystems"
 +    echo "PKG_COMP ==> Unmounting sandboxed file systems"
  
      if [ ! -f $fsstate ]; then
          echo "None mounted."
 @@ -352,7 +356,7 @@
      fi
  
      if [ "$fsfailed" = "yes" ]; then
 -        err "FATAL: failed to umount all filesystems"
 +        err "FATAL: failed to unmount all file systems."
      else
          rm $fsstate
      fi
 @@ -370,10 +374,12 @@
  pkg_maketemplate()
  {
      if [ -f "$conffile" ]; then
 -        err "$conffile already exists"
 +        err "configuration file $conffile already exists."
      fi
  
 -    mkdir -p $confdir
 +    if [ -n "$confdir" ]; then
 +       mkdir -p "$confdir"
 +    fi
      cat > $conffile <<EOF
  # -*- sh -*-
  #
 @@ -396,7 +402,7 @@
          echo "$var=\"$val\"" >> $conffile
      done
  
 -    echo "pkg_comp: $conffile created.  Edit the file by hand now."
 +    echo "pkg_comp: configuration file $conffile created.  Edit the file by 
hand now."
  }
  
  # ----------------------------------------------------------------------
 @@ -431,35 +437,35 @@
  {
      # Check for directories that will be null mounted.
      if [ -n "$REAL_SRC" -a ! -d "$REAL_SRC" ]; then
 -        err "REAL_SRC $REAL_SRC does not exist"
 +        err "REAL_SRC $REAL_SRC does not exist."
      fi
  
      if [ -n "$REAL_PKGSRC" -a ! -d "$REAL_PKGSRC" ]; then
 -        err "REAL_PKGSRC $REAL_PKGSRC does not exist"
 +        err "REAL_PKGSRC $REAL_PKGSRC does not exist."
      fi
  
      if [ -n "$REAL_DISTFILES" -a ! -d "$REAL_DISTFILES" ]; then
 -        err "REAL_DISTFILES $REAL_DISTFILES does not exist"
 +        err "REAL_DISTFILES $REAL_DISTFILES does not exist."
      fi
  
      if [ -n "$REAL_PACKAGES" -a ! -d "$REAL_PACKAGES" ]; then
 -        err "REAL_PACKAGES $REAL_PACKAGES does not exist"
 +        err "REAL_PACKAGES $REAL_PACKAGES does not exist."
      fi
  
      if echo ${PKGSRC_COMPILER} | grep ccache >/dev/null 2>&1 && \
          [ -z "${REAL_CCACHE}" ]; then
 -        warn "PKGSRC_COMPILER contains 'ccache' but REAL_CCACHE is unset"
 +        warn "PKGSRC_COMPILER contains 'ccache' but REAL_CCACHE is unset."
      elif [ -n "${REAL_CCACHE}" -a ! -d "${REAL_CCACHE}" ]; then
 -        err "REAL_CCACHE ${REAL_CCACHE} does not exist"
 +        err "REAL_CCACHE ${REAL_CCACHE} does not exist."
      fi
  
      # Check for required directories.
      if [ ! -d $DISTRIBDIR ]; then
 -        err "DISTRIBDIR $DISTRIBDIR does not exist"
 +        err "DISTRIBDIR $DISTRIBDIR does not exist."
      fi
  
      if [ -d $DESTDIR ]; then
 -        err "DESTDIR $DESTDIR already exists"
 +        err "DESTDIR $DESTDIR already exists."
      fi
  
      if [ "$SETS_X11" = "no" ]; then
 @@ -470,7 +476,7 @@
  
      for s in $allsets; do
          if [ ! -f $DISTRIBDIR/binary/sets/$s ]; then
 -            err "$DISTRIBDIR/binary/sets/$s does not exist"
 +            err "$DISTRIBDIR/binary/sets/$s does not exist."
          fi
      done
  
 @@ -532,8 +538,8 @@
  
      echo "PKG_DBDIR=${PKG_DBDIR}" >> ${DESTDIR}/etc/pkg_install.conf
  
 -    # From now on, filesystems may be mounted, so we need to trap
 -    # signals to umount them.
 +    # From now on, file systems may be mounted, so we need to trap
 +    # signals to unmount them.
      trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT
  
      makeroot_libkver
 @@ -580,14 +586,14 @@
      if [ -n "$EXTRAMK" ]; then
          for mkfile in $EXTRAMK; do
              if [ ! -f "$mkfile" ]; then
 -                err "Cannot find $mkfile"
 +                err "cannot find $mkfile."
              else
                  cat $mkfile >> $file
              fi
          done
      fi
  
 -    if [ "$USE_AUDIT_PACKAGES" != "yes" ]; then
 +    if [ "$COPY_PKG_VULNERABILITIES" != "yes" ]; then
          echo "ALLOW_VULNERABLE_PACKAGES ?= YES" >> $file
      fi
  
 @@ -666,15 +672,15 @@
      rfile=${DESTDIR}/pkg_comp/tmp/auto.list
      target="${AUTO_TARGET}"
  
 -    [ -z "${REAL_PACKAGES}" ] && err "this is useless without REAL_PACKAGES"
 +    [ -z "${REAL_PACKAGES}" ] && err "this is useless without REAL_PACKAGES."
      [ -z "${pkgs}" ] &&
 -        err "this is useless without AUTO_PACKAGES nor package names"
 +        err "this is useless without AUTO_PACKAGES or package names."
  
      if [ "$1" = resume ]; then
 -        [ -f ${rfile} ] || err "there is no auto build to resume"
 +        [ -f ${rfile} ] || err "there is no auto build to resume."
          pkgs=`cat ${rfile}`
      elif [ -f ${rfile} ]; then
 -        err "there is an stopped auto build; removeroot first or resume it"
 +        err "there is a stopped auto build; removeroot first or resume it."
      else
          makeroot
  
 @@ -725,12 +731,12 @@
          fi
      done
      if [ -n "$invalid" ]; then
 -        err "invalid packages:$invalid"
 +        err "invalid packages:$invalid."
      fi
  
      # Build them
      fsmount
 -    copy_vulnerabilities
 +    copy_pkg_vulnerabilities
      failed=""
      for p in $pkgs; do
          echo "PKG_COMP ==> Building and installing $p"
 @@ -843,9 +849,9 @@
  
      pkgs="$*"
  
 -    [ -z "$REAL_PACKAGES" ] && err "REAL_PACKAGES is not set"
 +    [ -z "$REAL_PACKAGES" ] && err "REAL_PACKAGES is not set."
  
 -    copy_vulnerabilities
 +    copy_pkg_vulnerabilities
  
      fsmount
      failed=""
 @@ -877,9 +883,9 @@
  {
      local prefix script exitstatus
  
 -    [ -d $DESTDIR ] || err "$DESTDIR does not exist"
 +    [ -d $DESTDIR ] || err "$DESTDIR does not exist."
  
 -    copy_vulnerabilities
 +    copy_pkg_vulnerabilities
  
      fsmount
      echo "PKG_COMP ==> Entering sandbox \`$DESTDIR'"
 @@ -915,7 +921,7 @@
  #
  pkg_removeroot()
  {
 -    [ -f $fsstate ] && err "filesystems may still be mounted; cannot remove"
 +    [ -f $fsstate ] && err "file systems may still be mounted; cannot remove."
      echo "PKG_COMP ==> Removing sandbox \`${DESTDIR}'"
      rm -rf $DESTDIR
  }
 @@ -933,26 +939,28 @@
  fi
  set -- $args
  conffile=
 -nflag=no
  Nflag=no
 +nflag=no
  while [ $# -gt 0 ]; do
      case "$1" in
 -        -c)
 +        -C)
              [ -n "$conffile" ] && usage
 -            conffile="$confdir/$2.conf"
 +            conffile="$2"
 +            [ -d `dirname "$conffile"` -a ! -d "$conffile" ] || err "invalid 
configuration file path."
 +            unset confdir
              shift
              ;;
 -        -C)
 +        -c)
              [ -n "$conffile" ] && usage
 -            conffile="$2"
 +            conffile="$confdir/$2.conf"
              shift
              ;;
 -        -n)
 +        -N)
 +            Nflag=yes
              nflag=yes
              ;;
 -        -N)
 +        -n)
              nflag=yes
 -            Nflag=yes
              ;;
          --)
              shift; break
 @@ -988,12 +996,12 @@
  readconf()
  {
      if [ -f $conffile ]; then
 -        [ `id -u` -ne 0 ] && err "must be run as root"
 +        [ `id -u` -ne 0 ] && err "must be run as root."
          env_clean
          . $conffile
          env_setdefaults
      else
 -        err "$conffile does not exist"
 +        err "configuration file $conffile does not exist."
      fi
  
      fsstate="$DESTDIR/pkg_comp/tmp/mount.stat"
 @@ -1010,11 +1018,11 @@
          err "sandbox not initialized; use makeroot first."
      fi
      if [ "$DESTDIR" = "/" ]; then
 -        err "DESTDIR cannot be /"
 +        err "DESTDIR cannot be /."
      fi
  
 -    # From now on, filesystems may be mounted, so we need to trap
 -    # signals to umount them.
 +    # From now on, file systems may be mounted, so we need to trap
 +    # signals to unmount them.
      trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT
  }
  
 @@ -1058,7 +1066,7 @@
          pkg_auto $args
          ;;
      *)
 -        err "unknown target \`$target'"
 +        err "unknown target \`$target'."
          ;;
  esac
  
 
 --DIOMP1UsTsWJauNi--
 


Home | Main Index | Thread Index | Old Index