# -*- ruby -*-
#
# pkgtools.conf - the configuration file for the pkgtools suite
#
# $Idaemons: /home/cvs/pkgtools/etc/pkgtools.conf,v 1.32 2003/10/19 11:56:30 knu Exp $

# Syntax:
#   string:	'...' or "..."; use the `+' operator to concatenate
#   boolean:	true or false
#   array:	[ value, ... ]; use the `+' operator to concatenate
#   hash:	{ key => value, ... }
#   procedure:	proc { |arglist| statements; return_value }

# Useful predefined constants:
#
#   Name:		Example values:
#   OS_RELEASE:		"5.0-CURRENT"	"4.6.1-RELEASE-p8"
#   OS_REVISION:	"5.0"		"4.6.1"
#   OS_MAJOR:		"5"		"4"
#   OS_BRANCH:		"CURRENT"	"RELEASE"
#   OS_PATCHLEVEL:	""		"-p8"
#   OS_PLATFORM:	"i386"		"alpha"
#   OS_PKGBRANCH:	"5-current"	"4.6.1-release"

# Useful predefined functions:
#
#  localbase()
#    Returns LOCALBASE.
#
#  x11base()
#    Returns X11BASE.
#
#  pkg_site_builder([latest])
#    Returns a URI of the packages directory on the package builder site;
#    Equivalent to:
#     on i386:
#      sprintf('http://bento.FreeBSD.org/errorlogs/packages-%s-%s/',
#              OS_MAJOR, latest ? 'latest' : 'full')
#     on alpha:
#      sprintf('http://beta.FreeBSD.org/errorlogs/packages-%s-%s/',
#              OS_MAJOR, latest ? 'latest' : 'full')
#
#  pkg_site_mirror([root])
#    Returns a URI of the packages directory on the preferred mirror site;
#    Equivalent to:
#      sprintf('%s/pub/FreeBSD/ports/%s/packages-%s/',
#              root  || ENV['PACKAGEROOT'] || 'ftp://ftp.FreeBSD.org',
#              OS_PLATFORM, OS_PKGBRANCH)
#
#  pkg_site_primary()
#    Returns a URI of the packages directory on the primary FTP site;
#    Equivalent to:
#      pkg_site_mirror('ftp://ftp.FreeBSD.org')
#
#  deorigin(origin)
#    Returns an installed package name which was installed from the
#    given origin port.
#    e.g.
#      deorigin('sysutils/portupgrade') => 'portupgrade-YYYYMMDD'
#
#  enabled_rc_scripts(origin_or_pkgname)
#    Returns an array of "enabled" rc scripts ($PREFIX/etc/rc.d/*.sh)
#    for the given package.  "Enabled" here means that files such as
#    *.sh.sample are ignored, however, if a package installs
#    foo.sh.sample and there is foo.sh, it is considered as an enabled
#    rc file for the package and thus returned.
#
#  disabled_rc_scripts(origin_or_pkgname)
#    Returns an array of disabled rc scripts ($PREFIX/etc/rc.d/*.sh.*)
#    that the given package installed.  If a package installs
#    foo.sh.sample and there is foo.sh, it is considered as enabled
#    and thus ignored.
#
#  cmd_start_rc(origin_or_pkgname)
#    Returns a command line string that starts the services of the
#    given package, if any. (Yields "start" for each enabled rc
#    script)
#
#  cmd_stop_rc(origin_or_pkgname)
#    Returns a command line string that stops the services of the
#    given package, if any. (Yields "stop" for each enabled rc script)
#
#  cmd_restart_rc(origin_or_pkgname)
#    Returns a command line string that restarts the services of the
#    given package, if any. (Yields "stop", sleeps for 3 seconds, then
#    yields "start" for each enabled rc script)
#
#  cmd_enable_rc(origin_or_pkgname)
#    Returns a command line string that enables the disabled rc
#    scripts of given package, if any.
#
#  cmd_disable_rc(origin_or_pkgname)
#    Returns a command line string that disables the enabled rc
#    scripts of given package, if any.
#

