Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge branch 'master' of github.com:freebsd/pkg
Matthew Seaman committed 12 years ago
commit 18c86675061a4b6811715db646415c8e1584ff64
parent 342287a
22 files changed +1301 -1249
modified Makefile
@@ -1,7 +1,8 @@

SUBDIR=	external \
	libpkg \
-
	pkg
+
	pkg \
+
	scripts

NEWVERS=	newvers.sh

modified README.md
@@ -447,22 +447,13 @@ Now you can share your repo with other people by letting them know of your repos

* The [pkgng Wiki page][2]

-
* [Doxygen documentation for libpkg][3]
-

-
* [Buildbot for pkgng][4]
-

-
* [LLVM scanbuild][6]
-

-
* [Jenkins CI instance for pkgng][7]
+
* [Jenkins instance for pkgng][3]

In order to get in contact with us, you can find us in the #pkgng@FreeNode IRC channel.

-
If you hit a bug when using pkgng, you can always submit an issue in the [pkgng issue tracker][5].
+
If you hit a bug when using pkgng, you can always submit an issue in the [pkgng issue tracker][4].

[1]: https://github.com/freebsd/pkg
[2]: http://wiki.freebsd.org/pkgng
-
[3]: http://jenkins.unix-heaven.org/jenkins/job/pkgng-doxygen/
-
[4]: http://buildbot.etoilebsd.net/
-
[5]: https://github.com/freebsd/pkg/issues
-
[6]: http://jenkins.unix-heaven.org/jenkins/job/pkgng-scan-build/
-
[7]: http://jenkins.unix-heaven.org/jenkins/
+
[3]: http://jenkins.unix-heaven.org/jenkins/
+
[4]: https://github.com/freebsd/pkg/issues
modified libpkg/Makefile
@@ -64,7 +64,7 @@ ${_snapshot}:
all: ${PC}

realinstall: ${PC}
-
	${INSTALL} -m 644 ${PC} ${DESTDIR}${PREFIX}/libdata/pkgconfig
+
	${INSTALL} -m 644 ${.OBJDIR}/${PC} ${DESTDIR}${PREFIX}/libdata/pkgconfig

#
# Set DEFAULT_MIRROR_TYPE default to SRV
deleted ports/pkg2ng
@@ -1,14 +0,0 @@
-
#!/bin/sh
-

-
: "${PORTSDIR:=/usr/ports}"
-

-
if [ -f ${PORTSDIR}/Mk/bsd.pkgng.mk ]; then
-
	FORCE_POST=$(make _POSTMKINCLUDED=1 -f ${PORTSDIR}/Mk/bsd.pkgng.mk -V _FORCE_POST_PATTERNS)
-
else
-
	FORCE_POST="rmdir kldxref mkfontscale mkfontdir fc-cache fonts.dir fonts.scale gtk-update-icon-cache gio-querymodules ldconfig update-desktop-database update-mime-database gdk-pixbuf-query-loaders catalog.ports glib-compile-schemas"
-
fi
-

-
FORCE_PORT=$FORCE_POST pkg convert
-

-
# Delete the portupgrade pkgdb to avoid discrepencies. It will be auto recreated.
-
rm -f /var/db/pkg/pkgdb.db > /dev/null 2>&1
added scripts/Makefile
@@ -0,0 +1,5 @@
+
SUBDIR=	periodic \
+
	completion \
+
	sbin
+

+
.include <bsd.subdir.mk>
deleted scripts/bash/_pkg.bash
@@ -1,679 +0,0 @@
-
#! /bin/bash
-
######################################################################
-
#                                                                    #
-
# Copyright (c) 2013, Niamkik <niamkik@gmail.com>                    # 
-
# 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.                                                       #
-
#                                                                    #
-
# The views and conclusions contained in the software and            #
-
# documentation are those of the authors and should not be           #
-
# interpreted as representing official policies, either expressed or #
-
# implied, of the FreeBSD Project.                                   #
-
#                                                                    #
-
# ================================================================== #
-
#                                                                    #
-
# Usage: put "source _pkg.bash" into ~/.bashrc or /etc/bash.bashrc.  #
-
#                                                                    #
-
######################################################################
-

-
######################################################################
-
# Global function (generate dynamic package list e.g.)               #
-
######################################################################
-

-
_pkg_installed () {
-
    pkg query "%n-%v"
-
}
-

-
_pkg_available_name () {
-
    pkg rquery "%n"
-
}
-

-
_pkg_available () {
-
    pkg rquery "%n-%v"
-
}
-

-
######################################################################
-
# pkgng subfunction for pkg subcommand.                              #
-
######################################################################
-

-
_pkgng_add () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-

-
    small_info="Registers a package and installs it on the system"
-
    large_info=""
-
}
-

-
_pkgng_audit () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-F' '-q')
-
    lopts=()
-

-
    small_info="Reports vulnerable packages"
-
    large_info=""
-
}
-

-
_pkgng_autoremove () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Removes orphan packages"
-
    large_info=""
-
}
-

-
_pkgng_backup () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-r' '-d')
-
    lopts=('-r[Restore the local package database]' 
-
           '-d[Dumps the local package database]')
-

-
    small_info="Backs-up and restores the local package database"
-
    large_info=""
-
}
-

-
_pkgng_check () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-B' '-d' '-r' '-s' '-v' '-g' '-x' '-X' '-a')
-
    lopts=()
-
    small_info="Checks for missing dependencies and database consistency"
-
    large_info=""
-
}
-

-
_pkgng_clean () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Cleans old packages from the cache"
-
    large_info=""
-
}
-

-
_pkgng_convert () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Convert database from/to pkgng"
-
    large_info=""
-
}
-

-
_pkgng_create () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-r' '-m' '-f' '-o' '-g' '-x' '-X' '-a')
-
    lopts=()
-
    small_info="Creates software package distributions"
-
    large_info=""
-
}
-

-
_pkgng_delete () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-y' '-n' '-f' '-g' '-x' '-X' '-a')
-
    lopts=()
-
    small_info="Deletes packages from the database and the system"
-
    large_info=""
-
}
-

-
_pkgng_fetch () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-y' '-L' '-q' '-g' '-x' '-X' '-a')
-
    lopts=()
-
    small_info="Fetches packages from a remote repository"
-
    large_info=""
-
}
-

-
_pkgng_help () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Displays help information"
-
    large_info=""
-
}
-

-
_pkgng_info () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-e' '-d' '-r' '-l' '-o' '-p' '-D' 
-
          '-f' '-q' '-g' '-x' '-X' '-F' '-a')
-
    lopts=()
-
    small_info="Displays information about installed packages"
-
    large_info=""
-
}
-

-
_pkgng_install () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-y' '-n' '-f' '-R' '-L' '-x' '-X' '-g')
-
    lopts=()
-
    small_info="Installs packages from remote package repositories"
-
    large_info=""
-
}
-

-
_pkgng_query () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-g' '-x' '-X' '-F' '-e' '-a')
-
    lopts=()
-
    small_info="Queries information about installed packages"
-
    large_info=""
-
}
-

-
_pkgng_register () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-l' '-d' '-f' '-m' '-a' '-i')
-
    lopts=()
-
    small_info="Registers a package into the local database"
-
    large_info=""
-
}
-

-
_pkgng_remove () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Deletes packages from the database and the system"
-
    large_info=""
-
}
-

-
_pkgng_repo () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Creates a package repository catalogue"
-
    large_info=""
-
}
-

-
_pkgng_rquery () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-g' '-x' '-X' '-e' '-a')
-
    lopts=()
-
    small_info="Queries information in repository catalogues"
-
    large_info=""
-
}
-

-
_pkgng_search () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-x' '-X' '-g')
-
    lopts=()
-
    small_info="Performs a search of package repository catalogues"
-
    large_info=""
-
}
-

-
_pkgng_set () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=('-o' '-A' '-y' '-g' '-x' '-X' '-a')
-
    lopts=('(-o)-A[Mark as automatic or not]'
-
           '(-A)-o[Change the origin]'
-
           '-y[Assume yes when asked for confirmation]'
-
           '(-g -x -X)-a[Process all packages]'
-
           '(-x -X -a)-g[Process packages that matches glob]'
-
           '(-g -X -a)-x[Process packages that matches regex]'
-
           '(-g -x -a)-X[Process packages that matches extended regex]')
-

-
    small_info="Modifies information about packages in the local database"
-
    large_info=""
-
}
-

-
_pkgng_shell () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=('-q[Be quiet]'
-
           '(-l)-r[Display stats only for the local package database]'
-
           '(-r)-l[Display stats only for the remote package database(s)]')
-

-
    small_info="Opens a debug shell"
-
    large_info=""
-
}
-

-
_pkgng_shlib () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=('-f[Force updating]'
-
           '-q[Be quiet]')
-

-
    small_info="Displays which packages link against a specific shared library"
-
    large_info=""
-
}
-

-
_pkgng_stats () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Displays package database statistics"
-
    large_info=""
-
}
-

-
_pkgng_update () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Updates package repository catalogues"
-
    large_info=""
-
}
-

-
_pkgng_updating () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Displays UPDATING information for a package"
-
    large_info=""
-
}
-

-
_pkgng_upgrade () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Performs upgrades of packaged software distributions"
-
    large_info=""
-
}
-

-
_pkgng_version () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=('(-P -R)-I[Use INDEX file]'
-
           '(-R -I)-P[Force checking against the ports tree]'
-
           '(-I -P)-R[Use remote repository]'
-
           '-o[Display package origin, instead of package name]'
-
           '-q[Be quiet]'
-
           '-v[Be verbose]'
-
           '(-L)-l[Display only the packages for given status flag]'
-
           '(-l)-L[Display only the packages without given status flag]')
-

-
    small_info="Displays the versions of installed packages"
-
    large_info=""
-
}
-

-
_pkgng_which () {
-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    opts=()
-
    lopts=()
-
    small_info="Displays which package installed a specific file"
-
    large_info=""
-
}
-

