]> CyberLeo.Net >> Repos - CDN/Mosi.git/blob - script/makepkg
script/makepkg: avoid explicitly building ports-mgmt/portmaster since it is implicitl...
[CDN/Mosi.git] / script / makepkg
1 #!/bin/sh
2
3 # Load shlib and modules
4 _root="$(dirname "${0}")"; . "${_root}/lib/env.sh"
5 want log root
6
7 ########
8 #
9 # Chroot handling
10 #
11 ########
12
13 # Prepare a chroot for work
14 chprepare() {
15   # Verify environment sanity
16   [ -d "${chroot_dir}" ] && omg "${chroot_dir}: directory exists; purging" && chdestroy
17   mount | grep -q "${chroot_dir}" && wtf "Stuff is mounted under ${chroot_dir}; cannot continue"
18   [ -d "${seed_dir}" -a -f "${seed_dir}/COPYRIGHT" ] || wtf "Use 'makeworld' to create a root build first"
19   [ -f "/usr/ports/UPDATING" ] || wtf "Need ports tree in /usr/ports to build"
20   [ -f "/usr/src/sys/conf/newvers.sh" ] || omg "No base sourcetree in /usr/src"
21
22   meh "Setting up chroot tree"
23
24   # Just in case we're aborted partway through the prepare
25   trap "chdestroy" exit hup int term kill
26
27   # Make sure config dir exists for later save
28   [ -d "${conf_dir}" ] || mkdir -p "${conf_dir}"
29
30   # Populate initial seed
31   mkdir -p "$(dirname "${chroot_dir}")" || wtf "chroot path create failed"
32   cp -pR "${seed_dir}" "${chroot_dir}" || wtf "chroot seeding failed"
33
34   # Create distfile cache
35   mkdir -p "${dist_dir}" || wtf "mkdir ${dist_dir} failed"
36
37   # Create mountpoint directories
38   mkdir -p "${chroot_dir}/dev" || wtf "mkdir /dev failed"
39   mkdir -p "${chroot_dir}/usr/src" || wtf "mkdir /usr/src failed"
40   mkdir -p "${chroot_dir}/usr/obj" || wtf "mkdir /usr/obj failed"
41   mkdir -p "${chroot_dir}/usr/ports" || wtf "mkdir /usr/ports failed"
42   mkdir -p "${chroot_dir}/var/ports/distfiles" || wtf "mkdir /var/ports/distfiles failed"
43
44   # Create pkg directories
45   mkdir -p "${pkg_dir}" || wtf "mkdir ${chroot_pkg_dir} failed"
46   mkdir -p "${bdeps_dir}" || wtf "mkdir ${chroot_bdeps_dir} failed"
47
48   # Copy in cached configuration, if necessary
49   [ -f "${conf_dir}/make.conf" ] && cp -p "${conf_dir}/make.conf" "${chroot_dir}/etc/make.conf"
50
51   # If you have WITHOUT_INFO set in src.conf during buildworld/installworld, ports that need
52   # makeinfo and install-info will fail horribly; stub them
53   [ -f "${chroot_dir}/usr/bin/makeinfo" ] || ln -sf true "${chroot_dir}/usr/bin/makeinfo"
54   [ -f "${chroot_dir}/usr/bin/install-info" ] || ln -sf true "${chroot_dir}/usr/bin/install-info"
55
56   # Tweak make.conf to support read-only ports tree
57   cat <<EOF >> "${chroot_dir}/etc/make.conf"
58
59 # Read-only ports tree
60 DISTDIR=/var/ports/distfiles
61 PACKAGES=/var/ports/packages
62 WRKDIRPREFIX=/usr/obj
63 EOF
64
65   trap "" exit hup int term kill
66   meh "Chroot tree set up in ${chroot_dir}"
67
68   return 0
69 }
70
71 # Set up chroot mounts and runtime configuration
72 chstartup() {
73   [ -d "${chroot_dir}" -a -f "${chroot_dir}/COPYRIGHT" -a -d "${chroot_dir}/dev" ] || wtf "Chroot not prepared"
74   chup && return 0
75
76   # Rollback if a problem occurs during startup
77   trap "chshutdown" exit hup int term kill
78
79   meh "Starting up chroot"
80
81   # Necessary mountpoints
82   mount -t devfs devfs "${chroot_dir}/dev" || wtf "mount /dev failed"
83   mount -t nullfs -r /usr/src "${chroot_dir}/usr/src" || wtf "mount /usr/src failed"
84   mount -t nullfs -r /usr/ports "${chroot_dir}/usr/ports" || wtf "mount /usr/ports failed"
85   mount -t nullfs -w "${dist_dir}" "${chroot_dir}/var/ports/distfiles" || wtf "mount /var/ports/distfiles failed"
86
87   # Chroot configuration
88   cp -f /etc/resolv.conf "${chroot_dir}/etc/resolv.conf" || wtf "seeding /etc/resolv.conf failed"
89
90   # Load port configuration, now that chroot is running
91   port_load_config
92
93   # Update ld.so.hints
94   cheval "/etc/rc.d/ldconfig start"
95
96   trap "" exit hup int term kill
97   meh "Chroot up and running in ${chroot_dir}"
98
99   return 0
100 }
101
102 # Check if the chroot is probably ready for use
103 chup() {
104   [ -d "${chroot_dir}" -a -f "${chroot_dir}/COPYRIGHT" -a -c "${chroot_dir}/dev/null" ]
105   return $?
106 }
107
108 # Unmount all chroot directories
109 chshutdown() {
110   # Short-circuit if nothing is mounted
111   mount | grep -q "${chroot_dir}" || return 0
112   chup && port_save_config || meh "Not saving port config"
113   meh "Shutting down chroot"
114   umount "${chroot_dir}/var/ports/distfiles"
115   umount "${chroot_dir}/usr/ports"
116   umount "${chroot_dir}/usr/src"
117   umount "${chroot_dir}/dev"
118   return 0
119 }
120
121 # Remove all chroot contents
122 chdestroy() {
123   chshutdown
124   meh "Destroying chroot"
125   chflags -R noschg "${chroot_dir}" || wtf "noschg failed"
126   rm -Rf "${chroot_dir}" || wtf "chroot removal failed"
127   return 0
128 }
129
130 # Evaluate a command line within the chroot
131 cheval() {
132   chup || wtf "Chroot not ready"
133   chroot "${chroot_dir}" env -i ${chroot_env} /bin/sh -c "cd ${chroot_pkg_dir}; ${*}"
134   return $?
135 }
136
137 # Run chrooted make
138 chmake() {
139   local port="/usr/ports/${1##/usr/ports/}"
140   shift
141   cheval "make -C ${port} ${*}"
142   return $?
143 }
144
145 ########
146 #
147 # Port Dependency Tracking
148 #
149 ########
150
151 # Translate port origin to package name
152 port2pkg() {
153   while [ "${1}" ]
154   do
155     chmake "${1}" -V PKGNAME
156     shift
157   done
158 }
159
160 # Build dependencies (shallow, recursive, package)
161 port_bdeps() {
162   while [ "${1}" ]
163   do
164     chmake "${1}" build-depends-list | sed -e 's#^/usr/ports/##'
165     shift
166   done
167 }
168 port_all_bdeps() {
169   # Clear cache if first value isn't '-r'
170   [ "${1}" = '-r' ] && shift || { : > "${_port_all_bdeps_cache}"; : > "${_port_all_rdeps_cache}"; }
171   # rdeps for rdeps are rdeps, bdeps for rdeps are bdeps, rdeps for bdeps are bdeps; thus:
172   (
173     port_bdeps "${@}" | while read port
174     do
175       [ "${VERBOSE_CACHE}" ] && logf "**** bdep cache %s: '%s'\n" "$(grep -q "${port}" \
176         "${_port_all_bdeps_cache}" && echo "hit" || echo "miss")"  "${port}" >&2
177       if ! grep -q "${port}" "${_port_all_bdeps_cache}"
178       then
179         echo "${port}" >> "${_port_all_bdeps_cache}"
180         echo "${port}"
181         port_all_bdeps -r "${port}"
182         port_all_rdeps -r "${port}"
183       fi
184     done
185     port_all_rdeps -r "${@}" | while read port
186     do
187       [ "${VERBOSE_CACHE}" ] && logf "**** bdep cache %s: '%s'\n" "$(grep -q "${port}" \
188         "${_port_all_bdeps_cache}" && echo "hit" || echo "miss")"  "${port}" >&2
189       if ! grep -q "${port}" "${_port_all_bdeps_cache}"
190       then
191         echo "${port}" >> "${_port_all_bdeps_cache}"
192         port_all_bdeps -r "${port}"
193       fi
194     done
195   ) | sort | uniq
196 }
197 pkg_bdeps() {
198   port2pkg $(port_all_bdeps "${@}")
199 }
200
201 # Runtime dependencies (shallow, recursive, package)
202 port_rdeps() {
203   while [ "${1}" ]
204   do
205     chmake "${1}" run-depends-list | sed -e 's#^/usr/ports/##'
206     shift
207   done
208 }
209 port_all_rdeps() {
210   # Clear cache if first value isn't '-r'
211   [ "${1}" = '-r' ] && shift || { : > "${_port_all_rdeps_cache}"; }
212   port_rdeps "${@}" | while read port
213   do
214     [ "${VERBOSE_CACHE}" ] && logf "**** rdep cache %s: '%s'\n" "$(grep -q "${port}" \
215       "${_port_all_rdeps_cache}" && echo "hit" || echo "miss")"  "${port}" >&2
216     if ! grep -q "${port}" "${_port_all_rdeps_cache}"
217     then
218       echo "${port}" >> "${_port_all_rdeps_cache}"
219       echo "${port}"
220       port_all_rdeps -r "${port}"
221     fi
222   done | sort | uniq
223 }
224 pkg_rdeps() {
225   port2pkg $(port_all_rdeps "${@}")
226 }
227
228 # All dependencies (shallow, recursive, package)
229 port_deps() {
230   while [ "${1}" ]
231   do
232     chmake "${1}" all-depends-list | sed -e 's#^/usr/ports/##'
233     shift
234   done
235 }
236 port_all_deps() {
237   port_deps "${@}" | while read port
238   do
239     echo "${port}"
240     port_deps "${port}"
241   done | sort | uniq
242 }
243 pkg_deps() {
244   port2pkg $(port_all_deps "${@}")
245 }
246
247 # Dump a list of leaf ports from a working system
248 # Leaf ports are ports that have nothing depending upon them
249 # These are generally the top-level ports; everything else should
250 # be pulled in by them; on a system that has had updates applied
251 # this may pick up orphaned packages as well, so try cutleaves?
252 leaf_ports() {
253   ( cd /var/db/pkg; ls -1 ) | while read pkg
254   do
255     pkg_info -Rq "${pkg}" | grep -q '' || pkg_info -oq "${pkg}"
256   done | sort
257 }
258
259 # Display a tree of all build dependencies (and
260 # any runtime dependencies those build dependencies
261 # depend upon). Individual ports may appear more than
262 # once, as it is a tree and not a list.
263 port_bdep_tree() {
264   # Clear cache if first value isn't '-r'
265   [ "${1}" = '-r' ] && shift || {
266     [ ${VERBOSE_CACHE} ] && logf "**** bdep_tree cache cleared\n"
267     : > "${_port_bdep_tree_cache}"
268   }
269   port="${1##/usr/ports/}"
270   printf "%${2}s%s\n" "" "${port}"
271   
272   [ "${VERBOSE_CACHE}" ] && logf "**** bdep_tree cache %s: '%s'\n" "$(grep -q "${port}" \
273     "${_port_bdep_tree_cache}" && echo "hit" || echo "miss")"  "${port}" >&2
274
275   if ! grep -q "${port}" "${_port_bdep_tree_cache}"
276   then
277     ( chmake "${port}" build-depends-list
278       chmake "${port}" run-depends-list
279     ) | sort -u | while read port
280     do
281       port_bdep_tree -r "${port}" $(( ${2:-0} + 1 ))
282       echo "${port}" >> "${_port_bdep_tree_cache}"
283     done
284   else
285     printf "%${2}s %s\n" "" "..."
286   fi
287 }
288
289 # Display a tree of all runtime dependencies. Individual
290 # ports may appear more than once, as it is a tree and
291 # not a list.
292 # Cache already-visted branches into ... to eliminate recursion delays
293 # (x11-drivers/xorg-drivers computes forever!)
294 port_rdep_tree() {
295   # Clear cache if first value isn't '-r'
296   [ "${1}" = '-r' ] && shift || {
297     [ ${VERBOSE_CACHE} ] && logf "**** rdep_tree cache cleared\n"
298     : > "${_port_rdep_tree_cache}"
299   }
300   port="${1##/usr/ports/}"
301   printf "%${2}s%s\n" "" "${port}"
302
303   [ "${VERBOSE_CACHE}" ] && logf "**** rdep_tree cache %s: '%s'\n" "$(grep -q "${port}" \
304     "${_port_rdep_tree_cache}" && echo "hit" || echo "miss")"  "${port}" >&2
305
306   if ! grep -q "${port}" "${_port_rdep_tree_cache}"
307   then
308     chmake "${port}" run-depends-list | sort -u | while read port
309     do
310       port_rdep_tree -r "${port}" $(( ${2:-0} + 1 ))
311       echo "${port}" >> "${_port_rdep_tree_cache}"
312     done
313   else
314     printf "%${2}s %s\n" "" "..."
315   fi
316 }
317
318 ########
319 #
320 # Port Configuration Handling
321 #
322 ########
323
324 # Run make config on a list of ports
325 port_config() {
326   while [ "${1}" ]
327   do
328     meh "port config ${1}"
329     chmake "${1}" config < /dev/tty
330     shift
331   done
332 }
333
334 # Make config-conditional for a list of ports, and all dependencies
335 port_config_recursive() {
336   # Clear cache if first value isn't '-r'
337   [ "${1}" = '-r' ] && shift || _port_config_recursive_cache=""
338   while [ "${1}" ]
339   do
340     # Do not use config-recursive because it computes the depchain first;
341     # instead, manually compute the depchain after each config to ensure the
342     # proper depchain is followed. Use config-conditional to avoid dialog
343     # if the config is already complete. Also use a cache to avoid re-config
344     # and re-recurse on previously handled port branches.
345     if echo "${_port_config_recursive_cache}" | grep -qv " ${1} "
346     then
347       meh "port config-recursive ${1}"
348       chmake "${1}" config-conditional < /dev/tty
349       port_config_recursive -r $(port_deps "${1}")
350       _port_config_recursive_cache="${_port_config_recursive_cache} ${1} "
351     fi
352     shift
353   done
354 }
355 # Config cache
356 unset _port_config_recursive_cache
357
358 # Remove saved config for a list of ports
359 port_rmconfig() {
360   while [ "${1}" ]
361   do
362     meh "port rmconfig ${1}"
363     chmake "${1}" rmconfig
364     shift
365   done
366 }
367
368 # Remove saved config for a list of ports and all dependencies
369 port_rmconfig_recursive() {
370   meh "port rmconfig-recursive ${*}"
371   port_rmconfig $(echo "${@}" $(port_all_deps "${@}") | sort | uniq)
372 }
373
374 # Obliterate saved configuration for all ports
375 port_rmconfig_all() {
376   meh "port rmconfig-all"
377   cheval "cd /var/db/ports; find . -name 'options' -delete; find . -type d | xargs rmdir 2>/dev/null"
378 }
379
380 # Restore port build options from directory
381 port_load_config() {
382   [ -d "${conf_dir}/port.options" ] || return 0
383   meh "port load-config"
384   ( cd "${conf_dir}/port.options"; find . | cpio -oHnewc ) | cheval "cd /var/db/ports; cpio -i" || wtf "port load-config failed"
385 }
386
387 # Dump port build options to directory
388 port_save_config() {
389   meh "port save-config"
390   rm -Rf "${conf_dir}/port.options.tmp" "${conf_dir}/port.options.old"
391   mkdir -p "${conf_dir}/port.options" "${conf_dir}/port.options.tmp"
392   cheval "cd /var/db/ports; find . -type d -o -type f -name options | cpio -oHnewc" | ( cd "${conf_dir}/port.options.tmp"; cpio -i ) || wtf "port safe-config failed"
393   mv -f "${conf_dir}/port.options" "${conf_dir}/port.options.old" && \
394     mv -f "${conf_dir}/port.options.tmp" "${conf_dir}/port.options" && \
395     rm -Rf "${conf_dir}/port.options.old" || \
396     wtf "port save-config atomic commit failed"
397 }
398
399 ########
400 #
401 # Port distfile handling
402 #
403 ########
404
405 # Recursively retrieve distfiles
406 port_fetch_recursive() {
407   while [ "${1}" ]
408   do
409     meh "fetch-recursive ${1}"
410     chmake "${1}" fetch-recursive
411     shift
412   done
413 }
414
415 ########
416 #
417 # Port building and packaging
418 #
419 ########
420
421 # Copy in and install dependency packages
422 # Missing dependencies are not fatal, since a port build will rebuild them anyways
423 port_load_deps() {
424   local port="${1}"
425   # Install portmaster: it's needed to clean up dependencies after an update build
426   portmaster_port="ports-mgmt/portmaster"
427   portmaster=$(port2pkg "${portmaster_port}")
428   if [ -f "${final_bdeps_dir}/${portmaster}.tbz" ]
429   then
430     cp -f "${final_bdeps_dir}/${portmaster}.tbz" "${bdeps_dir}" 2>/dev/null && meh "Loading ${portmaster}"
431   else
432     meh "No portmaster package exists; building one"
433     chmake "${portmaster_port}" BATCH=yes clean build install clean || wtf "port_build ${portmaster_port} failed"
434   fi
435
436   # And now for the dependencies
437   for pkg in $(port2pkg $(port_all_deps "${port}"))
438   do
439     cp -f "${final_bdeps_dir}/${pkg}.tbz" "${bdeps_dir}" 2>/dev/null && meh "Loading dependent ${pkg}"
440   done
441
442   # Install all selected packages, ignoring already-installed packages and missing dependencies
443   if ls "${bdeps_dir}"/*.tbz >/dev/null 2>&1
444   then
445     meh "Installing dependencies"
446     cheval "cd ${chroot_bdeps_dir}; pkg_add -Ff *" || wtf "port_load_deps ${port} failed"
447   fi
448 }
449
450 # Build and install a port
451 port_build() {
452   local port="${1}"
453   meh "Building ${port}"
454   chmake "${port}" clean build install clean || wtf "port_build ${port} failed"
455 }
456
457 # Package a port
458 port_package() {
459   local port="${1}"
460   meh "Cleaning up dependency tree"
461   cheval "portmaster --check-depends"
462   meh "Creating rdep package tree for ${port}"
463   cheval "pkg_create -Rvb $(port2pkg "${port}")" || wtf "port_package ${port} failed"
464 }
465
466 # Package port build dependencies, unless they're already run deps
467 port_stash_bdeps() {
468   meh "Stashing unsaved bdeps"
469   # This doesn't work well, because there can be bdeps that aren't listed as bdeps (bison)
470   # Actually, that was due to a bug in port_all_bdeps; but I like the other solution better anyways
471   #for pkg in $(pkg_bdeps "${1}")
472   #do
473   #  [ ! -f "${pkg_dir}/${pkg}.tbz" ] && cheval "cd ${chroot_bdeps_dir}; pkg_create -vb ${pkg}"
474   #done
475   #
476   # Instead, just save everything that's not already in rdeps as bdeps
477   for pkg in $(cheval pkg_info | awk '{print $1}')
478   do
479     if [ ! -f "${pkg_dir}/${pkg}.tbz" -a ! -f "${bdeps_dir}/${pkg}.tbz" ]
480     then
481       cheval "cd ${chroot_bdeps_dir}; pkg_create -vb ${pkg}" || wtf "port_stash_bdeps failed"
482     fi
483   done
484 }
485
486 # Copy generated packages out of tree
487 pkg_final() {
488   meh "Moving created packages to repo"
489   mkdir -p "${final_pkg_dir}"
490   ls "${pkg_dir}"/*.tbz >/dev/null 2>&1 && mv -f "${pkg_dir}"/*.tbz "${final_pkg_dir}"
491   mkdir -p "${final_bdeps_dir}"
492   ls "${bdeps_dir}"/*.tbz >/dev/null 2>&1 && mv -f "${bdeps_dir}"/*.tbz "${final_bdeps_dir}"
493   # link everything into ${bdeps_dir} so we can find it easily later
494   ( cd "${final_pkg_dir}"; find . -type f | cpio -plu --quiet "${final_bdeps_dir}" )
495 }
496
497 # Delete all installed packages (hope you saved them first)
498 pkg_delete_all() {
499   meh "Clearing out installed packages"
500   cheval "pkg_delete -f \*" || wtf "pkg_delete_all failed"
501 }
502
503 ########
504 #
505 # All of the above?
506 #
507 ########
508
509 # Execute a complete port build, using prebuilt packages to fulfill dependencies when available
510 # Be sure to chsetup and populate your config before running!
511 chport() {
512   [ "${#}" -gt 0 ] || set -- $(cat ${conf_dir}/port.lst)
513   while [ "${1}" ]
514   do
515     local port="${1}"
516     meh "config-recursive"
517     port_config_recursive "${port}"
518     meh "fetch-recursive"
519     port_fetch_recursive "${port}"
520     meh "load-deps"
521     port_load_deps "${port}"
522     meh "build"
523     # Avoid building ports-mgmt/portmaster because port_load_deps already has
524     [ "${port}" = "ports-mgmt/portmaster" ] || port_build "${port}"
525     meh "package"
526     port_package "${port}"
527     meh "stash-deps"
528     port_stash_bdeps
529     meh "final"
530     pkg_final
531     meh "delete-all"
532     pkg_delete_all
533     shift
534   done
535 }
536
537
538 ########
539 #
540 # Configuration variable setup
541 #
542 ########
543
544 ARCH="${ARCH:-$(uname -m)}"
545 CONF="${CONF:-GENERIC}"
546
547 # Root directory of makepkg
548 ROOT="$(realpath "$(dirname "${0}")/..")"
549
550 # Location of targets
551 TARGETS="${ROOT}/targets"
552
553 # Base directory for selected target
554 base_dir="${TARGETS}/${ARCH}/${CONF}"
555
556 # Link to appropriate world
557 world_dir="${base_dir}/world"
558
559 # Verify that world points to a proper world
560 if [ ! -d "${world_dir}" ]
561 then
562   omg "World link is not appropriate; defaulting to ${ARCH}/GENERIC"
563   world_dir="${ROOT}/worlds/${ARCH}/GENERIC"
564 fi
565
566 # Directory holding configuration
567 conf_dir="${base_dir}/config"
568
569 # Root tree for chroot seeding
570 seed_dir="${world_dir}/root"
571
572 # Directory where distfiles will be stored between builds (common to all targets)
573 dist_dir="${ROOT}/seed/distfiles"
574
575 # Final directory for built packages (Outside chroot)
576 final_pkg_dir="${base_dir}/pkg"
577 final_bdeps_dir="${base_dir}/bdeps"
578
579 # Chroot directory
580 chroot_dir="${base_dir}/chroot"
581
582 # Package directories (must be under ${chroot_dir})
583 pkg_dir="${chroot_dir}/pkg"
584 bdeps_dir="${pkg_dir}/bdeps"
585
586 # Compute in-chroot pkg and bdeps dirs
587 chroot_pkg_dir="${pkg_dir##${chroot_dir}}"
588 chroot_bdeps_dir="${bdeps_dir##${chroot_dir}}"
589
590 # Cache files to speed up recursive bdep/rdep scanning
591 _port_all_bdeps_cache="${chroot_dir}/tmp/_port_all_bdeps_cache"
592 _port_all_rdeps_cache="${chroot_dir}/tmp/_port_all_rdeps_cache"
593 _port_bdep_tree_cache="${chroot_dir}/tmp/_port_bdep_tree_cache"
594 _port_rdep_tree_cache="${chroot_dir}/tmp/_port_rdep_tree_cache"
595
596 # Chroot environment
597 chroot_env="
598 USER=root
599 HOME=/root
600 LOGNAME=root
601 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
602 SHELL=/bin/sh
603 TERM=${TERM}
604 "
605
606 help() {
607   cat <<EOF
608 Configuration variables:
609
610 ARCH (${ARCH})
611 CONF (${CONF})
612
613 Functions:
614
615 Chroot Handling:
616 ------------------------------
617 chprepare      Prepare chroot
618 chstartup      Start up chroot
619 cheval         Evaluate a command string within chroot
620 chmake         Run port make within chroot
621 chshutdown     Shut down chroot
622 chdestroy      Destroy chroot
623
624 Port Dependency Tracking
625 ------------------------------
626 port2pkg       Translate a port dirname to a package name
627
628 port_bdeps     Compute port build dependencies
629 port_all_bdeps Recursively compute port build dependencies
630 pkg_bdeps      port2pkg port_all_bdeps
631
632 port_rdeps     Compute port run dependencies
633 port_all_rdeps Recursively compute port run dependencies
634 pkg_rdeps      port2pkg port_all_rdeps
635
636 port_deps      Compute port build and run dependencies
637 port_all_deps  Recursively compute port build and run dependencies
638 pkg_deps       port2pkg port_all_deps
639
640 leaf_ports     Dump a list of leaf ports (ports with nothing depending upon them) from a running system
641 port_bdep_tree Display a tree of all build dependencies
642 port_rdep_tree Display a tree of all run dependencies
643
644 Port Configuration Handling
645 ------------------------------
646 port_config              Make config for a port
647 port_config_recursive    Make config recursive, recomputing depchain for each
648 port_rmconfig            Remove saved configuration
649 port_rmconfig_recursive  Remove saved configuration for a port and all dependencies
650 port_rmconfig_all        Remove all saved configuration
651 port_load_config         Restore port configuration from cpio
652 port_save_config         Save port configuration to cpio
653
654 Port Distfile Handling
655 ------------------------------
656 port_fetch_recursive     fetch-recursive
657
658 Port Building And Packaging
659 ------------------------------
660 port_load_deps           
661 port_build               
662 port_package             
663 port_stash_bdeps         
664 pkg_final                
665 pkg_delete_all           
666
667 All Of The Above?
668 ------------------------------
669
670 chport <port>            
671 EOF
672 }
673
674 # Blind passthru for testing
675 [ "${#}" ] && "${@}"
676
677 # Todo: Clean up entrypoint to support proper options
678 # Todo: Add methods to autoprocess a ports.lst file to produce packages
679 # Todo: Unify chroot handling with makeworld
680