Artifact Content

Artifact ef045b499c071234b576e67d4d97fd5d8c3da424:


#compdef poudriere

_poudriere_jail() {
	_values "poudriere jails" ${${(f)"$(${service} jails -lq)"}%% *}
}

_poudriere_pt() {
	_values "poudriere portstrees" ${${(f)"$(${service} ports -lq)"}%% *}
}

# shamelessely stolen from
# /usr/local/share/zsh/4.3.12/functions/Completion/BSD/_portmaster
_poudriere_ports() {
  local ret=1 _fbsd_ports _fbsd_cat
   _fbsd_cat=(${PORTSDIR:-/usr/local/poudriere/ports/default/ports}/[a-z]*(/:t))
   if [[ $PREFIX != */* ]] ; then
     _wanted cat_packages expl 'category/ports' compadd -S '/' $_fbsd_cat
   else
     compset -P '*/'
     _fbsd_ports=(${PORTSDIR:-/usr/local/poudriere/ports/default/ports}/$IPREFIX/*(/:t))
     _wanted cat_packages expl 'category/ports' compadd $_fbsd_ports
   fi
  return ret
}

_bulk=(
	'-a[Build all ports in the tree]'
	'-B[What buildname to use]:buildname'
	'-f[Give the list of ports to build]:name of file:_files'
	'-F[Only fetch from original master_sites; skip FreeBSD mirrors]'
	'-c[Clean the previous built binary packages]'
	'-C[Clean previous packages for the given list to build]'
	'-N[Do not build repository or INDEX when done building]'
	'-t[Test the specified ports for leftovers]'
	'-r[Recursively test all dependencies as well]'
	'-s[Skip sanity]'
	'-j[Run only on the given jail]::jail name:_poudriere_jail'
	'-p[Specify on which ports tree the bulk will be done]::tree:_poudriere_pt'
	'-T[Try building BROKEN ports]'
	'-J[Specify the number of jobs you want to run in parallel]::'
	'-R[Remove RESTRICTED packages after building]'
	'-v[Be verbose; show more information. Specify twice to enable debug output.]'
	'-z[Specify on which SET to use]::'
)

_jail=(
	'(-d -l -s -k -u -i)-c[create a jail]' 
	'(-c -l -s -k -u -i)-d[delete a jail]' 
	'(-c -d -s -k -u -i)-l[list all available jails]' 
	'(-c -d -l -k -u -i)-s[start a jail]' 
	'(-c -d -i -s -u -i)-k[kill (stop) a jail]' 
	'(-c -d -l -s -k -i)-u[update a jail]' 
	'(-c -d -l -s -k -u)-i[show information about a jail]'
	'-q[quiet (remove the header in list)]::' \
	'-j[Specifies the jailname]::jailname:_poudriere_jail' \
	'-v[Specifies which version of FreeBSD we want in jail]::version' \
	'-a[Indicates architecture of the jail: i386 or amd64(same as host by default)]::arch:(amd64 i386)' \
	'-m[Method used to create jail, specify NONE if you want to use your home made jail(ftp by default)]::method:((ftp svn svn+http svn+ssh csup))' \
	'-f[FS name (tank/jails/myjail)]::fs:_files -/' \
	'-t[version to upgrade to]' \
	'-M[mountpoint]::mountpoint:_files -/'
)

_options=(
	'-c[Use config target]::'
	'-C[Use config-conditional target]::'
	'-f[Give the list of ports to configure]:name of file:_files'
	'-j[run only inside the given jail]::name:_poudriere_jail'
	'-n[do not be recursive]::'
	'-p[specify on which portstree we work]::tree:_poudriere_pt'
	'-s[show options instead of configuring them]::'
	'-r[remove options instead of configuring them]::'
	'-z[Specify on which SET to use]::'
)

_distclean=(
	'-J[Specify the number of jobs you want to run in parallel]::'
	'-n[dry run, only show what would be done]::'
	'-p[specify on which portstree we work]::tree:_poudriere_pt'
	'-v[Be verbose; show more information. Specify twice to enable debug output.]'
	'-y[assume yes and do not confirm before deleting]::'
)

_testport=(
	'(-o)-d[specify on which port we work]::path:_files -/'
	'-c[run make config for the given port]::'
	'-j[run only inside the given jail]::name:_poudriere_jail'
	'-n[no custom prefix]::'
	'-p[specify on which portstree we work]::tree:_poudriere_pt'
	'-v[Be verbose; show more information. Specify twice to enable debug output.]'
	'-z[Specify on which SET to use]::'
)

_status=(
	'-j[run only inside the given jail]::name:_poudriere_jail'
	'-p[specify on which portstree we work]::tree:_poudriere_pt'
	'-z[Specify on which SET to use]::'
)

_ports=(
	'(-d -u -l)-c[create a portstree]'
	'(-c -u -l)-d[delete a portstree]'
	'(-c -d -l)-u[update a portstree]'
	'(-c -d -u)-l[lists all available portstrees]'
	'-q[quiet (remove the header in list)]'
	'-F[when used with -c, only create the needed ZFS filesystems and directories, but do not populate them]'
	'-p[specify the name of the portstree we work on]::tree:_poudriere_pt'
	'-f[FS name (tank/jails/myjail)]::fs:_files -/'
	'-M[mountpoint]::mountpoint:_files -/'
	'-m[method]::method:((portsnap svn svn+http svn+ssh git))'
	'-v[Be verbose; show more information.]'
)

_poudriere () {
	local cmds
	local context state line
	typeset -A val_args
	cmds=(
		'bulk:generate packages for given ports'
		'daemon:process jobs in the queue'
		'jail:manage the jails used by poudriere'
		'distclean:clean old distfiles'
		'options:allows to configure the options for a given port'
		'ports:create, update or delete the portstrees used by poudriere'
		'queue:queue a build request (through daemon)'
		'testport:launch a test on a given port'
		'version:show poudriere version'
	)
	# we are in second argument
	if ((CURRENT == 2)); then
		_describe "poudriere main commands" cmds
	# the main command has been typed, now we take care of the action
	elif ((CURRENT >= 3)); then
		case $words[2] in
			bulk)
			_arguments : $_bulk "::" && return
			;;
			jail)
			_arguments : $_jail "::" && return
			;;
			distclean)
			_arguments : $_distclean "::" && return
			;;
			options)
			_arguments : $_options "::" && return
			;;
			ports)
			_arguments : $_ports "::" && return
			;;
			testport)
			_arguments : $_testport "::" && return
			;;
			status)
			_arguments : $_status "::" && return
			;;
		esac
	fi

}

_poudriere "$@"