-
######################################################################
-
# Main function for completion, only for "pkg" command. Other        #
-
# subcommand use function like _pkgng_[subfunction].                 #
-
######################################################################
-

-
_pkg () {
-

-
    local cur prev opts lopts
-
    COMPREPLY=()
-

-
    # get command name
-
    cur="${COMP_WORDS[COMP_CWORD]}"
-
    
-
    # get first arguments
-
    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
    
-
    # init opts for first completion
-
    opts='add audit autoremove backup check clean create delete
-
          fetch help info install query rquery search set shell
-
          shlib stats update updating upgrade version which'
-

-
    # init lopts for second completion with details
-
    lopts=( 'add[Registers a package and installs it on the system]'
-
            'audit[Reports vulnerable packages]'
-
            'autoremove[Removes orphan packages]'
-
            'backup[Backs-up and restores the local package database]'
-
            'check[Checks for missing dependencies and database consistency]'
-
            'clean[Cleans old packages from the cache]'
-
            'convert[Convert database from/to pkgng]'
-
            'create[Creates software package distributions]'
-
            'delete[Deletes packages from the database and the system]'
-
            'fetch[Fetches packages from a remote repository]'
-
            'help[Displays help information]'
-
	    'info[Displays information about installed packages]'
-
            'install[Installs packages from remote package repositories]'
-
            'query[Queries information about installed packages]'
-
            'register[Registers a package into the local database]'
-
            'remove[Deletes packages from the database and the system]'
-
            'repo[Creates a package repository catalogue]'
-
            'rquery[Queries information in repository catalogues]'
-
            'search[Performs a search of package repository catalogues]'
-
            'set[Modifies information about packages in the local database]'
-
            'shell[Opens a debug shell]'
-
            'shlib[Displays which packages link against a specific shared library]'
-
            'stats[Displays package database statistics]'
-
            'update[Updates package repository catalogues]'
-
            'updating[Displays UPDATING information for a package]'
-
            'upgrade[Performs upgrades of packaged software distributions]'
-
            'version[Displays the versions of installed packages]'
-
            'which[Displays which package installed a specific file]' )
-

-
    # switch on second arguments
-
    case "${prev}" in 
-

-
 	add) 
-
	    COMPREPLY=( $(compgen -A file *.t?z ) ) && \
-
	    return 0 
-
            ;;
-

-
        audit) 
-
	    COMPREPLY=( 
-
		'-F[Fetch the database before checking.]'
-
		'-q[Quiet]'
-
		$(compgen -F _pkg_installed) 
-
	    )
-
	    return 0 
-
            ;;
-

-
        autoremove) 
-
	    COMPREPLY=( $(compgen) ) && \
-
		return 0 ;;
-

-
        backup) 
-
	    COMPREPLY=(
-
		'(-r)-d[Dumps the local package database]'
-
		'(-d)-r[Restrore the local package database]'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        check) 
-
	    COMPREPLY=(
-
		'-B[reanalyse SHLIBS of installed packages]' 
-
		'-d[check for and install missing dependencies]' 
-
		'-r[recompute sizes and checksums of installed]' 
-
		'-s[find invalid checksums]' 
-
		'-v[Be verbose]' 
-
		'(-g -x -X)-a[Process all packages]' 
-
		'(-x -X -a)-g[Process packages that matches glob]'
-
		'(-g -X -a)-x[Process packages that matches regex]'
-
		'(-g -x -a)-X[Process packages that matches extended regex]'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        clean) 
-
	    return 0 ;;
-
	
-
        convert)
-
            # _arguments -s \
-
            # '-r[Revert conversion]' \
-
            # return 0
-
            return 0;;
-

-
        create) 
-
	    COMPREPLY=(
-
		'-r[Root directory] -/'
-
		'-m[Manifest directory] -/'
-
		'-f[format]'
-
		'-o[Ouput directory] -/'
-
		'(-g -x -X)-a[Process all packages]'
-
		'(-x -X -a)-g[Process packages that matches glob]'
-
		'(-g -X -a)-x[Process packages that matches regex]'
-
		'(-g -x -a)-X[Process packages that matches extended regex]'
-
		'*:Package:_pkg_installed'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        delete|remove) 
-
	    COMPREPLY=(
-
		'(-y)-n[Assume yes when asked for confirmation]'
-
		'(-n)-y[Assume no (dry run) for confirmations]'
-
		'-f[Forces packages to be removed]'
-
		'(-g -x -X)-a[Process all packages]'
-
		'(-x -X -a)-g[Process packages that matches glob]'
-
		'(-g -X -a)-x[Process packages that matches regex]'
-
		'(-g -x -a)-X[Process packages that matches extended regex]'
-
		'*:Package:_pkg_installed'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        fetch) 
-
	    COMPREPLY=(
-
		'-y[Assume yes when asked for confirmation]'
-
		'-L[Do not try to update the repository metadata]'
-
		'-q[Be quiet]'
-
		'(-g -x -X)-a[Process all packages]'
-
		'(-x -X -a)-g[Process packages that matches glob]'
-
		'(-g -X -a)-x[Process packages that matches regex]' 
-
		'(-g -x -a)-X[Process packages that matches extended regex]'
-
		'*:Available packages:_pkg_available'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        help) 
-
	    COMPREPLY=() && \
-
		return 0 ;;
-

-
        info) 
-
	    COMPREPLY=(
-
		'(-e -d -r -l -o -p -D)-f[Displays full information]'
-
		'(-f -d -r -l -o -p -D)-e[Returns 0 if <pkg-name> is installed]'
-
		'(-e -f -r -l -o -p -D)-d[Displays the dependencies]'
-
		'(-e -d -f -l -o -p -D)-r[Displays the reverse dependencies]'
-
		'(-e -d -r -f -o -p -D)-l[Displays all files]'
-
		'(-e -d -r -l -f -p -D)-o[Displays origin]'
-
		'(-e -d -r -l -o -f -D)-p[Displays prefix]'
-
		'(-e -d -r -l -o -p -f)-D[Displays message]'
-
		'-q[Be quiet]'
-
		'(-g -x -X -F)-a[Process all packages]'
-
		'(-x -X -a -F)-g[Process packages that matches glob]'
-
		'(-g -X -a -F)-x[Process packages that matches regex]'
-
		'(-g -x -a -F)-X[Process packages that matches extended regex]'
-
		'(-g -x -X -a)-F[Process the specified package]'
-
		'*:Package:_pkg_installed'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        install) 
-
	    COMPREPLY=(
-
		'(-y)-n[Assume yes when asked for confirmation]'
-
		'(-n)-y[Assume no (dry run) for confirmations]'
-
		'-f[Force reinstallation if needed]'
-
		'-R[Reinstall every package depending on matching expressions]'
-
		'-L[Do not try to update the repository metadata]'
-
		'(-x -X)-g[Process packages that matches glob]'
-
		'(-g -X)-x[Process packages that matches regex]'
-
		'(-g -x)-X[Process packages that matches extended regex]'
-
		'*:Available packages:_pkg_available'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        query) 
-
	    COMPREPLY=(
-
		'(-g -x -X -F -e)-a[Process all packages]'
-
		'(-x -X -a -F -e)-g[Process packages that matches glob]'
-
		'(-g -X -a -F -e)-x[Process packages that matches regex]'
-
		'(-g -x -a -F -e)-X[Process packages that matches extended regex]'
-
		'(-g -x -X -a -F)-e[Process packages that matches the evaluation]'
-
		'(-g -x -X -a -e)-F[Process the specified package]'
-
		':Ouput format:'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        register) 
-
	    COMPREPLY=(
-
		'-l[registered as a legacy format]'
-
		'-d[mark the package as an automatic dependency]'
-
		'-f[packing list file]'
-
		'-m[metadata directory]'
-
		'-a[ABI]'
-
		'-i[input path (aka root directory)]'
-
	    )
-
	    return 0 ;;
-

-
        repo) 
-
	    COMPREPLY=() && \
-
		return 0 ;;
-

-
        rquery) 
-
	    COMPREPLY=(
-
		'(-g -x -X -e)-a[Process all packages]'
-
		'(-x -X -a -e)-g[Process packages that matches glob]'
-
		'(-g -X -a -e)-x[Process packages that matches regex]'
-
		'(-g -x -a -e)-X[Process packages that matches extended regex]'
-
		'(-g -x -X -a)-e[Process packages that matches the evaluation]'
-
	    )
-
	    return 0 ;;
-

-
        search) 
-
	    COMPREPLY=(
-
		'(-x -X)-g[Process packages that matches glob]'
-
		'(-g -X)-x[Process packages that matches regex]'
-
		'(-g -x)-X[Process packages that matches extended regex]'
-
	    )
-
	    return 0 ;;
-

-
        set) 
-
	    COMPREPLY=(
-
		'(-o)-A[Mark as automatic or not]'
-
		'(-A)-o[Change the origin]'
-
		'-y[Assume yes when asked for confirmation]'
-
		'(-g -x -X)-a[Process all packages]'
-
		'(-x -X -a)-g[Process packages that matches glob]'
-
		'(-g -X -a)-x[Process packages that matches regex]'
-
		'(-g -x -a)-X[Process packages that matches extended regex]'
-
	    )
-
	    return 0 ;;
-

-
        shell) 
-
	    COMPREPLY=() && \
-
		return 0 ;;
-

-
        shlib) 
-
	    COMPREPLY=() && \
-
		return 0 ;;
-

-
        stats) 
-
	    COMPREPLY=(
-
		'-q[Be quiet]'
-
		'(-l)-r[Display stats only for the local package database]'
-
		'(-r)-l[Display stats only for the remote package database(s)]' 
-
	    )
-
	    return 0 ;;
-

-
        update) 
-
	    COMPREPLY=(
-
		'-f[Force updating]'
-
		'-q[Be quiet]'
-
	    )
-
	    return 0 ;;
-

-
        updating) 