module PkgConfig

  # Environment Variables: string
  #
  # Uncomment and edit as necessary.  The `||=' operator means `set only
  # if it is not set', i.e. it gives a variable its default value.
  #
  # It is particularly recommended that you set PORTS_INDEX to
  # something other than the default value to avoid conflicts with CVS,
  # CVSup, and CTM.
  #
  # cf. portupgrade(1), pkg_which(1)
  #
  # defaults:
  #   ENV['PORTSDIR'] ||= '/usr/ports'
  #   ENV['PORTS_INDEX'] ||= ENV['PORTSDIR'] + '/INDEX'
  #   ENV['PORTS_DBDIR'] ||= ENV['PORTSDIR']
  #   ENV['PKG_DBDIR'] ||= '/var/db/pkg'
  #
  #   ENV['PKG_TMPDIR'] ||= '/var/tmp'
  #
  #   ENV['PACKAGES'] ||= ENV['PORTSDIR'] + '/packages'
  #
  # e.g.:
  #   ENV['PORTSDIR'] ||= '/export/freebsd/ports'
  #   ENV['PORTS_INDEX'] ||= ENV['PORTSDIR'] + '/INDEX.local'
  #   ENV['PORTS_DBDIR'] ||= ENV['PKG_DBDIR']
  #
  #   ENV['PACKAGES'] ||= sprintf('/export/freebsd/packages-%s',
  #	OS_PKGBRANCH)
  #   ENV['PKG_PATH'] ||= ENV['PACKAGES'] + '/All'
  #
  #   ENV['PKG_FETCH'] = "wget -O '%2$s' '%1$s'"
  #   ENV['PKG_FETCH'] = "curl '%s' -o '%s'"
  #   ENV['PKG_FETCH'] = 'false'	# never fetch packages from a remote site
  #   ENV['PACKAGEROOT'] = 'ftp://ftpN.XX.FreeBSD.org'

  ENV['PORTSDIR'] ||= '/usr/ports'
  ENV['PACKAGES'] ||= ENV['PORTSDIR'] + '/packages'
  ENV['PKG_PATH'] ||= ENV['PACKAGES'] + '/All'

  # SANITY_CHECK: boolean (default: true)
  #
  # If true, perform sanity checks on stale dependencies.  This makes
  # it up to 50% slower to parse package globs but offers unfailing
  # upgrades.  If you are sure you won't forget to run `pkgdb -F'
  # regularly, turn this off to improve performance. (default: true)
  #
  # cf. -O/--omit-check of pkg_deinstall(1), pkg_glob(1),
  #     portupgrade(1) and portversion(1)

  SANITY_CHECK = true

  # IGNORE_CATEGORIES: array
  #
  # This is a list of port categories you want the pkgtools to ignore.
  # Typically you want to list language specific categories of the
  # languages you don't use.
  #
  # After configuring this list, you need to rebuild the ports
  # database to reflect the changes. (run 'portsdb -Ufu')
  #
  # e.g.:
     IGNORE_CATEGORIES = [
       'chinese',
       'french',
       'german',
       'hebrew',
       'japanese',
       'korean',
       'russian',
       'ukrainian',
       'vietnamese',
     ]

  # EXTRA_CATEGORIES: array
  #
  # This is a list of extra port categories you put your locally
  # maintained ports into.  You must prepare a Makefile in each directory
  # that defines a variable SUBDIR which lists all the ports in the
  # category.
  #
  # After configuring this list, you need to rebuild the ports
  # database to reflect the change. (run 'portsdb -Ufu')
  #
  # e.g.:
  #   EXTRA_CATEGORIES = [
  #     'local',
  #   ]

  EXTRA_CATEGORIES = [
  ]

  # HOLD_PKGS: array
  #
  # This is a list of ports you don't want portupgrade(1) to upgrade,
  # portversion(1) to suggest upgrading, or pkgdb(1) to fix.
  # You can use wildcards ("ports glob" and "pkgname glob").
  # -f/--force with each command will override the held status.
  #
  # To completely hide the existence of a package, put a dummy file
  # named "+IGNOREME" in the package directory.
  #
  # cf. pkg_glob(1), ports_glob(1)
  #
  # e.g.:
  #   HOLD_PKGS = [
  #     'bsdpan-*',
  #     'x11*/XFree86*',
  #   ]

  HOLD_PKGS = [
    'x11*/XFree86*/xorg*',
    'bsdpan-*',
    'ucspi-tcp-*',
    'qmail-*',
    'djbdns-',
    'p5-SOAP-Lite-*',
  ]

  # USE_PKGS: array
  # USE_PKGS_ONLY: array
  #
  # These are lists of ports that you prefer to use packages to
  # upgrade or install.  They apply -P/--use-packages and
  # -PP/--use-packages-only to specific ports, respectively.
  #
  # cf. -P/--use-packages and -PP/--use-packages-only of
  # portupgrade(1) and portinstall(1)
  #
  # e.g.:
  #   USE_PKGS = [
  #     'perl',
  #     'ruby',
  #	'python',
  #   ]
  #
  #   USE_PKGS_ONLY = [
  #     'x11*/XFree86*',
  #     '*openoffice*',
  #   ]

  USE_PKGS = [
  ]

  USE_PKGS_ONLY = [
       'x11*/XFree86*/xorg*',
  ]

  # ALT_PKGDEP: hash
  #
  # This is a hash to define alternative package dependencies.  For
  # each pair A => B, when a package X claims that it depends on a
  # package that matches the "pkgname glob" pattern A which is not
  # installed, the dependency is replaced with one installed
  # package that matches the "pkgname glob" pattern B.  If glob B
  # matches more than one installed package, replacement is not done
  # automatically.  <:delete> and <:skip> are special symbols that can
  # be used as B values, instead of pkgname glob patterns.  <:delete>
  # means to delete the dependency and <:skip> to skip it.
  #
  # cf. pkg_glob(1)
  #
  # e.g.:
  #   ALT_PKGDEP = {
  #     # If you use apache13-modssl instead of apache13
  #     'apache-1.3.*' => 'apache+mod_ssl-1.3.*',
  #
  #     # The same as above; you can use origins also
  #     'www/apache13' => 'www/apache13-modssl',
  #
  #     # If you install Apache from source (not from ports/packages)
  #     'apache' => :delete,
  #
  #     # You can specify pkgname w/o version; see pkg_glob(1)
  #     'w3m' => 'w3m-m17n',
  #   }

  ALT_PKGDEP = {
  }

  # MAKE_ARGS: hash
  #
  # This is a hash of ports glob or package glob => arguments mapping.
  # portupgrade(1) and portinstall(1) look it up to pick command line
  # arguments to pass to make(1).  You can use wildcards ("ports glob"
  # or "package glob").  If a port/package matches multiple entries,
  # all the arguments are joined using the space as separator.
  #
  # cf. -m/--make-args of portupgrade(1), ports_glob(1)
  #
  # You can alternatively specify a procedure instead of a string if
  # you want to specify arguments which can vary depending on the port.
  # The procedure is called with a port origin as an argument.
  #
  # e.g.:
  #   MAKE_ARGS = {
  #     'databases/mysql323-*' => 'WITH_CHARSET=ujis',
  #     'ruby18-*' => 'RUBY_VER=1.8',
  #     'ruby16-*' => 'RUBY_VER=1.6',
  #   }
  #
  # To specify multiple arguments for each port, use one of the
  # following:
  #
  #   MAKE_ARGS = {
  #     # a) Separate them with the space
  #     'databases/mysql41-*' => 'WITH_LINUXTHREADS=1 SKIP_DNS_CHECK=1',
  #
  #     # b) Specify them using an array
  #     'databases/mysql41-*' => [
  #        'WITH_LINUXTHREADS=1',
  #        'SKIP_DNS_CHECK=1',
  #     ],
  #   }

  MAKE_ARGS = {
	'databases/mysql4*'  => 'BUILD_OPTIMIZED=yes WITH_OPENSSL=yes',
	'lang/php4*'         => 'WITH_IMAP=1 WITH_APACHE2=1 WITH_SNMP=4 WITH_GD=1 WITH_OPENSSL=1',
	'mail/sqwebmail'     => 'AUTHMOD=authvchkpw WITH_HTTPS=1 WITH_VCHKPW=1 WITH_ISPELL=1 CACHEDIR=/var/run/sqwebmail',
	'mail/courier-imap'  => 'AUTHMOD=authvchkpw WITHOUT_AUTHDAEMON=1 WITH_CRAM=1 WITH_VPOPMAIL=1',
	'mail/courier-authlib' => 'AUTHMOD=authvchkpw WITH_VPOPMAIL=1 WITHOUT_PAM=1',
	'mail/dcc-dccd'      => 'WITHOUT_SENDMAIL=yes',
	'security/courier-authlib' => 'AUTHMOD=authvchkpw WITH_VPOPMAIL=1 WITHOUT_PAM=1',
    'mail/maildrop'      => 'WITH_MAILDIRQUOTA=yes',
	'security/clamav'    => 'WITHOUT_LDAP=1',
	'www/p5-Apache-DBI'  => 'WITH_MODPERL2=1',
  }

  # BEFOREBUILD: hash
  #
  # This is a hash of ports glob => command mapping.  portupgrade(1)
  # and portinstall(1) look it up to pick commands to run before
  # building a port.  You can use wildcards ("ports glob").  If a
  # port/package matches multiple entries, all the commands are joined
  # using the semicolon as separator and run.
  #
  # cf. -B/--beforebuild of portupgrade(1), ports_glob(1)
  #
  # You can alternatively specify a procedure instead of a string if
  # you want to run a command which can vary depending on the port.
  # The procedure is called with a port origin as an argument.  See
  # the examples in the AFTERINSTALL paragraph.
  #
  # e.g.:
  #   BEFOREBUILD = {
  #     # Always do cvs update before building a port
  #     '*' => 'cvs update',
  #   }

  BEFOREBUILD = {
  }

  # BEFOREDEINSTALL: hash
  #
  # This is a hash of ports glob => command mapping.  pkg_deinstall(1)
  # looks it up to pick commands to run after installing a port.  You
  # can use wildcards ("ports glob").  If a port/package matches
  # multiple entries, all the commands are joined using the semicolon
  # as separator and run.
  #
  # You can alternatively specify a procedure instead of a string if
  # you want to run a command which can vary depending on the port.
  # The procedure is called with a port origin as an argument.  See

  # the following examples.
  #
  # e.g.:
  #   BEFOREDEINSTALL = {
  #     # Automatically stop the service for each package that has a
  #     # rc script enabled
  #     '*' => proc { |origin|
  #       cmd_stop_rc(origin)
  #     },
  #
  #     # Stop postfix
  #     'mail/postfix*' => localbase() + '/sbin/postfix stop',
  #   }

  BEFOREDEINSTALL = {
  }

  # AFTERINSTALL: hash
  #
  # This is a hash of ports glob => command mapping.  portupgrade(1)
  # and portinstall(1) look it up to pick commands to run after
  # installing a port.  You can use wildcards ("ports glob").  If a
  # port/package matches multiple entries, all the commands are joined
  # using the semicolon as separator and run.
  #
  # cf. -B/--afterinstall of portupgrade(1), ports_glob(1)
  #
  # You can alternatively specify a procedure instead of a string if
  # you want to run a command which can vary depending on the port.
  # The procedure is called with an argument of a port origin.  See
  # the following examples.
  #
  # e.g.:
  #   AFTERINSTALL = {
  #     # Re-enable the X wrapper
  #     'x11-servers/XFree86-4-Server' => sprintf('cd %s/bin && if [ -x Xwrapper-4 ]; then ln -sf Xwrapper-4 X; fi', x11base()),
  #
  #     # Automatically start the server for each package that
  #     # installs a rc file enabled
  #     '*' => proc { |origin|
  #       cmd_start_rc(origin)
  #     },
  #
  #     # Automatically start MySQL server
  #     'databases/mysql323-server' => proc { |origin|
  #       cmd_enable_rc(origin) + ';' + cmd_start_rc(origin)
  #     },
  #
  #     # Start postfix
  #     'mail/postfix*' => localbase() + '/sbin/postfix start',
  #   }

  AFTERINSTALL = {
    # Re-enable the X wrapper
    'x11-servers/XFree86-4-Server' => sprintf(
     'cd %s/bin && if [ -x Xwrapper-4 ]; then ln -sf Xwrapper-4 X; fi',
     x11base()),
#     'databases/mysql40-server' => proc { |origin|
#         cmd_enable_rc(origin) + ';' + cmd_start_rc(origin)
  }

  # PKG_SITES: array
  #
  # This is a list of URI's to get packages from.  Each site directory
  # must contain directories named 'All' and 'Latest'.  The value of
  # the environment variable `PKG_SITES' is automatically prepended to
  # the list. (default: [pkg_site_mirror()])
  #
  # e.g.:
  #   PKG_SITES = [
  #     sprintf('ftp://ftp.localdomain/pub/freebsd/packages-%s/', OS_MAJOR),
  #     pkg_site_builder(true),
  #     pkg_site_builder(),
  #     pkg_site_mirror(),
  #     pkg_site_primary(),
  #   ]

  PKG_SITES = [
    pkg_site_mirror(),
  ]

  # PORTUPGRADE_ARGS: string
  #
  # This sets the default options passed to portupgrade(1).
  #
  # e.g.:
  #   PORTUPGRADE_ARGS = ENV['PORTUPGRADE'] || \
  #     '-v -D -l /var/tmp/portupgrade.results ' + \
  #     '-L /var/tmp/portupgrade-%s::%s.log'

  PORTUPGRADE_ARGS = ENV['PORTUPGRADE']

end
