head	1.8;
access;
symbols
	RELEASE_2_4_6:1.6
	RELEASE_2_4_5:1.6
	RELEASE_2_4_3:1.6
	RELEASE_2_4_2:1.6
	RELEASE_2_4_1:1.6
	RELEASE_2_4_0:1.6
	RELEASE_2_3_2:1.6
	RELEASE_2_3_1:1.5
	STABLE_2_3:1.5.0.2
	RELEASE_2_3_0:1.5
	RELEASE_2_2_6:1.4.2.1
	RELEASE_2_2_5:1.4.2.1
	RELEASE_2_2_4:1.5
	RELEASE_2_2_3:1.4.2.1
	STABLE_2_2:1.4.0.2
	RELEASE_2_2_2:1.4
	RELEASE_2_2_1:1.4
	RELEASE_2_2_0:1.4
	RELEASE_2_1_3_3:1.1.1.1
	RELEASE_2_1_7:1.4
	RELEASE_2_1_6:1.3
	RELEASE_2_1_3_2:1.1.1.1
	RELEASE_2_1_5:1.3
	RELEASE_2_1_3_1:1.1.1.1.0.4
	STABLE:1.1.1.1.0.2
	PKGTOOLS_2_1_4:1.2
	PKGTOOLS_2_1_3:1.1.1.1
	sem:1.1.1;
locks; strict;
comment	@# @;


1.8
date	2011.08.19.00.57.22;	author stas;	state dead;
branches;
next	1.7;

1.7
date	2008.07.17.00.26.38;	author sem;	state Exp;
branches;
next	1.6;

1.6
date	2008.01.08.11.32.27;	author sem;	state Exp;
branches;
next	1.5;

1.5
date	2007.02.22.13.36.34;	author sem;	state Exp;
branches;
next	1.4;

1.4
date	2006.08.13.11.15.21;	author sem;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	2006.06.30.20.09.28;	author sem;	state Exp;
branches;
next	1.2;

1.2
date	2006.06.14.11.52.38;	author sem;	state Exp;
branches;
next	1.1;

1.1
date	2006.06.13.12.59.00;	author sem;	state Exp;
branches
	1.1.1.1;
next	;

1.4.2.1
date	2007.02.22.14.00.36;	author sem;	state Exp;
branches;
next	;

1.1.1.1
date	2006.06.13.12.59.00;	author sem;	state Exp;
branches;
next	;


desc
@@


1.8
log
@- The project data has moved to github (https://github.com/stass/pkgtools).
@
text
@#!/usr/bin/env ruby
# -*- ruby -*-
#
# Copyright (c) 2000-2004 Akinori MUSHA
# Copyright (c) 2006-2008 Sergey Matveychuk <sem@@FreeBSD.org>
#
# 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
#

MYREVISION = %w$Rev: 52 $[1]
MYDATE = %w$Date: 2008/01/08 11:32:27 $[1]
MYNAME = File.basename($0)

require "optparse"
require "pkgtools"

COLUMNSIZE = 22
NEXTLINE = "\n%*s" % [5 + COLUMNSIZE, '']

def init_global
  $noconfig = false
  $temp_dir = ""
end

def main(argv)
  usage = <<-"EOF"
usage: #{MYNAME} [-hq]
  EOF

  banner = <<-"EOF"
#{MYNAME} #{Version} (#{MYDATE})

#{usage}
  EOF

  dry_parse = true

  OptionParser.new(banner, COLUMNSIZE) do |opts|
    opts.def_option("-h", "--help", "Show this message") {
      print opts
      exit 0
    }

    opts.def_option("-q", "--noconfig", "Do not read pkgtools.conf") { |v|
      $noconfig = v
    }

    opts.def_tail_option '
Environment Variables [default]:
    PKGTOOLS_CONF            configuration file [$PREFIX/etc/pkgtools.conf]
    PKG_DBDIR                packages DB directory [/var/db/pkg]'

    tasks = []

    begin
      init_global
      init_pkgtools_global

      rest = opts.order(*argv)

      unless $noconfig
        init_global
	load_config
      else
	argv = rest
      end

      dry_parse = false

      opts.order!(argv)
    rescue OptionParser::ParseError => e
      STDERR.puts "#{MYNAME}: #{e}", usage
      exit 64
    end

    pkgs = []

    STDIN.each { |line|
      pkg = line.chomp

      if $pkgdb.installed?(pkg)
	pkgs << pkg
      else
	STDERR.puts "No such package is installed: #{pkg}"
      end
    }

    list = $pkgdb.sort_build!(pkgs) 

    puts(*list) unless list.empty?

    return 0
  end
end

if $0 == __FILE__
  set_signal_handlers

  exit(main(ARGV) || 1)
end
@


1.7
log
@Adapt to ruby 1.9
@
text
@@


1.6
log
@New year in COPYRIGHTS
@
text
@d32 1
a32 1
MYDATE = %w$Date: 2007/02/22 13:36:34 $[1]
d65 2
a66 2
    opts.def_option("-q", "--noconfig", "Do not read pkgtools.conf") {
      |$noconfig|
@


1.5
log
@Update COPYRIGHTS
@
text
@d5 1
a5 1
# Copyright (c) 2006,2007 Sergey Matveychuk <sem@@FreeBSD.org>
d32 1
a32 1
MYDATE = %w$Date: 2006/08/13 11:15:21 $[1]
@


1.4
log
@Adjust Copyright notices
@
text
@d5 1
a5 1
# Copyright (c) 2006 Sergey Matveychuk <sem@@FreeBSD.org>
d32 1
a32 1
MYDATE = %w$Date: 2006/06/30 20:09:28 $[1]
@


1.4.2.1
log
@Merge patches from HEAD
@
text
@d5 1
a5 1
# Copyright (c) 2006,2007 Sergey Matveychuk <sem@@FreeBSD.org>
d32 1
a32 1
MYDATE = %w$Date: 2007/02/22 13:36:34 $[1]
@


1.3
log
@Get back second init_global. It's necessary for doubled options like -DD.
Really it's needed only for portupgrade and portsclean, but be consistent.
@
text
@d5 1
d32 1
a32 1
MYDATE = %w$Date: 2006/06/14 11:52:38 $[1]
@


1.2
log
@- Refactoring:
  * Get rid of warnings with ruby --debug
  * Rework ugly init_pkgtools_global call. Now it's more consistent.
@
text
@d31 1
a31 1
MYDATE = %w$Date: 2006/06/13 12:59:00 $[1]
d82 1
@


1.1
log
@Initial revision
@
text
@d31 1
a31 1
MYDATE = %w$Date: 2006-01-01 15:26:59 +0900 (Sun, 01 Jan 2006) $[1]
d42 1
d77 1
a81 1
	init_global
@


1.1.1.1
log
@Initial import
@
text
@@