-
	    COMPREPLY=(
-
		'-d[Only entries newer than date are shown]'
-
		'-f[Defines a alternative location of the UPDATING file]'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        upgrade) 
-
	    COMPREPLY=(
-
		'(-y)-n[Assume no (dry run) for confirmations]' 
-
		'(-n)-y[Assume yes when asked for confirmation]' 
-
		'-f[Upgrade/Reinstall everything]' 
-
		'-L[Do not try to update the repository metadata]'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        version) 
-
	    COMPREPLY=(
-
		'(-P -R)-I[Use INDEX file]'
-
		'(-R -I)-P[Force checking against the ports tree]'
-
		'(-I -P)-R[Use remote repository]'
-
		'-o[Display package origin, instead of package name]'
-
		'-q[Be quiet]'
-
		'-v[Be verbose]'
-
		'(-L)-l[Display only the packages for given status flag]'
-
		'(-l)-L[Display only the packages without given status flag]'
-
	    )
-
	    return 0 
-
	    ;;
-

-
        which) 
-
	    COMPREPLY=( $(compgen -W "$(compgen -A file)") ) && \
-
		return 0 
-
	    ;;
-
    esac
-

-
    # if doesn't exist, return opts
-
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-
}
-

-
complete -F _pkg pkg
added scripts/completion/Makefile
@@ -0,0 +1,24 @@
+
.SUFFIXES:	.in
+

+
PREFIX?=	/usr/local
+

+
COMPLETION_SRCS=	_pkg.bash.in \
+
			_pkg.zsh.in
+
COMPLETION=	${COMPLETION_SRCS:R}
+

+
.in:
+
	sed -e 's,__PREFIX__,${PREFIX},g' \
+
		${.IMPSRC} > ${.TARGET}
+

+
all: ${COMPLETION}
+

+
clean:
+
	rm -f ${.OBJDIR}/${COMPLETION}
+

+
install: all
+
	install -d ${DESTDIR}${PREFIX}/share/zsh/site-functions/
+
	install -d ${DESTDIR}${PREFIX}/etc/bash_completion.d/
+
	install -m 444 ${.OBJDIR}/_pkg.bash ${DESTDIR}${PREFIX}/etc/bash_completion.d/
+
	install -m 444 ${.OBJDIR}/_pkg.zsh ${DESTDIR}${PREFIX}/share/zsh/site-functions/_pkg
+

+
.include <bsd.own.mk>
added scripts/completion/_pkg.bash.in
@@ -0,0 +1,679 @@
+
#! /bin/bash
+
######################################################################
+
#                                                                    #
+
# Copyright (c) 2013, Niamkik <niamkik@gmail.com>                    # 
+
# 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.                                                       #
+
#                                                                    #
+
# The views and conclusions contained in the software and            #
+
# documentation are those of the authors and should not be           #
+
# interpreted as representing official policies, either expressed or #
+
# implied, of the FreeBSD Project.                                   #
+
#                                                                    #
+
# ================================================================== #
+
#                                                                    #
+
# Usage: put "source _pkg.bash" into ~/.bashrc or /etc/bash.bashrc.  #
+
#                                                                    #
+
######################################################################
+

+
######################################################################
+
# Global function (generate dynamic package list e.g.)               #
+
######################################################################
+

+
_pkg_installed () {
+
    __PREFIX__/sbin/pkg query "%n-%v"
+
}
+

+
_pkg_available_name () {
+
    __PREFIX__/sbin/pkg rquery "%n"
+
}
+

+
_pkg_available () {
+
    __PREFIX__/sbin/pkg rquery "%n-%v"
+
}
+

+
######################################################################
+
# pkgng subfunction for pkg subcommand.                              #
+
######################################################################
+

+
_pkgng_add () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+

+
    small_info="Registers a package and installs it on the system"
+
    large_info=""
+
}
+

+
_pkgng_audit () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-F' '-q')
+
    lopts=()
+

+
    small_info="Reports vulnerable packages"
+
    large_info=""
+
}
+

+
_pkgng_autoremove () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Removes orphan packages"
+
    large_info=""
+
}
+

+
_pkgng_backup () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-r' '-d')
+
    lopts=('-r[Restore the local package database]' 
+
           '-d[Dumps the local package database]')
+

+
    small_info="Backs-up and restores the local package database"
+
    large_info=""
+
}
+

+
_pkgng_check () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-B' '-d' '-r' '-s' '-v' '-g' '-x' '-X' '-a')
+
    lopts=()
+
    small_info="Checks for missing dependencies and database consistency"
+
    large_info=""
+
}
+

+
_pkgng_clean () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Cleans old packages from the cache"
+
    large_info=""
+
}
+

+
_pkgng_convert () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Convert database from/to pkgng"
+
    large_info=""
+
}
+

+
_pkgng_create () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-r' '-m' '-f' '-o' '-g' '-x' '-X' '-a')
+
    lopts=()
+
    small_info="Creates software package distributions"
+
    large_info=""
+
}
+

+
_pkgng_delete () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-y' '-n' '-f' '-g' '-x' '-X' '-a')
+
    lopts=()
+
    small_info="Deletes packages from the database and the system"
+
    large_info=""
+
}
+

+
_pkgng_fetch () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-y' '-L' '-q' '-g' '-x' '-X' '-a')
+
    lopts=()
+
    small_info="Fetches packages from a remote repository"
+
    large_info=""
+
}
+

+
_pkgng_help () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Displays help information"
+
    large_info=""
+
}
+

+
_pkgng_info () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-e' '-d' '-r' '-l' '-o' '-p' '-D' 
+
          '-f' '-q' '-g' '-x' '-X' '-F' '-a')
+
    lopts=()
+
    small_info="Displays information about installed packages"
+
    large_info=""
+
}
+

+
_pkgng_install () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-y' '-n' '-f' '-R' '-L' '-x' '-X' '-g')
+
    lopts=()
+
    small_info="Installs packages from remote package repositories"
+
    large_info=""
+
}
+

+
_pkgng_query () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-g' '-x' '-X' '-F' '-e' '-a')
+
    lopts=()
+
    small_info="Queries information about installed packages"
+
    large_info=""
+
}
+

+
_pkgng_register () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-l' '-d' '-f' '-m' '-a' '-i')
+
    lopts=()
+
    small_info="Registers a package into the local database"
+
    large_info=""
+
}
+

+
_pkgng_remove () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Deletes packages from the database and the system"
+
    large_info=""
+
}
+

+
_pkgng_repo () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Creates a package repository catalogue"
+
    large_info=""
+
}
+

+
_pkgng_rquery () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-g' '-x' '-X' '-e' '-a')
+
    lopts=()
+
    small_info="Queries information in repository catalogues"
+
    large_info=""
+
}
+

+
_pkgng_search () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-x' '-X' '-g')
+
    lopts=()
+
    small_info="Performs a search of package repository catalogues"
+
    large_info=""
+
}
+

+
_pkgng_set () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=('-o' '-A' '-y' '-g' '-x' '-X' '-a')
+
    lopts=('(-o)-A[Mark as automatic or not]'
+
           '(-A)-o[Change the origin]'
+
           '-y[Assume yes when asked for confirmation]'
+
           '(-g -x -X)-a[Process all packages]'
+
           '(-x -X -a)-g[Process packages that matches glob]'
+
           '(-g -X -a)-x[Process packages that matches regex]'
+
           '(-g -x -a)-X[Process packages that matches extended regex]')
+

+
    small_info="Modifies information about packages in the local database"
+
    large_info=""
+
}
+

+
_pkgng_shell () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=('-q[Be quiet]'
+
           '(-l)-r[Display stats only for the local package database]'
+
           '(-r)-l[Display stats only for the remote package database(s)]')
+

+
    small_info="Opens a debug shell"
+
    large_info=""
+
}
+

+
_pkgng_shlib () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=('-f[Force updating]'
+
           '-q[Be quiet]')
+

+
    small_info="Displays which packages link against a specific shared library"
+
    large_info=""
+
}
+

+
_pkgng_stats () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Displays package database statistics"
+
    large_info=""
+
}
+

+
_pkgng_update () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Updates package repository catalogues"
+
    large_info=""
+
}
+

+
_pkgng_updating () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Displays UPDATING information for a package"
+
    large_info=""
+
}
+

+
_pkgng_upgrade () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Performs upgrades of packaged software distributions"
+
    large_info=""
+
}
+

+
_pkgng_version () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=('(-P -R)-I[Use INDEX file]'
+
           '(-R -I)-P[Force checking against the ports tree]'
+
           '(-I -P)-R[Use remote repository]'
+
           '-o[Display package origin, instead of package name]'
+
           '-q[Be quiet]'
+
           '-v[Be verbose]'
+
           '(-L)-l[Display only the packages for given status flag]'
+
           '(-l)-L[Display only the packages without given status flag]')
+

+
    small_info="Displays the versions of installed packages"
+
    large_info=""
+
}
+

+
_pkgng_which () {
+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    opts=()
+
    lopts=()
+
    small_info="Displays which package installed a specific file"
+
    large_info=""
+
}
+

+
######################################################################
+
# Main function for completion, only for "pkg" command. Other        #
+
# subcommand use function like _pkgng_[subfunction].                 #
+
######################################################################
+

