commit
						d124d0f097
					
				
							
								
								
									
										168
									
								
								src/_port
								
								
								
								
							
							
						
						
									
										168
									
								
								src/_port
								
								
								
								
							|  | @ -16,23 +16,79 @@ | ||||||
| # ------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------ | ||||||
| 
 | 
 | ||||||
| _port() { | _port() { | ||||||
|   # Variables for _argument |   local -a  upgrade_options revupgrade_options select_options \ | ||||||
|   typeset -A opt_args |               actions pseudo_common pseudo_advanced port_prefix | ||||||
|   local   context state state_descr line |  | ||||||
| 
 |  | ||||||
|   local   actions pseudo_common pseudo_advanced select_options port_prefix |  | ||||||
| 
 | 
 | ||||||
|   port_prefix=$(which port | sed 's|/bin/port||') |   port_prefix=$(which port | sed 's|/bin/port||') | ||||||
| 
 | 
 | ||||||
|   actions=( activate archive archivefetch build cat cd |   actions=( | ||||||
|   checksum clean configure contents deactivate dependents deps |     'activate\:Activate\ the\ given\ ports' | ||||||
|   destroot dir distcheck distfiles dmg dpkg echo edit exit |     'archive\:Archive\ the\ given\ ports,\ i.e.\ install\ the\ port\ image\ but\ do\ not\ activate' | ||||||
|   extract fetch file gohome help info install installed lint list |     'archivefetch\:Fetch\ archive\ for\ the\ given\ ports' | ||||||
|   livecheck load location log logfile mdmg mirror mpkg notes |     'build\:Build\ the\ given\ ports' | ||||||
|   outdated patch pkg platform portpkg provides quit rdependents |     'cat\:Writes\ the\ Portfiles\ of\ the\ given\ ports\ to\ stdout' | ||||||
|   rdeps rev-upgrade rpm search select selfupdate setrequested space |     'checksum\:Compares\ the\ checksums\ for\ the\ downloaded\ files\ of\ the\ given\ ports' | ||||||
|   srpm submit sync test unarchive uninstall unload unsetrequested |     'clean\:Removes\ files\ associated\ with\ the\ given\ ports' | ||||||
|   upgrade url usage variants version work ) |     'configure\:Configure\ the\ given\ ports' | ||||||
|  |     'contents\:\Returns\ a\ list\ of\ files\ installed\ by\ given\ ports' | ||||||
|  |     'deactivate\:Deactivates\ the\ given\ ports' | ||||||
|  |     'dependents\:Returns\ a\ list\ of\ installed\ dependents\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'deps\:Display\ a\ dependency\ listing\ for\ the\ given\ ports' | ||||||
|  |     'destroot\:Destroot\ the\ given\ ports' | ||||||
|  |     'dir\:Returns\ the\ directories\ of\ the\ given\ ports' | ||||||
|  |     'distcheck\:Checks\ if\ the\ given\ ports\ can\ be\ fetched\ from\ all\ of\ its\ master_sites' | ||||||
|  |     'distfiles\:Returns\ a\ list\ of\ distfiles\ for\ the\ given\ port' | ||||||
|  |     'dmg\:Creates\ a\ dmg\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'dpkg\:Creates\ a\ dpkg\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'echo\:Returns\ the\ list\ of\ ports\ the\ argument\ expands\ to' | ||||||
|  |     'edit\:Edit\ given\ ports' | ||||||
|  |     'extract\:Extract\ the\ downloaded\ files\ of\ the\ given\ ports' | ||||||
|  |     'fetch\:Downloaded\ distfiles\ for\ the\ given\ ports' | ||||||
|  |     'file\:Returns\ the\ path\ to\ the\ Portfile\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'gohome\:Opens\ the\ homepages\ of\ the\ given\ ports\ in\ your\ browser' | ||||||
|  |     'help\:Displays\ short\ help\ texts\ for\ the\ given\ actions' | ||||||
|  |     'info\:Returns\ information\ about\ the\ given\ ports ' | ||||||
|  |     'install\:Installs\ the\ given\ ports' | ||||||
|  |     'installed\:List\ installed\ versions\ of\ the\ given\ port,\ or\ all\ installed\ ports\ if\ no\ port\ is\ given' | ||||||
|  |     'lint\:Checks\ if\ the\ Portfile\ is\ lint-free\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'list\:List\ the\ available\ version\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'livecheck\:Checks\ if\ a\ new\ version\ of\ the\ software\ is\ available' | ||||||
|  |     'load\:Interface\ to\ launchctl(1)\ for\ ports\ providing\ startup\ items' | ||||||
|  |     'location\:Returns\ the\ install\ location\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'log\:Shows\ main\ log\ for\ given\ ports' | ||||||
|  |     'logfile\:Returns\ the\ log\ file\ path\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'mdmg\:Creates\ a\ dmg\ containing\ an\ mpkg\ for\ each\ of\ the\ given\ ports\ and\ their\ dependencies' | ||||||
|  |     'mirror\:Fetches\ distfiles\ for\ the\ given\ ports' | ||||||
|  |     'mpkg\:Creates\ an\ mpkg\ for\ each\ of\ the\ given\ ports\ and\ their\ dependencies' | ||||||
|  |     'notes\:Displays\ informational\ notes\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'outdated\:Returns\ a\ list\ of\ outdated\ ports' | ||||||
|  |     'patch\:Applies\ patches\ to\ each\ of\ the\ given\ ports' | ||||||
|  |     'pkg\:Creates\ a\ pkg\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'platform\:Returns\ the\ current\ platform\ that\ port\ is\ running\ on' | ||||||
|  |     'provides\:Return\ which\ port\ provides\ each\ of\ the\ files\ given' | ||||||
|  |     'rdependents\:Recursive\ version\ of\ dependents' | ||||||
|  |     'rdeps\:Display\ a\ recursive\ dependency\ listing\ for\ the\ given\ ports' | ||||||
|  |     'rev-upgrade\:Scan\ for\ broken\ binaries\ in\ the\ installed\ ports\ and\ rebuild\ them\ as\ needed' | ||||||
|  |     'rpm\:Creates\ a\ rpm\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'search\:Search\ for\ a\ port' | ||||||
|  |     'select\:Select\ between\ multiple\ versions\ of\ a\ versioned\ port' | ||||||
|  |     'selfupdate\:Upgrade\ MacPorts\ itself\ and\ run\ the\ sync\ target' | ||||||
|  |     'setrequested\:Marks\ each\ of\ the\ given\ ports\ as\ requested' | ||||||
|  |     'space\:Show\ the\ disk\ space\ used\ by\ the\ given\ ports' | ||||||
|  |     'srpm\:Creates\ a\ srpm\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'sync\:Synchronize\ the\ set\ of\ Portfiles' | ||||||
|  |     'test\:Run\ tests\ on\ each\ of\ the\ given\ ports' | ||||||
|  |     'unarchive\:Unarchive\ the\ destroot\ of\ the\ given\ ports\ from\ installed\ images' | ||||||
|  |     'uninstall\:Uninstall\ the\ given\ ports' | ||||||
|  |     'unload\:Interface\ to\ launchctl(1)\ for\ ports\ providing\ startup\ items' | ||||||
|  |     'unsetrequested\:Marks\ each\ of\ the\ given\ ports\ as\ unrequested' | ||||||
|  |     'upgrade\:Upgrades\ the\ given\ ports\ to\ the\ latest\ version' | ||||||
|  |     'url\:Returns\ the\ URL\ for\ each\ of\ the\ given\ ports' | ||||||
|  |     'usage\:Returns\ basic\ usage\ of\ the\ port\ command' | ||||||
|  |     'variants\:Returns\ a\ list\ of\ variants\ provided\ by\ the\ given\ ports,\ with\ descriptions\ if\ present' | ||||||
|  |     'version\:Returns\ the\ version\ of\ MacPorts' | ||||||
|  |     'work\:Returns\ the\ path\ to\ the\ work\ directory\ for\ each\ of\ the\ given\ ports' | ||||||
|  |   ) | ||||||
| 
 | 
 | ||||||
|   pseudo_common=(all current active inactive actinact installed uninstalled outdated |   pseudo_common=(all current active inactive actinact installed uninstalled outdated | ||||||
|   obsolete requested unrequested leaves) |   obsolete requested unrequested leaves) | ||||||
|  | @ -50,42 +106,40 @@ _port() { | ||||||
| 
 | 
 | ||||||
|   revupgrade_options=('--id-loadcmd-check:Run more checks against a special loadcommand in Mach-O binaries') |   revupgrade_options=('--id-loadcmd-check:Run more checks against a special loadcommand in Mach-O binaries') | ||||||
| 
 | 
 | ||||||
|   local cache_policy |   upgrade_options=( | ||||||
|   zstyle -s ":completion:${curcontext}:" cache-policy cache_policy |     '--force\:Ignore\ circumstances\ that\ would\ normally\ cause\ ports\ to\ be\ skipped\ \(e.g.\ not\ outdated\).' \ | ||||||
|   if [[ -z "$cache_policy" ]]; then |     '--enforce-variants\:If\ the\ installed\ variants\ do\ not\ match\ those\ requested,\ upgrade\ even\ if\ the\ port\ is\ not\ outdated.' \ | ||||||
|     zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy |     '--no-replace\:Do\ not\ replace\ one\ port\ with\ another\ according\ to\ the\ replaced_by\ field.' \ | ||||||
|   fi |   ) | ||||||
| 
 | 
 | ||||||
|   _arguments -s -C \ |   _arguments -s -C \ | ||||||
|     '-v[verbose mode (generate verbose messages)]' \ |     '-v[Verbose mode (generate verbose messages)]' \ | ||||||
|     '-d[debug mode (generate debugging messages, implies -v)]' \ |     '-d[Debug mode (generate debugging messages, implies -v)]' \ | ||||||
|     '-q[quiet mode (suppress messages)]' \ |     '-q[Quiet mode (suppress messages)]' \ | ||||||
|     "-n[don't upgrade dependencies (affects upgrade and install)]" \ |     "-n[Don't upgrade dependencies (affects upgrade and install)]" \ | ||||||
|     "-R[also upgrade dependents (only affects upgrade) - note that this does not upgrade dependents' dependencies]" \ |     "-R[Also upgrade dependents (only affects upgrade) - note that this does not upgrade dependents' dependencies]" \ | ||||||
|     '-u[uninstall non-active ports when upgrading and uninstalling]' \ |     '-u[Uninstall non-active ports when upgrading and uninstalling]' \ | ||||||
|     '-f[force mode (ignore state file)]' \ |     '-f[Force mode (ignore state file)]' \ | ||||||
|     '-o[honor state files even if the Portfile has been modified since (called -o because it used to mean "older")]' \ |     '-o[Honor state files even if the Portfile has been modified since (called -o because it used to mean "older")]' \ | ||||||
|     '-s[source-only mode (build and install from source, do not attempt to fetch binary archives)]' \ |     '-s[Source-only mode (build and install from source, do not attempt to fetch binary archives)]' \ | ||||||
|     '-b[binary-only mode (build and install from binary archives, ignore source, abort if no archive available)]' \ |     '-b[Binary-only mode (build and install from binary archives, ignore source, abort if no archive available)]' \ | ||||||
|     '-c[autoclean mode (execute clean after install)]' \ |     '-c[Autoclean mode (execute clean after install)]' \ | ||||||
|     "-k[keep mode (don't autoclean after install)]" \ |     "-k[Keep mode (don't autoclean after install)]" \ | ||||||
|     '-D[specify portdir]' \ |     '-D[Specify portdir]' \ | ||||||
|     '-F[Read and process the file of commands specified by the argument.]' \ |     '-F[Read and process the file of commands specified by the argument.]' \ | ||||||
|     '-p[Despite any errors encountered, proceed to process multiple ports and commands.]' \ |     '-p[Despite any errors encountered, proceed to process multiple ports and commands.]' \ | ||||||
|     '-y[Perform a dry run.]' \ |     '-y[Perform a dry run.]' \ | ||||||
|     '-t[enable trace mode debug facilities on platforms that support it (Mac OS X).]' \ |     '-t[Enable trace mode debug facilities on platforms that support it (Mac OS X).]' \ | ||||||
|     "1:Port actions:($actions)" \ |     "1:Port actions:(($actions))" \ | ||||||
|     '*:extra:->extra' \ |     '::Per-action arguments:_port_dispatch' \ | ||||||
|     && return 0 |     && return 0 | ||||||
| 
 |  | ||||||
|   case "$state" in |  | ||||||
|     extra) |  | ||||||
|       _port_dispatch |  | ||||||
|       ;; |  | ||||||
|   esac |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| _port_dispatch() { | _port_dispatch() { | ||||||
|  |   local cache_policy | ||||||
|  |   zstyle -s ":completion:${curcontext}:" cache-policy cache_policy | ||||||
|  |   zstyle ":completion:${curcontext}:" cache-policy ${cache_policy:-_port_caching_policy} | ||||||
|  | 
 | ||||||
|   case "$words[2]" in |   case "$words[2]" in | ||||||
|     provides) |     provides) | ||||||
|       _files |       _files | ||||||
|  | @ -104,7 +158,7 @@ _port_dispatch() { | ||||||
|       if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && |       if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) && | ||||||
|         ! _retrieve_cache PORT_INSTALLED_PACKAGES; |         ! _retrieve_cache PORT_INSTALLED_PACKAGES; | ||||||
|       then |       then | ||||||
|         _port_installed_packages=( $(_call_program path-all "port echo all") ) |         _port_installed_packages=( $(_call_program path-all "port -q echo installed") ) | ||||||
|         _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages |         _store_cache PORT_INSTALLED_PACKAGES _port_installed_packages | ||||||
|       fi |       fi | ||||||
|       _alternative \ |       _alternative \ | ||||||
|  | @ -113,21 +167,33 @@ _port_dispatch() { | ||||||
|         "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" |         "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" | ||||||
|       ;; |       ;; | ||||||
|     upgrade) |     upgrade) | ||||||
|  |       # No good reason to actually cache outdated ports list | ||||||
|       local outdated_packages |       local outdated_packages | ||||||
|       outdated_packages=("${(f)$(port outdated | sed -e '1 d' -e 's/^\([[:graph:]]*\).*/\1/')}") |       outdated_packages=( $(_call_program path-outdated "port -q echo outdated") ) | ||||||
|       _describe "Outdated ports" outdated_packages |       _alternative -- \ | ||||||
|  |         "upgrade-options:Upgrade options:(($upgrade_options))" \ | ||||||
|  |         "ports:Outdated ports:($outdated_packages)" \ | ||||||
|  |         "pseudo-common:Common Pseudo-portnames:($pseudo_common)" \ | ||||||
|  |         "pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)" | ||||||
|       ;; |       ;; | ||||||
|     rev-upgrade) |     rev-upgrade) | ||||||
|       if (( CURRENT == 3 )); then |       if (( CURRENT == 3 )); then | ||||||
|         _describe 'Rev-upgrade options' revupgrade_options |         _describe 'Rev-upgrade options' revupgrade_options | ||||||
|       fi |       fi | ||||||
|       ;; |       ;; | ||||||
|  |     outdated|sync) | ||||||
|  |       # No need to complete anything more here. | ||||||
|  |       return 0; | ||||||
|  |       ;; | ||||||
|  |     selfupdate) | ||||||
|  |       _all_labels 'Selfupdate options' '--nosync' | ||||||
|  |       ;; | ||||||
|     *) |     *) | ||||||
|       # Cache the list of all ports. |       # Cache the list of all ports. | ||||||
|       if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && |       if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) && | ||||||
|         ! _retrieve_cache PORT_AVAILABLE_PACKAGES; |         ! _retrieve_cache PORT_AVAILABLE_PACKAGES; | ||||||
|       then |       then | ||||||
|         _port_available_packages=( $(_call_program path-all "port echo all") ) |         _port_available_packages=( $(_call_program path-all "port -q echo all") ) | ||||||
|         _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages |         _store_cache PORT_AVAILABLE_PACKAGES _port_available_packages | ||||||
|       fi |       fi | ||||||
|       _alternative \ |       _alternative \ | ||||||
|  | @ -156,8 +222,16 @@ _port_select() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| _port_caching_policy() { | _port_caching_policy() { | ||||||
|   local reg_time comp_time |   local reg_time comp_time check_file | ||||||
|   reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db) |   case "${1##*/}" in | ||||||
|  |     PORT_INSTALLED_PACKAGES) | ||||||
|  |       check_file=$port_prefix/var/macports/registry/registry.db | ||||||
|  |       ;; | ||||||
|  |     PORT_AVAILABLE_PACKAGES) | ||||||
|  |       check_file=${$(port dir MacPorts)%/*/*}/PortIndex | ||||||
|  |       ;; | ||||||
|  |   esac | ||||||
|  |   reg_time=$(stat -c '%Z' $check_file) | ||||||
|   comp_time=$(stat -c '%Z' $1) |   comp_time=$(stat -c '%Z' $1) | ||||||
|   return $(( reg_time < comp_time )) |   return $(( reg_time < comp_time )) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue