Bug 158967 - sysutils/bsdadminscripts: pkg_libchk doesn't work at all when run from bash
Summary: sysutils/bsdadminscripts: pkg_libchk doesn't work at all when run from bash
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Eygene Ryabinkin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-16 12:00 UTC by Matthias Andree
Modified: 2011-08-06 22:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Andree freebsd_committer freebsd_triage 2011-07-16 12:00:19 UTC
pkg_libchk doesn't work at all when run from bash. The problem is that
bash sets OSTYPE to "freebsd8.2" rather than "FreeBSD", hence the
"readelf -e" header matching doesn't see a match.

Fix: OSTYPE=$(uname -s) early in the script.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2011-07-16 12:00:28 UTC
Maintainer of sysutils/bsdadminscripts,

Please note that PR ports/158967 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/158967

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2011-07-16 12:00:30 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Eygene Ryabinkin freebsd_committer freebsd_triage 2011-07-16 19:10:09 UTC
Responsible Changed
From-To: freebsd-ports-bugs->rea

Grabbing PR.
Comment 4 Eygene Ryabinkin freebsd_committer freebsd_triage 2011-07-16 20:07:45 UTC
The following patch fixes the issue:
  http://codelabs.ru/fbsd/ports/bsdadminscripts/fix-missing-OSTYPE.diff

Tinderbox builds are OK:
  - http://gpf.codelabs.ru/tb-logs/mine-9/bsdadminscripts-6.1.1_1.log
  - http://gpf.codelabs.ru/tb-logs/mine-8/bsdadminscripts-6.1.1_1.log
  - http://gpf.codelabs.ru/tb-logs/mine-7/bsdadminscripts-6.1.1_1.log
-- 
Eygene Ryabinkin                                        ,,,^..^,,,
[ Life's unfair - but root password helps!           | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]
Comment 5 kamikaze 2011-07-17 15:55:39 UTC
Go ahead, commit.

BTW, problem doesn't occur on -stable.

Regards,
Dominic
Comment 6 Eygene Ryabinkin freebsd_committer freebsd_triage 2011-07-18 08:48:07 UTC
Dominic, good day.

Sun, Jul 17, 2011 at 03:00:26PM +0000, Dominic Fandrey wrote:
>  BTW, problem doesn't occur on -stable.


Occurs for me:
{{{
$ uname -r
8.0-STABLE
$ env -i /bin/sh -c 'echo $OSTYPE'

$ env -i /bin/csh -c 'echo $OSTYPE'
FreeBSD
$ env -i /bin/tcsh -c 'echo $OSTYPE'
FreeBSD
$ env -i /usr/local/bin/bash -c 'echo $OSTYPE'
freebsd8.0
}}}

How had you tested for the problem?  Under which shell?  Going
to /bin/sh from /bin/t?csh won't show the problem, because OSTYPE
is exported by CSH to the environment:
{{{
$ /bin/csh
%sh -c 'echo $OSTYPE'
FreeBSD
}}}
-- 
Eygene Ryabinkin                                        ,,,^..^,,,
[ Life's unfair - but root password helps!           | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]
Comment 7 dfilter service freebsd_committer freebsd_triage 2011-07-18 11:06:58 UTC
rea         2011-07-18 10:06:50 UTC

  FreeBSD ports repository

  Modified files:
    sysutils/bsdadminscripts Makefile 
  Added files:
    sysutils/bsdadminscripts/files patch-src::pkg_libchk 
  Log:
  Allow pkg_libchk to work from non-CSH shells
  
  /bin/sh does not set OSTYPE, so this variable is inherited from the
  shell from which pkg_libchk is invoked.  From all standard shells in
  the base system, only csh and tcsh do set this variable, so when
  pkg_libchk is invoked from sh (that is not invoked from csh-like
  shell), this variable will be empty.  Moreover, bash sets OSTYPE to
  freebsdX.Y, so grepping on output of 'readelf -e' wont work either.
  
  'uname -s' provides much more reliable way to get the name of the
  operating system and all *BSD ELF ABI types inside readelf correspond
  to the 'uname -s':
  {{{
      case ELFOSABI_NETBSD:       return "UNIX - NetBSD";
      case ELFOSABI_FREEBSD:      return "UNIX - FreeBSD";
      case ELFOSABI_OPENBSD:      return "UNIX - OpenBSD";
  }}}
  
  PR: ports/158967
  Approved-by: Dominic Fandrey <kamikaze@bsdforen.de> (maintainer), erwin (mentor)
  Feature-safe: yes
  
  Revision  Changes    Path
  1.25      +1 -0      ports/sysutils/bsdadminscripts/Makefile
  1.1       +19 -0     ports/sysutils/bsdadminscripts/files/patch-src::pkg_libchk (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 8 Matthias Andree freebsd_committer freebsd_triage 2011-07-18 11:52:18 UTC
great, thanks - and sorry about the misconfigured sender address and
incurred bounces.
Comment 9 Matthias Andree freebsd_committer freebsd_triage 2011-08-06 22:35:07 UTC
State Changed
From-To: feedback->closed

closing PR, bug was fixed 3 weeks ago.