+
_pkg () {
+

+
    local cur prev opts lopts
+
    COMPREPLY=()
+

+
    # get command name
+
    cur="${COMP_WORDS[COMP_CWORD]}"
+
    
+
    # get first arguments
+
    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
    
+
    # init opts for first completion
+
    opts='add audit autoremove backup check clean create delete
+
          fetch help info install query rquery search set shell
+
          shlib stats update updating upgrade version which'
+

+
    # init lopts for second completion with details
+
    lopts=( 'add[Registers a package and installs it on the system]'
+
            'audit[Reports vulnerable packages]'
+
            'autoremove[Removes orphan packages]'
+
            'backup[Backs-up and restores the local package database]'
+
            'check[Checks for missing dependencies and database consistency]'
+
            'clean[Cleans old packages from the cache]'
+
            'convert[Convert database from/to pkgng]'
+
            'create[Creates software package distributions]'
+
            'delete[Deletes packages from the database and the system]'
+
            'fetch[Fetches packages from a remote repository]'
+
            'help[Displays help information]'
+
	    'info[Displays information about installed packages]'
+
            'install[Installs packages from remote package repositories]'
+
            'query[Queries information about installed packages]'
+
            'register[Registers a package into the local database]'
+
            'remove[Deletes packages from the database and the system]'
+
            'repo[Creates a package repository catalogue]'
+
            'rquery[Queries information in repository catalogues]'
+
            'search[Performs a search of package repository catalogues]'
+
            'set[Modifies information about packages in the local database]'
+
            'shell[Opens a debug shell]'
+
            'shlib[Displays which packages link against a specific shared library]'
+
            'stats[Displays package database statistics]'
+
            'update[Updates package repository catalogues]'
+
            'updating[Displays UPDATING information for a package]'
+
            'upgrade[Performs upgrades of packaged software distributions]'
+
            'version[Displays the versions of installed packages]'
+
            'which[Displays which package installed a specific file]' )
+

+
    # switch on second arguments
+
    case "${prev}" in 
+

+
 	add) 
+
	    COMPREPLY=( $(compgen -A file *.t?z ) ) && \
+
	    return 0 
+
            ;;
+

+
        audit) 
+
	    COMPREPLY=( 
+
		'-F[Fetch the database before checking.]'
+
		'-q[Quiet]'
+
		$(compgen -F _pkg_installed) 
+
	    )
+
	    return 0 
+
            ;;
+

+
        autoremove) 
+
	    COMPREPLY=( $(compgen) ) && \
+
		return 0 ;;
+

+
        backup) 
+
	    COMPREPLY=(
+
		'(-r)-d[Dumps the local package database]'
+
		'(-d)-r[Restrore the local package database]'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        check) 
+
	    COMPREPLY=(
+
		'-B[reanalyse SHLIBS of installed packages]' 
+
		'-d[check for and install missing dependencies]' 
+
		'-r[recompute sizes and checksums of installed]' 
+
		'-s[find invalid checksums]' 
+
		'-v[Be verbose]' 
+
		'(-g -x -X)-a[Process all packages]' 
+
		'(-x -X -a)-g[Process packages that matches glob]'
+
		'(-g -X -a)-x[Process packages that matches regex]'
+
		'(-g -x -a)-X[Process packages that matches extended regex]'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        clean) 
+
	    return 0 ;;
+
	
+
        convert)
+
            # _arguments -s \
+
            # '-r[Revert conversion]' \
+
            # return 0
+
            return 0;;
+

+
        create) 
+
	    COMPREPLY=(
+
		'-r[Root directory] -/'
+
		'-m[Manifest directory] -/'
+
		'-f[format]'
+
		'-o[Ouput directory] -/'
+
		'(-g -x -X)-a[Process all packages]'
+
		'(-x -X -a)-g[Process packages that matches glob]'
+
		'(-g -X -a)-x[Process packages that matches regex]'
+
		'(-g -x -a)-X[Process packages that matches extended regex]'
+
		'*:Package:_pkg_installed'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        delete|remove) 
+
	    COMPREPLY=(
+
		'(-y)-n[Assume yes when asked for confirmation]'
+
		'(-n)-y[Assume no (dry run) for confirmations]'
+
		'-f[Forces packages to be removed]'
+
		'(-g -x -X)-a[Process all packages]'
+
		'(-x -X -a)-g[Process packages that matches glob]'
+
		'(-g -X -a)-x[Process packages that matches regex]'
+
		'(-g -x -a)-X[Process packages that matches extended regex]'
+
		'*:Package:_pkg_installed'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        fetch) 
+
	    COMPREPLY=(
+
		'-y[Assume yes when asked for confirmation]'
+
		'-L[Do not try to update the repository metadata]'
+
		'-q[Be quiet]'
+
		'(-g -x -X)-a[Process all packages]'
+
		'(-x -X -a)-g[Process packages that matches glob]'
+
		'(-g -X -a)-x[Process packages that matches regex]' 
+
		'(-g -x -a)-X[Process packages that matches extended regex]'
+
		'*:Available packages:_pkg_available'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        help) 
+
	    COMPREPLY=() && \
+
		return 0 ;;
+

+
        info) 
+
	    COMPREPLY=(
+
		'(-e -d -r -l -o -p -D)-f[Displays full information]'
+
		'(-f -d -r -l -o -p -D)-e[Returns 0 if <pkg-name> is installed]'
+
		'(-e -f -r -l -o -p -D)-d[Displays the dependencies]'
+
		'(-e -d -f -l -o -p -D)-r[Displays the reverse dependencies]'
+
		'(-e -d -r -f -o -p -D)-l[Displays all files]'
+
		'(-e -d -r -l -f -p -D)-o[Displays origin]'
+
		'(-e -d -r -l -o -f -D)-p[Displays prefix]'
+
		'(-e -d -r -l -o -p -f)-D[Displays message]'
+
		'-q[Be quiet]'
+
		'(-g -x -X -F)-a[Process all packages]'
+
		'(-x -X -a -F)-g[Process packages that matches glob]'
+
		'(-g -X -a -F)-x[Process packages that matches regex]'
+
		'(-g -x -a -F)-X[Process packages that matches extended regex]'
+
		'(-g -x -X -a)-F[Process the specified package]'
+
		'*:Package:_pkg_installed'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        install) 
+
	    COMPREPLY=(
+
		'(-y)-n[Assume yes when asked for confirmation]'
+
		'(-n)-y[Assume no (dry run) for confirmations]'
+
		'-f[Force reinstallation if needed]'
+
		'-R[Reinstall every package depending on matching expressions]'
+
		'-L[Do not try to update the repository metadata]'
+
		'(-x -X)-g[Process packages that matches glob]'
+
		'(-g -X)-x[Process packages that matches regex]'
+
		'(-g -x)-X[Process packages that matches extended regex]'
+
		'*:Available packages:_pkg_available'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        query) 
+
	    COMPREPLY=(
+
		'(-g -x -X -F -e)-a[Process all packages]'
+
		'(-x -X -a -F -e)-g[Process packages that matches glob]'
+
		'(-g -X -a -F -e)-x[Process packages that matches regex]'
+
		'(-g -x -a -F -e)-X[Process packages that matches extended regex]'
+
		'(-g -x -X -a -F)-e[Process packages that matches the evaluation]'
+
		'(-g -x -X -a -e)-F[Process the specified package]'
+
		':Ouput format:'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        register) 
+
	    COMPREPLY=(
+
		'-l[registered as a legacy format]'
+
		'-d[mark the package as an automatic dependency]'
+
		'-f[packing list file]'
+
		'-m[metadata directory]'
+
		'-a[ABI]'
+
		'-i[input path (aka root directory)]'
+
	    )
+
	    return 0 ;;
+

+
        repo) 
+
	    COMPREPLY=() && \
+
		return 0 ;;
+

+
        rquery) 
+
	    COMPREPLY=(
+
		'(-g -x -X -e)-a[Process all packages]'
+
		'(-x -X -a -e)-g[Process packages that matches glob]'
+
		'(-g -X -a -e)-x[Process packages that matches regex]'
+
		'(-g -x -a -e)-X[Process packages that matches extended regex]'
+
		'(-g -x -X -a)-e[Process packages that matches the evaluation]'
+
	    )
+
	    return 0 ;;
+

+
        search) 
+
	    COMPREPLY=(
+
		'(-x -X)-g[Process packages that matches glob]'
+
		'(-g -X)-x[Process packages that matches regex]'
+
		'(-g -x)-X[Process packages that matches extended regex]'
+
	    )
+
	    return 0 ;;
+

+
        set) 
+
	    COMPREPLY=(
+
		'(-o)-A[Mark as automatic or not]'
+
		'(-A)-o[Change the origin]'
+
		'-y[Assume yes when asked for confirmation]'
+
		'(-g -x -X)-a[Process all packages]'
+
		'(-x -X -a)-g[Process packages that matches glob]'
+
		'(-g -X -a)-x[Process packages that matches regex]'
+
		'(-g -x -a)-X[Process packages that matches extended regex]'
+
	    )
+
	    return 0 ;;
+

+
        shell) 
+
	    COMPREPLY=() && \
+
		return 0 ;;
+

+
        shlib) 
+
	    COMPREPLY=() && \
+
		return 0 ;;
+

+
        stats) 
+
	    COMPREPLY=(
+
		'-q[Be quiet]'
+
		'(-l)-r[Display stats only for the local package database]'
+
		'(-r)-l[Display stats only for the remote package database(s)]' 
+
	    )
+
	    return 0 ;;
+

+
        update) 
+
	    COMPREPLY=(
+
		'-f[Force updating]'
+
		'-q[Be quiet]'
+
	    )
+
	    return 0 ;;
+

+
        updating) 
+
	    COMPREPLY=(
+
		'-d[Only entries newer than date are shown]'
+
		'-f[Defines a alternative location of the UPDATING file]'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        upgrade) 
+
	    COMPREPLY=(
+
		'(-y)-n[Assume no (dry run) for confirmations]' 
+
		'(-n)-y[Assume yes when asked for confirmation]' 
+
		'-f[Upgrade/Reinstall everything]' 
+
		'-L[Do not try to update the repository metadata]'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        version) 
+
	    COMPREPLY=(
+
		'(-P -R)-I[Use INDEX file]'
+
		'(-R -I)-P[Force checking against the ports tree]'
+
		'(-I -P)-R[Use remote repository]'
+
		'-o[Display package origin, instead of package name]'
+
		'-q[Be quiet]'
+
		'-v[Be verbose]'
+
		'(-L)-l[Display only the packages for given status flag]'
+
		'(-l)-L[Display only the packages without given status flag]'
+
	    )
+
	    return 0 
+
	    ;;
+

+
        which) 
+
	    COMPREPLY=( $(compgen -W "$(compgen -A file)") ) && \
+
		return 0 
+
	    ;;
+
    esac
+

+
    # if doesn't exist, return opts
+
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+
}
+

+
complete -F _pkg pkg
added scripts/completion/_pkg.zsh.in
@@ -0,0 +1,308 @@
+
#compdef pkg
+

+
_pkg_installed() {
+
	compadd "$@" - $(__PREFIX__/sbin/pkg query "%n-%v")
+
}
+

+
_pkg_available_name() {
+
	compadd "$@" - $(__PREFIX__/sbin/pkg rquery "%n")
+
}
+

+
_pkg_available() {
+
	compadd "$@" - $(__PREFIX__/pkg rquery "%n-%v")
+
}
+

+
_pkg() {
+
	local earlyargs subcmd
+
	local subcmd_list cmd
+
	earlyargs=(
+
	'-d[Increment debug level]'
+
	'-j[Execute pkg(1) inside a jail(8)]:jail:'
+
	'-c[Execute pkg(1) inside a chroot(8)]:chroot:_files -/'
+
	'-C[Use the specified configuration file]'
+
	'-l[List available command and exit'
+
	'-v[Display pkg(1) version]'
+
	'-N[Test if pkg(1) is activated and avoid auto-activation]'
+
	)
+

+
	subcmd=(
+
		'add[Registers a package and installs it on the system]'
+
		'audit[Reports vulnerable packages]'
+
		'autoremove[Removes orphan packages]'
+
		'backup[Backs-up and restores the local package database]'
+
		'check[Checks for missing dependencies and database consistency]'
+
		'clean[Cleans old packages from the cache]'
+
		'convert[Convert database from/to pkgng]'
+
		'create[Creates software package distributions]'
+
		'delete[Deletes packages from the database and the system]'
+
		'fetch[Fetches packages from a remote repository]'
+
		'help[Displays help information]'
+
		'info[Displays information about installed packages]'
+
		'install[Installs packages from remote package repositories]'
+
		'query[Queries information about installed packages]'
+
		'register[Registers a package into the local database]'
+
		'remove[Deletes packages from the database and the system]'
+
		'repo[Creates a package repository catalogue]'
+
		'rquery[Queries information in repository catalogues]'
+
		'search[Performs a search of package repository catalogues]'
+
		'set[Modifies information about packages in the local database]'
+
		'shell[Opens a debug shell]'
+
		'shlib[Displays which packages link against a specific shared library]'
+
		'stats[Displays package database statistics]'
+
		'update[Updates package repository catalogues]'
+
		'updating[Displays UPDATING information for a package]'
+
		'upgrade[Performs upgrades of packaged software distributions]'
+
		'version[Displays the versions of installed packages]'
+
		'which[Displays which package installed a specific file]'
+
	)
+

+
	if [[ $service = "pkg" ]]; then
+

+
		_arguments -C -A "-*" \
+
			$earlyargs \
+
			'*::command:->subcmd' && return 0
+

+
		if (( CURRENT == 1 )); then
+
			_values 'pkg subcommands' \
+
				$subcmd && return 0
+
			return 0
+
		fi
+
		service="$words[1]"
+
		curcontext="${curcontext%:*}=$service:"
+
	fi
+

+
	case $service in
+
		(add) _arguments -A 'package' \
+
			'*:package:_files -g "*.t?z"' && return 0
+
			;;
+
		(audit)
+
			_arguments -s \
+
				'-F[Fetch the database before checking.]' \
+
				'-q[Quiet]' \
+
				'*:package:_pkg_installed' \
+
				&& return 0
+
			;;
+
		(autoremove)
+
			_arguments -s \
+
				'(-y)-n[Assume yes when asked for confirmation]' \
+
				'(-n)-y[Assume no (dry run) for confirmations]' \
+
				&& return 0
+
			;;
+
		(backup)
+
			_arguments -s \
+
				'(-r)-d[Dumps the local package database]:destination:_files' \
+
				'(-d)-r[Restrore the local package database]:destination:_files' \
+
				&& return 0
+
			;;
+
		(check)
+
			_arguments -s \
+
				'-B[reanalyse SHLIBS of installed packages]' \
+
				'-d[check for and install missing dependencies]' \
+
				'-r[recompute sizes and checksums of installed]' \
+
				'-s[find invalid checksums]' \
+
				'-v[Be verbose]' \
+
				'(-g -x -X)-a[Process all packages]' \
+
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				&& return 0
+
			;;
+
		(clean)
+
			return 0
+
			;;
+
		(convert)
+
			_arguments -s \
+
				'-r[Revert conversion]' \
+
				&& return 0
+
			;;
+
		(create)
+
			_arguments -s \
+
				'-r[Root directory]:rootdir:_files -/' \
+
				'-m[Manifest directory]:manifestdir:_files -/' \
+
				'-f[format]:format:((tar tgz tbz txz))' \
+
				'-o[Ouput directory]:outdir:_files -/' \
+
				'(-g -x -X)-a[Process all packages]' \
+
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Package:_pkg_installed' \
+
				&& return 0
+
			;;
+
		(delete|remove)
+
			_arguments -s \
+
				'(-y)-n[Assume yes when asked for confirmation]' \
+
				'(-n)-y[Assume no (dry run) for confirmations]' \
+
				'-f[Forces packages to be removed]' \
+
				'(-g -x -X)-a[Process all packages]' \
+
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Package:_pkg_installed' \
+
				&& return 0
+
			;;
+
		(fetch)
+
			_arguments -s \
+
				'-y[Assume yes when asked for confirmation]' \
+
				'-L[Do not try to update the repository metadata]' \
+
				'-q[Be quiet]' \
+
				'(-g -x -X)-a[Process all packages]' \
+
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Available packages:_pkg_available' \
+
				&& return 0
+
			;;
+
		(help)
+
			_arguments -s \
+
				':command:_values -S " " -w "pkg subcommands" ${subcmd/\[*/}'
+
			return 0
+
			;;
+
		(info)
+
			_arguments -s \
+
				'(-e -d -r -l -o -p -D)-f[Displays full information]' \
+
				'(-f -d -r -l -o -p -D)-e[Returns 0 if <pkg-name> is installed]' \
+
				'(-e -f -r -l -o -p -D)-d[Displays the dependencies]' \
+
				'(-e -d -f -l -o -p -D)-r[Displays the reverse dependencies]' \
+
				'(-e -d -r -f -o -p -D)-l[Displays all files]' \
+
				'(-e -d -r -l -f -p -D)-o[Displays origin]' \
+
				'(-e -d -r -l -o -f -D)-p[Displays prefix]' \
+
				'(-e -d -r -l -o -p -f)-D[Displays message]' \
+
				'-q[Be quiet]' \
+
				'(-g -x -X -F)-a[Process all packages]' \
+
				'(-x -X -a -F)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a -F)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a -F)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'(-g -x -X -a)-F[Process the specified package]:package:_files -g "*.t?z"' \
+
				'*:Package:_pkg_installed' \
+
				&& return 0
+
			;;
+
		(install)
+
			_arguments -s \
+
				'(-y)-n[Assume yes when asked for confirmation]' \
+
				'(-n)-y[Assume no (dry run) for confirmations]' \
+
				'-f[Force reinstallation if needed]' \
+
				'-R[Reinstall every package depending on matching expressions]' \
+
				'-L[Do not try to update the repository metadata]' \
+
				'(-x -X)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Available packages:_pkg_available' \
+
				&& return 0
+
			;;
+
		(query)
+
			_arguments -s \
+
				'(-g -x -X -F -e)-a[Process all packages]' \
+
				'(-x -X -a -F -e)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a -F -e)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a -F -e)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'(-g -x -X -a -F)-e[Process packages that matches the evaluation]:evaluation:' \
+
				'(-g -x -X -a -e)-F[Process the specified package]:package:_files -g "*.t?z"' \
+
				':Ouput format:' \
+
				&& return 0
+
			;;
+
		(register)
+
			_arguments -s \
+
				'-l[registered as a legacy format]' \
+
				'-d[mark the package as an automatic dependency]' \
+
				'-f[packing list file]:packing list file:_files' \
+
				'-m[metadata directory]:metadatadir:_files -/' \
+
				'-a[ABI]:abi:' \
+
				'-i[input path (aka root directory)]:input path:_files -/' \
+
				&& return 0
+
			;;
+
		(repo)
+
			_arguments -s \
+
				':Repository path:_files -/' \
+
				':RSA key:_files' \
+
				&& return 0
+
			;;
+
		(rquery)
+
			_arguments -s \
+
				'(-g -x -X -e)-a[Process all packages]' \
+
				'(-x -X -a -e)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a -e)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a -e)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'(-g -x -X -a)-e[Process packages that matches the evaluation]:evaluation:' \
+
				':Ouput format:' \
+
				&& return 0
+
			;;
+
		(search)
+
			_arguments -s \
+
				'(-x -X)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Available packages:_pkg_available_name' \
+
				&& return 0
+
			;;
+
		(set)
+
			_arguments -s \
+
				'(-o)-A[Mark as automatic or not]:flag:((1\:automatic 0\:not\ automatic))' \
+
				'(-A)-o[Change the origin]:oldorigin\:neworigin:' \
+
				'-y[Assume yes when asked for confirmation]' \
+
				'(-g -x -X)-a[Process all packages]' \
+
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
+
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
+
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
+
				'*:Package:_pkg_installed'
+
			return 0
+
			;;
+
		(shell)
+
			_arguments -s \
+
				':database:_files' \
+
				&& return 0
+
			;;
+
		(shlib)
+
			_arguments -s \
+
				':Library:' \
+
				&& return 0
+
			;;
+
		(stats)
+
			_arguments -s \
+
				'-q[Be quiet]' \
+
				'(-l)-r[Display stats only for the local package database]' \
+
				'(-r)-l[Display stats only for the remote package database(s)]' \
+
				&& return 0
+
			;;
+
		(update)
+
			_arguments -s \
+
				'-f[Force updating]' \
+
				'-q[Be quiet]' \
+
				&& return 0
+
			;;
+
		(updating)
+
			_arguments -s \
+
				'-d[Only entries newer than date are shown]:date:' \
+
				'-f[Defines a alternative location of the UPDATING file]:UPDATING file:_files' \
+
				'*:Package:_pkg_installed' \
+
				&& return 0
+
			;;
+
		(upgrade)
+
			_arguments -s \
+
				'(-y)-n[Assume no (dry run) for confirmations]' \
+
				'(-n)-y[Assume yes when asked for confirmation]' \
+
				'-f[Upgrade/Reinstall everything]' \
+
				'-L[Do not try to update the repository metadata]' \
+
				&& return 1
+
			;;
+
		(version)
+
			#TODO: complete
+
			_arguments -s \
+
				'(-P -R)-I[Use INDEX file]' \
+
				'(-R -I)-P[Force checking against the ports tree]' \
+
				'(-I -P)-R[Use remote repository]' \
+
				'-o[Display package origin, instead of package name]' \
+
				'-q[Be quiet]' \
+
				'-v[Be verbose]' \
+
				'(-L)-l[Display only the packages for given status flag]:flag:((\< = \>))' \
+
				'(-l)-L[Display only the packages without given status flag]:flag:((\< = \>))' \
+
				&& return 0
+
			;;
+
		(which)
+
			_arguments -s \
+
				':file:_files' \
+
			&& return 0
+
			;;
+
	esac
+
}
+

+
_pkg "$@"
deleted scripts/periodic/400.status-pkg
@@ -1,35 +0,0 @@
-
#!/bin/sh -
-
#
-
# $FreeBSD$
-
#
-

-
if [ -r /etc/defaults/periodic.conf ]; then
-
    . /etc/defaults/periodic.conf
-
    source_periodic_confs
-
fi
-
pkgcmd=/usr/sbin/pkg
-

-
case "$weekly_status_pkg_enable" in
-
	[Yy][Ee][Ss])
-

-
	echo
-
	echo 'Checking for out of date packages:'
-

-
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
-
	    echo 'status-pkg is enabled but pkg is not used'
-
	    rc=2
-
	else
-
		rc=$(${pkgcmd} version -v ${pkg_version_index} |
-
			sed -n -e '/up-to-date/d' \
-
			-e 's/^\([^[:space:]]*\)[[:space:]]*[<>=!?][[:space:]]*\(.*\)$/\1 \2/p' |
-
			tee /dev/stderr |
-
			wc -l)
-
		[ $rc -gt 1 ] && rc=1
-
	fi
-
	;;
-
	*)
-
	rc=0
-
	;;
-
esac
-

-
exit $rc
added scripts/periodic/400.status-pkg.in
@@ -0,0 +1,35 @@
+
#!/bin/sh -
+
#
+
# $FreeBSD$
+
#
+

+
if [ -r /etc/defaults/periodic.conf ]; then
+
    . /etc/defaults/periodic.conf
+
    source_periodic_confs
+
fi
+
pkgcmd=__PREFIX__/sbin/pkg
+

+
case "$weekly_status_pkg_enable" in
+
	[Yy][Ee][Ss])
+

+
	echo
+
	echo 'Checking for out of date packages:'
+

+
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
+
	    echo 'status-pkg is enabled but pkg is not used'
+
	    rc=2
+
	else
+
		rc=$(${pkgcmd} version -v ${pkg_version_index} |
+
			sed -n -e '/up-to-date/d' \
+
			-e 's/^\([^[:space:]]*\)[[:space:]]*[<>=!?][[:space:]]*\(.*\)$/\1 \2/p' |
+
			tee /dev/stderr |
+
			wc -l)
+
		[ $rc -gt 1 ] && rc=1
+
	fi
+
	;;
+
	*)
+
	rc=0
+
	;;
+
esac
+

+
exit $rc
deleted scripts/periodic/410.pkg-audit
@@ -1,74 +0,0 @@
-
#!/bin/sh -f
-
#
-
# Copyright (c) 2004 Oliver Eikemeier. 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.
-
#
-
# 3. Neither the name of the author nor the names of its contributors may be
-
#    used to endorse or promote products derived from this software without
-
#    specific prior written permission.
-
#
-
# THIS SOFTWARE IS PROVIDED "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
-
# COPYRIGHT OWNER 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.
-
#
-
# $FreeBSD$
-
#
-

-
if [ -r /etc/defaults/periodic.conf ]; then
-
    . /etc/defaults/periodic.conf
-
    source_periodic_confs
-
fi
-

-
# Compute PKG_DBDIR from the config file.
-
pkgcmd=/usr/sbin/pkg
-
PKG_DBDIR=`${pkgcmd} -vv | awk -F: '$1 ~ /PKG_DBDIR$/ { print $2 }'`
-
auditfile="${PKG_DBDIR}/auditfile"
-

-
rc=0
-

-
case "${daily_status_security_pkgaudit_enable:-YES}" in
-
	[Nn][Oo])
-
	;;
-
	*)
-

-
	echo
-
	echo 'Checking for packages with security vulnerabilities:'
-

-
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
-
		echo 'pkg-audit is enabled but pkg is not used'
-
		rc=2
-
	else
-
		then=`stat -f '%m' "${auditfile}" 2> /dev/null` || rc=3
-
		now=`date +%s` || rc=3
-
		# Add 10 minutes of padding since the check is in seconds.
-
		if [ $rc -ne 0 -o \
-
			$(( 86400 \* "${daily_status_security_pkgaudit_expiry:-2}" )) \
-
			-le $(( ${now} - ${then} + 600 )) ]; then
-
			${pkgcmd} audit -Fq || { rc=$?; [ $rc -lt 3 ] && rc=3; }
-
		else
-
			echo -n 'Database fetched: '
-
			date -r "${then}" || rc=3
-
			${pkgcmd} audit || { rc=$?; [ $rc -lt 3 ] && rc=3; }
-
		fi
-
	fi
-
	;;
-
esac
-

-
exit "$rc"
added scripts/periodic/410.pkg-audit.in
@@ -0,0 +1,74 @@
+
#!/bin/sh -f
+
#
+
# Copyright (c) 2004 Oliver Eikemeier. 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.
+
#
+
# 3. Neither the name of the author nor the names of its contributors may be
+
#    used to endorse or promote products derived from this software without
+
#    specific prior written permission.
+
#
+
# THIS SOFTWARE IS PROVIDED "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
+
# COPYRIGHT OWNER 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.
+
#
+
# $FreeBSD$
+
#
+

+
if [ -r /etc/defaults/periodic.conf ]; then
+
    . /etc/defaults/periodic.conf
+
    source_periodic_confs
+
fi
+

+
# Compute PKG_DBDIR from the config file.
+
pkgcmd=__PREFIX__/sbin/pkg
+
PKG_DBDIR=`${pkgcmd} -vv | awk -F: '$1 ~ /PKG_DBDIR$/ { print $2 }'`
+
auditfile="${PKG_DBDIR}/auditfile"
+

+
rc=0
+

+
case "${daily_status_security_pkgaudit_enable:-YES}" in
+
	[Nn][Oo])
+
	;;
+
	*)
+

+
	echo
+
	echo 'Checking for packages with security vulnerabilities:'
+

+
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
+
		echo 'pkg-audit is enabled but pkg is not used'
+
		rc=2
+
	else
+
		then=`stat -f '%m' "${auditfile}" 2> /dev/null` || rc=3
+
		now=`date +%s` || rc=3
+
		# Add 10 minutes of padding since the check is in seconds.
+
		if [ $rc -ne 0 -o \
+
			$(( 86400 \* "${daily_status_security_pkgaudit_expiry:-2}" )) \
+
			-le $(( ${now} - ${then} + 600 )) ]; then
+
			${pkgcmd} audit -Fq || { rc=$?; [ $rc -lt 3 ] && rc=3; }
+
		else
+
			echo -n 'Database fetched: '
+
			date -r "${then}" || rc=3
+
			${pkgcmd} audit || { rc=$?; [ $rc -lt 3 ] && rc=3; }
+
		fi
+
	fi
+
	;;
+
esac
+

+
exit "$rc"
deleted scripts/periodic/411.pkg-backup
@@ -1,48 +0,0 @@
-
#!/bin/sh -
-
#
-
# $FreeBSD$
-
#
-

-
if [ -r /etc/defaults/periodic.conf ]; then
-
	. /etc/defaults/periodic.conf
-
	source_periodic_confs
-
fi
-

-
rc=0
-

-
case "${daily_backup_pkgng_enable:-YES}" in
-
	[Nn][Oo])
-
	;;
-
	*)
-
	bak="${daily_backup_pkgng_dir:-/var/backups}"
-
	bak_file="${bak}/pkgng.db"
-
	pkgcmd=/usr/sbin/pkg
-

-
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
-
		echo 'pkg-backup is enabled but pkg is not used'
-
		rc=2
-
 	else
-
		if [ ! -d "$bak" ]
-
		then
-
			install -d -o root -g wheel -m 750 $bak || {
-
			echo 'pkg-backup is enabled but' \
-
				"$daily_backup_pkgng_dbdir doesn't exist" ;
-
			exit 2 ; }
-
		fi
-

-
		echo
-
		echo 'Backing up pkgng database:'
-

-
		[ -e "${bak_file}.txz" ] && \
-
			mv -f "${bak_file}.txz" "${bak_file}.txz.2"
-

-
		if ${pkgcmd} backup -d ${bak_file} 2>/dev/null; then
-
			rc=0
-
		else
-
			rc=3
-
		fi
-
	fi
-
	;;
-
esac
-

-
exit $rc
added scripts/periodic/411.pkg-backup.in
@@ -0,0 +1,48 @@
+
#!/bin/sh -
+
#
+
# $FreeBSD$
+
#
+

+
if [ -r /etc/defaults/periodic.conf ]; then
+
	. /etc/defaults/periodic.conf
+
	source_periodic_confs
+
fi
+

+
rc=0
+

+
case "${daily_backup_pkgng_enable:-YES}" in
+
	[Nn][Oo])
+
	;;
+
	*)
+
	bak="${daily_backup_pkgng_dir:-/var/backups}"
+
	bak_file="${bak}/pkgng.db"
+
	pkgcmd=__PREFIX__/sbin/pkg
+

+
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
+
		echo 'pkg-backup is enabled but pkg is not used'
+
		rc=2
+
 	else
+
		if [ ! -d "$bak" ]
+
		then
+
			install -d -o root -g wheel -m 750 $bak || {
+
			echo 'pkg-backup is enabled but' \
+
				"$daily_backup_pkgng_dbdir doesn't exist" ;
+
			exit 2 ; }
+
		fi
+

+
		echo
+
		echo 'Backing up pkgng database:'
+

+
		[ -e "${bak_file}.txz" ] && \
+
			mv -f "${bak_file}.txz" "${bak_file}.txz.2"
+

+
		if ${pkgcmd} backup -d ${bak_file} 2>/dev/null; then
+
			rc=0
+
		else
+
			rc=3
+
		fi
+
	fi
+
	;;
+
esac
+

+
exit $rc
deleted scripts/periodic/460.pkg-checksum
@@ -1,36 +0,0 @@
-
#!/bin/sh -
-
#
-
# $FreeBSD$
-
#
-

-
if [ -r /etc/defaults/periodic.conf ]; then
-
	. /etc/defaults/periodic.conf
-
	source_periodic_confs
-
fi
-

-
. /etc/periodic/security/security.functions
-

-
case "${daily_status_security_pkg_checksum_enable}" in
-
	[Yy][Ee][Ss])
-
	pkgcmd=/usr/sbin/pkg
-

-
	echo
-
	echo 'Checking for packages with mismatched checksums:'
-

-
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
-
		echo 'pkg-checksum is enabled but pkg is not used'
-
		rc=2
-
	else
-
		rc=$(${pkgcmd} check -sa 2>&1 |
-
		sed -e 's/ checksum mismatch for//' |
-
		tee /dev/stderr |
-
		wc -l)
-
		[ $rc -gt 1 ] && rc=1
-
	fi
-
	;;
-
	*)
-
	rc=0
-
	;;
-
esac
-

-
exit $rc
added scripts/periodic/460.pkg-checksum.in
@@ -0,0 +1,36 @@
+
#!/bin/sh -
+
#
+
# $FreeBSD$
+
#
+

+
if [ -r /etc/defaults/periodic.conf ]; then
+
	. /etc/defaults/periodic.conf
+
	source_periodic_confs
+
fi
+

+
. /etc/periodic/security/security.functions
+

+
case "${daily_status_security_pkg_checksum_enable}" in
+
	[Yy][Ee][Ss])
+
	pkgcmd=__PREFIX__/sbin/pkg
+

+
	echo
+
	echo 'Checking for packages with mismatched checksums:'
+

+
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
+
		echo 'pkg-checksum is enabled but pkg is not used'
+
		rc=2
+
	else
+
		rc=$(${pkgcmd} check -sa 2>&1 |
+
		sed -e 's/ checksum mismatch for//' |
+
		tee /dev/stderr |
+
		wc -l)
+
		[ $rc -gt 1 ] && rc=1
+
	fi
+
	;;
+
	*)
+
	rc=0
+
	;;
+
esac
+

+
exit $rc
deleted scripts/periodic/490.status-pkg-changes
@@ -1,40 +0,0 @@
-
#!/bin/sh -
-
#
-
# $FreeBSD$
-
#
-

-
if [ -r /etc/defaults/periodic.conf ]; then
-
	. /etc/defaults/periodic.conf
-
	source_periodic_confs
-
fi
-

-
case "$daily_status_pkg_changes_enable" in
-
	[Yy][Ee][Ss])
-
	pkgcmd=/usr/sbin/pkg
-

-
	echo
-
	echo 'Changes in installed packages:'
-

-
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
-
		echo 'status-pkg-changes is enabled but pkg is not used'
-
		rc=2
-
	else
-
		bak=/var/backups
-
		rc=0
-

-
		[ -r $bak/pkg.bak ] && mv -f $bak/pkg.bak $bak/pkg.bak2
-
		${pkgcmd} info > $bak/pkg.bak
-

-
		cmp -sz $bak/pkg.bak $bak/pkg.bak2
-
		if [ $? -eq 1 ]; then
-
			diff -U 0 $bak/pkg.bak2 $bak/pkg.bak | \
-
			grep '^[-+][^-+]' | sort -k 1.2
-
		fi
-
	fi
-
	;;
-
	*)
-
	rc=0
-
	;;
-
esac
-

-
exit $rc
added scripts/periodic/490.status-pkg-changes.in
@@ -0,0 +1,40 @@
+
#!/bin/sh -
+
#
+
# $FreeBSD$
+
#
+

+
if [ -r /etc/defaults/periodic.conf ]; then
+
	. /etc/defaults/periodic.conf
+
	source_periodic_confs
+
fi
+

+
case "$daily_status_pkg_changes_enable" in
+
	[Yy][Ee][Ss])
+
	pkgcmd=__PREFIX__/sbin/pkg
+

+
	echo
+
	echo 'Changes in installed packages:'
+

+
	if ! ${pkgcmd} -N >/dev/null 2>&1 ; then
+
		echo 'status-pkg-changes is enabled but pkg is not used'
+
		rc=2
+
	else
+
		bak=/var/backups
+
		rc=0
+

+
		[ -r $bak/pkg.bak ] && mv -f $bak/pkg.bak $bak/pkg.bak2
+
		${pkgcmd} info > $bak/pkg.bak
+

+
		cmp -sz $bak/pkg.bak $bak/pkg.bak2
+
		if [ $? -eq 1 ]; then
+
			diff -U 0 $bak/pkg.bak2 $bak/pkg.bak | \
+
			grep '^[-+][^-+]' | sort -k 1.2
+
		fi
+
	fi
+
	;;
+
	*)
+
	rc=0
+
	;;
+
esac
+

+
exit $rc
added scripts/periodic/Makefile
@@ -0,0 +1,31 @@
+
.SUFFIXES:	.in
+

+
PREFIX?=	/usr/local
+

+
SCRIPTS_DAILY=	400.status-pkg.in \
+
		411.pkg-backup.in \
+
		490.status-pkg-changes.in
+
SCRIPTS_SECURITY=	410.pkg-audit.in \
+
			460.pkg-checksum.in
+
SCRIPTS=	${SCRIPTS_DAILY:R} ${SCRIPTS_SECURITY:R}
+

+
.in:
+
	sed -e 's,__PREFIX__,${PREFIX},g' \
+
		${.IMPSRC} > ${.TARGET}
+

+
all: ${SCRIPTS}
+

+
clean:
+
	rm -f ${.OBJDIR}/${SCRIPTS}
+

+
install: all
+
	install -d ${DESTDIR}${PREFIX}/etc/periodic/security
+
	install -d ${DESTDIR}${PREFIX}/etc/periodic/daily
+
.for periodic in ${SCRIPTS_DAILY:R}
+
	install -m 555 ${.OBJDIR}/${periodic} ${DESTDIR}${PREFIX}/etc/periodic/daily
+
.endfor
+
.for periodic in ${SCRIPTS_SECURITY:R}
+
	install -m 555 ${.OBJDIR}/${periodic} ${DESTDIR}${PREFIX}/etc/periodic/security
+
.endfor
+

+
.include <bsd.own.mk>
added scripts/sbin/pkg2ng.in
@@ -0,0 +1,14 @@
+
#!/bin/sh
+

+
: "${PORTSDIR:=/usr/ports}"
+

+
if [ -f ${PORTSDIR}/Mk/bsd.pkgng.mk ]; then
+
	FORCE_POST=$(make _POSTMKINCLUDED=1 -f ${PORTSDIR}/Mk/bsd.pkgng.mk -V _FORCE_POST_PATTERNS)
+
else
+
	FORCE_POST="rmdir kldxref mkfontscale mkfontdir fc-cache fonts.dir fonts.scale gtk-update-icon-cache gio-querymodules ldconfig update-desktop-database update-mime-database gdk-pixbuf-query-loaders catalog.ports glib-compile-schemas"
+
fi
+

+
FORCE_PORT=$FORCE_POST __PREFIX__/sbin/pkg convert
+

+
# Delete the portupgrade pkgdb to avoid discrepencies. It will be auto recreated.
+
rm -f /var/db/pkg/pkgdb.db > /dev/null 2>&1
deleted scripts/zsh/_pkg
@@ -1,308 +0,0 @@
-
#compdef pkg
-

-
_pkg_installed() {
-
	compadd "$@" - $(pkg query "%n-%v")
-
}
-

-
_pkg_available_name() {
-
	compadd "$@" - $(pkg rquery "%n")
-
}
-

-
_pkg_available() {
-
	compadd "$@" - $(pkg rquery "%n-%v")
-
}
-

-
_pkg() {
-
	local earlyargs subcmd
-
	local subcmd_list cmd
-
	earlyargs=(
-
	'-d[Increment debug level]'
-
	'-j[Execute pkg(1) inside a jail(8)]:jail:'
-
	'-c[Execute pkg(1) inside a chroot(8)]:chroot:_files -/'
-
	'-C[Use the specified configuration file]'
-
	'-l[List available command and exit'
-
	'-v[Display pkg(1) version]'
-
	'-N[Test if pkg(1) is activated and avoid auto-activation]'
-
	)
-

-
	subcmd=(
-
		'add[Registers a package and installs it on the system]'
-
		'audit[Reports vulnerable packages]'
-
		'autoremove[Removes orphan packages]'
-
		'backup[Backs-up and restores the local package database]'
-
		'check[Checks for missing dependencies and database consistency]'
-
		'clean[Cleans old packages from the cache]'
-
		'convert[Convert database from/to pkgng]'
-
		'create[Creates software package distributions]'
-
		'delete[Deletes packages from the database and the system]'
-
		'fetch[Fetches packages from a remote repository]'
-
		'help[Displays help information]'
-
		'info[Displays information about installed packages]'
-
		'install[Installs packages from remote package repositories]'
-
		'query[Queries information about installed packages]'
-
		'register[Registers a package into the local database]'
-
		'remove[Deletes packages from the database and the system]'
-
		'repo[Creates a package repository catalogue]'
-
		'rquery[Queries information in repository catalogues]'
-
		'search[Performs a search of package repository catalogues]'
-
		'set[Modifies information about packages in the local database]'
-
		'shell[Opens a debug shell]'
-
		'shlib[Displays which packages link against a specific shared library]'
-
		'stats[Displays package database statistics]'
-
		'update[Updates package repository catalogues]'
-
		'updating[Displays UPDATING information for a package]'
-
		'upgrade[Performs upgrades of packaged software distributions]'
-
		'version[Displays the versions of installed packages]'
-
		'which[Displays which package installed a specific file]'
-
	)
-

-
	if [[ $service = "pkg" ]]; then
-

-
		_arguments -C -A "-*" \
-
			$earlyargs \
-
			'*::command:->subcmd' && return 0
-

-
		if (( CURRENT == 1 )); then
-
			_values 'pkg subcommands' \
-
				$subcmd && return 0
-
			return 0
-
		fi
-
		service="$words[1]"
-
		curcontext="${curcontext%:*}=$service:"
-
	fi
-

-
	case $service in
-
		(add) _arguments -A 'package' \
-
			'*:package:_files -g "*.t?z"' && return 0
-
			;;
-
		(audit)
-
			_arguments -s \
-
				'-F[Fetch the database before checking.]' \
-
				'-q[Quiet]' \
-
				'*:package:_pkg_installed' \
-
				&& return 0
-
			;;
-
		(autoremove)
-
			_arguments -s \
-
				'(-y)-n[Assume yes when asked for confirmation]' \
-
				'(-n)-y[Assume no (dry run) for confirmations]' \
-
				&& return 0
-
			;;
-
		(backup)
-
			_arguments -s \
-
				'(-r)-d[Dumps the local package database]:destination:_files' \
-
				'(-d)-r[Restrore the local package database]:destination:_files' \
-
				&& return 0
-
			;;
-
		(check)
-
			_arguments -s \
-
				'-B[reanalyse SHLIBS of installed packages]' \
-
				'-d[check for and install missing dependencies]' \
-
				'-r[recompute sizes and checksums of installed]' \
-
				'-s[find invalid checksums]' \
-
				'-v[Be verbose]' \
-
				'(-g -x -X)-a[Process all packages]' \
-
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				&& return 0
-
			;;
-
		(clean)
-
			return 0
-
			;;
-
		(convert)
-
			_arguments -s \
-
				'-r[Revert conversion]' \
-
				&& return 0
-
			;;
-
		(create)
-
			_arguments -s \
-
				'-r[Root directory]:rootdir:_files -/' \
-
				'-m[Manifest directory]:manifestdir:_files -/' \
-
				'-f[format]:format:((tar tgz tbz txz))' \
-
				'-o[Ouput directory]:outdir:_files -/' \
-
				'(-g -x -X)-a[Process all packages]' \
-
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Package:_pkg_installed' \
-
				&& return 0
-
			;;
-
		(delete|remove)
-
			_arguments -s \
-
				'(-y)-n[Assume yes when asked for confirmation]' \
-
				'(-n)-y[Assume no (dry run) for confirmations]' \
-
				'-f[Forces packages to be removed]' \
-
				'(-g -x -X)-a[Process all packages]' \
-
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Package:_pkg_installed' \
-
				&& return 0
-
			;;
-
		(fetch)
-
			_arguments -s \
-
				'-y[Assume yes when asked for confirmation]' \
-
				'-L[Do not try to update the repository metadata]' \
-
				'-q[Be quiet]' \
-
				'(-g -x -X)-a[Process all packages]' \
-
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Available packages:_pkg_available' \
-
				&& return 0
-
			;;
-
		(help)
-
			_arguments -s \
-
				':command:_values -S " " -w "pkg subcommands" ${subcmd/\[*/}'
-
			return 0
-
			;;
-
		(info)
-
			_arguments -s \
-
				'(-e -d -r -l -o -p -D)-f[Displays full information]' \
-
				'(-f -d -r -l -o -p -D)-e[Returns 0 if <pkg-name> is installed]' \
-
				'(-e -f -r -l -o -p -D)-d[Displays the dependencies]' \
-
				'(-e -d -f -l -o -p -D)-r[Displays the reverse dependencies]' \
-
				'(-e -d -r -f -o -p -D)-l[Displays all files]' \
-
				'(-e -d -r -l -f -p -D)-o[Displays origin]' \
-
				'(-e -d -r -l -o -f -D)-p[Displays prefix]' \
-
				'(-e -d -r -l -o -p -f)-D[Displays message]' \
-
				'-q[Be quiet]' \
-
				'(-g -x -X -F)-a[Process all packages]' \
-
				'(-x -X -a -F)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a -F)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a -F)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'(-g -x -X -a)-F[Process the specified package]:package:_files -g "*.t?z"' \
-
				'*:Package:_pkg_installed' \
-
				&& return 0
-
			;;
-
		(install)
-
			_arguments -s \
-
				'(-y)-n[Assume yes when asked for confirmation]' \
-
				'(-n)-y[Assume no (dry run) for confirmations]' \
-
				'-f[Force reinstallation if needed]' \
-
				'-R[Reinstall every package depending on matching expressions]' \
-
				'-L[Do not try to update the repository metadata]' \
-
				'(-x -X)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Available packages:_pkg_available' \
-
				&& return 0
-
			;;
-
		(query)
-
			_arguments -s \
-
				'(-g -x -X -F -e)-a[Process all packages]' \
-
				'(-x -X -a -F -e)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a -F -e)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a -F -e)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'(-g -x -X -a -F)-e[Process packages that matches the evaluation]:evaluation:' \
-
				'(-g -x -X -a -e)-F[Process the specified package]:package:_files -g "*.t?z"' \
-
				':Ouput format:' \
-
				&& return 0
-
			;;
-
		(register)
-
			_arguments -s \
-
				'-l[registered as a legacy format]' \
-
				'-d[mark the package as an automatic dependency]' \
-
				'-f[packing list file]:packing list file:_files' \
-
				'-m[metadata directory]:metadatadir:_files -/' \
-
				'-a[ABI]:abi:' \
-
				'-i[input path (aka root directory)]:input path:_files -/' \
-
				&& return 0
-
			;;
-
		(repo)
-
			_arguments -s \
-
				':Repository path:_files -/' \
-
				':RSA key:_files' \
-
				&& return 0
-
			;;
-
		(rquery)
-
			_arguments -s \
-
				'(-g -x -X -e)-a[Process all packages]' \
-
				'(-x -X -a -e)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a -e)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a -e)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'(-g -x -X -a)-e[Process packages that matches the evaluation]:evaluation:' \
-
				':Ouput format:' \
-
				&& return 0
-
			;;
-
		(search)
-
			_arguments -s \
-
				'(-x -X)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Available packages:_pkg_available_name' \
-
				&& return 0
-
			;;
-
		(set)
-
			_arguments -s \
-
				'(-o)-A[Mark as automatic or not]:flag:((1\:automatic 0\:not\ automatic))' \
-
				'(-A)-o[Change the origin]:oldorigin\:neworigin:' \
-
				'-y[Assume yes when asked for confirmation]' \
-
				'(-g -x -X)-a[Process all packages]' \
-
				'(-x -X -a)-g[Process packages that matches glob]:glob pattern:' \
-
				'(-g -X -a)-x[Process packages that matches regex]:regex pattern:' \
-
				'(-g -x -a)-X[Process packages that matches extended regex]:extended regex pattern:' \
-
				'*:Package:_pkg_installed'
-
			return 0
-
			;;
-
		(shell)
-
			_arguments -s \
-
				':database:_files' \
-
				&& return 0
-
			;;
-
		(shlib)
-
			_arguments -s \
-
				':Library:' \
-
				&& return 0
-
			;;
-
		(stats)
-
			_arguments -s \
-
				'-q[Be quiet]' \
-
				'(-l)-r[Display stats only for the local package database]' \
-
				'(-r)-l[Display stats only for the remote package database(s)]' \
-
				&& return 0
-
			;;
-
		(update)
-
			_arguments -s \
-
				'-f[Force updating]' \
-
				'-q[Be quiet]' \
-
				&& return 0
-
			;;
-
		(updating)
-
			_arguments -s \
-
				'-d[Only entries newer than date are shown]:date:' \
-
				'-f[Defines a alternative location of the UPDATING file]:UPDATING file:_files' \
-
				'*:Package:_pkg_installed' \
-
				&& return 0
-
			;;
-
		(upgrade)
-
			_arguments -s \
-
				'(-y)-n[Assume no (dry run) for confirmations]' \
-
				'(-n)-y[Assume yes when asked for confirmation]' \
-
				'-f[Upgrade/Reinstall everything]' \
-
				'-L[Do not try to update the repository metadata]' \
-
				&& return 1
-
			;;
-
		(version)
-
			#TODO: complete
-
			_arguments -s \
-
				'(-P -R)-I[Use INDEX file]' \
-
				'(-R -I)-P[Force checking against the ports tree]' \
-
				'(-I -P)-R[Use remote repository]' \
-
				'-o[Display package origin, instead of package name]' \
-
				'-q[Be quiet]' \
-
				'-v[Be verbose]' \
-
				'(-L)-l[Display only the packages for given status flag]:flag:((\< = \>))' \
-
				'(-l)-L[Display only the packages without given status flag]:flag:((\< = \>))' \
-
				&& return 0
-
			;;
-
		(which)
-
			_arguments -s \
-
				':file:_files' \
-
			&& return 0
-
			;;
-
	esac
-
}
-

-
_pkg "$@"