# file      : tests/pkg-build.testscript
# license   : MIT; see accompanying LICENSE file

.include common.testscript \
         config.testscript \
         remote.testscript \
         remote-git.testscript

# Source repository:
#
# pkg-build
# |-- libbar-1.0.0.tar.gz -> libfoo
# |-- libbaz-1.1.0.tar.gz -> libfoo, libbar
# |-- libfix-0.0.1.tar.gz
# |-- libfoo-0.0.1.tar.gz -> libfix
# |-- libfoo-1.0.0.tar.gz
# |
# |-- libfoo-1.1.0
# |   |-- build
# |   |   `-- bootstrap.build
# |   |-- buildfile
# |   `-- manifest
# |
# |-- libhello-1.0.0
# |   |-- build
# |   |   |-- bootstrap.build
# |   |   |-- export.build
# |   |   `-- root.build
# |   `-- *
# |
# |-- libfoo-1.1.0.tar.gz
# |-- libfoo-1.2.0.tar.gz
# |
# |-- t0a
# |   |-- libbar-0.0.1.tar.gz   -> libbaz == 0.0.1
# |   |-- libbaz-0.0.1.tar.gz   -> libfox
# |   |-- libbaz-0.0.3.tar.gz   -> libfoo
# |   |-- libbox-0.0.1.tar.gz   -> libbaz
# |   |-- libfix-0.0.1.tar.gz
# |   |-- libfoo-0.0.1.tar.gz   -> libfix
# |   |-- libfox-0.0.1.tar.gz
# |   `-- repositories.manifest
# |
# |-- t0b
# |   |-- libbar-0.0.2.tar.gz   -> libbaz <= 0.0.2
# |   |-- libbaz-0.0.2.tar.gz   -> libfoo
# |   |-- libbiz-0.0.2.tar.gz   -> libbaz <= 0.0.3
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t0c
# |   |-- libbar-0.0.3.tar.gz   -> libbaz
# |   |-- libbar-1.0.0.tar.gz   -> libfoo
# |   |-- libbaz-0.0.3.tar.gz   -> libfoo
# |   |-- libbaz-0.0.4.tar.gz
# |   |-- libbaz-0.1.0.tar.gz
# |   |-- libbox-0.0.1.tar.gz   -> libbaz
# |   |-- libfix-0.0.3.tar.gz   -> libbaz >= 0.0.3
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t0d
# |   |-- libbiz-0.0.1.tar.gz   -> libbox, libfox
# |   |-- libbox-0.0.2.tar.gz   -> libfoo == 1.0.0
# |   |-- libfix-0.0.1.tar.gz
# |   |-- libfox-0.0.2.tar.gz   -> libfoo == 0.0.1
# |   |-- libfoo-0.0.1.tar.gz   -> libfix
# |   |-- libfoo-1.0.0.tar.gz
# |   |-- libfox-0.0.1.tar.gz
# |   `-- repositories.manifest
# |
# |-- t1
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t2
# |   |-- libbar-1.0.0.tar.gz   -> libfoo
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t3                        -> t2 (prerequisite repository)
# |   |-- libbaz-1.0.0.tar.gz   -> libbar
# |   |-- libfox-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t4a
# |   |-- libfoo-1.1.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t4b                       -> t4a (prerequisite repository)
# |   |-- libbar-1.1.0.tar.gz   -> libfoo == 1.1.0
# |   `-- repositories.manifest
# |
# |-- t4c                       -> t4b (prerequisite repository)
# |   |-- libbaz-1.1.0.tar.gz   -> libfoo, libbar
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t4d                       -> t4c (complement repository)
# |   |-- libbiz-1.0.0.tar.gz   -> libfox, libfoo, libbaz
# |   |-- libfox-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t4e
# |   |-- libfoo-1.1.0+1.tar.gz
# |   `-- repositories.manifest
# |
# |-- t5
# |   |-- libbar-1.2.0.tar.gz
# |   |-- libbox-1.2.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t6
# |   |-- libBar-2.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t7a
# |   |-- libbaz-1.0.0.tar.gz
# |   |-- libbuild2-bar-1.0.0.tar.gz
# |   |-- foo-1.0.0.tar.gz            -> * libbuild2-bar ^1.0.0, libbaz ^1.0.0
# |   |-- libbuild2-foo-1.0.0.tar.gz  -> libbaz ^1.0.0
# |   |-- libbiz-1.0.0.tar.gz         -> * libbuild2-foo ^1.0.0, * foo ^1.0.0,
# |   |                                  libbaz ^1.0.0
# |   |-- libbuz-1.0.0.tar.gz         -> * libbuild2-foo ^1.0.0, * foo ^1.0.0
# |   |-- libbix-1.0.0.tar.gz         -> libbiz ^1.0.0, libbuz ^1.0.0
# |   |-- libbar-1.0.0.tar.gz         -> * foo ^1.0.0, libbaz ^1.0.0
# |   |-- libbox-1.0.0.tar.gz         -> * foo ^1.0.0, libbaz ^1.0.0
# |   |-- libfax-1.0.0.tar.gz
# |   |-- libfix-1.0.0.tar.gz         -> libbar ^1.0.0, libbox ^1.0.0,
# |   |                                  libfax ^1.0.0
# |   `-- repositories.manifest
# |
# |-- t7b                       -> t7a (complement repository)
# |   |-- libbaz-1.1.0.tar.gz
# |   |-- foo-1.1.0.tar.gz      -> libbaz ^1.1.0
# |   |-- libbar-1.1.0.tar.gz   -> * foo ^1.1.0, libbaz ^1.0.0
# |   |-- libbox-1.1.0.tar.gz   -> * foo ^1.0.0
# |   `-- repositories.manifest
# |
# |-- t8a
# |   |-- libbar-1.0.0.tar.gz
# |   |-- libbaz-1.0.0.tar.gz
# |   |-- libbaz-1.1.0.tar.gz
# |   |-- libbiz-0.1.0.tar.gz
# |   |-- libbiz-1.0.0.tar.gz
# |   |-- libbox-0.1.0.tar.gz
# |   |-- libbox-0.1.1.tar.gz
# |   |-- libbox-1.0.0.tar.gz
# |   |-- foo-1.0.0.tar.gz      -> {libbar libbaz} ^1.0.0
# |   |-- fox-1.0.0.tar.gz      -> libbar ^1.0.0 | libbaz ^1.0.0
# |   |-- fix-1.0.0.tar.gz      -> libbaz ^1.0.0 | libbar ^1.0.0
# |   |-- fax-1.0.0.tar.gz      -> libbar ^1.0.0 ? ($cxx.target.class == 'windows') config.fax.backend=libbar |
# |   |                            libbaz ^1.0.0 ? ($cxx.target.class != 'windows') config.fax.backend=libbaz,
# |   |                            libbiz ? ($config.fax.libbiz) config.fax.extras='[b\i$z]',
# |   |                            libbox ? ($config.fax.libbox && $config.fax.backend == libbaz && $config.fax.extras == '[b\i$z]')
# |   |-- fux                   -> libbiz ? (!$config.fux.libbiz_old) | libbiz ^0.1.0 ? ($config.fux.libbiz_old)
# |   |-- box                   -> libbiz ^1.0.0 config.box.backend=libbiz |
# |   |                            libbox >= 0.1.1 config.box.backend=libbox,
# |   |                            libbaz
# |   `-- repositories.manifest
# |
# |-- t9
# |   |-- libbar-1.0.0.tar.gz
# |   |-- libbaz-1.0.0.tar.gz   -> libbar ^1.0.0
# |   |-- libbox-1.0.0.tar.gz   -> libbar ^1.0.0
# |   |-- foo-1.0.0.tar.gz      -> libbaz, libbox
# |   `-- repositories.manifest
# |
# |-- t10
# |   |-- libfoo-bar-1.0.0.tar.gz   -> libfoo-tests
# |   |-- libfoo-baz-1.0.0.tar.gz   -> libfoo-tests
# |   |-- libfoo-tests-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t11a
# |   |-- libfoo-0.1.0.tar.gz
# |   |-- libfoo-1.0.0.tar.gz
# |   |-- libbar-0.1.0.tar.gz
# |   |-- libbar-1.0.0.tar.gz
# |   |-- libbaz-0.1.0.tar.gz
# |   |-- libbaz-1.0.0.tar.gz
# |   |-- libbox-0.1.0.tar.gz
# |   |-- libbox-1.0.0.tar.gz
# |   |-- foo-0.1.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}}
# |   |-- foo-0.2.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}} | libbar
# |   |-- foo-1.0.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}}
# |   |-- fox-0.1.0.tar.gz      -> libfoo {prefer {config.libfoo.extras=true} accept (false)} |
# |   |                            libbar
# |   |-- fox-0.2.0.tar.gz      -> libfoo {prefer {config.libfoo.extras=false} accept (!$config.libfoo.extras)} |
# |   |                            libfoo {prefer {config.libfoo.extras=true}  accept (true)} |
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- fox-1.0.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}}
# |   |-- fux-1.0.0.tar.gz      -> libfoo
# |   |-- fix-1.0.0.tar.gz      -> foo {require {config.foo.extras=true}}
# |   |-- fex-1.0.0.tar.gz      -> foo, libfoo {require {config.libfoo.extras=true}}
# |   |-- bar-0.1.0.tar.gz      -> libbar == 0.1.0 {require {config.libbar.extras=true}}
# |   |-- bar-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}}
# |   |-- baz-0.1.0.tar.gz      -> {libbar libfoo} == 0.1.0 {require {config.libbar.extras=true config.libfoo.extras=true}}
# |   |-- baz-1.0.0.tar.gz      -> {libbar libfoo} {require {config.libbar.extras=true config.libfoo.extras=true}}
# |   |-- bac-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            libbaz {require {config.libbaz.extras=true}},
# |   |                            libfoo {require {config.libfoo.extras=true}}
# |   |-- bat-1.0.0.tar.gz      -> libbaz {require {config.libbaz.extras=true}}
# |   |-- bas-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            bus {require {config.bus.extras=true}}
# |   |-- bus-1.0.0.tar.gz      -> libaz {require {config.libbox.extras=true}},
# |   |                            foo {require {config.foo.extras=true}}
# |   |-- box-0.1.0.tar.gz      -> libbox {require {config.libbox.extras=true}}
# |   |-- box-1.0.0.tar.gz      -> {libbar libfoo} {require {config.libbar.extras=true config.libfoo.extras=true}} |
# |   |                            libbox
# |   |-- bax-1.0.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}},
# |   |                            {libbox libbar} {require {config.libbox.extras=true config.libbar.extras=true}}
# |   |-- bux-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}}
# |   |-- bix-1.0.0.tar.gz      -> {libbar bar} {require {config.libbar.extras=true config.bar.extras=true}},
# |   |                            bux
# |   |-- bex-1.0.0.tar.gz      -> libbar
# |   |-- boo-1.0.0.tar.gz      -> libbar | libfoo {require {config.libfoo.extras=true}} | libbox
# |   |-- biz-1.0.0.tar.gz      -> boo {require {config.boo.extras=true}}
# |   |-- buz-1.0.0.tar.gz      -> bux {require {config.bux.extras=true}}
# |   |-- buc-1.0.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}},
# |   |                            bux {require {config.bux.extras=true}}
# |   |-- tax-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            libfoo
# |   |-- tex-0.1.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}}
# |   |-- tex-0.2.0.tar.gz      -> libbar,
# |   |                            libfoo {require {config.libfoo.extras=true}}
# |   |-- tex-0.3.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            libfoo {require {config.libfoo.extras=true}}
# |   |-- tex-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            libfoo {require {config.libfoo.extras=true}}
# |   |-- tix-0.1.0.tar.gz
# |   |-- tix-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            tex {require {config.tex.extras=true}}
# |   |-- tiz-1.0.0.tar.gz      -> tex {require {config.tex.extras=true}},
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- toz-0.1.0.tar.gz
# |   |-- toz-0.2.0.tar.gz      -> libfoo {require {config.libfoo.extras=true}},
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- toz-1.0.0.tar.gz      -> libbaz {require {config.libbaz.extras=true}},
# |   |                            libfoo {require {config.libfoo.extras=true}},
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- tez-1.0.0.tar.gz      -> libbox {require {config.libbox.extras=true}},
# |   |                            toz == 0.1.0 {require {config.toz.extras=true}},
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- tux-1.0.0.tar.gz      -> libbox {require {config.libbox.extras=true}},
# |   |                            tix == 0.1.0
# |   |-- dex-1.0.0.tar.gz      -> bar {require {config.bar.extras=true}},
# |   |                            libfoo {require {config.libfoo.extras=true}}
# |   |-- dix-1.0.0.tar.gz      -> libbar {require {config.libbar.extras=true}},
# |   |                            libbox {require {config.libbox.extras=true}},
# |   |                            dox {require {config.dox.extras=true}}
# |   |-- diz-1.0.0.tar.gz      -> dox {require {config.dox.extras=true}},
# |   |                            libbox {require {config.libbox.extras=true}},
# |   |                            libbar {require {config.libbar.extras=true}}
# |   |-- dox-1.0.0.tar.gz      -> dex {require {config.dex.extras=true}}
# |   `-- repositories.manifest
# |
# |-- t12a
# |   |-- libbaz-1.0.0.tar.gz
# |   |-- libbar-0.1.0.tar.gz   -> libbaz
# |   `-- repositories.manifest
# |
# |-- t12b                      -> t12a (prerequisite repository)
# |   |-- libbaz-0.1.0.tar.gz
# |   |-- libbar-1.0.0.tar.gz   -> libbaz == 0.1.0
# |   |-- foo-0.1.0.tar.gz
# |   |-- foo-1.0.0.tar.gz      -> libbar
# |   |-- bar-1.0.0.tar.gz      -> libbar == 0.1.0
# |   |-- baz-0.1.0.tar.gz      -> libbaz
# |   |-- baz-1.0.0.tar.gz      -> libbaz == 1.0.0
# |   `-- repositories.manifest
# |
# |-- t13a
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- biz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t13b
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- biz-1.0.0.tar.gz      -> liba {require {...}}
# |   `-- repositories.manifest
# |
# |-- t13c
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {require {...}}
# |   `-- repositories.manifest
# |
# |-- t13d
# |   |-- liba-0.1.0.tar.gz
# |   |-- libb-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)},
# |   |                            libb ? (...)
# |   |-- baz-1.0.0.tar.gz      -> bar, liba {require {...}}
# |   `-- repositories.manifest
# |
# |-- t13e
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)},
# |   |                            bar ? (...),
# |   |                            biz
# |   |-- biz-1.0.0.tar.gz      -> liba {require {...}}
# |   `-- repositories.manifest
# |
# |-- t13f
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t13g
# |   |-- liba-0.1.0.tar.gz
# |   |-- libb-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)},
# |   |                            libb {prefer {...} accept (...) reflect (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)},
# |   |                            libb ? (...)
# |   |-- biz-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)},
# |   |                            libb {prefer {...} accept (...) reflect (...)}
# |   |-- box-1.0.0.tar.gz      -> liba {prefer {...} accept (...) reflect (...)},
# |   |                            libb {prefer {...} accept (...) reflect (...)}
# |   `-- repositories.manifest
# |
# |-- t13h
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t13i
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {require {...} reflect (...)}
# |   `-- repositories.manifest
# |
# |-- t13j
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {require {...}}
# |   |-- biz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t13k
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t13l
# |   |-- liba-0.1.0.tar.gz
# |   |-- libb-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {require {...}},
# |   |                            libb ? (...)
# |   |-- baz-1.0.0.tar.gz      -> liba {prefer {...} accept (...)},
# |   |                            libb ? (...)
# |   `-- repositories.manifest
# |
# |-- t13m
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {require {...}}
# |   |-- baz-1.0.0.tar.gz      -> liba {require {...}},
# |   |                            bar  { enable (...) reflect {...}}
# |   |-- biz-1.0.0.tar.gz      -> liba {require {...}}
# |   |-- bix-1.0.0.tar.gz      -> liba {require {...}}
# |   |-- box-1.0.0.tar.gz      -> liba {require {...}}
# |   `-- repositories.manifest
# |
# |-- t13n
# |   |-- liba-0.1.0.tar.gz
# |   |-- libb-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {reflect {...}},
# |   |                            libb {reflect {...}}
# |   `-- repositories.manifest
# |
# |-- t13o
# |   |-- liba-0.1.0.tar.gz
# |   |-- bar-1.0.0.tar.gz      -> liba {reflect {...}}
# |   |-- baz-1.0.0.tar.gz      -> bar  {require {...}}
# |   |-- biz-1.0.0.tar.gz      -> bar  {prefer {...} accept (...)}
# |   |-- bix-1.0.0.tar.gz      -> bar  {prefer {...} accept (...)}
# |   `-- repositories.manifest
# |
# |-- t14a
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14b
# |   |-- libfoo-1.1.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14c
# |   |-- libfoo-1.1.0+1.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14d
# |   |-- libfoo-1.1.0+2.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14e
# |   |-- libfoo-1.1.0+3.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14f
# |   |-- libfoo-1.1.1.tar.gz
# |   `-- repositories.manifest
# |
# |-- t14i
# |   |-- libfoo-1.2.0.tar.gz
# |   `-- repositories.manifest
# |
# `-- git
#     |-- libbar.git            -> style-basic.git (prerequisite repository)
#     |-- libbaz.git
#     `-- style-basic.git

posix = ($cxx.target.class != 'windows')

# Prepare repositories used by tests if running in the local mode.
#
+if! $remote
  rep_create += 2>!

  cp -r $src/t0a  $out/t0a  && $rep_create $out/t0a  &$out/t0a/packages.manifest
  cp -r $src/t0b  $out/t0b  && $rep_create $out/t0b  &$out/t0b/packages.manifest
  cp -r $src/t0c  $out/t0c  && $rep_create $out/t0c  &$out/t0c/packages.manifest
  cp -r $src/t0d  $out/t0d  && $rep_create $out/t0d  &$out/t0d/packages.manifest
  cp -r $src/t1   $out/t1   && $rep_create $out/t1   &$out/t1/packages.manifest
  cp -r $src/t2   $out/t2   && $rep_create $out/t2   &$out/t2/packages.manifest
  cp -r $src/t3   $out/t3   && $rep_create $out/t3   &$out/t3/packages.manifest
  cp -r $src/t4a  $out/t4a  && $rep_create $out/t4a  &$out/t4a/packages.manifest
  cp -r $src/t4b  $out/t4b  && $rep_create $out/t4b  &$out/t4b/packages.manifest
  cp -r $src/t4c  $out/t4c  && $rep_create $out/t4c  &$out/t4c/packages.manifest
  cp -r $src/t4d  $out/t4d  && $rep_create $out/t4d  &$out/t4d/packages.manifest
  cp -r $src/t4e  $out/t4e  && $rep_create $out/t4e  &$out/t4e/packages.manifest
  cp -r $src/t5   $out/t5   && $rep_create $out/t5   &$out/t5/packages.manifest
  cp -r $src/t6   $out/t6   && $rep_create $out/t6   &$out/t6/packages.manifest
  cp -r $src/t7a  $out/t7a  && $rep_create $out/t7a  &$out/t7a/packages.manifest
  cp -r $src/t7b  $out/t7b  && $rep_create $out/t7b  &$out/t7b/packages.manifest
  cp -r $src/t8a  $out/t8a  && $rep_create $out/t8a  &$out/t8a/packages.manifest
  cp -r $src/t9   $out/t9   && $rep_create $out/t9   &$out/t9/packages.manifest
  cp -r $src/t10  $out/t10  && $rep_create $out/t10  &$out/t10/packages.manifest
  cp -r $src/t11a $out/t11a && $rep_create $out/t11a &$out/t11a/packages.manifest
  cp -r $src/t12a $out/t12a && $rep_create $out/t12a &$out/t12a/packages.manifest
  cp -r $src/t12b $out/t12b && $rep_create $out/t12b &$out/t12b/packages.manifest
  cp -r $src/t13a $out/t13a && $rep_create $out/t13a &$out/t13a/packages.manifest
  cp -r $src/t13b $out/t13b && $rep_create $out/t13b &$out/t13b/packages.manifest
  cp -r $src/t13c $out/t13c && $rep_create $out/t13c &$out/t13c/packages.manifest
  cp -r $src/t13d $out/t13d && $rep_create $out/t13d &$out/t13d/packages.manifest
  cp -r $src/t13e $out/t13e && $rep_create $out/t13e &$out/t13e/packages.manifest
  cp -r $src/t13f $out/t13f && $rep_create $out/t13f &$out/t13f/packages.manifest
  cp -r $src/t13g $out/t13g && $rep_create $out/t13g &$out/t13g/packages.manifest
  cp -r $src/t13h $out/t13h && $rep_create $out/t13h &$out/t13h/packages.manifest
  cp -r $src/t13i $out/t13i && $rep_create $out/t13i &$out/t13i/packages.manifest
  cp -r $src/t13j $out/t13j && $rep_create $out/t13j &$out/t13j/packages.manifest
  cp -r $src/t13k $out/t13k && $rep_create $out/t13k &$out/t13k/packages.manifest
  cp -r $src/t13l $out/t13l && $rep_create $out/t13l &$out/t13l/packages.manifest
  cp -r $src/t13m $out/t13m && $rep_create $out/t13m &$out/t13m/packages.manifest
  cp -r $src/t13n $out/t13n && $rep_create $out/t13n &$out/t13n/packages.manifest
  cp -r $src/t13o $out/t13o && $rep_create $out/t13o &$out/t13o/packages.manifest
  cp -r $src/t14a $out/t14a && $rep_create $out/t14a &$out/t14a/packages.manifest
  cp -r $src/t14b $out/t14b && $rep_create $out/t14b &$out/t14b/packages.manifest
  cp -r $src/t14c $out/t14c && $rep_create $out/t14c &$out/t14c/packages.manifest
  cp -r $src/t14d $out/t14d && $rep_create $out/t14d &$out/t14d/packages.manifest
  cp -r $src/t14e $out/t14e && $rep_create $out/t14e &$out/t14e/packages.manifest
  cp -r $src/t14f $out/t14f && $rep_create $out/t14f &$out/t14f/packages.manifest
  cp -r $src/t14i $out/t14i && $rep_create $out/t14i &$out/t14i/packages.manifest

  # Create git repositories.
  #
  $git_extract $src/git/style-basic.tar
  $git_extract $src/git/libbar.tar &$out_git/state0/***
  $git_extract $src/git/libbaz.tar &$out_git/state1/***
end

config_cxx = [cmdline] config.cxx=$quote($recall($cxx.path) $cxx.config.mode, true)

cfg_create    += 2>!
cfg_link      += 2>!
pkg_configure += -d cfg 2>!
pkg_disfigure += -d cfg
pkg_drop      += -d cfg --yes 2>!
pkg_fetch     += -d cfg 2>!
pkg_purge     += -d cfg
pkg_status    += -d cfg
pkg_unpack    += -d cfg 2>!
rep_add       += -d cfg 2>!
rep_remove    += -d cfg 2>!
rep_fetch     += -d cfg --auth all --trust-yes 2>!
rep_list      += -d cfg

# Let's disable the progress indication that complicates stderr output
# validation.
#
test.options += --no-progress

# Disable the use of the system package manager.
#
test.arguments += --sys-no-query

: libfoo
:
: Test building different versions of libfoo.
:
{
  test.arguments += --print-only

  : no-name
  :
  $clone_root_cfg;
  $* 2>>EOE != 0
    error: package name argument expected
      info: run 'bpkg help pkg-build' for more information
    EOE

  : version
  :
  {
    : empty
    :
    $clone_root_cfg;
    $* libfoo/ 2>>EOE != 0
      error: empty package version in 'libfoo/'
      EOE

    : earliest
    :
    $clone_root_cfg;
    $* libfoo/1.0.0- 2>>EOE != 0
      error: invalid package version '1.0.0-' in 'libfoo/1.0.0-': earliest version
      EOE

    : earliest-constraint
    :
    $clone_root_cfg;
    $* -- 'libfoo == 1.0.0-' 2>>EOE != 0
      error: invalid package version constraint '== 1.0.0-' in 'libfoo == 1.0.0-': invalid version: equal version endpoints are earliest
      EOE

    : stub
    :
    $clone_root_cfg;
    $* libfoo/0+1 2>>EOE != 0
      error: invalid package version '0+1' in 'libfoo/0+1': stub version
      EOE

    : stub-constraint
    :
    $clone_root_cfg;
    $* -- 'libfoo [0 1]' 2>>EOE != 0
      error: invalid package version constraint '[0 1]' in 'libfoo [0 1]': endpoint is a stub
      EOE
  }

  : unknown-package
  :
  $clone_root_cfg;
  $* libfoo 2>>/EOE != 0
    error: unknown package libfoo
      info: configuration cfg/ has no repositories
      info: use 'bpkg rep-add' to add a repository
    EOE

  : unknown-package-ver
  :
  $clone_root_cfg;
  $* libfoo/1.0.0 2>>/EOE != 0
    error: unknown package libfoo
      info: configuration cfg/ has no repositories
      info: use 'bpkg rep-add' to add a repository
    EOE

  : unknown-package-constraint
  :
  $clone_root_cfg;
  $* 'libfoo>1.0.0' 2>>/EOE != 0
    error: unknown package libfoo
      info: configuration cfg/ has no repositories
      info: use 'bpkg rep-add' to add a repository
    EOE

  : mask-repository-not-found
  :
  $clone_root_cfg;
  $* --mask-repository 'https://example.com/1' libfoo 2>>EOE != 0
    error: repository 'https://example.com/1' cannot be masked: not found
    EOE

  : mask-repository-empty
  :
  $clone_root_cfg;
  $* --mask-repository '' libfoo 2>>EOE != 0
    error: repository '' cannot be masked: invalid repository location: empty URL
    EOE

  : mask-repository-uuid-db-not-found
  :
  $clone_root_cfg;
  $* --mask-repository-uuid '00000000-0000-0000-0000-123456789012=repo' libfoo 2>>/EOE != 0
    error: configuration repository '00000000-0000-0000-0000-123456789012=repo' cannot be masked: no configuration with uuid 00000000-0000-0000-0000-123456789012 is linked with cfg/
    EOE

  : mask-repository-uuid-empty
  :
  $clone_root_cfg;
  $* --mask-repository-uuid "$cfg_uuid=" libfoo 2>>EOE != 0
    error: configuration repository '00000000-0000-0000-0000-000000000001=' cannot be masked: invalid repository location '': empty URL
    EOE

  : mask-repository-uuid-not-found
  :
  $clone_root_cfg;
  $* --mask-repository-uuid "$cfg_uuid=https://example.com/1" libfoo 2>>EOE != 0
    error: configuration repository '00000000-0000-0000-0000-000000000001=https://example.com/1' cannot be masked: repository location 'https://example.com/1' not found in configuration 00000000-0000-0000-0000-000000000001
    EOE

  : archive
  :
  $clone_root_cfg;
  $* $src/libfoo-1.1.0.tar.gz >'new libfoo/1.1.0'

  : dir
  :
  $clone_root_cfg;
  $* $src/libfoo-1.1.0/ >'new libfoo/1.1.0'

  : unpacked-dir
  :
  {
    $clone_root_cfg && $pkg_unpack -e $src/libfoo-1.1.0;

    $* libfoo               >'update libfoo/1.1.0';
    $* libfoo/1.1.0         >'update libfoo/1.1.0';
    $* -- 'libfoo == 1.1.0' >'update libfoo/1.1.0';
    $* libfoo libfoo        >'update libfoo/1.1.0';

    $* libfoo libfoo/1.1.0 2>>EOE != 0;
      error: duplicate package libfoo
        info: first mentioned as libfoo
        info: second mentioned as libfoo/1.1.0
      EOE

    $* libfoo/1.1.0 libfoo 2>>EOE != 0;
      error: duplicate package libfoo
        info: first mentioned as libfoo/1.1.0
        info: second mentioned as libfoo
      EOE

    $* libfoo/1.1.0 libfoo/1.1.0 >'update libfoo/1.1.0';

    $* libfoo/1.0.0 2>>/EOE != 0;
      error: unknown package libfoo
        info: configuration cfg/ has no repositories
        info: use 'bpkg rep-add' to add a repository
      EOE

    $pkg_purge libfoo 2>'purged libfoo/1.1.0'
  }

  : t1
  :
  {
    +$clone_root_cfg && $rep_add $rep/t1 && $rep_fetch

    : downgrade
    :
    {
      $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;

      $* libfoo       >'update libfoo/1.1.0';
      $* libfoo/1.0.0 >'downgrade libfoo/1.0.0';

      $* libfoo/0.0.1 2>>EOE != 0;
        error: libfoo/0.0.1 is not available in source
          info: specify sys:libfoo/0.0.1 if it is available from the system
        EOE

      $pkg_purge libfoo 2>'purged libfoo/1.1.0'
    }

    : downgrade-constraint
    :
    {
      $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;

      $* libfoo         >'update libfoo/1.1.0';
      $* 'libfoo<1.1.0' >'downgrade libfoo/1.0.0';

      $* 'libfoo<1.0.0' 2>>EOE != 0;
        error: 'libfoo < 1.0.0' is not available in source
          info: specify sys:libfoo/... if it is available from the system
        EOE

      $pkg_purge libfoo 2>'purged libfoo/1.1.0'
    }

    : upgrade
    :
    {
      $clone_cfg;
      $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo;
      $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix;

      $* libfoo >'upgrade libfoo/1.0.0';

      $* libfoo/0.0.1 >>EOE;
        update libfix/0.0.1 (required by libfoo)
        update libfoo/0.0.1
        EOE

      $* libfoo/1.1.0 2>>EOE != 0;
        error: libfoo/1.1.0 is not available in source
          info: specify sys:libfoo/1.1.0 if it is available from the system
        EOE

      $pkg_purge libfoo 2>'purged libfoo/0.0.1';
      $pkg_purge libfix 2>'purged libfix/0.0.1'
    }

    : upgrade-failure
    :
    {
      $clone_cfg;

      $* libfoo       >'new libfoo/1.0.0';
      $* libfoo/1.0.0 >'new libfoo/1.0.0';

      $* libfoo/1.1.0 2>>EOE != 0
        error: libfoo/1.1.0 is not available in source
          info: specify sys:libfoo/1.1.0 if it is available from the system
        EOE
    }
  }

  : revision
  :
  {
    +$clone_root_cfg
    +$rep_add $rep/t4e && $rep_fetch

    : latest
    :
    {
      $clone_cfg;

      $* libfoo/1.1.0 >>EOO
        new libfoo/1.1.0+1
        EOO
    }

    : zero
    :
    {
      $clone_cfg;

      $* libfoo/1.1.0+0 >>EOO
        new libfoo/1.1.0
        EOO
    }
  }
}

: libbar-libfoo
:
: Test building libbar that depends on libfoo.
:
{
  test.arguments += --print-only

  : unknown-dependency
  :
  $clone_root_cfg;
  $* $src/libbar-1.0.0.tar.gz 2>>EOE != 0
    error: no package available for dependency libfoo of package libbar
    info: while satisfying libbar/1.0.0
    EOE

  : unknown-dependency-config
  :
  : As above but with a linked configuration.
  :
  $clone_root_cfg;
  $cfg_create -d cfg2 &cfg2/***;
  $cfg_link -d cfg cfg2;
  $* $src/libbar-1.0.0.tar.gz +{ --config-id 1 } 2>>~%EOE% != 0
    %error: no package available for dependency libfoo of package libbar \[cfg2.\]%
    %info: while satisfying libbar/1.0.0 \[cfg2.\]%
    EOE

  : t2
  :
  {
    +$clone_root_cfg && $rep_add $rep/t2 && $rep_fetch

    : build-dependency
    :
    {
      $clone_cfg;

      $* libbar >>EOO;
        new libfoo/1.0.0 (required by libbar)
        new libbar/1.0.0
        EOO

      $* libbar libfoo >>EOO;
        new libfoo/1.0.0
        new libbar/1.0.0
        EOO

      $* libbar libfoo/1.0.0 >>EOO;
        new libfoo/1.0.0
        new libbar/1.0.0
        EOO

      $* libbar libfoo libbar/1.0.0 2>>EOE != 0;
        error: duplicate package libbar
          info: first mentioned as libbar
          info: second mentioned as libbar/1.0.0
        EOE

      $* libbar libfoo/1.1.0 2>>EOE != 0
        error: libfoo/1.1.0 is not available in source
          info: specify sys:libfoo/1.1.0 if it is available from the system
        EOE
    }

    : upgrade-dependency
    :
    {
      $clone_cfg;
      $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo;
      $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix;

      $* libbar >>EOO;
        update libfix/0.0.1 (required by libfoo)
        update libfoo/0.0.1 (required by libbar)
        new libbar/1.0.0
        EOO

      $* libbar libfoo >>EOO;
        upgrade libfoo/1.0.0
        new libbar/1.0.0
        EOO

      $* libbar libfoo/0.0.1 >>EOO;
        update libfix/0.0.1 (required by libfoo)
        update libfoo/0.0.1
        new libbar/1.0.0
        EOO

      $pkg_purge libfoo 2>'purged libfoo/0.0.1';
      $pkg_purge libfix 2>'purged libfix/0.0.1'
    }

    : downgrade-dependency
    :
    {
      $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;

      $* libbar >>EOO;
        update libfoo/1.1.0 (required by libbar)
        new libbar/1.0.0
        EOO

      $* libbar libfoo >>EOO;
        update libfoo/1.1.0
        new libbar/1.0.0
        EOO

      $* libbar libfoo/1.0.0 >>EOO;
        downgrade libfoo/1.0.0
        new libbar/1.0.0
        EOO

      $pkg_purge libfoo 2>'purged libfoo/1.1.0'
    }
  }

  : dependency-revision
  :
  {
    +$clone_root_cfg && $rep_add $rep/t4e && $rep_fetch

    : latest
    :
    {
      $clone_cfg;

      $* libbar/1.1.0 >>EOO
        new libfoo/1.1.0+1 (required by libbar)
        new libbar/1.1.0
        EOO
    }

    : latest-config
    :
    : As above but with a linked configuration.
    :
    {
      $clone_cfg;
      $cfg_create -d cfg2 &cfg2/***;
      $cfg_link -d cfg cfg2;

      $* "libbar/1.1.0@$rep/t4e" +{ --config-id 1 } --trust-yes >>~%EOO% 2>!
        %new libfoo/1.1.0\+1 \[cfg2.\] \(required by libbar \[cfg2.\]\)%
        %new libbar/1.1.0 \[cfg2.\]%
        EOO
    }

    : zero
    :
    {
      $clone_cfg;

      $* libbar/1.1.1 >>EOO
        new libfoo/1.1.0 (required by libbar)
        new libbar/1.1.1
        EOO
    }
  }
}

: libbaz-libbar
:
: Test building libbaz that depends on libbar; libbar is in prerequisite
: repository.
:
{
  test.arguments += --print-only

  : t3
  :
  {
    +$clone_root_cfg && $rep_add $rep/t3 && $rep_fetch

    : prerequisites-build-failure
    :
    : Fail to build packages that are only in prerequisite repository.
    :
    {
      $clone_cfg;

      $* libfoo 2>>EOE != 0;
        error: unknown package libfoo
        EOE

      $* libbar 2>>EOE != 0;
        error: unknown package libbar
        EOE

      $* libbaz libbar 2>>EOE != 0
        error: unknown package libbar
        EOE
    }

    : prerequisites-build
    :
    $clone_cfg;
    $* libbaz >>EOO
      new libfoo/1.0.0 (required by libbar)
      new libbar/1.0.0 (required by libbaz)
      new libbaz/1.0.0
      EOO

    : different-build-order
    :
    {
      +$clone_cfg && $rep_add $rep/t2 && $rep_fetch

      : fox-foo
      :
      $clone_cfg;
      $* libfox libfoo >>EOO
        new libfox/1.0.0
        new libfoo/1.0.0
        EOO

      : foo-fox
      :
      $clone_cfg;
      $* libfoo libfox >>EOO
        new libfoo/1.0.0
        new libfox/1.0.0
        EOO

      : baz-foo
      :
      $clone_cfg;
      $* libbaz libfoo >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : foo-baz
      :
      $clone_cfg;
      $* libfoo libbaz >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : baz-fox
      :
      $clone_cfg;
      $* libbaz libfox >>EOO
        new libfoo/1.0.0 (required by libbar)
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        new libfox/1.0.0
        EOO

      : fox-baz
      :
      $clone_cfg;
      $* libfox libbaz >>EOO
        new libfox/1.0.0
        new libfoo/1.0.0 (required by libbar)
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : fox-foo-baz
      :
      $clone_cfg;
      $* libfox libfoo libbaz >>EOO
        new libfox/1.0.0
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : fox-baz-foo
      :
      $clone_cfg;
      $* libfox libbaz libfoo >>EOO
        new libfox/1.0.0
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : foo-fox-baz
      :
      $clone_cfg;
      $* libfoo libfox libbaz >>EOO
        new libfoo/1.0.0
        new libfox/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : foo-baz-fox
      :
      $clone_cfg;
      $* libfoo libbaz libfox >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        new libfox/1.0.0
        EOO

      : baz-fox-foo
      :
      : This one is contradictory: baz before fox but fox before foo.
      :
      $clone_cfg;
      $* libbaz libfox libfoo >>EOO
        new libfox/1.0.0
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        EOO

      : baz-foo-fox
      :
      $clone_cfg;
      $* libbaz libfoo libfox >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0 (required by libbaz)
        new libbaz/1.0.0
        new libfox/1.0.0
        EOO

      : baz-foo-bar
      :
      $clone_cfg;
      $* libbaz libfoo libbar >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0
        new libbaz/1.0.0
        EOO

      : baz-bar-foo
      :
      $clone_cfg;
      $* libbaz libbar libfoo >>EOO
        new libfoo/1.0.0
        new libbar/1.0.0
        new libbaz/1.0.0
        EOO
    }
  }
}

: libbaz-libfoo-libbar
:
: Test building libbaz that depends on libfoo and libbar; libbar depends on
: libfoo == 1.1.0.
:
{
  test.arguments += --print-only

  : t4c
  :
  {
    +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch

    : baz
    :
    $clone_cfg;
    $* libbaz >>EOO
      new libfoo/1.1.0 (required by libbar, libbaz)
      new libbar/1.1.0 (required by libbaz)
      new libbaz/1.1.0
      EOO

    : foo-baz
    :
    $clone_cfg;
    $* libfoo libbaz >>EOO
      new libfoo/1.1.0
      new libbar/1.1.0 (required by libbaz)
      new libbaz/1.1.0
      EOO

    : unable-satisfy
    :
    $clone_cfg;
    $* libfoo/1.0.0 libbaz 2>>EOE != 0
      error: unable to satisfy constraints on package libfoo
        info: command line depends on (libfoo == 1.0.0)
        info: libbar depends on (libfoo == 1.1.0)
        info: available libfoo/1.0.0
        info: available libfoo/1.1.0
        info: explicitly specify libfoo version to manually satisfy both constraints
      info: while satisfying libbar/1.1.0
      info: while satisfying libbaz/1.1.0
      EOE

    : unable-satisfy-config
    :
    : As above but with a linked configuration.
    :
    $clone_cfg;
    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;
    $rep_add -d cfg2 $rep/t4c && $rep_fetch -d cfg2;
    $* libbaz ?libbar +{ --config-id 1 } libfoo/1.0.0 +{ --config-id 1 } 2>>~%EOE% != 0
      error: unable to satisfy constraints on package libfoo
        info: command line depends on (libfoo == 1.0.0)
      %  info: libbar \[cfg2.\] depends on \(libfoo == 1.1.0\)%
        info: available libfoo/1.0.0
        info: available libfoo/1.1.0
        info: explicitly specify libfoo version to manually satisfy both constraints
      %info: while satisfying libbar/1.1.0 \[cfg2.\]%
      info: while satisfying libbaz/1.1.0
      EOE

    : not-available
    :
    $clone_cfg;
    $* libfoo/1.1.0 libbaz 2>>EOE != 0
      error: libfoo/1.1.0 is not available in source
        info: specify sys:libfoo/1.1.0 if it is available from the system
      EOE

    : upgrade
    :
    {
      $clone_cfg;
      $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo;
      $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix;

      $* libbaz >>EOO;
        upgrade libfoo/1.1.0 (required by libbar, libbaz)
        new libbar/1.1.0 (required by libbaz)
        new libbaz/1.1.0
        EOO

      $pkg_purge libfoo 2>'purged libfoo/0.0.1';
      $pkg_purge libfix 2>'purged libfix/0.0.1'
    }

    : downgrade
    :
    {
      $clone_cfg;
      $pkg_fetch -e $src/libfoo-1.2.0.tar.gz && $pkg_unpack libfoo;

      $* libbaz >>EOO;
        downgrade libfoo/1.1.0 (required by libbar, libbaz)
        new libbar/1.1.0 (required by libbaz)
        new libbaz/1.1.0
        EOO

      $rep_add $rep/t4a && $rep_fetch;

      $* libfoo/1.1.0 libbaz >>EOO;
        downgrade libfoo/1.1.0
        new libbar/1.1.0 (required by libbaz)
        new libbaz/1.1.0
        EOO

      $pkg_purge libfoo 2>'purged libfoo/1.2.0'
    }

    : unable-downgrade
    :
    : Test that dependent prevents up/downgrade that would break dependency
    : constraints.
    :
    {
      $clone_cfg;

      $rep_add $rep/t4a $rep/t4b && $rep_fetch;
      $pkg_build libfoo/1.1.0 libbar/1.1.0 -d cfg 2>!;

      $* libfoo-1.2.0.tar.gz 2>>EOE != 0;
        error: unknown package libfoo-1.2.0.tar.gz
        EOE

      $* libfoo/1.0.0 2>>EOE != 0;
        error: unable to downgrade package libfoo/1.1.0 to 1.0.0
          info: because package libbar depends on (libfoo == 1.1.0)
          info: explicitly request up/downgrade of package libbar
          info: or explicitly specify package libfoo version to manually satisfy these constraints
        EOE

      $* libfoo/1.1.0 --keep-unused >'update libfoo/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : unable-downgrade-config
    :
    : As above but with a linked configuration.
    :
    {
      $clone_cfg;
      $cfg_create -d cfg2 &cfg2/***;
      $rep_add -d cfg2 $rep/t4a $rep/t4b $rep/t4c && $rep_fetch -d cfg2;
      $cfg_link -d cfg2 cfg;

      $rep_add $rep/t4a $rep/t4b && $rep_fetch;
      $pkg_build libfoo/1.1.0 libbar/1.1.0 -d cfg 2>!;

      $* libfoo-1.2.0.tar.gz 2>>EOE != 0;
        error: unknown package libfoo-1.2.0.tar.gz
        EOE

      test.arguments = $regex.apply($test.arguments, cfg, cfg2);

      $* libfoo/1.0.0 +{ --config-id 1 } 2>>~%EOE% != 0;
        %error: unable to downgrade package libfoo/1.1.0 \[cfg.\] to 1.0.0%
        %  info: because package libbar \[cfg.\] depends on \(libfoo == 1.1.0\)%
          info: explicitly request up/downgrade of package libbar
          info: or explicitly specify package libfoo version to manually satisfy these constraints
        EOE

      test.arguments = $regex.apply($test.arguments, cfg2, cfg);

      $* libfoo/1.1.0 --keep-unused >'update libfoo/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : able-downgrade
    :
    : Similar to the above unable-downgrade, but this time libfoo and libbar
    : are configured manually and so are not held. Thus, libfoo downgrades
    : successfully since libbar is just dropped having no dependents.
    :
    {
      $clone_cfg;

      $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo && $pkg_configure libfoo;
      $pkg_fetch libbar/1.1.0 && $pkg_unpack libbar && $pkg_configure libbar;

      $* libfoo/1.0.0 >>EOO;
        downgrade libfoo/1.0.0
        drop libbar/1.1.0 (unused)
        EOO

      $pkg_drop libbar libfoo
    }

    : able-downgrade-config
    :
    : As above but with a linked configuration.
    :
    {
      $clone_cfg;
      $cfg_create -d cfg2 &cfg2/***;
      $rep_add -d cfg2 $rep/t4c && $rep_fetch -d cfg2;
      $cfg_link -d cfg2 cfg;

      $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo && $pkg_configure libfoo;
      $pkg_fetch libbar/1.1.0 && $pkg_unpack libbar && $pkg_configure libbar;

      test.arguments = $regex.apply($test.arguments, cfg, cfg2);

      $* libfoo/1.0.0 +{ --config-id 1 } >>~%EOO%;
        %downgrade libfoo/1.0.0 \[cfg.\]%
        %drop libbar/1.1.0 \[cfg.\] \(unused\)%
        EOO

      $pkg_drop libbar libfoo
    }
  }

  : dependent-reconfiguration
  :
  {
    test.arguments += --keep-unused

    +$clone_root_cfg

    +$pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo
    +$pkg_configure libfoo

    +$pkg_fetch -e $src/libbar-1.0.0.tar.gz && $pkg_unpack libbar
    +$pkg_configure libbar

    +$pkg_fetch -e $src/libbaz-1.1.0.tar.gz && $pkg_unpack libbaz
    +$pkg_configure libbaz

    +$rep_add $rep/t4a && $rep_add $rep/t4b && $rep_fetch

    : bar
    :
    : Only libbar/1.1.0 (that we are upgrading to) requires libfoo/1.1.0.
    : libbaz, that depends on libfoo and libbar, is happy with any version of
    : its dependencies.
    :
    $clone_cfg;
    $* libbar >>EOO
      upgrade libfoo/1.1.0 (required by libbar)
      upgrade libbar/1.1.0
      reconfigure libbaz (dependent of libbar, libfoo)
      EOO

    : foo
    :
    $clone_cfg;
    $* libfoo >>EOO
      upgrade libfoo/1.1.0
      reconfigure libbar (dependent of libfoo)
      reconfigure libbaz (dependent of libbar, libfoo)
      EOO

    : foo-bar
    :
    $clone_cfg;
    $* libfoo libbar/1.0.0 >>EOO
      upgrade libfoo/1.1.0
      reconfigure/update libbar/1.0.0
      reconfigure libbaz (dependent of libbar, libfoo)
      EOO

    : bar-foo
    :
    $clone_cfg;
    $* libbar/1.0.0 libfoo >>EOO
      upgrade libfoo/1.1.0
      reconfigure/update libbar/1.0.0
      reconfigure libbaz (dependent of libbar, libfoo)
      EOO

    : baz-foo
    :
    $clone_cfg;
    $* libbaz libfoo >>EOO
      upgrade libfoo/1.1.0
      reconfigure libbar (dependent of libfoo)
      reconfigure/update libbaz/1.1.0
      EOO

    : baz-foo-1.0.0
    :
    $clone_cfg;
    $* libbaz libfoo/1.0.0 >>EOO
      update libfoo/1.0.0
      update libbaz/1.1.0
      EOO

    -$pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'
    -$pkg_purge     libbaz 2>'purged libbaz/1.1.0'

    -$pkg_disfigure libbar 2>'disfigured libbar/1.0.0'
    -$pkg_purge     libbar 2>'purged libbar/1.0.0'

    -$pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'
    -$pkg_purge     libfoo 2>'purged libfoo/1.0.0'
  }
}

# Note that when we fetch a package from remote repository the bpkg stderr
# contains fetch program progress output, that comes prior the informational
# message.
#

: actual-build
:
{
  test.arguments += --yes

  : with-dependencies
  :
  {
    $clone_root_cfg && $rep_add $rep/t4c && $rep_fetch;

    $* libbaz 2>>~%EOE%;
      fetched libfoo/1.1.0
      unpacked libfoo/1.1.0
      fetched libbar/1.1.0
      unpacked libbar/1.1.0
      fetched libbaz/1.1.0
      unpacked libbaz/1.1.0
      configured libfoo/1.1.0
      configured libbar/1.1.0
      configured libbaz/1.1.0
      %info: .+ is up to date%
      updated libbaz/1.1.0
      EOE

    $pkg_status libfoo/1.1.0 >'libfoo configured 1.1.0';
    $pkg_status libbar/1.1.0 >'libbar configured 1.1.0';
    $pkg_status libbaz/1.1.0 >'!libbaz configured 1.1.0';

    $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
    $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

    $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
    $pkg_purge     libbar 2>'purged libbar/1.1.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }

  : hold-fs-fetched
  :
  {
    : direct
    :
    {
      $clone_root_cfg;

      $* $src/libfoo-1.0.0.tar.gz 2>>~%EOE%;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured !1.0.0';

      $* $src/libfoo-1.1.0/ 2>>~%EOE%;
        disfigured libfoo/1.0.0
        using libfoo/1.1.0 (external)
        configured libfoo/1.1.0
        %info: .+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status libfoo >'!libfoo configured !1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : pre-fetch
    :
    {
      $clone_root_cfg;
      $pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo;
      $pkg_configure libfoo;

      $pkg_status libfoo >'libfoo configured 1.0.0';

      $* libfoo 2>>~%EOE%;
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.0.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
    }
  }

  : hold-repo-fetched
  :
  {
    +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch

    : package-version
    :
    {
      $clone_cfg;

      $* libfoo 2>>~%EOE%;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]';

      $* libfoo/1.0.0 2>>~%EOE%;
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
    }

    : version
    :
    {
      $clone_cfg;

      $* libfoo/1.0.0 2>>~%EOE%;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
    }

    : not-held
    :
    {
      $clone_cfg;

      $* libbaz 2>>~%EOE%;
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        configured libfoo/1.1.0
        configured libbar/1.1.0
        configured libbaz/1.1.0
        %info: .+ is up to date%
        updated libbaz/1.1.0
        EOE

      $pkg_status libfoo >'libfoo configured 1.1.0';

      $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
      $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : forcing-upgrade-unheld
    :
    {
      $clone_cfg;

      $* libfoo 2>>~%EOE%;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]';

      $* libbaz 2>>~%EOE%;
        warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
        disfigured libfoo/1.0.0
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        configured libfoo/1.1.0
        configured libbar/1.1.0
        configured libbaz/1.1.0
        %info: .+ is up to date%
        updated libbaz/1.1.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.1.0';

      $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
      $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : forcing-upgrade-held
    :
    {
      $clone_cfg;

      $* libfoo/1.0.0 2>>~%EOE%;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]';

      $* libbaz 2>>EOE != 0;
        error: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
          info: package version libfoo/1.0.0 is held
          info: explicitly request version upgrade to continue
        info: while satisfying libbar/1.1.0
        info: while satisfying libbaz/1.1.0
        EOE

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
    }

    : forcing-upgrade-held-config
    :
    : As above but with a linked configuration.
    :
    {
      $clone_cfg;
      $cfg_create -d cfg2 &cfg2/***;
      $cfg_link -d cfg cfg2;
      $rep_fetch -d cfg2 $rep/t4c;

      $* libfoo/1.0.0 +{ --config-id 1 } 2>>~%EOE%;
        %fetched libfoo/1.0.0 \[cfg2.\]%
        %unpacked libfoo/1.0.0 \[cfg2.\]%
        %configured libfoo/1.0.0 \[cfg2.\]%
        %info: .+ is up to date%
        %updated libfoo/1.0.0 \[cfg2.\]%
        EOE

      $pkg_status -d cfg2 libfoo >'!libfoo configured !1.0.0 available [1.1.0]';

      $* libbaz ?libbar +{ --config-id 1 } 2>>~%EOE% != 0;
        %error: package libbar \[cfg2.\] dependency on \(libfoo == 1.1.0\) is forcing upgrade of libfoo/1.0.0 \[cfg2.\] to 1.1.0%
        %  info: package version libfoo/1.0.0 \[cfg2.\] is held%
          info: explicitly request version upgrade to continue
        %info: while satisfying libbar/1.1.0 \[cfg2.\]%
        info: while satisfying libbaz/1.1.0
        EOE

      $pkg_disfigure -d cfg2 libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     -d cfg2 libfoo 2>'purged libfoo/1.0.0'
    }
  }

  : drop-dependencies
  :
  {
    $clone_root_cfg && $rep_add $rep/t2 && $rep_fetch;

    $* libbar 2>>~%EOE%;
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbar/1.0.0
      unpacked libbar/1.0.0
      configured libfoo/1.0.0
      configured libbar/1.0.0
      %info: .+ is up to date%
      updated libbar/1.0.0
      EOE

    $pkg_status libfoo >'libfoo configured 1.0.0';
    $pkg_status libbar >'!libbar configured 1.0.0';

    $rep_add $rep/t5 && $rep_fetch;

    $* libbar 2>>~%EOE%;
      disfigured libbar/1.0.0
      disfigured libfoo/1.0.0
      purged libfoo/1.0.0
      fetched libbar/1.2.0
      unpacked libbar/1.2.0
      configured libbar/1.2.0
      %info: .+ is up to date%
      updated libbar/1.2.0
      EOE

    $pkg_status libfoo >'libfoo available 1.0.0';
    $pkg_status libbar >'!libbar configured 1.2.0';

    $* libbar/1.0.0 libfoo 2>>~%EOE%;
      disfigured libbar/1.2.0
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbar/1.0.0
      unpacked libbar/1.0.0
      configured libfoo/1.0.0
      configured libbar/1.0.0
      %info: .+ is up to date%{2}
      updated libfoo/1.0.0
      updated libbar/1.0.0
      EOE

    $pkg_status libfoo >'!libfoo configured 1.0.0';
    $pkg_status libbar >'!libbar configured !1.0.0 available 1.2.0';

    $* libbar 2>>~%EOE%;
      disfigured libbar/1.0.0
      fetched libbar/1.2.0
      unpacked libbar/1.2.0
      configured libbar/1.2.0
      %info: .+ is up to date%
      updated libbar/1.2.0
      EOE

    $pkg_status libfoo >'!libfoo configured 1.0.0';
    $pkg_status libbar >'!libbar configured 1.2.0';

    $pkg_disfigure libbar 2>'disfigured libbar/1.2.0';
    $pkg_purge     libbar 2>'purged libbar/1.2.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
  }

  : local-dependency
  :
  : Test that the local package can be built against the local dependency
  : package.
  :
  {
    # Prepare libbar and libbaz (libbaz->libbar) local packages using the
    # temporary configuration.
    #
    $clone_root_cfg;

    $pkg_fetch -e $src/t4b/libbar-1.1.0.tar.gz;
    $pkg_unpack libbar &cfg/libbar-1.1.0/***;

    $pkg_fetch -e $src/t4c/libbaz-1.1.0.tar.gz;
    $pkg_unpack libbaz &cfg/libbaz-1.1.0/***;

    mv cfg/libbar-1.1.0 libbar;
    mv cfg/libbaz-1.1.0 libbaz;

    rm -r cfg && $clone_root_cfg;    # Re-clone.
    $rep_add $rep/t4a && $rep_fetch;

    $* ./libbar/ 2>>~%EOE%;
      fetched libfoo/1.1.0
      unpacked libfoo/1.1.0
      using libbar/1.1.0 (external)
      configured libfoo/1.1.0
      configured libbar/1.1.0
      %info: .+ is up to date%
      updated libbar/1.1.0
      EOE

    $* ./libbaz/ 2>>~%EOE%;
      using libbaz/1.1.0 (external)
      configured libbaz/1.1.0
      %info: .+ is up to date%
      updated libbaz/1.1.0
      EOE

    $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
    $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

    $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
    $pkg_purge     libbar 2>'purged libbar/1.1.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }

  : upgrade-all-held
  :
  {
    $clone_root_cfg && $rep_fetch $rep/t2 $rep/t5;

    $* libbar/1.0 2>>~%EOE%;
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbar/1.0.0
      unpacked libbar/1.0.0
      configured libfoo/1.0.0
      configured libbar/1.0.0
      %info: .+ is up to date%
      updated libbar/1.0.0
      EOE

    $* --upgrade 2>>~%EOE%;
      disfigured libbar/1.0.0
      disfigured libfoo/1.0.0
      purged libfoo/1.0.0
      fetched libbar/1.2.0
      unpacked libbar/1.2.0
      configured libbar/1.2.0
      %info: .+ is up to date%
      updated libbar/1.2.0
      EOE

    $pkg_status libbar >'!libbar configured 1.2.0';

    # While at it, test using --mask-repository* instead of rep-remove.
    #
    $* --upgrade --mask-repository $rep/t2 --mask-repository $rep/t5 2>>/EOE != 0;
      error: libbar is not available
      EOE

    $* --upgrade --mask-repository-uuid "$cfg_uuid=($rep/t2)" \
                 --mask-repository-uuid "$cfg_uuid=($rep/t5)" 2>>/EOE != 0;
      error: libbar is not available
      EOE

    $rep_remove $rep/t2 $rep/t5;

    $* --upgrade 2>>/EOE != 0;
      error: libbar is not available
        info: configuration cfg/ has no repositories
        info: use 'bpkg rep-add' to add a repository
      EOE

    $pkg_drop libbar
  }

  : foo-baz-box-bar
  :
  : Test build scenarios described in
  : https://github.com/conan-io/conan/issues/9547.
  :
  : Note: using tar on Windows is a bit hairy (needs --force-local, etc), so
  : we do not run this test on Windows.
  :
  if ($posix && !$remote)
  {
    +mkdir 1/

    # Repository state 0: initial (see the above t9 directory tree for details).

    # Repository state 1: libbar/2.0.0 is released.
    #
    r = 1/t9-1
    +cp -r $rep/t9 $r && \
     tar xzf $r/libbar-1.0.0.tar.gz -C $r && \
     mv $r/libbar-1.0.0 $r/libbar-2.0.0 && \
     sed -i -e 's/(version:).+/\1 2.0.0/' $r/libbar-2.0.0/manifest && \
     tar cfz $r/libbar-2.0.0.tar.gz -C $r libbar-2.0.0 &$r/libbar-2.0.0.tar.gz && \
     rm -r $r/libbar-2.0.0 && \
     $rep_create $r &$r/packages.manifest

    # Repository state 2: libbaz/2.0.0 is released, which depends on
    #                     libbar ^2.0.0.
    #
    r = 1/t9-2
    +cp -r 1/t9-1 $r && \
     tar xzf $r/libbaz-1.0.0.tar.gz -C $r && \
     mv $r/libbaz-1.0.0 $r/libbaz-2.0.0 && \
     sed -i -e 's/(version:).+/\1 2.0.0/' -e 's/(depends: libbar).+/\1 ^2.0.0/' $r/libbaz-2.0.0/manifest && \
     tar cfz $r/libbaz-2.0.0.tar.gz -C $r libbaz-2.0.0 &$r/libbaz-2.0.0.tar.gz && \
     rm -r $r/libbaz-2.0.0 && \
     $rep_create $r &$r/packages.manifest

    # Repository state 3: libbox/1.1.0 is released, which still depends on
    #                     libbar ^1.0.0.
    #
    r = 1/t9-3
    +cp -r 1/t9-2 $r && \
     tar xzf $r/libbox-1.0.0.tar.gz -C $r && \
     mv $r/libbox-1.0.0 $r/libbox-1.1.0 && \
     sed -i -e 's/(version:).+/\1 1.1.0/' $r/libbox-1.1.0/manifest && \
     tar cfz $r/libbox-1.1.0.tar.gz -C $r libbox-1.1.0 &$r/libbox-1.1.0.tar.gz && \
     rm -r $r/libbox-1.1.0 && \
     $rep_create $r &$r/packages.manifest

    : repo-state-1
    :
    {
      : build
      :
      {
        $clone_root_cfg;
        $rep_add ../../1/t9-1 && $rep_fetch;

        $* foo 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $pkg_drop foo
      }

      : upgrade
      :
      : Test upgrade of packages (initially built from the repository state 0)
      : after the state 1 is fetched.
      :
      {
        $clone_root_cfg;

        mkdir 1/;
        ln -s $rep/t9 1/repo;
        $rep_add 1/repo && $rep_fetch;

        $* foo 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0
          EOO

        rm 1/repo;
        ln -s ../../../1/t9-1 1/repo;

        $rep_fetch;

        $* foo 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $* ?libbar 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $* ?libbaz 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $pkg_drop foo
      }
    }

    : repo-state-2
    :
    {
      : build
      :
      {
        $clone_root_cfg;
        $rep_add ../../1/t9-2 && $rep_fetch;

        # Picks up the latest libbaz (2.0.0) as a prerequisite for foo, which
        # leads to the conflict between libbaz/2.0.0 and libbox/1.0.0 about
        # prerequisite libbar because of the incompatible version constraints.
        #
        $* foo 2>>EOE != 0;
          error: unable to satisfy constraints on package libbar
            info: libbaz depends on (libbar ^2.0.0)
            info: libbox depends on (libbar ^1.0.0)
            info: available libbar/2.0.0
            info: available libbar/1.0.0
            info: explicitly specify libbar version to manually satisfy both constraints
          info: while satisfying libbox/1.0.0
          info: while satisfying foo/1.0.0
          EOE

        $* foo ?libbaz/1.0.0 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured !1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $pkg_drop foo
      }

      : upgrade
      :
      : Test upgrade of packages (initially built from the repository state 0)
      : after the state 2 is fetched.
      :
      {
        $clone_root_cfg;

        mkdir 1/;
        ln -s $rep/t9 1/repo;
        $rep_add 1/repo && $rep_fetch;

        $* foo 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0
          EOO

        rm 1/repo;
        ln -s ../../../1/t9-2 1/repo;

        $rep_fetch;

        $* foo 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $* ?libbar 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        # Unable to satisfy the dependent libbox with an upgraded (due to
        # libbaz 2.0.0) prerequisite libbar/2.0.0.
        #
        $* ?libbaz 2>>EOE != 0;
          error: unable to upgrade package libbar/1.0.0 to 2.0.0
            info: because package libbox depends on (libbar ^1.0.0)
            info: package libbar/2.0.0 required by libbaz
            info: explicitly request up/downgrade of package libbox
            info: or explicitly specify package libbar version to manually satisfy these constraints
          EOE

        $pkg_drop foo
      }
    }

    : repo-state-3
    :
    {
      : build
      :
      {
        $clone_root_cfg;
        $rep_add ../../1/t9-3 && $rep_fetch;

        # Similar to the repository state 2, picks up the latest libbaz (2.0.0)
        # as a prerequisite for foo, which leads to the conflict.
        #
        $* foo 2>>EOE != 0;
          error: unable to satisfy constraints on package libbar
            info: libbaz depends on (libbar ^2.0.0)
            info: libbox depends on (libbar ^1.0.0)
            info: available libbar/2.0.0
            info: available libbar/1.0.0
            info: explicitly specify libbar version to manually satisfy both constraints
          info: while satisfying libbox/1.1.0
          info: while satisfying foo/1.0.0
          EOE

        $* foo ?libbaz/1.0.0 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured !1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.1.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $pkg_drop foo
      }

      : upgrade
      :
      : Test upgrade of packages (initially built from the repository state 0)
      : after the state 3 is fetched.
      :
      {
        $clone_root_cfg;

        mkdir 1/;
        ln -s $rep/t9 1/repo;
        $rep_add 1/repo && $rep_fetch;

        $* foo 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0
              libbar configured 1.0.0
            libbox configured 1.0.0
              libbar configured 1.0.0
          EOO

        rm 1/repo;
        ln -s ../../../1/t9-3 1/repo;

        $rep_fetch;

        $* foo 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0 available 1.1.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $* ?libbar 2>!; # Noop.
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.0.0 available 1.1.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        # Unable to satisfy the dependent libbox with an upgraded (due to
        # libbaz 2.0.0) prerequisite libbar/2.0.0.
        #
        $* foo ?libbaz 2>>EOE != 0;
          error: unable to upgrade package libbar/1.0.0 to 2.0.0
            info: because package libbox depends on (libbar ^1.0.0)
            info: package libbar/2.0.0 required by libbaz
            info: explicitly request up/downgrade of package libbox
            info: or explicitly specify package libbar version to manually satisfy these constraints
          EOE

        # libbar/2.0.0 is still unsatisfactory as a prerequisite for libbox,
        # even after libbox upgrade is requested on the command line.
        #
        $* foo ?libbaz ?libbox 2>>EOE != 0;
          error: unable to satisfy constraints on package libbar
            info: libbaz depends on (libbar ^2.0.0)
            info: libbox depends on (libbar ^1.0.0)
            info: available libbar/2.0.0
            info: available libbar/1.0.0
            info: explicitly specify libbar version to manually satisfy both constraints
          info: while satisfying libbox/1.1.0
          EOE

        $* ?libbox 2>!;
        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libbaz configured 1.0.0 available 2.0.0
              libbar configured 1.0.0 available 2.0.0
            libbox configured 1.1.0
              libbar configured 1.0.0 available 2.0.0
          EOO

        $pkg_drop foo
      }
    }
  }

  : config-vars
  :
  {
    +$cfg_create -d cfg cc config.cc.coptions=-Wall 2>- &cfg/***
    +$rep_add $rep/t5 && $rep_fetch

    : override-package-specific
    :
    {
      $clone_cfg;

      $* --configure-only { config.cc.coptions+=-g }+ libbar \
                          { config.cc.coptions+=-O }+ libbox 2>>EOE;
        fetched libbar/1.2.0
        unpacked libbar/1.2.0
        fetched libbox/1.2.0
        unpacked libbox/1.2.0
        configured libbar/1.2.0
        configured libbox/1.2.0
        EOE

      cat cfg/build/config.build >>~%EOO%;
        %.*
        config.cc.coptions = -Wall
        %.*
        EOO

      cat cfg/libbar-1.2.0/build/config.build >>~%EOO%;
        %.*
        config.cc.coptions = -Wall -g
        %.*
        EOO

      cat cfg/libbox-1.2.0/build/config.build >>~%EOO%;
        %.*
        config.cc.coptions = -Wall -O
        %.*
        EOO

      $pkg_drop libbar libbox
    }

    : override-globally
    :
    {
      $clone_cfg;

      $* --configure-only config.cc.coptions+=-g \
                          config.cc.coptions+=-O -- libbar 2>>EOE;
        fetched libbar/1.2.0
        unpacked libbar/1.2.0
        configured libbar/1.2.0
        EOE

      cat cfg/build/config.build >>~%EOO%;
        %.*
        config.cc.coptions = -Wall
        %.*
        EOO

      cat cfg/libbar-1.2.0/build/config.build >>~%EOO%;
        %.*
        config.cc.coptions = -Wall -g -O
        %.*
        EOO

      $pkg_drop libbar
    }
  }
}

: dependency
:
{
  : upgrade-diag
  :
  {
    +$clone_root_cfg && $rep_fetch $rep/t1

    : warning
    :
    {
      $clone_cfg;

      $* libfoo 2>!;
      $rep_fetch $rep/t4b;

      $* libbar --yes 2>>~%EOE%;
        warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
        disfigured libfoo/1.0.0
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        configured libfoo/1.1.0
        configured libbar/1.1.0
        %info: .+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_drop libbar libfoo
    }

    : error
    :
    {
      $clone_cfg;

      $* libfoo/1.0.0 2>!;
      $rep_fetch $rep/t4b;

      $* libbar 2>>EOE != 0;
        error: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
          info: package version libfoo/1.0.0 is held
          info: explicitly request version upgrade to continue
        info: while satisfying libbar/1.1.0
        EOE

      $pkg_drop libfoo
    }

    : info
    :
    {
      $clone_cfg && $rep_fetch $rep/t2;

      $* libbar --yes 2>!;
      $rep_fetch $rep/t4b;

      $* -v libbar --yes 2>>~%EOE%;
        info: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0
        %.*
        EOE

      $pkg_drop libbar
    }

    : none
    :
    {
      $clone_cfg && $rep_fetch $rep/t2;

      $* libbar --yes 2>!;
      $rep_fetch $rep/t4b;

      $* libbar --yes 2>>~%EOE%;
        disfigured libbar/1.0.0
        disfigured libfoo/1.0.0
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        configured libfoo/1.1.0
        configured libbar/1.1.0
        %info: .+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_drop libbar
    }
  }

  : unknown
  :
  {
    $clone_root_cfg;
    $rep_fetch $rep/t0c;

    $* '?libbux'      2>'error: unknown package libbux' != 0;
    $* '?sys:libbux'  2>>EOE != 0;
      error: unknown package sys:libbux
        info: consider specifying sys:libbux/*
      EOE
    $* '?libbar/1.3'  2>'error: unknown package libbar/1.3' != 0;
    $* '?libbar[5 7]' 2>"error: unknown package 'libbar [5 7]'" != 0
  }

  : constraint
  :
  {
    $clone_root_cfg;
    $rep_fetch $rep/t0c;

    # Constraint the dependency version.
    #
    $* libbox '?libbaz < 0.1.0' 2>>~%EOE%;
      fetched libbaz/0.0.4
      unpacked libbaz/0.0.4
      fetched libbox/0.0.1
      unpacked libbox/0.0.1
      configured libbaz/0.0.4
      configured libbox/0.0.1
      %info: .+libbox.+ is up to date%
      updated libbox/0.0.1
      EOE

    $pkg_status libbaz >'libbaz configured !0.0.4 available 0.1.0';

    # The selected dependency libbaz/0.0.4 satisfies the constraint, thus it
    # is not upgraded.
    #
    $* '?libbaz < 1.0.0';

    $pkg_status libbaz >'libbaz configured !0.0.4 available 0.1.0';

    # Upgrade the dependency.
    #
    $* '?libbaz > 0.0.4' --yes 2>>~%EOE%;
      disfigured libbox/0.0.1
      disfigured libbaz/0.0.4
      fetched libbaz/0.1.0
      unpacked libbaz/0.1.0
      configured libbaz/0.1.0
      configured libbox/0.0.1
      %info: .+libbox.+ is up to date%
      updated libbox/0.0.1
      EOE

    $pkg_status libbaz >'libbaz configured !0.1.0';

    $pkg_drop libbox
  }

  : system-no-repo
  :
  {
    $clone_root_cfg;

    cp -r $src/libfoo-1.1.0 libfoo;
    echo 'depends: libhello >= 1.0' >+libfoo/manifest;
    $rep_add libfoo --type dir;

    $rep_fetch;

    $* libfoo 2>>~%EOE% != 0;
      error: no package available for dependency libhello of package libfoo
      %.+
      EOE

    $* libfoo '?sys:libhello' 2>>EOE != 0;
      error: unknown package sys:libhello
        info: consider specifying sys:libhello/*
      EOE

    $* "sys:libhello/2.0@$rep/t0a" --trust-yes 2>>~%EOE% != 0;
      %.+
      %error: package sys:libhello/2\.0 is not found in .+t0a%
      EOE

    $* libfoo '?sys:libhello/0.1' 2>>~%EOE% != 0;
      error: unable to satisfy constraints on package libhello
      %.+
      EOE

    $* libfoo '?sys:libhello/*' 2>>~%EOE%;
      using libfoo/1.1.0 (external)
      configured sys:libhello/*
      configured libfoo/1.1.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    $pkg_status libhello >'libhello configured,system !*';

    $* '?sys:libhello/2.0' --yes 2>>~%EOE%;
      disfigured libfoo/1.1.0
      purged libhello/*
      configured sys:libhello/2.0
      configured libfoo/1.1.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    $pkg_status libhello >'libhello configured,system !2.0';

    $pkg_drop libfoo
  }

  : unused
  :
  {
    test.arguments += --configure-only

    +$clone_root_cfg
    +$rep_fetch $rep/t2 $rep/t5

    : drop
    :
    : Test dropping of unused dependencies (default behavior).
    :
    {
      $clone_cfg;

      # Here we also test that specifying unknown but unused system
      # dependencies.
      #
      $* --yes libbar/1.0.0 '?sys:libbox/*' '?sys:libbux/1' 2>>EOE;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        configured libfoo/1.0.0
        configured libbar/1.0.0
        EOE

      $* libbar/1.2.0 <'y' 2>>EOE;
          drop libfoo/1.0.0 (unused)
          upgrade libbar/1.2.0
        continue? [Y/n] disfigured libbar/1.0.0
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbar/1.2.0
        unpacked libbar/1.2.0
        configured libbar/1.2.0
        EOE

      $pkg_status libfoo >'libfoo available 1.0.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.2.0';
      $pkg_purge     libbar 2>'purged libbar/1.2.0'
    }

    : keep
    :
    : Test keeping of unused dependencies (--keep-unused option).
    :
    {
      $clone_cfg;

      $* --yes libbar/1.0.0 2>>EOE;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        configured libfoo/1.0.0
        configured libbar/1.0.0
        EOE

      $* --keep-unused libbar/1.2.0 <'y' 2>>EOE;
          upgrade libbar/1.2.0
        continue? [Y/n] disfigured libbar/1.0.0
        fetched libbar/1.2.0
        unpacked libbar/1.2.0
        configured libbar/1.2.0
        EOE

      $pkg_status libfoo >'libfoo configured 1.0.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.2.0';
      $pkg_purge     libbar 2>'purged libbar/1.2.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
    }

    : drop-recursive
    :
    {
      test.arguments += --yes

      $clone_root_cfg;
      $rep_fetch $rep/t0a $rep/t0c;

      $* libbar/0.0.1 2>!;

      $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';
      $pkg_status libfox >'libfox configured 0.0.1';

      $* libbar 2>>EOE;
        disfigured libbar/0.0.1
        disfigured libbaz/0.0.1
        disfigured libfox/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        purged libfox/0.0.1
        purged libbaz/0.0.1
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        configured libfoo/1.0.0
        configured libbar/1.0.0
        EOE

      $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1';
      $pkg_status libfox >'libfox available 0.0.1';

      $pkg_drop libbar
    }

    : drop-unsatisfactory
    :
    : Test that a dependency (libbaz/0.0.3) that doesn't satisfy its dependent
    : (libbar/0.0.1) but get dropped during the plan refinement, doesn't
    : prevent the command to succeed.
    :
    {
      test.arguments += --yes

      $clone_root_cfg;
      $rep_fetch $rep/t0a $rep/t0c;

      $* libbar/0.0.1 2>!;

      $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';
      $pkg_status libfox >'libfox configured 0.0.1';

      $* ?libbar ?libbaz/0.0.3 2>>EOE;
        disfigured libbar/0.0.1
        disfigured libbaz/0.0.1
        disfigured libfox/0.0.1
        purged libfox/0.0.1
        purged libbaz/0.0.1
        purged libbar/0.0.1
        EOE

      $pkg_status libbar >'libbar available 1.0.0 0.0.3 0.0.1';
      $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1';
      $pkg_status libfox >'libfox available 0.0.1'
    }
  }

  : apply-constraints
  :
  : Test that the desired dependency version imposes constraint that is taken
  : into account during prerequisites collection (see collect_prerequisites()
  : for more details).
  :
  {
    test.arguments += --yes --configure-only

    : unable-satisfy
    :
    {
      $clone_root_cfg;
      $rep_fetch $rep/t0a $rep/t0b;

      $* libbar/0.0.1 ?libbaz/0.0.2 2>>EOE != 0;
        error: unable to satisfy constraints on package libbaz
          info: libbar depends on (libbaz == 0.0.1)
          info: command line depends on (libbaz == 0.0.2)
          info: specify libbaz version to satisfy libbar constraint
        info: while satisfying libbar/0.0.1
        EOE

      $* -- libbar/0.0.1 '?libbaz>=0.0.2' 2>>EOE != 0
        error: unable to satisfy constraints on package libbaz
          info: libbar depends on (libbaz == 0.0.1)
          info: command line depends on (libbaz >= 0.0.2)
          info: specify libbaz version to satisfy libbar constraint
        info: while satisfying libbar/0.0.1
        EOE
    }

    : resolve-conflict
    :
    {
      : satisfy-dependents
      :
      : Test resolving a conflict when libfix and libbiz have selected such
      : versions of their dependency libbaz, that do not satisfy each other
      : constraints. We resolve the conflict explicitly specifying
      : ?libbaz/0.0.3 on the command line, which satisfies both constraints.
      :
      {
        $clone_root_cfg;
        $rep_fetch $rep/t0b $rep/t0c;

        $* libfix libbiz 2>>EOE != 0;
          error: unable to satisfy constraints on package libbaz
            info: libfix depends on (libbaz >= 0.0.3)
            info: libbiz depends on (libbaz <= 0.0.3)
            info: available libbaz/0.1.0
            info: available libbaz/0.0.2
            info: explicitly specify libbaz version to manually satisfy both constraints
          info: while satisfying libbiz/0.0.2
          EOE

        $* libfix libbiz ?libbaz/0.0.3 2>>EOE;
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbaz/0.0.3
          unpacked libbaz/0.0.3
          fetched libfix/0.0.3
          unpacked libfix/0.0.3
          fetched libbiz/0.0.2
          unpacked libbiz/0.0.2
          configured libfoo/1.0.0
          configured libbaz/0.0.3
          configured libfix/0.0.3
          configured libbiz/0.0.2
          EOE

        $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4';

        $pkg_drop libbiz libfix
      }

      : postpone
      :
      : Same as above but with an opposite order of dependents on the command
      : line. This would normally fail due the inability to find libbaz/0.0.3
      : in repositories available to libbiz, unless libbaz dependencies
      : collection were not postponed (see collect_build_prerequisites()
      : function for more details).
      :
      {
        $clone_root_cfg;
        $rep_fetch $rep/t0b $rep/t0c;

        $* libbiz libfix ?libbaz/0.0.3 2>>EOE;
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbaz/0.0.3
          unpacked libbaz/0.0.3
          fetched libbiz/0.0.2
          unpacked libbiz/0.0.2
          fetched libfix/0.0.3
          unpacked libfix/0.0.3
          configured libfoo/1.0.0
          configured libbaz/0.0.3
          configured libbiz/0.0.2
          configured libfix/0.0.3
          EOE

        $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4';

        $pkg_drop libbiz libfix
      }

      : replace-dependent
      :
      : Test resolving a conflict when libbox and libfox have selected such
      : versions of their dependency libfoo, that do not satisfy each other
      : constraints. Note that these constraints are incompatible, so we
      : resolve the conflict explicitly specifying ?libfox/0.0.1 on the
      : command line, to replace one of the conflicting dependents.
      :
      {
        $clone_root_cfg;
        $rep_fetch $rep/t0d;

        $* libbiz 2>>EOE != 0;
          error: unable to satisfy constraints on package libfoo
            info: libfox depends on (libfoo == 0.0.1)
            info: libbox depends on (libfoo == 1.0.0)
            info: available libfoo/0.0.1
            info: available libfoo/1.0.0
            info: explicitly specify libfoo version to manually satisfy both constraints
          info: while satisfying libbox/0.0.2
          info: while satisfying libbiz/0.0.1
          EOE

        $* libbiz ?libfox/0.0.1 2>>EOE;
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbox/0.0.2
          unpacked libbox/0.0.2
          fetched libbiz/0.0.1
          unpacked libbiz/0.0.1
          configured libfox/0.0.1
          configured libfoo/1.0.0
          configured libbox/0.0.2
          configured libbiz/0.0.1
          EOE

        $pkg_status libfox >'libfox configured !0.0.1 available 0.0.2';

        $pkg_drop libbiz
      }
    }

    : selected
    :
    : Test cases when the selected package (partially) satisfies the
    : user-imposed dependency constraint.
    :
    {
      +$clone_root_cfg
      +$rep_fetch $rep/t0a $rep/t0b $rep/t0c

      : same
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 2>!;
        $* libbar/0.0.2 ?libbaz/0.0.1 2>!;

        $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';
        $pkg_status libfox >'libfox configured 0.0.1';

        $pkg_drop libbar
      }

      : same-constraint
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 2>!;
        $* libbar/0.0.2 '?libbaz<0.0.2' 2>!;

        $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';
        $pkg_status libfox >'libfox configured 0.0.1';

        $pkg_drop libbar
      }

      : src-to-sys
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 2>!;
        $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!;

        $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';
        $pkg_status libfox >'libfox available 0.0.1';

        $pkg_drop libbar
      }

      : sysver-to-wildcard
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>!;
        $* libbar/0.0.2 '?sys:libbaz' 2>!;

        $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3 0.0.2 0.0.1';

        $pkg_drop libbar
      }

      : wildcard-to-sysver
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?sys:libbaz' 2>!;
        $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!;

        $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';

        $pkg_drop libbar
      }
    }

    : unknown
    :
    {
      $clone_root_cfg;
      $rep_fetch $rep/t0a $rep/t0c;

      $* libbar/1.0.0 ?libfoo/0.0.1 2>>EOE != 0
        error: unable to satisfy dependency constraint (libfoo == 0.0.1) of package libbar
          info: available libfoo versions: 1.0.0
        info: while satisfying libbar/1.0.0
        EOE
    }
  }

  : refine
  :
  {
    test.arguments += --yes --configure-only

    +$clone_root_cfg
    +$rep_fetch $rep/t0a $rep/t0c

    : system
    :
    {
      +$clone_cfg

      : wildcard-to-version
      :
      {
        $clone_cfg;

        $* libbar '?sys:libfoo' 2>>EOE;
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured sys:libfoo/*
          configured libbar/1.0.0
          EOE

        $* '?sys:libfoo/0.1' 2>>EOE;
          disfigured libbar/1.0.0
          purged libfoo/*
          configured sys:libfoo/0.1
          configured libbar/1.0.0
          EOE

        $pkg_drop libbar
      }

      : wildcard-to-itself
      :
      {
        $clone_cfg;

        $* libbar '?sys:libfoo' 2>>EOE;
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured sys:libfoo/*
          configured libbar/1.0.0
          EOE

        $* '?sys:libfoo';

        $pkg_drop libbar
      }

      : wildcard-to-src
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?sys:libbaz' 2>>EOE;
          fetched libbar/0.0.1
          unpacked libbar/0.0.1
          configured sys:libbaz/*
          configured libbar/0.0.1
          EOE

        $* '?libbaz' 2>>EOE;
          disfigured libbar/0.0.1
          purged libbaz/*
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libbaz/0.0.1
          unpacked libbaz/0.0.1
          configured libfox/0.0.1
          configured libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $pkg_drop libbar
      }

      : version-to-wildcard
      :
      {
        $clone_cfg;

        $* libbar '?sys:libfoo/0.1' 2>>EOE;
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured sys:libfoo/0.1
          configured libbar/1.0.0
          EOE

        $* '?sys:libfoo' 2>>EOE;
          disfigured libbar/1.0.0
          purged libfoo/0.1
          configured sys:libfoo/*
          configured libbar/1.0.0
          EOE

        $pkg_drop libbar
      }

      : version-to-itself
      :
      {
        $clone_cfg;

        $* libbar '?sys:libfoo/0.1' 2>>EOE;
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured sys:libfoo/0.1
          configured libbar/1.0.0
          EOE

        $* '?sys:libfoo/0.1';

        $pkg_drop libbar
      }

      : version-to-version
      :
      {
        $clone_cfg;

        $* libbar '?sys:libfoo/0.2' 2>>EOE;
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured sys:libfoo/0.2
          configured libbar/1.0.0
          EOE

        $* '?sys:libfoo/0.1' 2>>EOE;
          disfigured libbar/1.0.0
          purged libfoo/0.2
          configured sys:libfoo/0.1
          configured libbar/1.0.0
          EOE

        $pkg_drop libbar
      }

      : version-to-src
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>>EOE;
          fetched libbar/0.0.1
          unpacked libbar/0.0.1
          configured sys:libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $* '?libbaz/0.0.1' 2>>EOE;
          disfigured libbar/0.0.1
          purged libbaz/0.0.1
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libbaz/0.0.1
          unpacked libbaz/0.0.1
          configured libfox/0.0.1
          configured libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $pkg_drop libbar
      }

      : version-to-constraint
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>>EOE;
          fetched libbar/0.0.1
          unpacked libbar/0.0.1
          configured sys:libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $* '?libbaz [0.0.1 0.0.2]' 2>>EOE;
          disfigured libbar/0.0.1
          purged libbaz/0.0.1
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libbaz/0.0.1
          unpacked libbaz/0.0.1
          configured libfox/0.0.1
          configured libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $pkg_drop libbar
      }

      : src-to-wildcard
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?libbaz' 2>>EOE;
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libbaz/0.0.1
          unpacked libbaz/0.0.1
          fetched libbar/0.0.1
          unpacked libbar/0.0.1
          configured libfox/0.0.1
          configured libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $* '?sys:libbaz' 2>>EOE;
          disfigured libbar/0.0.1
          disfigured libbaz/0.0.1
          disfigured libfox/0.0.1
          purged libfox/0.0.1
          purged libbaz/0.0.1
          configured sys:libbaz/*
          configured libbar/0.0.1
          EOE

        $pkg_drop libbar
      }

      : src-to-version
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 '?libbaz/0.0.1' 2>>EOE;
          fetched libfox/0.0.1
          unpacked libfox/0.0.1
          fetched libbaz/0.0.1
          unpacked libbaz/0.0.1
          fetched libbar/0.0.1
          unpacked libbar/0.0.1
          configured libfox/0.0.1
          configured libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $* '?sys:libbaz/0.0.1' 2>>EOE;
          disfigured libbar/0.0.1
          disfigured libbaz/0.0.1
          disfigured libfox/0.0.1
          purged libfox/0.0.1
          purged libbaz/0.0.1
          configured sys:libbaz/0.0.1
          configured libbar/0.0.1
          EOE

        $pkg_drop libbar
      }

      : sys-to-src-unhold
      :
      {
        $clone_cfg;

        $* 'sys:libbaz/1.2.0' 2>>EOE;
          configured sys:libbaz/1.2.0
          EOE

        $* ?libbaz libbar/0.0.3 2>>EOE;
          purged libbaz/1.2.0
          fetched libbaz/0.1.0
          unpacked libbaz/0.1.0
          fetched libbar/0.0.3
          unpacked libbar/0.0.3
          configured libbaz/0.1.0
          configured libbar/0.0.3
          EOE

        $pkg_drop libbar libbaz
      }

      : sys-to-src-unhold-same-ver
      :
      : Same as above but the version does not change.
      :
      {
        $clone_cfg;

        $* 'sys:libbaz/0.1.0' 2>>EOE;
          configured sys:libbaz/0.1.0
          EOE

        $* ?libbaz libbar/0.0.3 2>>EOE;
          purged libbaz/0.1.0
          fetched libbaz/0.1.0
          unpacked libbaz/0.1.0
          fetched libbar/0.0.3
          unpacked libbar/0.0.3
          configured libbaz/0.1.0
          configured libbar/0.0.3
          EOE

        $pkg_drop libbar libbaz
      }

      : sys-to-src
      :
      : As above but keep held.
      :
      {
        $clone_cfg;

        $* 'sys:libbaz/1.2.0' 2>>EOE;
          configured sys:libbaz/1.2.0
          EOE

        $* libbaz libbar/0.0.3 2>>EOE;
          purged libbaz/1.2.0
          fetched libbaz/0.1.0
          unpacked libbaz/0.1.0
          fetched libbar/0.0.3
          unpacked libbar/0.0.3
          configured libbaz/0.1.0
          configured libbar/0.0.3
          EOE

        $pkg_drop libbar libbaz
      }
    }

    : source
    :
    {
      +$clone_cfg

      : unavailable
      :
      {
        $clone_cfg;

        $* libbar/1.0.0 2>!;

        $* ?libfoo/0.0.1 2>>EOE != 0;
          error: libfoo/0.0.1 is not available from its dependents' repositories
          EOE

        $* '?libfoo < 0.0.2' 2>>EOE != 0;
          error: 'libfoo < 0.0.2' is not available from its dependents' repositories
          EOE

        $pkg_drop libbar
      }

      : satisfy
      :
      {
        $clone_cfg;
        $rep_fetch $rep/t0b;

        $* libbar/0.0.1 2>!;

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';

        $* libbar/0.0.2 ?libbaz 2>>EOE;
          disfigured libbar/0.0.1
          disfigured libbaz/0.0.1
          disfigured libfox/0.0.1
          purged libfox/0.0.1
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbaz/0.0.2
          unpacked libbaz/0.0.2
          fetched libbar/0.0.2
          unpacked libbar/0.0.2
          configured libfoo/1.0.0
          configured libbaz/0.0.2
          configured libbar/0.0.2
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3';

        $rep_remove $rep/t0b && $rep_fetch;

        # Test that the selected package, that is "better" than the available
        # one, is left.
        #
        $* libbox ?libbaz 2>>EOE;
          fetched libbox/0.0.1
          unpacked libbox/0.0.1
          configured libbox/0.0.1
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3';

        $rep_remove $rep/t0a && $rep_fetch;

        # Test that the selected package is left as there is no satisfactory
        # available package.
        #
        $* ?libbaz;

        # Test that the above behavior is not triggered for the system package.
        #
        $* '?sys:libbaz' 2>>EOE;
          disfigured libbar/0.0.2
          disfigured libbox/0.0.1
          disfigured libbaz/0.0.2
          disfigured libfoo/1.0.0
          purged libfoo/1.0.0
          purged libbaz/0.0.2
          configured sys:libbaz/*
          configured libbox/0.0.1
          configured libbar/0.0.2
          EOE

        $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3';

        $pkg_drop libbar libbox
      }

      : satisfy-masked
      :
      : As above but using --mask-repository* instead of rep-remove.
      :
      {
        $clone_cfg;
        $rep_fetch $rep/t0b;

        $* libbar/0.0.1 2>!;

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2';

        $* libbar/0.0.2 ?libbaz 2>>EOE;
          disfigured libbar/0.0.1
          disfigured libbaz/0.0.1
          disfigured libfox/0.0.1
          purged libfox/0.0.1
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbaz/0.0.2
          unpacked libbaz/0.0.2
          fetched libbar/0.0.2
          unpacked libbar/0.0.2
          configured libfoo/1.0.0
          configured libbaz/0.0.2
          configured libbar/0.0.2
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3';

        # Test that the selected package, that is "better" than the available
        # one, is left.
        #
        $* --mask-repository $rep/t0b libbox ?libbaz 2>>EOE;
          fetched libbox/0.0.1
          unpacked libbox/0.0.1
          configured libbox/0.0.1
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3';

        # Test that the selected package is left as there is no satisfactory
        # available package.
        #
        $* --mask-repository $rep/t0b --mask-repository-uuid "$cfg_uuid=($rep/t0a)" ?libbaz;

        # Test that the above behavior is not triggered for the system package.
        #
        $* --mask-repository $rep/t0b --mask-repository $rep/t0a '?sys:libbaz' 2>>EOE;
          disfigured libbar/0.0.2
          disfigured libbox/0.0.1
          disfigured libbaz/0.0.2
          disfigured libfoo/1.0.0
          purged libfoo/1.0.0
          purged libbaz/0.0.2
          configured sys:libbaz/*
          configured libbox/0.0.1
          configured libbar/0.0.2
          EOE

        $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3 0.0.2 0.0.1';

        $pkg_drop libbar libbox
      }

      : unsatisfied
      :
      {
        $clone_cfg;

        $* libbar/0.0.1 2>!;

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';

        $* ?libbaz/0.0.3 2>>EOE != 0;
          error: package libbaz doesn't satisfy its dependents
            info: libbaz/0.0.3 doesn't satisfy libbar/0.0.1
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';

        $pkg_drop libbar
      }

      : unsatisfied-config
      :
      : As above but with a linked configuration.
      :
      {
        $clone_cfg;
        $cfg_create -d cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $* libbar/0.0.1 2>!;

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';

        $* ?libbaz/0.0.3 +{ --config-id 1 } 2>>EOE != 0;
          error: unable to satisfy constraints on package libbaz
            info: libbar depends on (libbaz == 0.0.1)
            info: command line depends on (libbaz == 0.0.3)
            info: specify libbaz version to satisfy libbar constraint
          info: while satisfying libbar/0.0.1
          EOE

        $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3';

        $pkg_drop libbar
      }
    }

    : scratch
    :
    {
      $clone_cfg;

      $* libbox 2>!;

      $pkg_status libbaz >'libbaz configured 0.0.3 available 0.1.0 0.0.4';
      $pkg_status libfoo >'libfoo configured 0.0.1 available 1.0.0';
      $pkg_status libfox >'libfox available 0.0.1';

      # After the first simulation it is discovered that libfoo needs to be
      # upgraded to 1.0.0. But after the second simulation, that upgrades
      # libfoo, it is discovered that it is now unused (libbaz doesn't need it
      # anymore). So we replace libfoo upgrade with drop and start from
      # scratch.
      #
      $* ?libfoo/1.0.0 ?libbaz/0.0.1 2>>EOE;
        disfigured libbox/0.0.1
        disfigured libbaz/0.0.3
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        purged libfoo/0.0.1
        fetched libfox/0.0.1
        unpacked libfox/0.0.1
        fetched libbaz/0.0.1
        unpacked libbaz/0.0.1
        configured libfox/0.0.1
        configured libbaz/0.0.1
        configured libbox/0.0.1
        EOE

      $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3';
      $pkg_status libfoo >'libfoo available 1.0.0 0.0.1';
      $pkg_status libfox >'libfox configured 0.0.1';

      $pkg_drop libbox
    }

    : reconf-dependent
    :
    {
      $clone_cfg;
      $rep_fetch $rep/t0b;

      $* libbar/0.0.2 2>!;

      $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3';
      $pkg_status libfoo >'libfoo configured 1.0.0';

      $* '?sys:libfoo' ?libbaz/0.0.2 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        configured sys:libfoo/*
        configured libbaz/0.0.2
        configured libbar/0.0.2
        EOE

      $pkg_drop libbar
    }
  }

  : unhold
  :
  {
    test.arguments += --configure-only

    +$clone_root_cfg
    +$rep_fetch $rep/t0a

    : drop
    :
    {
      $clone_cfg;

      $* libfox 2>!;

      $* ?libfox --yes 2>>EOE;
        disfigured libfox/0.0.1
        purged libfox/0.0.1
        EOE

      $pkg_status libfox >'libfox available 0.0.1'
    }

    : silent
    :
    {
      $clone_cfg;

      $* libbar libbaz --yes 2>!;
      $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3';

      $* ?libbaz;
      $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3';

      $pkg_drop libbar
    }

    : prompt
    :
    {
      $clone_cfg;

      $* libbar libbaz --yes 2>!;
      $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3';

      $* '?sys:libbaz' < 'y' 2>>EOE;
          drop libfox/0.0.1 (unused)
          reconfigure/unhold sys:libbaz/*
          reconfigure libbar (dependent of libbaz)
        continue? [Y/n] disfigured libbar/0.0.1
        disfigured libbaz/0.0.1
        disfigured libfox/0.0.1
        purged libfox/0.0.1
        purged libbaz/0.0.1
        configured sys:libbaz/*
        configured libbar/0.0.1
        EOE

      $pkg_status libbaz >'libbaz configured,system !* available 0.0.3 0.0.1';

      $pkg_drop libbar
    }

    : unheld
    :
    {
      $clone_cfg;

      $* libbar ?libbaz --yes 2>!;
      $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3';

      $* ?libbaz;
      $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3';

      $pkg_drop libbar
    }
  }

  : options
  :
  {
    : keep-out
    :
    : Test that --keep-out is properly propagated when building libhello
    : as a dependency, so it is built incrementally.
    :
    {
      $cfg_create cxx $config_cxx -d cfg &cfg/***;

      # Add libhello as the dir repository.
      #
      cp -r $src/libhello-1.0.0 ./libhello;
      $rep_add libhello --type dir;

      # Add libfoo as the dir repository and make it a dependent of libhello.
      #
      cp -r $src/libfoo-1.1.0 libfoo;
      echo 'depends: libhello' >+libfoo/manifest;
      $rep_add libfoo --type dir;

      $rep_fetch;

      # Note that libfoo building doesn't trigger libhello building as it is a
      # fake dependent, so build both explicitly.
      #
      $* libfoo libhello 2>!;

      # Move libhello version ahead.
      #
      sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest;
      $rep_fetch;

      # Upgrade libhello as a dependency.
      #
      # Note that despite the fact that we have modified the libhello's
      # manifest file after the build, libhello may still be considered up to
      # date on filesystems with a low file timestamps resolution (for example
      # HFS+).
      #
      $* ?libhello --yes --keep-out 2>>~%EOE%;
        disfigured libfoo/1.1.0
        disfigured libhello/1.0.0
        using libhello/1.0.1 (external)
        configured libhello/1.0.1
        configured libfoo/1.1.0
        %info: .+libfoo.+ is up to date%
        updated libfoo/1.1.0
        EOE

      test -d cfg/libhello/libhello
    }
  }

  : dependents
  :
  {
    test.arguments += --yes --configure-only

    : order
    :
    : Test that libbar that is built but isn't upgraded (and so doesn't order
    : itself against dependencies) is still properly reconfigured being
    : ordered as (an indirect) dependent of libfoo.
    :
    {
      $clone_root_cfg;
      $rep_fetch $rep/t0a $rep/t0b;

      $* libbar libfoo/0.0.1 2>>EOE;
        fetched libfix/0.0.1
        unpacked libfix/0.0.1
        fetched libfoo/0.0.1
        unpacked libfoo/0.0.1
        fetched libbaz/0.0.2
        unpacked libbaz/0.0.2
        fetched libbar/0.0.2
        unpacked libbar/0.0.2
        configured libfix/0.0.1
        configured libfoo/0.0.1
        configured libbaz/0.0.2
        configured libbar/0.0.2
        EOE

      $* libbar libfoo 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        configured libbaz/0.0.2
        configured libbar/0.0.2
        EOE

      $pkg_drop libbaz libbar libfoo
    }

    : adjust-merge-build
    :
    : Test that the registered in the map but not ordered package build
    : (libfoo) is properly merged into the reconfigure adjustment as a
    : dependent of the reconfigured dependency (see collect_order_dependents()
    : for more details).
    :
    {
      $clone_root_cfg;
      $rep_fetch $rep/t0a;

      $* libfoo 2>>EOE;
        fetched libfix/0.0.1
        unpacked libfix/0.0.1
        fetched libfoo/0.0.1
        unpacked libfoo/0.0.1
        configured libfix/0.0.1
        configured libfoo/0.0.1
        EOE

      $* libbaz libbar 'sys:libfix' 2>>EOE;
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        fetched libfox/0.0.1
        unpacked libfox/0.0.1
        fetched libbaz/0.0.1
        unpacked libbaz/0.0.1
        fetched libbar/0.0.1
        unpacked libbar/0.0.1
        purged libfix/0.0.1
        configured libfox/0.0.1
        configured libbaz/0.0.1
        configured libbar/0.0.1
        configured sys:libfix/*
        configured libfoo/0.0.1
        EOE

      $pkg_drop libbaz libbar libfoo
    }
  }

  : upgrade
  :
  : Test dependency upgrade using --immediate and --recursive options.
  :
  {
    test.arguments += --configure-only --upgrade

    +$clone_root_cfg
    +$rep_fetch $rep/t0a $rep/t0b $rep/t0c

    +$* libbar/0.0.2 libbaz/0.0.2 libfoo/0.0.1 --yes 2>>EOE
       fetched libfix/0.0.1
       unpacked libfix/0.0.1
       fetched libfoo/0.0.1
       unpacked libfoo/0.0.1
       fetched libbaz/0.0.2
       unpacked libbaz/0.0.2
       fetched libbar/0.0.2
       unpacked libbar/0.0.2
       configured libfix/0.0.1
       configured libfoo/0.0.1
       configured libbaz/0.0.2
       configured libbar/0.0.2
       EOE

    clone_cfg = [cmdline] cp --no-cleanup -r ../cfg ./ &cfg/***

    : immediate
    :
    {
      $clone_cfg;

      $* libbar/0.0.3 --immediate --yes 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        fetched libbaz/0.1.0
        unpacked libbaz/0.1.0
        fetched libbar/0.0.3
        unpacked libbar/0.0.3
        configured libbaz/0.1.0
        configured libbar/0.0.3
        EOE

      $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0';
      $pkg_status libbaz >'!libbaz configured !0.1.0';
      $pkg_status libfoo >'!libfoo configured !0.0.1 available 1.0.0'
    }

    : recursive
    :
    {
      $clone_cfg;

      $* libbar/0.0.3 --recursive --yes 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbaz/0.1.0
        unpacked libbaz/0.1.0
        fetched libbar/0.0.3
        unpacked libbar/0.0.3
        configured libfoo/1.0.0
        configured libbaz/0.1.0
        configured libbar/0.0.3
        EOE

      $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0';
      $pkg_status libbaz >'!libbaz configured !0.1.0';
      $pkg_status libfoo >'!libfoo configured !1.0.0'
    }

    : all-held
    :
    {
      $clone_cfg;

      $* ?libfoo/0.0.1 ?libbaz/0.0.2; # Unhold.

      $* --upgrade --recursive <'y' 2>>EOE
          drop libfix/0.0.1 (unused)
          upgrade libfoo/1.0.0
          drop libbaz/0.0.2 (unused)
          upgrade libbar/1.0.0
        continue? [Y/n] disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        purged libbaz/0.0.2
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        configured libfoo/1.0.0
        configured libbar/1.0.0
        EOE
    }

    : prompt
    :
    {
      $clone_cfg;

      $* libbaz/0.0.2 --recursive <'y' 2>>EOE
          drop libfix/0.0.1 (unused)
          upgrade libfoo/1.0.0
          reconfigure libbaz/0.0.2
          reconfigure libbar (dependent of libbaz)
        continue? [Y/n] disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        configured libbaz/0.0.2
        configured libbar/0.0.2
        EOE
    }

    : override
    :
    {
      $clone_cfg;

      $* libbar/0.0.3 ?libbaz/0.0.3 --recursive --yes 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbaz/0.0.3
        unpacked libbaz/0.0.3
        fetched libbar/0.0.3
        unpacked libbar/0.0.3
        configured libfoo/1.0.0
        configured libbaz/0.0.3
        configured libbar/0.0.3
        EOE

      $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'
    }

    : unhold
    :
    {
      $clone_cfg;

      $* libbar/0.0.3 ?libbaz/0.0.3 ?libfoo --recursive --yes 2>>EOE;
        disfigured libbar/0.0.2
        disfigured libbaz/0.0.2
        disfigured libfoo/0.0.1
        disfigured libfix/0.0.1
        purged libfix/0.0.1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbaz/0.0.3
        unpacked libbaz/0.0.3
        fetched libbar/0.0.3
        unpacked libbar/0.0.3
        configured libfoo/1.0.0
        configured libbaz/0.0.3
        configured libbar/0.0.3
        EOE

      $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0';
      $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4';
      $pkg_status libfoo >'libfoo configured 1.0.0'
    }

    : unavailable
    :
    : Test that the selected dependency (libfix/0.0.1) is silently left
    : unchanged if there is no package available from the dependents
    : repositories.
    :
    {
      $clone_cfg;
      $rep_remove $rep/t0a $rep/t0b $rep/t0c;

      $* libbar --recursive --yes
    }

    : unavailable-masked
    :
    : As above but using --mask-repository* instead of rep-remove.
    :
    {
      $clone_cfg;

      $* libbar --mask-repository $rep/t0a --mask-repository $rep/t0b \
                --mask-repository-uuid "$cfg_uuid=($rep/t0c)" --recursive --yes
    }

    -$pkg_drop libbar libbaz libfoo
  }

  : alternative
  :
  {
    +$clone_root_cfg && $rep_add $rep/t8a && $rep_fetch

    : multiple-dependencies
    :
    {
      $clone_cfg;

      $* foo --yes 2>>~%EOE%;
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        configured libbaz/1.1.0
        configured libbar/1.0.0
        configured foo/1.0.0
        %info: .+foo-1.0.0.+ is up to date%
        updated foo/1.0.0
        EOE

      $pkg_drop foo
    }

    : multiple-alternatives
    :
    {
      +$clone_cfg

      test.arguments += --yes --plan 'build plan:'

      : ambiguity
      :
      {
        $clone_cfg;

        $* fox 2>>EOE != 0
          error: unable to select dependency alternative for package fox/1.0.0
            info: explicitly specify dependency packages to manually select the alternative
            info: alternative: libbar
            info: alternative: libbaz
          info: while satisfying fox/1.0.0
          EOE
      }

      : reuse
      :
      {
        +$clone_cfg

        : specified-dep-build
        :
        {
          $clone_cfg;

          $* fox ?libbaz 2>>~%EOE%;
            build plan:
              new libbaz/1.1.0 (required by fox)
              new fox/1.0.0
                config.fox.backend=libbaz (set by fox)
            fetched libbaz/1.1.0
            unpacked libbaz/1.1.0
            fetched fox/1.0.0
            unpacked fox/1.0.0
            configured libbaz/1.1.0
            configured fox/1.0.0
            %info: .+fox-1.0.0.+ is up to date%
            updated fox/1.0.0
            EOE

          $pkg_drop fox
        }

        : hold-build
        :
        {
          $clone_cfg;

          $* fox libbaz 2>>~%EOE%;
            build plan:
              new libbaz/1.1.0
              new fox/1.0.0
                config.fox.backend=libbaz (set by fox)
            fetched libbaz/1.1.0
            unpacked libbaz/1.1.0
            fetched fox/1.0.0
            unpacked fox/1.0.0
            configured libbaz/1.1.0
            configured fox/1.0.0
            %info: .+libbaz-1.1.0.+ is up to date%
            %info: .+fox-1.0.0.+ is up to date%
            updated libbaz/1.1.0
            updated fox/1.0.0
            EOE

          $pkg_drop fox;
          $pkg_drop libbaz
        }

        : configured
        :
        {
          $clone_cfg;

          $* libbaz 2>!;

          $* fox 2>>~%EOE%;
            build plan:
              new fox/1.0.0
                config.fox.backend=libbaz (set by fox)
            fetched fox/1.0.0
            unpacked fox/1.0.0
            configured fox/1.0.0
            %info: .+fox-1.0.0.+ is up to date%
            updated fox/1.0.0
            EOE

          $pkg_drop fox;
          $pkg_drop libbaz
        }

        : fetched
        :
        {
          $clone_cfg;

          $pkg_fetch libbaz/1.0.0;

          $* fox 2>>~%EOE%;
            build plan:
              update libbaz/1.0.0 (required by fox)
              new fox/1.0.0
                config.fox.backend=libbaz (set by fox)
            unpacked libbaz/1.0.0
            fetched fox/1.0.0
            unpacked fox/1.0.0
            configured libbaz/1.0.0
            configured fox/1.0.0
            %info: .+fox-1.0.0.+ is up to date%
            updated fox/1.0.0
            EOE

          $pkg_drop fox
        }
      }

      : postpone
      :
      {
        +$clone_cfg

        : basic
        :
        {
          $clone_cfg;

          $* fox foo 2>>~%EOE%;
            build plan:
              new libbaz/1.1.0 (required by foo)
              new libbar/1.0.0 (required by foo, fox)
              new fox/1.0.0
                config.fox.backend=libbar (set by fox)
              new foo/1.0.0
            fetched libbaz/1.1.0
            unpacked libbaz/1.1.0
            fetched libbar/1.0.0
            unpacked libbar/1.0.0
            fetched fox/1.0.0
            unpacked fox/1.0.0
            fetched foo/1.0.0
            unpacked foo/1.0.0
            configured libbaz/1.1.0
            configured libbar/1.0.0
            configured fox/1.0.0
            configured foo/1.0.0
            %info: .+fox-1.0.0.+ is up to date%
            %info: .+foo-1.0.0.+ is up to date%
            updated fox/1.0.0
            updated foo/1.0.0
            EOE

          $pkg_drop fox;
          $pkg_drop foo
        }

        : pick-libbaz
        :
        {
          $clone_cfg;

          $* baz fox bar 2>>~%EOE%;
            build plan:
              new libbaz/1.1.0 (required by baz)
              new baz/1.0.0
              new libbar/1.0.0 (required by bar, fox)
              new fox/1.0.0
                config.fox.backend=libbar (set by fox)
              new bar/1.0.0
            fetched libbaz/1.1.0
            unpacked libbaz/1.1.0
            fetched baz/1.0.0
            unpacked baz/1.0.0
            fetched libbar/1.0.0
            unpacked libbar/1.0.0
            fetched fox/1.0.0
            unpacked fox/1.0.0
            fetched bar/1.0.0
            unpacked bar/1.0.0
            configured libbaz/1.1.0
            configured baz/1.0.0
            configured libbar/1.0.0
            configured fox/1.0.0
            configured bar/1.0.0
            %info: .+baz-1.0.0.+ is up to date%
            %info: .+fox-1.0.0.+ is up to date%
            %info: .+bar-1.0.0.+ is up to date%
            updated baz/1.0.0
            updated fox/1.0.0
            updated bar/1.0.0
            EOE

          cat cfg/fox-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.fox.backend = libbar
            %.*
            EOO

          $pkg_drop fox;
          $pkg_drop bar;
          $pkg_drop baz
        }
      }

      : reconfigure-dependent
      :
      {
        $clone_cfg;

        $* fox ?libbaz/1.0.0 2>>~%EOE%;
          build plan:
            new libbaz/1.0.0 (required by fox)
            new fox/1.0.0
              config.fox.backend=libbaz (set by fox)
          fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched fox/1.0.0
          unpacked fox/1.0.0
          configured libbaz/1.0.0
          configured fox/1.0.0
          %info: .+fox-1.0.0.+ is up to date%
          updated fox/1.0.0
          EOE

        $* ?libbaz 2>>~%EOE%;
          build plan:
            upgrade libbaz/1.1.0
            reconfigure fox (dependent of libbaz)
          disfigured fox/1.0.0
          disfigured libbaz/1.0.0
          fetched libbaz/1.1.0
          unpacked libbaz/1.1.0
          configured libbaz/1.1.0
          configured fox/1.0.0
          %info: .+fox-1.0.0.+ is up to date%
          updated fox/1.0.0
          EOE

        cat cfg/fox-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.fox.backend = libbaz
          %.*
          EOO

        $pkg_drop fox
      }

      : recreate-decision
      :
      {
        +$clone_cfg

        : reevaluate-alternatives
        :
        {
          +$clone_cfg

          : preserve
          :
          : Test that the existing libbox dependency is preserved even though
          : libbiz is more preferable as a dependency.
          :
          {
            $clone_cfg;

            $* box libbox 2>!;

            $* box +{ config.box.extras=true } ?libbiz 2>>~%EOE%;
              build plan:
                reconfigure/update box/1.0.0
                  config.box.extras=true (user configuration)
                  config.box.backend=libbox (set by box)
              disfigured box/1.0.0
              configured box/1.0.0
              %info: .+box-1.0.0.+ is up to date%
              updated box/1.0.0
              EOE

            $* box +{ config.box.extras=false } libbiz 2>>~%EOE%;
              build plan:
                reconfigure/update box/1.0.0
                  config.box.extras=false (user configuration)
                  config.box.backend=libbox (set by box)
                new libbiz/1.0.0
              disfigured box/1.0.0
              fetched libbiz/1.0.0
              unpacked libbiz/1.0.0
              configured box/1.0.0
              configured libbiz/1.0.0
              %info: .+box-1.0.0.+ is up to date%
              %info: .+libbiz-1.0.0.+ is up to date%
              updated box/1.0.0
              updated libbiz/1.0.0
              EOE

            $pkg_status -r box >>EOO;
              !box configured 1.0.0
                libbaz configured 1.1.0
                !libbox configured 1.0.0
              EOO

            cat cfg/box-1.0.0/build/config.build >>~%EOO%;
              %.*
              config.box.backend = libbox
              %.*
              EOO

            $pkg_drop box;
            $pkg_drop libbox;
            $pkg_drop libbiz
          }

          : change-downgraded-depenency
          :
          : Test that libbiz is selected as a dependency since the existing
          : dependency decision cannot be preserved (libbox is downgraded to
          : 0.1.0 and becomes unsatisfactory for box).
          :
          {
            $clone_cfg;

            $* box libbox 2>!;

            $* box +{ config.box.extras=true } ?libbox/0.1.0 2>>~%EOE%;
              build plan:
                new libbiz/1.0.0 (required by box)
                drop libbox/1.0.0 (unused)
                reconfigure/update box/1.0.0
                  config.box.extras=true (user configuration)
                  config.box.backend=libbiz (set by box)
              disfigured box/1.0.0
              disfigured libbox/1.0.0
              fetched libbiz/1.0.0
              unpacked libbiz/1.0.0
              purged libbox/1.0.0
              configured libbiz/1.0.0
              configured box/1.0.0
              %info: .+box-1.0.0.+ is up to date%
              updated box/1.0.0
              EOE

            $pkg_status -r box >>EOO;
              !box configured 1.0.0
                libbaz configured 1.1.0
                libbiz configured 1.0.0
              EOO

            cat cfg/box-1.0.0/build/config.build >>~%EOO%;
              %.*
              config.box.backend = libbiz
              %.*
              EOO

            $pkg_drop box
          }

          : change-downgraded-hold
          :
          : As above but libbox is downgraded to hold.
          :
          {
            $clone_cfg;

            $* box libbox 2>!;

            # While at it, test the reused-only alternative selection mode.
            #
            $* box +{ config.box.extras=true } libbox/0.1.0 2>>EOE != 0;
              error: unable to select dependency alternative for package box/1.0.0
                info: explicitly specify dependency packages to manually select the alternative
                info: alternative: libbiz
                info: unsatisfactory alternative: libbox
                error: unable to satisfy constraints on package libbox
                info: command line depends on (libbox == 0.1.0)
                info: box depends on (libbox >= 0.1.1)
                info: available libbox/0.1.0
                info: available libbox/1.0.0
                info: explicitly specify libbox version to manually satisfy both constraints
              info: while satisfying box/1.0.0
              EOE

            $* box +{ config.box.extras=true } libbox/0.1.0 ?libbiz 2>>~%EOE%;
              build plan:
                new libbiz/1.0.0 (required by box)
                downgrade libbox/0.1.0
                reconfigure/update box/1.0.0
                  config.box.extras=true (user configuration)
                  config.box.backend=libbiz (set by box)
              disfigured box/1.0.0
              disfigured libbox/1.0.0
              fetched libbiz/1.0.0
              unpacked libbiz/1.0.0
              fetched libbox/0.1.0
              unpacked libbox/0.1.0
              configured libbiz/1.0.0
              configured libbox/0.1.0
              configured box/1.0.0
              %info: .+libbox-0.1.0.+ is up to date%
              %info: .+box-1.0.0.+ is up to date%
              updated libbox/0.1.0
              updated box/1.0.0
              EOE

            $pkg_status -r box >>EOO;
              !box configured 1.0.0
                libbaz configured 1.1.0
                libbiz configured 1.0.0
              EOO

            cat cfg/box-1.0.0/build/config.build >>~%EOO%;
              %.*
              config.box.backend = libbiz
              %.*
              EOO

            $pkg_drop box;
            $pkg_drop libbox
          }
        }

        : reconfigure
        :
        {
          $clone_cfg;

          $* box ?libbiz/0.1.0 2>>~%EOE%;
            build plan:
              new libbox/1.0.0 (required by box)
              new libbaz/1.1.0 (required by box)
              new box/1.0.0
                config.box.backend=libbox (set by box)
            fetched libbox/1.0.0
            unpacked libbox/1.0.0
            fetched libbaz/1.1.0
            unpacked libbaz/1.1.0
            fetched box/1.0.0
            unpacked box/1.0.0
            configured libbox/1.0.0
            configured libbaz/1.1.0
            configured box/1.0.0
            %info: .+box-1.0.0.+ is up to date%
            updated box/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !box configured 1.0.0
              libbaz configured 1.1.0
              libbox configured 1.0.0
            EOO

          cat cfg/box-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.box.backend = libbox
            %.*
            EOO

          # Downgrade libbaz to reconfigure box and make sure we still keep
          # libbox as a prerequisite of box.
          #
          $* libbiz ?libbaz/1.0.0 2>>~%EOE%;
            build plan:
              new libbiz/1.0.0
              downgrade libbaz/1.0.0
              reconfigure box (dependent of libbaz)
            disfigured box/1.0.0
            disfigured libbaz/1.1.0
            fetched libbiz/1.0.0
            unpacked libbiz/1.0.0
            fetched libbaz/1.0.0
            unpacked libbaz/1.0.0
            configured libbiz/1.0.0
            configured libbaz/1.0.0
            configured box/1.0.0
            %info: .+libbiz-1.0.0.+ is up to date%
            %info: .+box-1.0.0.+ is up to date%
            updated libbiz/1.0.0
            updated box/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !box configured 1.0.0
              libbaz configured !1.0.0 available 1.1.0
              libbox configured 1.0.0
            !libbiz configured 1.0.0
            EOO

          cat cfg/box-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.box.backend = libbox
            %.*
            EOO

          # Make sure the decision is hold for downgraded dependency either.
          #
          $* ?libbox/0.1.1 2>>~%EOE%;
            build plan:
              downgrade libbox/0.1.1
              reconfigure box (dependent of libbox)
            disfigured box/1.0.0
            disfigured libbox/1.0.0
            fetched libbox/0.1.1
            unpacked libbox/0.1.1
            configured libbox/0.1.1
            configured box/1.0.0
            %info: .+box-1.0.0.+ is up to date%
            updated box/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !box configured 1.0.0
              libbaz configured !1.0.0 available 1.1.0
              libbox configured !0.1.1 available 1.0.0
            !libbiz configured 1.0.0
            EOO

          cat cfg/box-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.box.backend = libbox
            %.*
            EOO

          $pkg_drop box;
          $pkg_drop libbiz
        }
      }
    }

    : enable-condition
    :
    {
      +$cfg_create cxx $config_cxx -d cfg &cfg/***
      +$rep_add $rep/t8a && $rep_fetch

      test.arguments += --yes

      backend            = ($posix ? 'libbaz' : 'libbar')
      backend_dep        = ($posix ? 'libbaz/1.1.0' : 'libbar/1.0.0')
      backend_configured = ($posix ? 'libbaz configured 1.1.0' : 'libbar configured 1.0.0')

      : cxx-target
      :
      {
        $clone_cfg;

        $* fax 2>>~"%EOE%";
          fetched $backend_dep
          unpacked $backend_dep
          fetched fax/1.0.0
          unpacked fax/1.0.0
          configured $backend_dep
          configured fax/1.0.0
          %info: .+fax-1.0.0.+ is up to date%
          updated fax/1.0.0
          EOE

        $pkg_status -r >>"EOO";
          !fax configured 1.0.0
            $backend_configured
          EOO

        cat cfg/fax-1.0.0/build/config.build >>~"%EOO%";
          %.*
          config.fax.backend = $backend
          config.fax.libbiz = false
          %.*
          EOO

        $pkg_drop fax
      }

      : config-var
      :
      {
        $clone_cfg;

        $* config.fax.libbiz=true -- fax 2>>~"%EOE%";
          fetched $backend_dep
          unpacked $backend_dep
          fetched libbiz/1.0.0
          unpacked libbiz/1.0.0
          fetched fax/1.0.0
          unpacked fax/1.0.0
          configured $backend_dep
          configured libbiz/1.0.0
          configured fax/1.0.0
          %info: .+fax-1.0.0.+ is up to date%
          updated fax/1.0.0
          EOE

        $pkg_status -r >>"EOO";
          !fax configured 1.0.0
            $backend_configured
            libbiz configured 1.0.0
          EOO

        cat cfg/fax-1.0.0/build/config.build >>~"%EOO%";
          %.*
          config.fax.backend = $backend
          config.fax.libbiz = true
          %.*
          EOO

        $pkg_drop fax
      }

      : reevaluate-alternatives
      :
      {
        +$clone_cfg

        : add-dependency
        :
        {
          $clone_cfg;

          $* fax 2>!;

          $pkg_status -r >>"EOO";
            !fax configured 1.0.0
              $backend_configured
            EOO

          $* config.fax.libbiz=true -- fax 2>>~%EOE%;
            disfigured fax/1.0.0
            fetched libbiz/1.0.0
            unpacked libbiz/1.0.0
            configured libbiz/1.0.0
            configured fax/1.0.0
            %info: .+fax-1.0.0.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fax configured 1.0.0
              $backend_configured
              libbiz configured 1.0.0
            EOO

          # While at it, tests that the dependency is properly removed.
          #
          $* config.fax.libbiz=false -- fax 2>>~%EOE%;
            disfigured fax/1.0.0
            disfigured libbiz/1.0.0
            purged libbiz/1.0.0
            configured fax/1.0.0
            %info: .+fax-1.0.0.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fax configured 1.0.0
              $backend_configured
            EOO

          $pkg_drop fax
        }

        : downgrade-dependency
        :
        {
          $clone_cfg;

          $* fux 2>!;

          $pkg_status -r >>"EOO";
            !fux configured 1.0.0
              libbiz configured 1.0.0
            EOO

          $* config.fux.libbiz_old=true -- fux 2>>~%EOE%;
            disfigured fux/1.0.0
            disfigured libbiz/1.0.0
            fetched libbiz/0.1.0
            unpacked libbiz/0.1.0
            configured libbiz/0.1.0
            configured fux/1.0.0
            %info: .+fux-1.0.0.+ is up to date%
            updated fux/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fux configured 1.0.0
              libbiz configured 0.1.0 available 1.0.0
            EOO

          # While at it, test that the dependency is properly upgraded.
          #
          # Note that, unless requested, libbiz is not upgraded, since 0.1.0
          # is still good for the selected alternative.
          #
          $* config.fux.libbiz_old=false -- fux 2>>~%EOE%;
            disfigured fux/1.0.0
            configured fux/1.0.0
            %info: .+fux-1.0.0.+ is up to date%
            updated fux/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fux configured 1.0.0
              libbiz configured 0.1.0 available 1.0.0
            EOO

          $* fux +{ config.fux.libbiz_old=false } ?libbiz 2>>~%EOE%;
            disfigured fux/1.0.0
            disfigured libbiz/0.1.0
            fetched libbiz/1.0.0
            unpacked libbiz/1.0.0
            configured libbiz/1.0.0
            configured fux/1.0.0
            %info: .+fux-1.0.0.+ is up to date%
            updated fux/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fux configured 1.0.0
              libbiz configured 1.0.0
            EOO

          $pkg_drop fux
        }
      }

      : external-package
      :
      if! $remote
      {
        +$clone_cfg

        +tar (!$posix ? --force-local : ) -xzf $src/t8a/fax-1.0.0.tar.gz &fax-1.0.0/***
        +mv fax-1.0.0 fax

        : change-manifest
        :
        {
          $clone_cfg;
          cp -rp ../fax/ ./;

          $* config.fax.libbiz=true -- fax/ 2>>~"%EOE%";
            fetched $backend_dep
            unpacked $backend_dep
            fetched libbiz/1.0.0
            unpacked libbiz/1.0.0
            using fax/1.0.0 \(external\)
            configured $backend_dep
            configured libbiz/1.0.0
            configured fax/1.0.0
            %info: .+fax.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fax configured !1.0.0
              $backend_configured
              libbiz configured 1.0.0
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = true
            %.*
            EOO

          # Upgrade the external package after changing its manifest and make
          # sure the configuration is preserved.
          #
          echo '' >+fax/manifest;

          $* fax/ 2>>~%EOE%;
            disfigured fax/1.0.0
            using fax/1.0.0#1 (external)
            configured fax/1.0.0#1
            %info: .+fax.+ is up to date%
            updated fax/1.0.0#1
            EOE

          $pkg_status -r >>"EOO";
            !fax configured !1.0.0#1
              $backend_configured
              libbiz configured 1.0.0
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = true
            %.*
            EOO

          # While at it, test that it's ok for out root directory to not
          # exist.
          #
          # Note that this testing is only meaningful when we replace an
          # external package with another external (see
          # build_package::external() for details).
          #
          echo '' >+fax/manifest;

          rm -r cfg/fax/;

          $* fax/ 2>>~%EOE%;
            disfigured fax/1.0.0#1
            disfigured libbiz/1.0.0
            purged libbiz/1.0.0
            using fax/1.0.0#2 (external)
            configured fax/1.0.0#2
            %info: .+fax.+ is up to date%
            updated fax/1.0.0#2
            EOE

          $pkg_status -r >>"EOO";
            !fax configured !1.0.0#2
              $backend_configured
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = false
            %.*
            EOO

          # Also tests that the depends value location is printed on the
          # enable condition evaluation failure for an external package.
          #
          sed -i -e 's/(depends: libbiz).+/\1 ? (config.fax.libbiz = true)/' fax/manifest;

          $* fax/ 2>>~%EOE% != 0;
            <depends-enable-clause>:1: error: invalid bool value: multiple names
              info: enable condition: (config.fax.libbiz = true)
            %  fax.manifest:10:10: info: in depends manifest value defined here%
            info: while satisfying fax/1.0.0#3
            EOE

          $pkg_drop fax
        }

        : change-buildfile
        :
        {
          +$clone_cfg

          : package-directory
          :
          {
            $clone_cfg;
            cp -rp ../../fax/ ./;

            $* fax 2>>~"%EOE%";
              fetched $backend_dep
              unpacked $backend_dep
              fetched fax/1.0.0
              unpacked fax/1.0.0
              configured $backend_dep
              configured fax/1.0.0
              %info: .+fax-1.0.0.+ is up to date%
              updated fax/1.0.0
              EOE

            $pkg_status -r >>"EOO";
              !fax configured 1.0.0
                $backend_configured
              EOO

            # Iteration increment and upgrade after turning a package from the
            # archive-based repo into an external package.
            #
            $* fax/ 2>>~%EOE%;
              disfigured fax/1.0.0
              using fax/1.0.0#1 (external)
              configured fax/1.0.0#1
              %info: .+dir.fax.+ is up to date%
              updated fax/1.0.0#1
              EOE

            $pkg_status -r >>"EOO";
              !fax configured !1.0.0#1
                $backend_configured
              EOO

            # Further upgrade after the package' buildfile is edited.
            #
            echo '' >+fax/build/root.build;

            $* fax/ 2>>~%EOE%;
              disfigured fax/1.0.0#1
              using fax/1.0.0#2 (external)
              configured fax/1.0.0#2
              %info: .+fax.+ is up to date%
              updated fax/1.0.0#2
              EOE

            $pkg_status -r >>"EOO";
              !fax configured !1.0.0#2
                $backend_configured
              EOO

            # No upgrade if the buildfile is not edited.
            #
            $* fax/ 2>>~%EOE%;
              %info: .+fax.+ is up to date%
              updated fax/1.0.0#2
              EOE

            $pkg_status -r >>"EOO";
              !fax configured !1.0.0#2
                $backend_configured
              EOO

            $pkg_drop fax
          }

          : directory-repo
          :
          {
            $clone_cfg;
            cp -rp ../../fax/ ./;

            $* fax 2>>~"%EOE%";
              fetched $backend_dep
              unpacked $backend_dep
              fetched fax/1.0.0
              unpacked fax/1.0.0
              configured $backend_dep
              configured fax/1.0.0
              %info: .+fax-1.0.0.+ is up to date%
              updated fax/1.0.0
              EOE

            $pkg_status -r >>"EOO";
              !fax configured 1.0.0
                $backend_configured
              EOO

            # Iteration increment and upgrade after turning a package from the
            # archive-based repo into an external package.
            #
            $rep_add --type dir fax/ && $rep_fetch;

            $* fax 2>>~%EOE%;
              disfigured fax/1.0.0
              using fax/1.0.0#1 (external)
              configured fax/1.0.0#1
              %info: .+dir.fax.+ is up to date%
              updated fax/1.0.0#1
              EOE

            $pkg_status -r >>"EOO";
              !fax configured 1.0.0#1
                $backend_configured
              EOO

            # Further upgrade after the package' buildfile is edited.
            #
            echo '' >+fax/build/root.build;

            $rep_fetch;

            $* fax 2>>~%EOE%;
              disfigured fax/1.0.0#1
              using fax/1.0.0#2 (external)
              configured fax/1.0.0#2
              %info: .+fax.+ is up to date%
              updated fax/1.0.0#2
              EOE

            $pkg_status -r >>"EOO";
              !fax configured 1.0.0#2
                $backend_configured
              EOO

            # No upgrade if the buildfile is not edited.
            #
            $rep_fetch;

            $* fax 2>>~%EOE%;
              %info: .+fax.+ is up to date%
              updated fax/1.0.0#2
              EOE

            $pkg_status -r >>"EOO";
              !fax configured 1.0.0#2
                $backend_configured
              EOO

            $pkg_drop fax
          }
        }

        : reconfigure-reflect-vars
        :
        {
          $clone_cfg;
          cp -rp ../fax/ ./;

          $* config.fax.libbiz=true -- fax/ 2>>~"%EOE%";
            fetched $backend_dep
            unpacked $backend_dep
            fetched libbiz/1.0.0
            unpacked libbiz/1.0.0
            using fax/1.0.0 \(external\)
            configured $backend_dep
            configured libbiz/1.0.0
            configured fax/1.0.0
            %info: .+fax.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>"EOO";
            !fax configured !1.0.0
              $backend_configured
              libbiz configured 1.0.0
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = true
            %config.fax.extras = '.+'%
            config.fax.libbox = false
            EOO

          # While at it, make sure none of the reflect variables are
          # unexpectedly wiped out on reconfiguration due to the dependency
          # upgrade.
          #
          $* fax/ "?sys:$backend/*" 2>>~"%EOE%";
            disfigured fax/1.0.0
            %disfigured $backend/.+%
            %purged $backend/.+%
            configured sys:$backend/*
            configured fax/1.0.0
            %info: .+fax.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>~"%EOO%";
            !fax configured !1.0.0
            %  $backend configured,system .+%
              libbiz configured 1.0.0
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = true
            %config.fax.extras = '.+'%
            config.fax.libbox = false
            EOO

          # Now make sure that dependency clauses re-evaluation is properly
          # reflected in the configuration.
          #
          $* config.fax.libbiz=false -- fax/ 2>>~"%EOE%";
            disfigured fax/1.0.0
            disfigured libbiz/1.0.0
            purged libbiz/1.0.0
            configured fax/1.0.0
            %info: .+fax.+ is up to date%
            updated fax/1.0.0
            EOE

          $pkg_status -r >>~"%EOO%";
            !fax configured !1.0.0
            %  $backend configured,system .+%
            EOO

          cat cfg/fax/build/config.build >>~"%EOO%";
            %.*
            config.fax.backend = $backend
            config.fax.libbiz = false
            config.fax.extras = [null]
            config.fax.libbox = false
            EOO

          $pkg_drop fax
        }
      }

      : evaluate-reflect-vars
      :
      {
        $clone_cfg;

        $* config.fax.libbox=true config.fax.libbiz=true -- fax 2>!;

        if $posix
          $pkg_status -r >>EOO
            !fax configured 1.0.0
              libbaz configured 1.1.0
              libbiz configured 1.0.0
              libbox configured 1.0.0
            EOO
        else
          $pkg_status -r >>EOO
            !fax configured 1.0.0
              libbar configured 1.0.0
              libbiz configured 1.0.0
            EOO
        end;

        $pkg_drop fax
      }
    }
  }

  : version-replacement
  :
  {
    +$clone_root_cfg && $rep_add $rep/t12b && $rep_fetch

    test.arguments += --yes

    : not-replaced
    :
    {
      $clone_cfg;

      $* bar foo 2>!;

      $pkg_status -r >>EOO;
        !bar configured 1.0.0
          libbar configured 0.1.0 available 1.0.0
            libbaz configured 1.0.0
        !foo configured 1.0.0
          libbar configured 0.1.0 available 1.0.0
            libbaz configured 1.0.0
        EOO

      $pkg_drop bar foo
    }

    : replaced-scratch
    :
    : Test that changing package order on the command line does not result
    : in a sub-optimal choice of the libbaz version (0.1.0).
    :
    : Note that this was not the case until we implemented the builds
    : re-collection on the package version change.
    :
    {
      $clone_cfg;

      $* foo bar --verbose 5 2>>~%EOE%;
        %.*
        trace: pkg_build: refine package collection/plan execution from scratch
        %.*
        trace: collect_build: add foo/1.0.0
        trace: collect_build: add bar/1.0.0
        trace: collect_build_prerequisites: begin foo/1.0.0
        %.*
        trace: collect_build: add libbar/1.0.0
        trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent foo/1.0.0
        trace: collect_build_prerequisites: begin libbar/1.0.0
        %.*
        trace: collect_build: add libbaz/0.1.0
        trace: collect_build_prerequisites: no cfg-clause for dependency libbaz/0.1.0 of dependent libbar/1.0.0
        trace: collect_build_prerequisites: begin libbaz/0.1.0
        trace: collect_build_prerequisites: end libbaz/0.1.0
        trace: collect_build_prerequisites: end libbar/1.0.0
        trace: collect_build_prerequisites: end foo/1.0.0
        trace: collect_build_prerequisites: begin bar/1.0.0
        %.*
        trace: collect_build: pick libbar/0.1.0 over libbar/1.0.0
        trace: collect_build: libbar/1.0.0 package version needs to be replaced with libbar/0.1.0
        trace: pkg_build: collection failed due to package version replacement, retry from scratch
        %.*
        trace: pkg_build: refine package collection/plan execution from scratch
        %.*
        trace: collect_build: add foo/1.0.0
        trace: collect_build: add bar/1.0.0
        trace: collect_build_prerequisites: begin foo/1.0.0
        %.*
        trace: collect_build: apply version replacement for libbar/1.0.0
        trace: collect_build: replacement: libbar/0.1.0
        trace: collect_build: add libbar/0.1.0
        trace: collect_build_prerequisites: no cfg-clause for dependency libbar/0.1.0 of dependent foo/1.0.0
        trace: collect_build_prerequisites: begin libbar/0.1.0
        %.*
        trace: collect_build: add libbaz/1.0.0
        trace: collect_build_prerequisites: no cfg-clause for dependency libbaz/1.0.0 of dependent libbar/0.1.0
        trace: collect_build_prerequisites: begin libbaz/1.0.0
        trace: collect_build_prerequisites: end libbaz/1.0.0
        trace: collect_build_prerequisites: end libbar/0.1.0
        trace: collect_build_prerequisites: end foo/1.0.0
        trace: collect_build_prerequisites: begin bar/1.0.0
        %.*
        trace: collect_build_prerequisites: no cfg-clause for dependency libbar/0.1.0 of dependent bar/1.0.0
        trace: collect_build_prerequisites: end bar/1.0.0
        trace: execute_plan: simulate: yes
        %.*
        EOE

      $pkg_status -r >>EOO;
        !foo configured 1.0.0
          libbar configured 0.1.0 available 1.0.0
            libbaz configured 1.0.0
        !bar configured 1.0.0
          libbar configured 0.1.0 available 1.0.0
            libbaz configured 1.0.0
        EOO

      $pkg_drop foo bar
    }

    : replaced-inplace
    :
    : Test the version replacement optimization. Here libbaz/1.0.0 get
    : replaced with 0.1.0 but without re-collection from scratch since it
    : does not have any dependencies.
    :
    {
      $clone_cfg && $rep_add $rep/t12a && $rep_fetch;

      $* libbaz libbar  --verbose 5 2>>~%EOE%;
        %.*
        trace: pkg_build: refine package collection/plan execution from scratch
        %.*
        trace: collect_build: add libbaz/1.0.0
        trace: collect_build: add libbar/1.0.0
        trace: collect_build_prerequisites: begin libbaz/1.0.0
        %.*
        trace: collect_build_prerequisites: end libbaz/1.0.0
        trace: collect_build_prerequisites: begin libbar/1.0.0
        %.*
        trace: collect_build: pick libbaz/0.1.0 over libbaz/1.0.0
        trace: collect_build: libbaz/1.0.0 package version needs to be replaced in-place with libbaz/0.1.0
        trace: collect_build_prerequisites: no cfg-clause for dependency libbaz/0.1.0 of dependent libbar/1.0.0
        trace: collect_build_prerequisites: begin libbaz/0.1.0
        trace: collect_build_prerequisites: end libbaz/0.1.0
        trace: collect_build_prerequisites: end libbar/1.0.0
        trace: execute_plan: simulate: yes
        %.*
        EOE

      $pkg_status -r >>EOO;
        !libbaz configured 0.1.0 available 1.0.0
        !libbar configured 1.0.0
          !libbaz configured 0.1.0 available 1.0.0
        EOO

      $pkg_drop libbaz libbar
    }
  }

  : drop-dependent
  :
  {
    +$clone_root_cfg && $rep_add $rep/t12b && $rep_fetch

    test.arguments += --yes

    : unhold
    :
    : Test that the being dropped dependent does not constrain a dependency
    : anymore.
    :
    {
      $clone_cfg;

      $* libbar 2>!;

      $pkg_status -r >>EOO;
        !libbar configured 1.0.0
          libbaz configured 0.1.0 available [1.0.0]
        EOO

      $* baz/0.1.0 ?libbar ?libbaz 2>!;

      $pkg_status -r >>EOO;
        !baz configured !0.1.0 available 1.0.0
          libbaz configured 1.0.0
        EOO

      $pkg_drop baz
    }

    : unuse
    :
    : Unlike the previous test, at the time we check the constraint applied
    : by libbar on libbaz (== 0.1.0) there is no evidence that libbar will be
    : dropped, which will happen some later execution plan refinement
    : iteration.
    :
    {
      $clone_cfg;

      $* foo 2>!;

      $pkg_status -r >>EOO;
        !foo configured 1.0.0
          libbar configured 1.0.0
            libbaz configured 0.1.0 available [1.0.0]
        EOO

      $* baz foo/0.1.0 2>!;

      $pkg_status -r >>EOO;
        !foo configured !0.1.0 available 1.0.0
        !baz configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $pkg_drop baz foo
    }
  }

  : config-negotiation-order
  :
  {
    +$clone_root_cfg && $rep_add $rep/t11a && $rep_fetch

    test.arguments += --yes --plan 'build plan:' --verbose 5 --build-option --quiet

    : initial-collection
    :
    {
      +$clone_cfg

      : postpone
      :
      {
        $clone_cfg;

        $* foo fox fux 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/1.0.0
          trace: collect_build: add fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/1.0.0
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone fox/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fox/1.0.0
          trace: collect_build_prerequisites: resume fox/1.0.0
          trace: collect_build_prerequisites: end fox/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo fox | libfoo->{foo/1,1 fox/1,1}}!
          trace: collect_build_postponed (1): end {foo fox | libfoo->{foo/1,1 fox/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          build plan:
            new libfoo/1.0.0 (required by foo, fox, fux)
              config.libfoo.extras=true (set by foo)
            new foo/1.0.0
            new fox/1.0.0
            new fux/1.0.0
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !fox configured 1.0.0
            libfoo configured 1.0.0
          !fux configured 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop foo fox fux
      }

      : postpone-system
      :
      {
        $clone_cfg;

        $* foo fox '?sys:libfoo/*' 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency sys:libfoo/* of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency sys:libfoo/* of dependent fox/1.0.0
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone fox/1.0.0
          %.*
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: skip system sys:libfoo/*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fox/1.0.0
          trace: collect_build_prerequisites: resume fox/1.0.0
          trace: collect_build_prerequisites: end fox/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo fox | libfoo->{foo/1,1 fox/1,1}}!
          trace: collect_build_postponed (1): end {foo fox | libfoo->{foo/1,1 fox/1,1}}
          trace: collect_build_postponed (0): end
          %.*
          trace: execute_plan: simulate: yes
          %.*
          build plan:
            configure sys:libfoo/* (required by foo, fox)
              config.libfoo.extras=true (expected by foo)
            new foo/1.0.0
            new fox/1.0.0
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured,system !* available 1.0.0 0.1.0
          !fox configured 1.0.0
            libfoo configured,system !* available 1.0.0 0.1.0
          EOO

        $pkg_drop foo fox
      }

      : postpone-merge
      :
      {
        $clone_cfg;

        $* foo bar baz 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add bar/1.0.0
          trace: collect_build: add baz/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin bar/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
          trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
          trace: collect_build_prerequisites: postpone bar/1.0.0
          trace: collect_build_prerequisites: begin baz/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent baz/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent baz/1.0.0
          trace: postponed_configurations::add: add {baz 1,1: libbar libfoo} to {foo | libfoo->{foo/1,1}}
          trace: postponed_configurations::add: merge {bar | libbar->{bar/1,1}} into {baz foo | libfoo->{baz/1,1 foo/1,1} libbar->{baz/1,1}}
          trace: collect_build_prerequisites: postpone baz/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {bar baz foo | libfoo->{baz/1,1 foo/1,1} libbar->{bar/1,1 baz/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {bar baz foo | libfoo->{baz/1,1 foo/1,1} libbar->{bar/1,1 baz/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bar/1.0.0
          trace: collect_build_prerequisites: resume bar/1.0.0
          trace: collect_build_prerequisites: end bar/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
          trace: collect_build_prerequisites: resume baz/1.0.0
          trace: collect_build_prerequisites: end baz/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {bar baz foo | libfoo->{baz/1,1 foo/1,1} libbar->{bar/1,1 baz/1,1}}!
          trace: collect_build_postponed (1): end {bar baz foo | libfoo->{baz/1,1 foo/1,1} libbar->{bar/1,1 baz/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          build plan:
            new libfoo/1.0.0 (required by baz, foo)
              config.libfoo.extras=true (set by baz)
            new foo/1.0.0
            new libbar/1.0.0 (required by bar, baz)
              config.libbar.extras=true (set by bar)
            new bar/1.0.0
            new baz/1.0.0
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !bar configured 1.0.0
            libbar configured 1.0.0
          !baz configured 1.0.0
            libbar configured 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop foo bar baz
      }

      : postpone-dependency-dependent
      :
      {
        $clone_cfg;

        $* fex 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fex/1.0.0
          trace: collect_build_prerequisites: begin fex/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency foo/1.0.0 of dependent fex/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fex/1.0.0
          trace: postponed_configurations::add: add {fex 2,1: libfoo} to {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone fex/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fex foo | libfoo->{fex/2,1 foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fex foo | libfoo->{fex/2,1 foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fex/1.0.0
          trace: collect_build_prerequisites: resume fex/1.0.0
          trace: collect_build_prerequisites: end fex/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {fex foo | libfoo->{fex/2,1 foo/1,1}}!
          trace: collect_build_postponed (1): end {fex foo | libfoo->{fex/2,1 foo/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fex configured 1.0.0
            foo configured 1.0.0
              libfoo configured 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop fex
      }

      : premature
      :
      {
        $clone_cfg;

        $* fux foo fox 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/1.0.0
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone fox/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo fox | libfoo->{foo/1,1 fox/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fox/1.0.0
          trace: collect_build_prerequisites: resume fox/1.0.0
          trace: collect_build_prerequisites: end fox/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo fox | libfoo->{foo/1,1 fox/1,1}}!
          trace: collect_build_postponed (1): end {foo fox | libfoo->{foo/1,1 fox/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fux configured 1.0.0
            libfoo configured 1.0.0
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !fox configured 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop fux foo fox
      }

      : bogus-postponment
      :
      {
        $clone_cfg;

        $* fux foo fix 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (foo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: pkg_build: dep-postpone user-specified foo
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: pkg_build: erase bogus postponement libfoo
          trace: pkg_build: bogus postponements erased, throwing
          trace: pkg_build: collection failed due to bogus dependency collection postponement cancellation, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: pkg_build: dep-postpone user-specified foo
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (foo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: pkg_build: dep-postpone user-specified foo
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fix/1.0.0
          trace: collect_build_prerequisites: resume fix/1.0.0
          trace: collect_build_prerequisites: end fix/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {fix | foo->{fix/1,1}}!
          trace: collect_build_postponed (2): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (2): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): end {fix | foo->{fix/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fux configured 1.0.0
            libfoo configured 1.0.0
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !fix configured 1.0.0
            !foo configured 1.0.0
              libfoo configured 1.0.0
          EOO

        $pkg_drop fux foo fix
      }
    }

    : existing
    :
    {
      +$clone_cfg

      : dependency
      :
      {
        $clone_cfg;

        $* libfoo 2>!;

        $* foo 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: skip configured libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (0): end
          %.*
          trace: execute_plan: simulate: yes
          %.*
          build plan:
            reconfigure/update libfoo/1.0.0 (required by foo)
              config.libfoo.extras=true (set by foo)
            new foo/1.0.0
          %.*
          EOE

        $pkg_status -r >>EOO;
          !libfoo configured 1.0.0
          !foo configured 1.0.0
            !libfoo configured 1.0.0
          EOO

        $pkg_drop foo libfoo
      }

      : dependent-single-pos
      :
      {
        +$clone_cfg

        : basic
        :
        {
          $clone_cfg;

          $* foo 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          # Downgrade the dependency.
          #
          $* ?libfoo/0.1.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: execute_plan: simulate: yes
            %.*
            trace: evaluate_dependency: libfoo/1.0.0: update to libfoo/0.1.0
            %.*
            trace: pkg_build: refine package collection/plan execution
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {foo^ | libfoo->{foo/1,1}}
            trace: collect_build: add foo/1.0.0
            trace: collect_build_prerequisites: reeval foo/1.0.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: postponed_configurations::add: add {foo^ 1,1: libfoo} to {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent foo/1.0.0 results in {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluated foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo^ | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): end {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            build plan:
              downgrade libfoo/0.1.0
                config.libfoo.extras=true (set by foo)
              reconfigure foo/1.0.0 (dependent of libfoo)
            %.*
            disfigured foo/1.0.0
            %.*
            disfigured libfoo/1.0.0
            %.*
            fetched libfoo/0.1.0
            %.*
            unpacked libfoo/0.1.0
            %.*
            configured libfoo/0.1.0
            %.*
            configured foo/1.0.0
            %.*
            updated foo/1.0.0
            %.*
            EOE

          $pkg_status -r >>EOO;
            !foo configured 1.0.0
              libfoo configured !0.1.0 available 1.0.0
            EOO

          # Reconfigure the dependency and hold.
          #
          $* libfoo/0.1.0 +{ config.libfoo.extras=true } 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build_prerequisites: reeval foo/1.0.0
            %.*
            trace: postponed_configurations::add: add {foo^ 1,1: libfoo} to {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent foo/1.0.0 results in {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluated foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: skip configured libfoo/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo^ | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): end {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            build plan:
              reconfigure/update libfoo/0.1.0
                config.libfoo.extras=true (user configuration)
              reconfigure foo/1.0.0 (dependent of libfoo)
            %.*
            disfigured foo/1.0.0
            %.*
            disfigured libfoo/0.1.0
            %.*
            configured libfoo/0.1.0
            %.*
            configured foo/1.0.0
            %.*
            updated libfoo/0.1.0
            %.*
            updated foo/1.0.0
            %.*
            EOE

          $pkg_status -r >>EOO;
            !libfoo configured !0.1.0 available 1.0.0
            !foo configured 1.0.0
              !libfoo configured !0.1.0 available 1.0.0
            EOO

          # Upgrade the dependency and unhold existing dependent.
          #
          $* libfoo ?foo 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of existing dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: reeval foo/1.0.0
            %.*
            trace: collect_build: pick libfoo/1.0.0 over libfoo/0.1.0
            trace: postponed_configurations::add: add {foo^ 1,1: libfoo} to {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent foo/1.0.0 results in {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: re-evaluated foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo^ | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): end {foo^ | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            trace: evaluate_dependency: foo/1.0.0: unused
            %.*
            trace: pkg_build: refine package collection/plan execution
            %.*
            trace: collect_drop: foo/1.0.0 package version needs to be replaced with drop
            trace: pkg_build: collection failed due to package version replacement, retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/1.0.0
            %.*
            trace: collect_build_prerequisites: skip expected to be dropped existing dependent foo of dependency libfoo
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_drop: overwrite foo
            %.*
            trace: execute_plan: simulate: yes
            %.*
            build plan:
              upgrade libfoo/1.0.0
              drop foo/1.0.0 (unused)
            %.*
            disfigured foo/1.0.0
            %.*
            disfigured libfoo/0.1.0
            %.*
            fetched libfoo/1.0.0
            %.*
            unpacked libfoo/1.0.0
            %.*
            purged foo/1.0.0
            %.*
            configured libfoo/1.0.0
            %.*
            updated libfoo/1.0.0
            %.*
            EOE

          $pkg_status -r >>EOO;
            !libfoo configured 1.0.0
            EOO

          $pkg_drop libfoo
        }

        : postpone-existing
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  fix/1.0.0: depends: foo(c)
          #  foo/1.0.0: depends: libfoo(c)
          #
          #  fix/0.1.0: depends: foo == 0.1.0
          #  foo/0.1.0: depends: libfoo(c)
          #
          $* fix 2>!;

          $* libfoo/0.1.0 fix/0.1.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add fix/0.1.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo^ | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_prerequisites: begin fix/0.1.0
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add fix/0.1.0
            %.*
            trace: collect_build_prerequisites: skip expected to be built existing dependent foo of dependency libfoo
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            %.*
            trace: collect_build_prerequisites: begin fix/0.1.0
            %.*
            trace: collect_build: apply version replacement for foo/0.1.0
            trace: collect_build: replacement: foo/0.1.0
            trace: collect_build: add foo/0.1.0
            info: package fix dependency on (foo == 0.1.0) is forcing downgrade of foo/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: no cfg-clause for dependency foo/0.1.0 of dependent fix/0.1.0
            %.*
            trace: collect_build_prerequisites: skip being built existing dependent fix of dependency foo
            trace: collect_build_prerequisites: begin foo/0.1.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/0.1.0 of dependent foo/0.1.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add fix/0.1.0
            trace: pkg_build: dep-postpone user-specified libfoo
            %.*
            trace: collect_build_prerequisites: begin fix/0.1.0
            %.*
            trace: collect_build: apply version replacement for foo/0.1.0
            trace: collect_build: replacement: foo/0.1.0
            trace: collect_build: add foo/0.1.0
            info: package fix dependency on (foo == 0.1.0) is forcing downgrade of foo/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: no cfg-clause for dependency foo/0.1.0 of dependent fix/0.1.0
            %.*
            trace: collect_build_prerequisites: skip being built existing dependent fix of dependency foo
            trace: collect_build_prerequisites: begin foo/0.1.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of dependent foo/0.1.0
            trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: postpone foo/0.1.0
            trace: collect_build_prerequisites: end fix/0.1.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): skip being built existing dependent foo of dependency libfoo
            trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/0.1.0
            trace: collect_build_prerequisites: resume foo/0.1.0
            trace: collect_build_prerequisites: end foo/0.1.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !libfoo configured !0.1.0 available 1.0.0
            !fix configured !0.1.0 available 1.0.0
              foo configured 0.1.0 available 1.0.0 0.2.0
                !libfoo configured !0.1.0 available 1.0.0
            EOO

          $pkg_drop fix libfoo --drop-dependent
        }
      }

      : dependent-mult-pos
      :
      {
        +$clone_cfg

        : non-negotiated
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          $* tex 2>!;

          $* libfoo/0.1.0 libbar/0.1.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add libbar/0.1.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/0.1.0 of existing dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex^ | libbar->{tex/1,1}}
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): cannot re-evaluate dependent tex to dependency index 2 due to earlier dependency index 1 in {tex^ | libbar->{tex/1,1}}, skipping {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (0): postpone cfg-negotiation of {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): begin {tex^ | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {tex^ | libbar->{tex/1,1}}
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: reeval tex/1.0.0
            %.*
            trace: collect_build: pick libbar/0.1.0 over libbar/1.0.0
            trace: postponed_configurations::add: add {tex^ 1,1: libbar} to {tex^ | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent tex/1.0.0 results in {tex^ | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: re-evaluated tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {tex^ | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/0.1.0
            trace: collect_build_prerequisites: end libbar/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 2,1: libfoo} to {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tex^ | libbar->{tex/1,1}}!
            trace: collect_build_postponed (2): begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libfoo
            trace: collect_build_postponed (2): cfg-negotiate begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tex^ | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (2): end {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): end {tex^ | libbar->{tex/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            build plan:
              downgrade libfoo/0.1.0
                config.libfoo.extras=true (set by tex)
              downgrade libbar/0.1.0
                config.libbar.extras=true (set by tex)
              reconfigure tex/1.0.0 (dependent of libbar)
            %.*
            disfigured tex/1.0.0
            %.*
            disfigured libbar/1.0.0
            %.*
            disfigured libfoo/1.0.0
            %.*
            fetched libfoo/0.1.0
            %.*
            unpacked libfoo/0.1.0
            %.*
            fetched libbar/0.1.0
            %.*
            unpacked libbar/0.1.0
            %.*
            configured libfoo/0.1.0
            %.*
            configured libbar/0.1.0
            %.*
            configured tex/1.0.0
            %.*
            updated libfoo/0.1.0
            %.*
            updated libbar/0.1.0
            %.*
            updated tex/1.0.0
            %.*
            EOE

          $pkg_status -r >>EOO;
            !libbar configured !0.1.0 available 1.0.0
            !libfoo configured !0.1.0 available 1.0.0
            !tex configured 1.0.0
              !libbar configured !0.1.0 available 1.0.0
              !libfoo configured !0.1.0 available 1.0.0
            EOO

          $pkg_drop tex libfoo libbar
        }

        : negotiated
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  bar: depends: libbar == 0.1.0 (c)
          #
          $* tex 2>!;

          $* libfoo/0.1.0 bar/0.1.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add bar/0.1.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: begin bar/0.1.0
            %.*
            trace: collect_build: add libbar/0.1.0
            info: package bar dependency on (libbar == 0.1.0) is forcing downgrade of libbar/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/0.1.0 of dependent bar/0.1.0
            trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: postpone bar/0.1.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: reeval tex/1.0.0
            %.*
            trace: collect_build: pick libbar/0.1.0 over libbar/1.0.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: postponed_configurations::add: add {tex^ 2,1: libfoo} to {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: re-evaluating dependent tex/1.0.0 results in {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: re-evaluated tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tex^ | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (2): begin {bar | libbar->{bar/1,1}}
            %.*
            trace: collect_build_postponed (2): re-evaluate existing dependents for {bar | libbar->{bar/1,1}}
            trace: collect_build_postponed (2): cannot re-evaluate dependent tex to dependency index 1 due to greater dependency index 2 in {tex^ | libfoo->{tex/2,1}}!, throwing postpone_position
            trace: pkg_build: collection failed due to earlier dependency position, retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add libfoo/0.1.0
            trace: collect_build: add bar/0.1.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of existing dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: begin bar/0.1.0
            %.*
            trace: collect_build: add libbar/0.1.0
            info: package bar dependency on (libbar == 0.1.0) is forcing downgrade of libbar/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/0.1.0 of dependent bar/0.1.0
            trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: postpone bar/0.1.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): pos-postpone existing dependent tex re-evaluation to dependency index 2 due to recorded index 1, skipping {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (0): postpone cfg-negotiation of {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): begin {bar | libbar->{bar/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {bar | libbar->{bar/1,1}}
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: reeval tex/1.0.0
            %.*
            trace: collect_build: pick libbar/0.1.0 over libbar/1.0.0
            trace: postponed_configurations::add: add {tex^ 1,1: libbar} to {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent tex/1.0.0 results in {bar tex^ | libbar->{bar/1,1 tex/1,1}}
            trace: collect_build_prerequisites: re-evaluated tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {bar tex^ | libbar->{bar/1,1 tex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/0.1.0
            trace: collect_build_prerequisites: end libbar/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bar/0.1.0
            trace: collect_build_prerequisites: resume bar/0.1.0
            trace: collect_build_prerequisites: end bar/0.1.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 2,1: libfoo} to {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {bar tex^ | libbar->{bar/1,1 tex/1,1}}!
            trace: collect_build_postponed (2): begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libfoo
            trace: collect_build_postponed (2): cfg-negotiate begin {tex^ | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tex^ | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (2): end {tex^ | libfoo->{tex/2,1}}
            trace: collect_build_postponed (1): end {bar | libbar->{bar/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !libfoo configured !0.1.0 available 1.0.0
            !tex configured 1.0.0
              libbar configured 0.1.0 available 1.0.0
              !libfoo configured !0.1.0 available 1.0.0
            !bar configured !0.1.0 available 1.0.0
              libbar configured 0.1.0 available 1.0.0
            EOO

          $pkg_drop tex libfoo bar
        }

        : up-negotiate
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  baz: depends: {libbar libfoo} == 0.1.0 (c)
          #
          $* tex 2>!;

          $* baz/0.1.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add baz/0.1.0
            trace: collect_build_prerequisites: begin baz/0.1.0
            %.*
            trace: collect_build: add libbar/0.1.0
            info: package baz dependency on (libbar == 0.1.0) is forcing downgrade of libbar/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/0.1.0 of dependent baz/0.1.0
            trace: collect_build: add libfoo/0.1.0
            info: package baz dependency on (libfoo == 0.1.0) is forcing downgrade of libfoo/1.0.0 to 0.1.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of dependent baz/0.1.0
            trace: postponed_configurations::add: create {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone baz/0.1.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): re-evaluate existing dependents for {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: reeval tex/1.0.0
            %.*
            trace: collect_build: pick libbar/0.1.0 over libbar/1.0.0
            trace: postponed_configurations::add: add {tex^ 1,1: libbar} to {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: re-evaluating dependent tex/1.0.0 results in {baz tex^ | libbar->{baz/1,1 tex/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: re-evaluated tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate begin {baz tex^ | libbar->{baz/1,1 tex/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/0.1.0
            trace: collect_build_prerequisites: end libbar/0.1.0
            trace: collect_build_prerequisites: begin libfoo/0.1.0
            trace: collect_build_prerequisites: end libfoo/0.1.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/0.1.0
            trace: collect_build_prerequisites: resume baz/0.1.0
            trace: collect_build_prerequisites: end baz/0.1.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: pick libfoo/0.1.0 over libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/0.1.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 2,1: libfoo} to {baz tex^ | libbar->{baz/1,1 tex/1,1} libfoo->{baz/1,1}}?
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tex/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libfoo/0.1.0 of dependent tex/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {baz tex^ | libbar->{baz/1,1 tex/1,1} libfoo->{baz/1,1 tex/2,1}}!
            trace: collect_build_postponed (1): end {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_postponed (0): end
            %.*
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tex configured 1.0.0
              libbar configured 0.1.0 available 1.0.0
              libfoo configured 0.1.0 available 1.0.0
            !baz configured !0.1.0 available 1.0.0
              libbar configured 0.1.0 available 1.0.0
              libfoo configured 0.1.0 available 1.0.0
            EOO

          $pkg_drop tex baz
        }

        : replace-reeval
        :
        {
          +$clone_cfg

          : initial-collection
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  bax: depends: libfoo(c)
            #       depends: {libbox libbar} (c)
            #
            #  baz: depends: {libbar libfoo} (c)
            #
            $* bax baz 2>!;

            $* libbox/0.1.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of existing dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax^ | libbox->{bax/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {bax^ | libbox->{bax/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libbox->{bax/2,1}}
              %.*
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {bax^ 2,1: libbox libbar} to {bax^ | libbox->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              %.*
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libbox->{bax/2,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libfoo
              trace: collect_build_postponed (1): cannot re-evaluate dependent bax to dependency index 1 since it is already re-evaluated to greater index 2 in {bax^ baz^ | libbox->{bax/2,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}, throwing postpone_position
              trace: pkg_build: collection failed due to earlier dependency position, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              %.*
              trace: collect_build_prerequisites: replace dependency at index 2 of existing dependent bax/1.0.0 with dependency libfoo/1.0.0 at index 1
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of existing dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}?
              %.*
              trace: collect_build_prerequisites: cfg-postponing dependent bax/1.0.0 involves (being) negotiated configurations and results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1}}?, throwing retry_configuration
              trace: collect_build_postponed (0): cfg-negotiation of {bax^ | libfoo->{bax/1,1}} failed due to dependent bax, refining configuration
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}?
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bax/1.0.0 is negotiated
              trace: collect_build_prerequisites: collecting cfg-postponed dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: begin libbox/0.1.0
              trace: collect_build_prerequisites: end libbox/0.1.0
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bax/1.0.0 is already (being) recursively collected, skipping
              trace: collect_build_prerequisites: end bax/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
              trace: collect_build_prerequisites: resume baz/1.0.0
              trace: collect_build_prerequisites: end baz/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1}}!
              trace: collect_build_postponed (1): end {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_status -r >>EOO;
              !libbox configured !0.1.0 available 1.0.0
              !bax configured 1.0.0
                libbar configured 1.0.0
                !libbox configured !0.1.0 available 1.0.0
                libfoo configured 1.0.0
              !baz configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
              EOO

            $pkg_drop bax baz libbox
          }

          : collect-postponed
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  bax: depends: libfoo(c)
            #       depends: {libbox libbar} (c)
            #
            #  baz: depends: {libbar libfoo} (c)
            #
            #  box: depends: libbox == 0.1.0 (c)
            #
            $* bax baz 2>!;

            $* box/0.1.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add box/0.1.0
              trace: collect_build_prerequisites: begin box/0.1.0
              %.*
              trace: collect_build: add libbox/0.1.0
              info: package box dependency on (libbox == 0.1.0) is forcing downgrade of libbox/1.0.0 to 0.1.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent box/0.1.0
              trace: postponed_configurations::add: create {box | libbox->{box/1,1}}
              trace: collect_build_prerequisites: postpone box/0.1.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {box | libbox->{box/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {box | libbox->{box/1,1}}
              %.*
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {bax^ 2,1: libbox libbar} to {box | libbox->{box/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ box | libbox->{bax/2,1 box/1,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ box | libbox->{bax/2,1 box/1,1} libbar->{bax/2,1}}
              %.*
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ box | libbox->{bax/2,1 box/1,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ box | libbox->{bax/2,1 box/1,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libfoo
              trace: collect_build_postponed (1): cannot re-evaluate dependent bax to dependency index 1 since it is already re-evaluated to greater index 2 in {bax^ baz^ box | libbox->{bax/2,1 box/1,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}, throwing postpone_position
              trace: pkg_build: collection failed due to earlier dependency position, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add box/0.1.0
              trace: collect_build_prerequisites: begin box/0.1.0
              %.*
              trace: collect_build: add libbox/0.1.0
              info: package box dependency on (libbox == 0.1.0) is forcing downgrade of libbox/1.0.0 to 0.1.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent box/0.1.0
              trace: postponed_configurations::add: create {box | libbox->{box/1,1}}
              trace: collect_build_prerequisites: postpone box/0.1.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {box | libbox->{box/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {box | libbox->{box/1,1}}
              trace: collect_build_postponed (1): pos-postpone existing dependent bax re-evaluation to dependency index 2 due to recorded index 1, skipping {box | libbox->{box/1,1}}
              trace: collect_build_postponed (0): replace dependency at index 2 of existing dependent bax/1.0.0 with dependency libfoo/1.0.0 at index 1
              trace: collect_build: add libfoo/1.0.0
              trace: postponed_configurations::add: create {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): postpone cfg-negotiation of {box | libbox->{box/1,1}}
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}?
              trace: postponed_configurations::add: merge {box | libbox->{box/1,1}} into {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1}}?
              trace: collect_build_prerequisites: cfg-postponing dependent bax/1.0.0 merges non-negotiated and/or being negotiated configurations in and results in {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1 box/1,1}}?, throwing merge_configuration
              trace: collect_build_postponed (0): cfg-negotiation of {bax^ | libfoo->{bax/1,1}} failed due to non-negotiated clusters, force-merging based on shadow cluster {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1 box/1,1}}?
              trace: collect_build_postponed (0): force-merge {box | libbox->{box/1,1}} into {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (1): begin {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}} (shadow cluster-based)
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build: add baz/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}} (shadow cluster-based)
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbox->{box/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbox->{box/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: begin libbox/0.1.0
              trace: collect_build_prerequisites: end libbox/0.1.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbox->{box/1,1} libbar->{baz/1,1}}? (shadow cluster-based)
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bax/1.0.0 is shadow-negotiated
              trace: collect_build_prerequisites: dependency libbox/0.1.0 of dependent bax/1.0.0 is already (being) recursively collected, skipping
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bax/1.0.0 is already (being) recursively collected, skipping
              trace: collect_build_prerequisites: end bax/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
              trace: collect_build_prerequisites: resume baz/1.0.0
              trace: collect_build_prerequisites: end baz/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent box/0.1.0
              trace: collect_build_prerequisites: resume box/0.1.0
              trace: collect_build_prerequisites: end box/0.1.0
              trace: collect_build_postponed (1): cfg-negotiate end {bax^ baz^ box | libfoo->{bax/1,1 baz/1,1} libbox->{bax/2,1 box/1,1} libbar->{bax/2,1 baz/1,1}}!
              trace: collect_build_postponed (1): end {bax^ box | libfoo->{bax/1,1} libbox->{box/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_status -r >>EOO;
              !bax configured 1.0.0
                libbar configured 1.0.0
                libbox configured 0.1.0 available 1.0.0
                libfoo configured 1.0.0
              !baz configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
              !box configured !0.1.0 available 1.0.0
                libbox configured 0.1.0 available 1.0.0
              EOO

            $pkg_drop bax baz box
          }

          : bogus-harmless
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  bax: depends: libfoo(c)
            #       depends: {libbox libbar} (c)
            #
            #  baz: depends: {libbar libfoo} (c)
            #
            $* bax baz 2>!;

            $* libbox/0.1.0 ?baz 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of existing dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax^ | libbox->{bax/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {bax^ | libbox->{bax/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libbox->{bax/2,1}}
              %.*
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {bax^ 2,1: libbox libbar} to {bax^ | libbox->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libbox->{bax/2,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libfoo
              trace: collect_build_postponed (1): cannot re-evaluate dependent bax to dependency index 1 since it is already re-evaluated to greater index 2 in {bax^ baz^ | libbox->{bax/2,1} libbar->{bax/2,1 baz/1,1} libfoo->{baz/1,1}}, throwing postpone_position
              trace: pkg_build: collection failed due to earlier dependency position, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              %.*
              trace: collect_build_prerequisites: replace dependency at index 2 of existing dependent bax/1.0.0 with dependency libfoo/1.0.0 at index 1
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of existing dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}?
              %.*
              trace: collect_build_prerequisites: cfg-postponing dependent bax/1.0.0 involves (being) negotiated configurations and results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1}}?, throwing retry_configuration
              trace: collect_build_postponed (0): cfg-negotiation of {bax^ | libfoo->{bax/1,1}} failed due to dependent bax, refining configuration
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build_prerequisites: reeval baz/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: add {baz^ 1,1: libbar libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent baz/1.0.0 results in {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              trace: collect_build_prerequisites: re-evaluated baz/1.0.0
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (1): skip being built existing dependent baz of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: add {bax 2,1: libbox libbar} to {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{baz/1,1}}?
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bax/1.0.0 is negotiated
              trace: collect_build_prerequisites: collecting cfg-postponed dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build_prerequisites: begin libbox/0.1.0
              trace: collect_build_prerequisites: end libbox/0.1.0
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bax/1.0.0 is already (being) recursively collected, skipping
              trace: collect_build_prerequisites: end bax/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
              trace: collect_build_prerequisites: resume baz/1.0.0
              trace: collect_build_prerequisites: end baz/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {bax^ baz^ | libfoo->{bax/1,1 baz/1,1} libbar->{bax/2,1 baz/1,1} libbox->{bax/2,1}}!
              trace: collect_build_postponed (1): end {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              trace: evaluate_dependency: baz/1.0.0: unused
              %.*
              trace: pkg_build: refine package collection/plan execution
              %.*
              trace: collect_drop: baz/1.0.0 package version needs to be replaced with drop
              trace: pkg_build: collection failed due to package version replacement, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              trace: pkg_build: dep-postpone user-specified libbox
              trace: collect_drop: overwrite baz
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (0): erase bogus postponement libbox
              trace: collect_build_postponed (0): bogus postponements erased, throwing
              trace: pkg_build: collection failed due to bogus dependency collection postponement cancellation, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add libbox/0.1.0
              %.*
              trace: collect_build_prerequisites: replace dependency at index 2 of existing dependent bax/1.0.0 with dependency libfoo/1.0.0 at index 1
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of existing dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax^ | libfoo->{bax/1,1}}
              trace: collect_drop: overwrite baz
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): skip being dropped existing dependent baz of dependency libfoo
              trace: collect_build_postponed (1): re-evaluate existing dependents for {bax^ | libfoo->{bax/1,1}}
              trace: collect_build: add bax/1.0.0
              trace: collect_build_prerequisites: reeval bax/1.0.0
              %.*
              trace: postponed_configurations::add: add {bax^ 1,1: libfoo} to {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bax/1.0.0 results in {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_prerequisites: re-evaluated bax/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {bax^ | libfoo->{bax/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              %.*
              trace: collect_build: pick libbox/0.1.0 over libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/0.1.0 of dependent bax/1.0.0
              trace: collect_build: add libbar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bax/1.0.0
              trace: postponed_configurations::add: create {bax | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_prerequisites: postpone bax/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {bax^ | libfoo->{bax/1,1}}!
              trace: collect_build_postponed (2): begin {bax | libbox->{bax/2,1} libbar->{bax/2,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent bax of dependency libbox
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent bax of dependency libbar
              trace: collect_build_postponed (2): skip being dropped existing dependent baz of dependency libbar
              trace: collect_build_postponed (2): cfg-negotiate begin {bax | libbox->{bax/2,1} libbar->{bax/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin libbox/0.1.0
              trace: collect_build_prerequisites: end libbox/0.1.0
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bax/1.0.0
              trace: collect_build_prerequisites: resume bax/1.0.0
              trace: collect_build_prerequisites: end bax/1.0.0
              trace: collect_build_postponed (2): cfg-negotiate end {bax | libbox->{bax/2,1} libbar->{bax/2,1}}!
              trace: collect_build_postponed (2): end {bax | libbox->{bax/2,1} libbar->{bax/2,1}}
              trace: collect_build_postponed (1): end {bax^ | libfoo->{bax/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_status -r >>EOO;
              !libbox configured !0.1.0 available 1.0.0
              !bax configured 1.0.0
                libbar configured 1.0.0
                !libbox configured !0.1.0 available 1.0.0
                libfoo configured 1.0.0
              EOO

            $pkg_drop bax libbox
          }
        }
      }
    }

    : postponed-collection
    :
    {
      +$clone_cfg

      : backtrace
      :
      {
        $clone_cfg;

        $* foo bar box 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add bar/1.0.0
          trace: collect_build: add box/1.0.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin bar/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
          trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
          trace: collect_build_prerequisites: postpone bar/1.0.0
          trace: collect_build_prerequisites: begin box/1.0.0
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent box/1.0.0 since max index is reached: 0
            info: dependency alternative: {libbar libfoo}
          {
            require
            {
              config.libbar.extras = true
              config.libfoo.extras = true
            }
          }
          trace: collect_build_prerequisites: postpone box/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (2): begin {bar | libbar->{bar/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {bar | libbar->{bar/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bar/1.0.0
          trace: collect_build_prerequisites: resume bar/1.0.0
          trace: collect_build_prerequisites: end bar/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {bar | libbar->{bar/1,1}}!
          trace: collect_build_postponed (2): index 1 collect alt-postponed box/1.0.0
          trace: collect_build_prerequisites: resume box/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent box/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent box/1.0.0
          %.*
          trace: postponed_configurations::add: add {box 1,1: libbar libfoo} to {foo | libfoo->{foo/1,1}}!
          trace: postponed_configurations::add: merge {bar | libbar->{bar/1,1}}! into {box foo | libfoo->{box/1,1 foo/1,1} libbar->{box/1,1}}!
          %.*
          trace: collect_build_prerequisites: cfg-postponing dependent box/1.0.0 involves (being) negotiated configurations and results in {bar box foo | libfoo->{box/1,1 foo/1,1} libbar->{bar/1,1 box/1,1}}!, throwing retry_configuration
          trace: collect_build_postponed (0): cfg-negotiation of {foo | libfoo->{foo/1,1}} failed due to dependent box, refining configuration
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (2): begin {bar | libbar->{bar/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {bar | libbar->{bar/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bar/1.0.0
          trace: collect_build_prerequisites: resume bar/1.0.0
          trace: collect_build_prerequisites: end bar/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {bar | libbar->{bar/1,1}}!
          trace: collect_build_postponed (2): index 1 collect alt-postponed box/1.0.0
          trace: collect_build_prerequisites: resume box/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent box/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent box/1.0.0
          %.*
          trace: postponed_configurations::add: add {box 1,1: libbar libfoo} to {foo | libfoo->{foo/1,1}}!
          trace: postponed_configurations::add: merge {bar | libbar->{bar/1,1}}! into {box foo | libfoo->{box/1,1 foo/1,1} libbar->{box/1,1}}!
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent box/1.0.0 is negotiated
          trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent box/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent box/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end box/1.0.0
          trace: collect_build_postponed (2): end {bar | libbar->{bar/1,1}}
          trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !bar configured 1.0.0
            libbar configured 1.0.0
          !box configured 1.0.0
            libbar configured 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop foo bar box
      }

      : premature
      :
      {
        $clone_cfg;

        $* fux fix 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fix/1.0.0
          trace: collect_build_prerequisites: resume fix/1.0.0
          trace: collect_build_prerequisites: end fix/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {fix | foo->{fix/1,1}}!
          trace: collect_build_postponed (2): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (2): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): end {fix | foo->{fix/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fux configured 1.0.0
            libfoo configured 1.0.0
          !fix configured 1.0.0
            foo configured 1.0.0
              libfoo configured 1.0.0
          EOO

        $pkg_drop fux fix
      }

      : double-premature
      :
      {
        $clone_cfg;

        $* fux bex fix buz 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add bex/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build: add buz/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin bex/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent bex/1.0.0
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_prerequisites: end bex/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_prerequisites: begin buz/1.0.0
          %.*
          trace: collect_build: add bux/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency bux/1.0.0 of dependent buz/1.0.0
          trace: postponed_configurations::add: create {buz | bux->{buz/1,1}}
          trace: collect_build_prerequisites: postpone buz/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add bex/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build: add buz/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin bex/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent bex/1.0.0
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_prerequisites: end bex/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_prerequisites: begin buz/1.0.0
          %.*
          trace: collect_build: add bux/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency bux/1.0.0 of dependent buz/1.0.0
          trace: postponed_configurations::add: create {buz | bux->{buz/1,1}}
          trace: collect_build_prerequisites: postpone buz/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fix/1.0.0
          trace: collect_build_prerequisites: resume fix/1.0.0
          trace: collect_build_prerequisites: end fix/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {fix | foo->{fix/1,1}}!
          trace: collect_build_postponed (2): begin {buz | bux->{buz/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {buz | bux->{buz/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin bux/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libbar/1.0.0 of dependent bux/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libbar), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fux/1.0.0
          trace: collect_build: add bex/1.0.0
          trace: collect_build: add fix/1.0.0
          trace: collect_build: add buz/1.0.0
          trace: collect_build_prerequisites: begin fux/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
          trace: collect_build_prerequisites: end fux/1.0.0
          trace: collect_build_prerequisites: begin bex/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libbar/1.0.0 of dependent bex/1.0.0
          trace: collect_build_prerequisites: end bex/1.0.0
          trace: collect_build_prerequisites: begin fix/1.0.0
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
          trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
          trace: collect_build_prerequisites: postpone fix/1.0.0
          trace: collect_build_prerequisites: begin buz/1.0.0
          %.*
          trace: collect_build: add bux/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency bux/1.0.0 of dependent buz/1.0.0
          trace: postponed_configurations::add: create {buz | bux->{buz/1,1}}
          trace: collect_build_prerequisites: postpone buz/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fix/1.0.0
          trace: collect_build_prerequisites: resume fix/1.0.0
          trace: collect_build_prerequisites: end fix/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {fix | foo->{fix/1,1}}!
          trace: collect_build_postponed (2): begin {buz | bux->{buz/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {buz | bux->{buz/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin bux/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bux/1.0.0
          trace: postponed_configurations::add: create {bux | libbar->{bux/1,1}}
          trace: collect_build_prerequisites: postpone bux/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent buz/1.0.0
          trace: collect_build_prerequisites: resume buz/1.0.0
          trace: collect_build_prerequisites: end buz/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {buz | bux->{buz/1,1}}!
          trace: collect_build_postponed (3): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (3): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (3): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (4): begin {bux | libbar->{bux/1,1}}
          %.*
          trace: collect_build_postponed (4): cfg-negotiate begin {bux | libbar->{bux/1,1}}
          %.*
          trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent bux/1.0.0
          trace: collect_build_prerequisites: resume bux/1.0.0
          trace: collect_build_prerequisites: end bux/1.0.0
          trace: collect_build_postponed (4): cfg-negotiate end {bux | libbar->{bux/1,1}}!
          trace: collect_build_postponed (4): end {bux | libbar->{bux/1,1}}
          trace: collect_build_postponed (3): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (2): end {buz | bux->{buz/1,1}}
          trace: collect_build_postponed (1): end {fix | foo->{fix/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fux configured 1.0.0
            libfoo configured 1.0.0
          !fix configured 1.0.0
            foo configured 1.0.0
              libfoo configured 1.0.0
          !bex configured 1.0.0
            libbar configured 1.0.0
          !buz configured 1.0.0
            bux configured 1.0.0
              libbar configured 1.0.0
          EOO

        $pkg_drop fux bex fix buz
      }

      : up-negotiate-dependency
      :
      {
        $clone_cfg;

        #  Dependencies:
        #
        #  bar: depends: libbar(c)
        #
        #  bux: depends: libbar(c)
        #
        #  bix: depends: {libbar bar} (c)
        #       depends: bux
        #
        $* bix 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add bix/1.0.0
          trace: collect_build_prerequisites: begin bix/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bix/1.0.0
          trace: collect_build: add bar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent bix/1.0.0
          trace: postponed_configurations::add: create {bix | libbar->{bix/1,1} bar->{bix/1,1}}
          trace: collect_build_prerequisites: postpone bix/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {bix | libbar->{bix/1,1} bar->{bix/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {bix | libbar->{bix/1,1} bar->{bix/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_prerequisites: begin bar/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
          trace: postponed_configurations::add: add {bar 1,1: libbar} to {bix | libbar->{bix/1,1} bar->{bix/1,1}}?
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
          trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end bar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bix/1.0.0
          trace: collect_build_prerequisites: resume bix/1.0.0
          %.*
          trace: collect_build: add bux/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency bux/1.0.0 of dependent bix/1.0.0
          trace: collect_build_prerequisites: begin bux/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bux/1.0.0
          trace: postponed_configurations::add: add {bux 1,1: libbar} to {bar bix | libbar->{bar/1,1 bix/1,1} bar->{bix/1,1}}?
          %.*
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bux/1.0.0 is negotiated
          trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bux/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end bux/1.0.0
          trace: collect_build_prerequisites: end bix/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {bar bix bux | libbar->{bar/1,1 bix/1,1 bux/1,1} bar->{bix/1,1}}!
          trace: collect_build_postponed (1): end {bix | libbar->{bix/1,1} bar->{bix/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !bix configured 1.0.0
            bar configured 1.0.0
              libbar configured 1.0.0
            bux configured 1.0.0
              libbar configured 1.0.0
            libbar configured 1.0.0
          EOO

        $pkg_drop bix
      }

      : postponed-alts
      :
      {
        +$clone_cfg

        : with-premature
        :
        {
          $clone_cfg;

          $* fux boo 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add fux/1.0.0
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: begin fux/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_prerequisites: end fux/1.0.0
            trace: collect_build_prerequisites: begin boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 0
              info: dependency alternative: libbar
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (0): index 1 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 1
              info: dependency alternative: libfoo
            {
              require
              {
                config.libfoo.extras = true
              }
            }
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (0): index 2 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent boo/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add fux/1.0.0
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: begin fux/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
            trace: collect_build_prerequisites: end fux/1.0.0
            trace: collect_build_prerequisites: begin boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 0
              info: dependency alternative: libbar
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (0): index 1 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 1
              info: dependency alternative: libfoo
            {
              require
              {
                config.libfoo.extras = true
              }
            }
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (0): index 2 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent boo/1.0.0
            %.*
            trace: postponed_configurations::add: create {boo | libfoo->{boo/1,2}}
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (1): begin {boo | libfoo->{boo/1,2}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {boo | libfoo->{boo/1,2}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            trace: collect_build_prerequisites: end boo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {boo | libfoo->{boo/1,2}}!
            trace: collect_build_postponed (1): end {boo | libfoo->{boo/1,2}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !fux configured 1.0.0
              libfoo configured 1.0.0
            !boo configured 1.0.0
              libfoo configured 1.0.0
            EOO

          $pkg_drop fux boo
        }

        : with-premature-complex
        :
        {
          $clone_cfg;

          $* fux bex fix biz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add fux/1.0.0
            trace: collect_build: add bex/1.0.0
            trace: collect_build: add fix/1.0.0
            trace: collect_build: add biz/1.0.0
            trace: collect_build_prerequisites: begin fux/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent fux/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_prerequisites: end fux/1.0.0
            trace: collect_build_prerequisites: begin bex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent bex/1.0.0
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: end bex/1.0.0
            trace: collect_build_prerequisites: begin fix/1.0.0
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
            trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
            trace: collect_build_prerequisites: postpone fix/1.0.0
            trace: collect_build_prerequisites: begin biz/1.0.0
            %.*
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency boo/1.0.0 of dependent biz/1.0.0
            trace: postponed_configurations::add: create {biz | boo->{biz/1,1}}
            trace: collect_build_prerequisites: postpone biz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add fux/1.0.0
            trace: collect_build: add bex/1.0.0
            trace: collect_build: add fix/1.0.0
            trace: collect_build: add biz/1.0.0
            trace: collect_build_prerequisites: begin fux/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent fux/1.0.0
            trace: collect_build_prerequisites: end fux/1.0.0
            trace: collect_build_prerequisites: begin bex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent bex/1.0.0
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: end bex/1.0.0
            trace: collect_build_prerequisites: begin fix/1.0.0
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent fix/1.0.0
            trace: postponed_configurations::add: create {fix | foo->{fix/1,1}}
            trace: collect_build_prerequisites: postpone fix/1.0.0
            trace: collect_build_prerequisites: begin biz/1.0.0
            %.*
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency boo/1.0.0 of dependent biz/1.0.0
            trace: postponed_configurations::add: create {biz | boo->{biz/1,1}}
            trace: collect_build_prerequisites: postpone biz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {fix | foo->{fix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {fix | foo->{fix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent fix/1.0.0
            trace: collect_build_prerequisites: resume fix/1.0.0
            trace: collect_build_prerequisites: end fix/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {fix | foo->{fix/1,1}}!
            trace: collect_build_postponed (2): begin {biz | boo->{biz/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {biz | boo->{biz/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 0
              info: dependency alternative: libbar
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent biz/1.0.0
            trace: collect_build_prerequisites: resume biz/1.0.0
            trace: collect_build_prerequisites: end biz/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {biz | boo->{biz/1,1}}!
            trace: collect_build_postponed (3): begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (3): index 1 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent boo/1.0.0
            trace: collect_build_prerequisites: end boo/1.0.0
            trace: collect_build_postponed (3): end {foo | libfoo->{foo/1,1}}
            trace: collect_build_postponed (2): end {biz | boo->{biz/1,1}}
            trace: collect_build_postponed (1): end {fix | foo->{fix/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !fux configured 1.0.0
              libfoo configured 1.0.0
            !fix configured 1.0.0
              foo configured 1.0.0
                libfoo configured 1.0.0
            !bex configured 1.0.0
              libbar configured 1.0.0
            !biz configured 1.0.0
              boo configured 1.0.0
                libbar configured 1.0.0
            EOO

          $pkg_drop fux bex fix biz
        }

        : up-negotiate
        :
        {
          $clone_cfg;

          $* foo boo 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_prerequisites: begin boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 0
              info: dependency alternative: libbar
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (1): index 1 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 1
              info: dependency alternative: libfoo
            {
              require
              {
                config.libfoo.extras = true
              }
            }
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (1): index 2 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent boo/1.0.0
            %.*
            trace: postponed_configurations::add: add {boo 1,2: libfoo} to {foo | libfoo->{foo/1,1}}!
            %.*
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent boo/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent boo/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end boo/1.0.0
            trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !foo configured 1.0.0
              libfoo configured 1.0.0
            !boo configured 1.0.0
              libfoo configured 1.0.0
            EOO

          $pkg_drop foo boo
        }

        : after-negotiation
        :
        {
          $clone_cfg;

          $* foo biz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add foo/1.0.0
            trace: collect_build: add biz/1.0.0
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_prerequisites: begin biz/1.0.0
            %.*
            trace: collect_build: add boo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency boo/1.0.0 of dependent biz/1.0.0
            %.*
            trace: postponed_configurations::add: create {biz | boo->{biz/1,1}}
            trace: collect_build_prerequisites: postpone biz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
            trace: collect_build_postponed (2): begin {biz | boo->{biz/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {biz | boo->{biz/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 0
              info: dependency alternative: libbar
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent biz/1.0.0
            trace: collect_build_prerequisites: resume biz/1.0.0
            trace: collect_build_prerequisites: end biz/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {biz | boo->{biz/1,1}}!
            trace: collect_build_postponed (2): index 1 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: alt-postpone dependent boo/1.0.0 since max index is reached: 1
              info: dependency alternative: libfoo
            {
              require
              {
                config.libfoo.extras = true
              }
            }
            trace: collect_build_prerequisites: postpone boo/1.0.0
            trace: collect_build_postponed (2): index 2 collect alt-postponed boo/1.0.0
            trace: collect_build_prerequisites: resume boo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent boo/1.0.0
            %.*
            trace: postponed_configurations::add: add {boo 1,2: libfoo} to {foo | libfoo->{foo/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent boo/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent boo/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end boo/1.0.0
            trace: collect_build_postponed (2): end {biz | boo->{biz/1,1}}
            trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !foo configured 1.0.0
              libfoo configured 1.0.0
            !biz configured 1.0.0
              boo configured 1.0.0
                libfoo configured 1.0.0
            EOO

          $pkg_drop foo biz
        }
      }

      : bogus-postponment
      :
      {
        $clone_cfg;

        #  Dependencies:
        #
        #  tax: depends: libbar(c)
        #       depends: libfoo
        #
        #  toz/0.1.0:
        #
        #  toz/1.0.0: depends: libbaz(c)
        #             depends: libfoo(c)
        #             depends: libbar(c)
        #
        #  tez: depends: libbox(c)
        #       depends: toz == 0.1.0 (c)
        #       depends: libbar(c)
        #
        $* tax toz tez 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add tax/1.0.0
          trace: collect_build: add toz/1.0.0
          trace: collect_build: add tez/1.0.0
          trace: collect_build_prerequisites: begin tax/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
          trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
          trace: collect_build_prerequisites: postpone tax/1.0.0
          trace: collect_build_prerequisites: begin toz/1.0.0
          %.*
          trace: collect_build: add libbaz/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent toz/1.0.0
          trace: postponed_configurations::add: create {toz | libbaz->{toz/1,1}}
          trace: collect_build_prerequisites: postpone toz/1.0.0
          trace: collect_build_prerequisites: begin tez/1.0.0
          %.*
          trace: collect_build: add libbox/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | libbox->{tez/1,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
          trace: collect_build_prerequisites: resume tax/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent tax/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end tax/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
          trace: collect_build_postponed (2): begin {toz | libbaz->{toz/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {toz | libbaz->{toz/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbaz/1.0.0
          trace: collect_build_prerequisites: end libbaz/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent toz/1.0.0
          trace: collect_build_prerequisites: resume toz/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent toz/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add tax/1.0.0
          trace: collect_build: add toz/1.0.0
          trace: collect_build: add tez/1.0.0
          trace: collect_build_prerequisites: begin tax/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
          trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
          trace: collect_build_prerequisites: postpone tax/1.0.0
          trace: collect_build_prerequisites: begin toz/1.0.0
          %.*
          trace: collect_build: add libbaz/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent toz/1.0.0
          trace: postponed_configurations::add: create {toz | libbaz->{toz/1,1}}
          trace: collect_build_prerequisites: postpone toz/1.0.0
          trace: collect_build_prerequisites: begin tez/1.0.0
          %.*
          trace: collect_build: add libbox/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | libbox->{tez/1,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
          trace: collect_build_prerequisites: resume tax/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
          trace: collect_build_prerequisites: end tax/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
          trace: collect_build_postponed (2): begin {toz | libbaz->{toz/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {toz | libbaz->{toz/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbaz/1.0.0
          trace: collect_build_prerequisites: end libbaz/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent toz/1.0.0
          trace: collect_build_prerequisites: resume toz/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent toz/1.0.0
          trace: postponed_configurations::add: create {toz | libfoo->{toz/2,1}}
          trace: collect_build_prerequisites: postpone toz/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {toz | libbaz->{toz/1,1}}!
          trace: collect_build_postponed (3): begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (3): cfg-negotiate begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbox/1.0.0
          trace: collect_build_prerequisites: end libbox/1.0.0
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build: pick toz/0.1.0 over toz/1.0.0
          trace: collect_build: toz/1.0.0 package version needs to be replaced with toz/0.1.0
          trace: pkg_build: collection failed due to package version replacement, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add tax/1.0.0
          trace: collect_build: apply version replacement for toz/1.0.0
          trace: collect_build: replacement: toz/0.1.0
          trace: collect_build: add toz/0.1.0
          trace: collect_build: add tez/1.0.0
          trace: collect_build_prerequisites: begin tax/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
          trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
          trace: collect_build_prerequisites: postpone tax/1.0.0
          trace: collect_build_prerequisites: begin toz/0.1.0
          trace: collect_build_prerequisites: end toz/0.1.0
          trace: collect_build_prerequisites: begin tez/1.0.0
          %.*
          trace: collect_build: add libbox/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | libbox->{tez/1,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
          trace: collect_build_prerequisites: resume tax/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
          trace: collect_build_prerequisites: end tax/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
          trace: collect_build_postponed (2): begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbox/1.0.0
          trace: collect_build_prerequisites: end libbox/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build_prerequisites: cannot cfg-postpone dependency toz/0.1.0 of dependent tez/1.0.0 (collected prematurely), throwing postpone_dependency
          trace: pkg_build: collection failed due to prematurely collected dependency (toz), retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add tax/1.0.0
          trace: collect_build: apply version replacement for toz/1.0.0
          trace: collect_build: replacement: toz/0.1.0
          trace: collect_build: add toz/0.1.0
          trace: collect_build: add tez/1.0.0
          trace: collect_build_prerequisites: begin tax/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
          trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
          trace: collect_build_prerequisites: postpone tax/1.0.0
          trace: pkg_build: dep-postpone user-specified toz
          trace: collect_build_prerequisites: begin tez/1.0.0
          %.*
          trace: collect_build: add libbox/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | libbox->{tez/1,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
          trace: collect_build_prerequisites: resume tax/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
          trace: collect_build_prerequisites: end tax/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
          trace: collect_build_postponed (2): begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbox/1.0.0
          trace: collect_build_prerequisites: end libbox/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency toz/0.1.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | toz->{tez/2,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {tez | libbox->{tez/1,1}}!
          trace: collect_build_postponed (3): begin {tez | toz->{tez/2,1}}
          %.*
          trace: collect_build_postponed (3): cfg-negotiate begin {tez | toz->{tez/2,1}}
          %.*
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin toz/0.1.0
          trace: collect_build_prerequisites: end toz/0.1.0
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: add {tez 3,1: libbar} to {tax | libbar->{tax/1,1}}!
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tez/1.0.0 is negotiated
          trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tez/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end tez/1.0.0
          trace: collect_build_postponed (3): cfg-negotiate end {tez | toz->{tez/2,1}}!
          trace: collect_build_postponed (3): erase bogus postponement libfoo
          trace: collect_build_postponed (3): bogus postponements erased, throwing
          trace: pkg_build: collection failed due to bogus dependency collection postponement cancellation, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add tax/1.0.0
          trace: collect_build: apply version replacement for toz/1.0.0
          trace: collect_build: replacement: toz/0.1.0
          trace: collect_build: add toz/0.1.0
          trace: collect_build: add tez/1.0.0
          trace: collect_build_prerequisites: begin tax/1.0.0
          %.*
          trace: collect_build: add libbar/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
          trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
          trace: collect_build_prerequisites: postpone tax/1.0.0
          trace: pkg_build: dep-postpone user-specified toz
          trace: collect_build_prerequisites: begin tez/1.0.0
          %.*
          trace: collect_build: add libbox/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | libbox->{tez/1,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
          trace: collect_build_prerequisites: resume tax/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent tax/1.0.0
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_prerequisites: end tax/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
          trace: collect_build_postponed (2): begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): cfg-negotiate begin {tez | libbox->{tez/1,1}}
          %.*
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libbox/1.0.0
          trace: collect_build_prerequisites: end libbox/1.0.0
          trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency toz/0.1.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: create {tez | toz->{tez/2,1}}
          trace: collect_build_prerequisites: postpone tez/1.0.0
          trace: collect_build_postponed (2): cfg-negotiate end {tez | libbox->{tez/1,1}}!
          trace: collect_build_postponed (3): begin {tez | toz->{tez/2,1}}
          %.*
          trace: collect_build_postponed (3): cfg-negotiate begin {tez | toz->{tez/2,1}}
          %.*
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin toz/0.1.0
          trace: collect_build_prerequisites: end toz/0.1.0
          trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tez/1.0.0
          trace: collect_build_prerequisites: resume tez/1.0.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tez/1.0.0
          trace: postponed_configurations::add: add {tez 3,1: libbar} to {tax | libbar->{tax/1,1}}!
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tez/1.0.0 is negotiated
          trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tez/1.0.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end tez/1.0.0
          trace: collect_build_postponed (3): cfg-negotiate end {tez | toz->{tez/2,1}}!
          trace: collect_build_postponed (3): end {tez | toz->{tez/2,1}}
          trace: collect_build_postponed (2): end {tez | libbox->{tez/1,1}}
          trace: collect_build_postponed (1): end {tax | libbar->{tax/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          EOE

        $pkg_status -r >>EOO;
          !toz configured 0.1.0 available 1.0.0 0.2.0
          !tax configured 1.0.0
            libbar configured 1.0.0
            libfoo configured 1.0.0
          !tez configured 1.0.0
            libbar configured 1.0.0
            libbox configured 1.0.0
            !toz configured 0.1.0 available 1.0.0 0.2.0
          EOO

        $pkg_drop tax toz tez
      }
    }

    : cycle
    :
    {
      +$clone_cfg

      : direct
      :
      {
        +$clone_cfg

        : args-tex-tix
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  tix: depends: libbar(c)
          #       depends: tex(c)
          #
          $* tex tix 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tix/1.0.0
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_prerequisites: begin tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: add {tix 1,1: libbar} to {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex tix | libbar->{tex/1,1 tix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tex tix | libbar->{tex/1,1 tix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (tex), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tix/1.0.0
            trace: pkg_build: dep-postpone user-specified tex
            trace: collect_build_prerequisites: begin tix/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | libbar->{tix/1,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | tex->{tix/2,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tix | libbar->{tix/1,1}}!
            trace: collect_build_postponed (2): begin {tix | tex->{tix/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tix | tex->{tix/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 1,1: libbar} to {tix | libbar->{tix/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tex/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tex/1.0.0 is already (being) recursively collected, skipping
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            trace: collect_build_prerequisites: end tix/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tix | tex->{tix/2,1}}!
            trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
            trace: collect_build_postponed (2): end {tix | tex->{tix/2,1}}
            trace: collect_build_postponed (1): end {tix | libbar->{tix/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tex configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !tix configured 1.0.0
              libbar configured 1.0.0
              !tex configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
            EOO

          $pkg_drop tex tix
        }

        : args-tix
        :
        : As above but with the different command-line arguments which results
        : in the different cluster list at the moment of the cycle detection.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  tix: depends: libbar(c)
          #       depends: tex(c)
          #
          $* tix 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tix/1.0.0
            trace: collect_build_prerequisites: begin tix/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | libbar->{tix/1,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | tex->{tix/2,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tix | libbar->{tix/1,1}}!
            trace: collect_build_postponed (2): begin {tix | tex->{tix/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tix | tex->{tix/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 1,1: libbar} to {tix | libbar->{tix/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tex/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tex/1.0.0 is already (being) recursively collected, skipping
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            trace: collect_build_prerequisites: end tix/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tix | tex->{tix/2,1}}!
            trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
            trace: collect_build_postponed (2): end {tix | tex->{tix/2,1}}
            trace: collect_build_postponed (1): end {tix | libbar->{tix/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tix configured 1.0.0
              libbar configured 1.0.0
              tex configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
            EOO

          $pkg_drop tix
        }

        : args-tex-tix-tux
        :
        : Here tux requires tix/0.1.0 which has no dependencies.
        :
        {
          $clone_cfg;

          $* tex tix tux 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tix/1.0.0
            trace: collect_build: add tux/1.0.0
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_prerequisites: begin tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: add {tix 1,1: libbar} to {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_prerequisites: begin tux/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tux/1.0.0
            trace: postponed_configurations::add: create {tux | libbox->{tux/1,1}}
            trace: collect_build_prerequisites: postpone tux/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex tix | libbar->{tex/1,1 tix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tex tix | libbar->{tex/1,1 tix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (tex), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tix/1.0.0
            trace: collect_build: add tux/1.0.0
            trace: pkg_build: dep-postpone user-specified tex
            trace: collect_build_prerequisites: begin tix/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | libbar->{tix/1,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_prerequisites: begin tux/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tux/1.0.0
            trace: postponed_configurations::add: create {tux | libbox->{tux/1,1}}
            trace: collect_build_prerequisites: postpone tux/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tix | libbar->{tix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
            trace: collect_build_prerequisites: resume tix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0
            trace: postponed_configurations::add: create {tix | tex->{tix/2,1}}
            trace: collect_build_prerequisites: postpone tix/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tix | libbar->{tix/1,1}}!
            trace: collect_build_postponed (2): begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tux/1.0.0
            trace: collect_build_prerequisites: resume tux/1.0.0
            %.*
            trace: collect_build: pick tix/0.1.0 over tix/1.0.0
            trace: collect_build: tix/1.0.0 package version needs to be replaced with tix/0.1.0
            trace: pkg_build: collection failed due to package version replacement, retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: apply version replacement for tix/1.0.0
            trace: collect_build: replacement: tix/0.1.0
            trace: collect_build: add tix/0.1.0
            trace: collect_build: add tux/1.0.0
            trace: pkg_build: dep-postpone user-specified tex
            trace: collect_build_prerequisites: begin tix/0.1.0
            trace: collect_build_prerequisites: end tix/0.1.0
            trace: collect_build_prerequisites: begin tux/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tux/1.0.0
            trace: postponed_configurations::add: create {tux | libbox->{tux/1,1}}
            trace: collect_build_prerequisites: postpone tux/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tux/1.0.0
            trace: collect_build_prerequisites: resume tux/1.0.0
            %.*
            trace: collect_build_prerequisites: no cfg-clause for dependency tix/0.1.0 of dependent tux/1.0.0
            trace: collect_build_prerequisites: end tux/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tux | libbox->{tux/1,1}}!
            trace: collect_build_postponed (1): erase bogus postponement tex
            trace: collect_build_postponed (1): bogus postponements erased, throwing
            trace: pkg_build: collection failed due to bogus dependency collection postponement cancellation, retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: apply version replacement for tix/1.0.0
            trace: collect_build: replacement: tix/0.1.0
            trace: collect_build: add tix/0.1.0
            trace: collect_build: add tux/1.0.0
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_prerequisites: begin tix/0.1.0
            trace: collect_build_prerequisites: end tix/0.1.0
            trace: collect_build_prerequisites: begin tux/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent tux/1.0.0
            trace: postponed_configurations::add: create {tux | libbox->{tux/1,1}}
            trace: collect_build_prerequisites: postpone tux/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tex | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tex | libbar->{tex/1,1}}!
            trace: collect_build_postponed (2): begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tux | libbox->{tux/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tux/1.0.0
            trace: collect_build_prerequisites: resume tux/1.0.0
            %.*
            trace: collect_build_prerequisites: no cfg-clause for dependency tix/0.1.0 of dependent tux/1.0.0
            trace: collect_build_prerequisites: end tux/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tux | libbox->{tux/1,1}}!
            trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
            trace: collect_build_postponed (2): end {tux | libbox->{tux/1,1}}
            trace: collect_build_postponed (1): end {tex | libbar->{tex/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tex configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !tix configured 0.1.0 available 1.0.0
            !tux configured 1.0.0
              libbox configured 1.0.0
              !tix configured 0.1.0 available 1.0.0
            EOO

          $pkg_drop tex tix tux
        }

        : args-tex-tiz
        :
        : Note that tiz is a correct version of tix, which fixes the
        : configuration cycle.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  tiz: depends: tex(c)
          #       depends: libbar(c)
          #
          $* tex tiz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tiz/1.0.0
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_prerequisites: begin tiz/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency tex/1.0.0 of dependent tiz/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (tex), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add tiz/1.0.0
            trace: pkg_build: dep-postpone user-specified tex
            trace: collect_build_prerequisites: begin tiz/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tiz/1.0.0
            trace: postponed_configurations::add: create {tiz | tex->{tiz/1,1}}
            trace: collect_build_prerequisites: postpone tiz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tiz | tex->{tiz/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tiz | tex->{tiz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tiz/1.0.0
            trace: collect_build_prerequisites: resume tiz/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tiz/1.0.0
            trace: postponed_configurations::add: add {tiz 2,1: libbar} to {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tiz/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tiz | tex->{tiz/1,1}}!
            trace: collect_build_postponed (2): begin {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tiz/1.0.0
            trace: collect_build_prerequisites: resume tiz/1.0.0
            trace: collect_build_prerequisites: end tiz/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tex tiz | libbar->{tex/1,1 tiz/2,1}}!
            trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
            trace: collect_build_postponed (2): end {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            trace: collect_build_postponed (1): end {tiz | tex->{tiz/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tex configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !tiz configured 1.0.0
              libbar configured 1.0.0
              !tex configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
            EOO

          $pkg_drop tex tiz
        }

        : args-tiz
        :
        : Note that tiz is a correct version of tix, which fixes the
        : configuration cycle.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  tiz: depends: tex(c)
          #       depends: libbar(c)
          #
          $* tiz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tiz/1.0.0
            trace: collect_build_prerequisites: begin tiz/1.0.0
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tiz/1.0.0
            trace: postponed_configurations::add: create {tiz | tex->{tiz/1,1}}
            trace: collect_build_prerequisites: postpone tiz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tiz | tex->{tiz/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tiz | tex->{tiz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tiz/1.0.0
            trace: collect_build_prerequisites: resume tiz/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tiz/1.0.0
            trace: postponed_configurations::add: add {tiz 2,1: libbar} to {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tiz/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tiz | tex->{tiz/1,1}}!
            trace: collect_build_postponed (2): begin {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tiz/1.0.0
            trace: collect_build_prerequisites: resume tiz/1.0.0
            trace: collect_build_prerequisites: end tiz/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {tex tiz | libbar->{tex/1,1 tiz/2,1}}!
            trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
            trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
            trace: collect_build_postponed (2): end {tex tiz | libbar->{tex/1,1 tiz/2,1}}
            trace: collect_build_postponed (1): end {tiz | tex->{tiz/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tiz configured 1.0.0
              libbar configured 1.0.0
              tex configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
            EOO

          $pkg_drop tiz
        }

        : depends-depends-conflict
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tex: depends: libbar(c)
          #       depends: libfoo(c)
          #
          #  toz: depends: libfoo(c)
          #       depends: libbar(c)
          #
          $* tex toz/0.2.0 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tex/1.0.0
            trace: collect_build: add toz/0.2.0
            trace: collect_build_prerequisites: begin tex/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_prerequisites: begin toz/0.2.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent toz/0.2.0
            trace: postponed_configurations::add: create {toz | libfoo->{toz/1,1}}
            trace: collect_build_prerequisites: postpone toz/0.2.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tex | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tex | libbar->{tex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
            trace: postponed_configurations::add: add {tex 2,1: libfoo} to {toz | libfoo->{toz/1,1}}
            trace: collect_build_prerequisites: postpone tex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tex | libbar->{tex/1,1}}!
            trace: collect_build_postponed (2): begin {tex toz | libfoo->{tex/2,1 toz/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {tex toz | libfoo->{tex/2,1 toz/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/1.0.0
            trace: collect_build_prerequisites: resume tex/1.0.0
            trace: collect_build_prerequisites: end tex/1.0.0
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent toz/0.2.0
            trace: collect_build_prerequisites: resume toz/0.2.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent toz/0.2.0
            trace: postponed_configurations::add: add {toz 2,1: libbar} to {tex | libbar->{tex/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent toz/0.2.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent toz/0.2.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end toz/0.2.0
            trace: collect_build_postponed (2): cfg-negotiate end {tex toz | libfoo->{tex/2,1 toz/1,1}}!
            trace: collect_build_postponed (2): end {tex toz | libfoo->{tex/2,1 toz/1,1}}
            trace: collect_build_postponed (1): end {tex | libbar->{tex/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tex configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !toz configured !0.2.0 available 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            EOO

          $pkg_drop tex toz
        }

        : package-depends-conflict
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  baz: depends: {libbar libfoo} (c)
          #
          #  bac: depends: libbar(c)
          #       depends: libbaz(c)
          #       depends: libfoo(c)
          #
          #  bat: depends: libbaz(c)
          #
          $* baz bac bat 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add baz/1.0.0
            trace: collect_build: add bac/1.0.0
            trace: collect_build: add bat/1.0.0
            trace: collect_build_prerequisites: begin baz/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent baz/1.0.0
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent baz/1.0.0
            trace: postponed_configurations::add: create {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone baz/1.0.0
            trace: collect_build_prerequisites: begin bac/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bac/1.0.0
            trace: postponed_configurations::add: add {bac 1,1: libbar} to {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone bac/1.0.0
            trace: collect_build_prerequisites: begin bat/1.0.0
            %.*
            trace: collect_build: add libbaz/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bat/1.0.0
            trace: postponed_configurations::add: create {bat | libbaz->{bat/1,1}}
            trace: collect_build_prerequisites: postpone bat/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {bac baz | libbar->{bac/1,1 baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {bac baz | libbar->{bac/1,1 baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bac/1.0.0
            trace: collect_build_prerequisites: resume bac/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bac/1.0.0
            trace: postponed_configurations::add: add {bac 2,1: libbaz} to {bat | libbaz->{bat/1,1}}
            trace: collect_build_prerequisites: postpone bac/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
            trace: collect_build_prerequisites: resume baz/1.0.0
            trace: collect_build_prerequisites: end baz/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {bac baz | libbar->{bac/1,1 baz/1,1} libfoo->{baz/1,1}}!
            trace: collect_build_postponed (2): begin {bac bat | libbaz->{bac/2,1 bat/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {bac bat | libbaz->{bac/2,1 bat/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbaz/1.0.0
            trace: collect_build_prerequisites: end libbaz/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bac/1.0.0
            trace: collect_build_prerequisites: resume bac/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent bac/1.0.0
            trace: postponed_configurations::add: add {bac 3,1: libfoo} to {bac baz | libbar->{bac/1,1 baz/1,1} libfoo->{baz/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bac/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent bac/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bac/1.0.0
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bat/1.0.0
            trace: collect_build_prerequisites: resume bat/1.0.0
            trace: collect_build_prerequisites: end bat/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {bac bat | libbaz->{bac/2,1 bat/1,1}}!
            trace: collect_build_postponed (2): end {bac bat | libbaz->{bac/2,1 bat/1,1}}
            trace: collect_build_postponed (1): end {bac baz | libbar->{bac/1,1 baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !baz configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !bac configured 1.0.0
              libbar configured 1.0.0
              libbaz configured 1.0.0
              libfoo configured 1.0.0
            !bat configured 1.0.0
              libbaz configured 1.0.0
            EOO

          $pkg_drop baz bac bat
        }

        : existing
        :
        {
          +$clone_cfg

          : dependency-new-downgrade
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  tex: depends: libbar(c)
            #       depends: libfoo(c)
            #
            #  tix: depends: libbar(c)
            #       depends: tex(c)
            #
            $* tex 2>!;

            # Build new dependency of an existing dependent.
            #
            $* tix 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: begin tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix | libbar->{tix/1,1}}
              trace: collect_build_prerequisites: postpone tix/1.0.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix | libbar->{tix/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix | libbar->{tix/1,1}}
              %.*
              trace: collect_build: add tex/1.0.0
              trace: collect_build_prerequisites: reeval tex/1.0.0
              %.*
              trace: postponed_configurations::add: add {tex^ 1,1: libbar} to {tix | libbar->{tix/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tex/1.0.0 results in {tex^ tix | libbar->{tex/1,1 tix/1,1}}
              trace: collect_build_prerequisites: re-evaluated tex/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tex^ tix | libbar->{tex/1,1 tix/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tex/1.0.0
              trace: collect_build_prerequisites: resume tex/1.0.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
              trace: collect_build_prerequisites: postpone tex/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              %.*
              trace: collect_build_prerequisites: cannot cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0 (collected prematurely), throwing postpone_dependency
              trace: pkg_build: collection failed due to prematurely collected dependency (tex), retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: begin tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix | libbar->{tix/1,1}}
              trace: collect_build_prerequisites: postpone tix/1.0.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix | libbar->{tix/1,1}}
              %.*
              trace: collect_build_postponed (1): skip dep-postponed existing dependent tex of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {tix | libbar->{tix/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              %.*
              trace: collect_build: add tex/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency tex/1.0.0 of dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix | tex->{tix/2,1}}
              trace: collect_build_prerequisites: postpone tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix | libbar->{tix/1,1}}!
              trace: collect_build_postponed (2): begin {tix | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (2): cfg-negotiate begin {tix | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/1.0.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/1.0.0
              trace: postponed_configurations::add: add {tex 1,1: libbar} to {tix | libbar->{tix/1,1}}!
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tex/1.0.0 is negotiated
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tex/1.0.0 is already (being) recursively collected, skipping
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/1.0.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
              trace: collect_build_prerequisites: postpone tex/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (2): cfg-negotiate end {tix | tex->{tix/2,1}}!
              trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (3): skip being built existing dependent tex of dependency libfoo
              trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/1.0.0
              trace: collect_build_prerequisites: resume tex/1.0.0
              trace: collect_build_prerequisites: end tex/1.0.0
              trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
              trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
              trace: collect_build_postponed (2): end {tix | tex->{tix/2,1}}
              trace: collect_build_postponed (1): end {tix | libbar->{tix/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_status -r >>EOO;
              !tex configured 1.0.0
                libbar configured 1.0.0
                libfoo configured 1.0.0
              !tix configured 1.0.0
                libbar configured 1.0.0
                !tex configured 1.0.0
                  libbar configured 1.0.0
                  libfoo configured 1.0.0
              EOO

            # Downgrade the existing dependency of an existing dependent.
            #
            $* tex/0.3.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tex/0.3.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.3.0 of existing dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: reeval tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              %.*
              trace: collect_build: pick tex/0.3.0 over tex/1.0.0
              trace: postponed_configurations::add: add {tix^ 2,1: tex} to {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tix/1.0.0 results in {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluated tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/0.3.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/0.3.0
              trace: postponed_configurations::add: create {tex | libbar->{tex/1,1}}
              trace: collect_build_prerequisites: postpone tex/0.3.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix^ | tex->{tix/2,1}}!
              trace: collect_build_postponed (2): begin {tex | libbar->{tex/1,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libbar
              trace: collect_build_postponed (2): re-evaluate existing dependents for {tex | libbar->{tex/1,1}}
              trace: collect_build_postponed (2): cannot re-evaluate dependent tix to dependency index 1 due to greater dependency index 2 in {tix^ | tex->{tix/2,1}}!, throwing postpone_position
              trace: pkg_build: collection failed due to earlier dependency position, retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tex/0.3.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.3.0 of existing dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (1): pos-postpone existing dependent tix re-evaluation to dependency index 2 due to recorded index 1, skipping {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): postpone cfg-negotiation of {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): non-negotiated clusters left and non-replace postponed positions are present, overriding first encountered non-replace position to replace
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (1): pos-postpone existing dependent tix re-evaluation to dependency index 2 due to recorded index 1, skipping {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): replace dependency at index 2 of existing dependent tix/1.0.0 with dependency libbar/1.0.0 at index 1
              trace: collect_build: add libbar/1.0.0
              trace: postponed_configurations::add: create {tix^ | libbar->{tix/1,1}}
              trace: collect_build_postponed (0): postpone cfg-negotiation of {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (1): begin {tix^ | libbar->{tix/1,1}}
              %.*
              trace: collect_build_postponed (1): skip being built existing dependent tex of dependency libbar
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | libbar->{tix/1,1}}
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: reeval tix/1.0.0
              %.*
              trace: postponed_configurations::add: add {tix^ 1,1: libbar} to {tix^ | libbar->{tix/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tix/1.0.0 results in {tix^ | libbar->{tix/1,1}}
              trace: collect_build_prerequisites: re-evaluated tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tix^ | libbar->{tix/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              %.*
              trace: collect_build: pick tex/0.3.0 over tex/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.3.0 of dependent tix/1.0.0
              trace: postponed_configurations::add: add {tix 2,1: tex} to {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: postpone tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix^ | libbar->{tix/1,1}}!
              trace: collect_build_postponed (2): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent tix of dependency tex
              trace: collect_build_postponed (2): cfg-negotiate begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/0.3.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tex/0.3.0
              trace: postponed_configurations::add: add {tex 1,1: libbar} to {tix^ | libbar->{tix/1,1}}!
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent tex/0.3.0 is negotiated
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent tex/0.3.0 is already (being) recursively collected, skipping
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/0.3.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
              trace: collect_build_prerequisites: postpone tex/0.3.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (2): cfg-negotiate end {tix^ | tex->{tix/2,1}}!
              trace: collect_build_postponed (3): begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (3): skip being built existing dependent tex of dependency libfoo
              trace: collect_build_postponed (3): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent tex/0.3.0
              trace: collect_build_prerequisites: resume tex/0.3.0
              trace: collect_build_prerequisites: end tex/0.3.0
              trace: collect_build_postponed (3): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
              trace: collect_build_postponed (3): end {tex | libfoo->{tex/2,1}}
              trace: collect_build_postponed (2): end {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (1): end {tix^ | libbar->{tix/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_drop tex tix
          }

          : dependency-downgrade
          :
          : Note that here we also specify the existing dependent tix on the
          : command line to make sure that its noop recursive collection
          : doesn't prevent it from being properly re-evaluated afterwords.
          :
          : Also note that tex/0.1.0 doesn't depend on libbar.
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  tex: depends: libbar(c)
            #       depends: libfoo(c)
            #
            #  tix: depends: libbar(c)
            #       depends: tex(c)
            #
            $* tex tix 2>!;

            $* tix tex/0.1.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build: add tex/0.1.0
              trace: collect_build_prerequisites: skip configured tix/1.0.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.1.0 of existing dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: reeval tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              %.*
              trace: collect_build: pick tex/0.1.0 over tex/1.0.0
              trace: postponed_configurations::add: add {tix^ 2,1: tex} to {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tix/1.0.0 results in {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluated tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/0.1.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/0.1.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/1,1}}
              trace: collect_build_prerequisites: postpone tex/0.1.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix^ | tex->{tix/2,1}}!
              trace: collect_build_postponed (2): begin {tex | libfoo->{tex/1,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libfoo
              trace: collect_build_postponed (2): cfg-negotiate begin {tex | libfoo->{tex/1,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/0.1.0
              trace: collect_build_prerequisites: resume tex/0.1.0
              trace: collect_build_prerequisites: end tex/0.1.0
              trace: collect_build_postponed (2): cfg-negotiate end {tex | libfoo->{tex/1,1}}!
              trace: collect_build_postponed (2): end {tex | libfoo->{tex/1,1}}
              trace: collect_build_postponed (1): end {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_drop tex tix
          }

          : dependency-downgrade-unhold
          :
          : As above but the dependency is also unheld.
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  tex: depends: libbar(c)
            #       depends: libfoo(c)
            #
            #  tix: depends: libbar(c)
            #       depends: tex(c)
            #
            $* tex tix 2>!;

            $* tix ?tex/0.1.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: skip configured tix/1.0.0
              trace: execute_plan: simulate: yes
              %.*
              trace: evaluate_dependency: tex/1.0.0: update to tex/0.1.0
              %.*
              trace: pkg_build: refine package collection/plan execution
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.1.0 of existing dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: reeval tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              %.*
              trace: collect_build: pick tex/0.1.0 over tex/1.0.0
              trace: postponed_configurations::add: add {tix^ 2,1: tex} to {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tix/1.0.0 results in {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluated tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/0.1.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/0.1.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/1,1}}
              trace: collect_build_prerequisites: postpone tex/0.1.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix^ | tex->{tix/2,1}}!
              trace: collect_build_postponed (2): begin {tex | libfoo->{tex/1,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libfoo
              trace: collect_build_postponed (2): cfg-negotiate begin {tex | libfoo->{tex/1,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/0.1.0
              trace: collect_build_prerequisites: resume tex/0.1.0
              trace: collect_build_prerequisites: end tex/0.1.0
              trace: collect_build_postponed (2): cfg-negotiate end {tex | libfoo->{tex/1,1}}!
              trace: collect_build_postponed (2): end {tex | libfoo->{tex/1,1}}
              trace: collect_build_postponed (1): end {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_drop tix
          }

          : dependency-downgrade-unhold-premature
          :
          : As above but the dependency (tex) depends on libbar without
          : configuration clause.
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  tex: depends: libbar(c)
            #       depends: libfoo(c)
            #
            #  tix: depends: libbar(c)
            #       depends: tex(c)
            #
            $* tex tix 2>!;

            $* tix ?tex/0.2.0 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add tix/1.0.0
              trace: collect_build_prerequisites: skip configured tix/1.0.0
              trace: execute_plan: simulate: yes
              %.*
              trace: evaluate_dependency: tex/1.0.0: update to tex/0.2.0
              %.*
              trace: pkg_build: refine package collection/plan execution
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency tex/0.2.0 of existing dependent tix/1.0.0
              trace: postponed_configurations::add: create {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: reeval tix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              %.*
              trace: collect_build: pick tex/0.2.0 over tex/1.0.0
              trace: postponed_configurations::add: add {tix^ 2,1: tex} to {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluating dependent tix/1.0.0 results in {tix^ | tex->{tix/2,1}}
              trace: collect_build_prerequisites: re-evaluated tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {tix^ | tex->{tix/2,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin tex/0.2.0
              %.*
              trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent tex/0.2.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent tex/0.2.0
              trace: postponed_configurations::add: create {tex | libfoo->{tex/2,1}}
              trace: collect_build_prerequisites: postpone tex/0.2.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tix/1.0.0
              trace: collect_build_prerequisites: resume tix/1.0.0
              trace: collect_build_prerequisites: end tix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {tix^ | tex->{tix/2,1}}!
              trace: collect_build_postponed (2): begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (2): skip being built existing dependent tex of dependency libfoo
              trace: collect_build_postponed (2): cfg-negotiate begin {tex | libfoo->{tex/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent tex/0.2.0
              trace: collect_build_prerequisites: resume tex/0.2.0
              trace: collect_build_prerequisites: end tex/0.2.0
              trace: collect_build_postponed (2): cfg-negotiate end {tex | libfoo->{tex/2,1}}!
              trace: collect_build_postponed (2): end {tex | libfoo->{tex/2,1}}
              trace: collect_build_postponed (1): end {tix^ | tex->{tix/2,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_drop tix
          }
        }
      }

      : indirect
      :
      {
        +$clone_cfg

        : args-tax-dex-dix
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tax: depends: libbar(c)
          #       depends: libfoo
          #
          #  bar: depends: libbar(c)
          #
          #  dex: depends: bar(c)
          #       depends: libfoo(c)
          #
          #  dox: dex(c)
          #
          #  dix: depends: libbar(c)
          #       depends: libbox(c) # causes postponment and initial cluster finished negotiating
          #       depends: dox(c)
          #
          $* tax dex dix 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add dix/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin dix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: add {dix 1,1: libbar} to {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_postponed (2): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add dix/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin dix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: add {dix 1,1: libbar} to {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_postponed (2): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (3): begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | dox->{dix/3,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {dix | libbox->{dix/2,1}}!
            trace: collect_build_postponed (4): begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
            trace: collect_build_postponed (5): begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (5): cfg-negotiate begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (dex), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add dix/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: pkg_build: dep-postpone user-specified dex
            trace: collect_build_prerequisites: begin dix/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: add {dix 1,1: libbar} to {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dix tax | libbar->{dix/1,1 tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_postponed (2): begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | dox->{dix/3,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {dix | libbox->{dix/2,1}}!
            trace: collect_build_postponed (3): begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
            trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
            trace: collect_build_prerequisites: postpone dox/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            trace: collect_build_prerequisites: end dix/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {dix | dox->{dix/3,1}}!
            trace: collect_build_postponed (4): begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent dox/1.0.0
            trace: collect_build_prerequisites: resume dox/1.0.0
            trace: collect_build_prerequisites: end dox/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {dox | dex->{dox/1,1}}!
            trace: collect_build_postponed (5): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {dix tax | libbar->{dix/1,1 tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (5): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (6): begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (6): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (6): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
            trace: collect_build_postponed (6): end {dex | libfoo->{dex/2,1}}
            trace: collect_build_postponed (5): end {dex | bar->{dex/1,1}}
            trace: collect_build_postponed (4): end {dox | dex->{dox/1,1}}
            trace: collect_build_postponed (3): end {dix | dox->{dix/3,1}}
            trace: collect_build_postponed (2): end {dix | libbox->{dix/2,1}}
            trace: collect_build_postponed (1): end {dix tax | libbar->{dix/1,1 tax/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tax configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !dex configured 1.0.0
              bar configured 1.0.0
                libbar configured 1.0.0
              libfoo configured 1.0.0
            !dix configured 1.0.0
              dox configured 1.0.0
                !dex configured 1.0.0
                  bar configured 1.0.0
                    libbar configured 1.0.0
                  libfoo configured 1.0.0
              libbar configured 1.0.0
              libbox configured 1.0.0
            EOO

          $pkg_drop tax dex dix --drop-dependent
        }

        : args-dix
        :
        : As above but with the different command-line arguments which results
        : in the different cluster list at the moment of the cycle detection.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  bar: depends: libbar(c)
          #
          #  dex: depends: bar(c)
          #       depends: libfoo(c)
          #
          #  dox: dex(c)
          #
          #  dix: depends: libbar(c)
          #       depends: libbox(c) # causes postponment and initial cluster finished negotiating
          #       depends: dox(c)
          #
          $* dix 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add dix/1.0.0
            trace: collect_build_prerequisites: begin dix/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | libbar->{dix/1,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dix | libbar->{dix/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dix | libbar->{dix/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dix | libbar->{dix/1,1}}!
            trace: collect_build_postponed (2): begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dix | libbox->{dix/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent dix/1.0.0
            trace: postponed_configurations::add: create {dix | dox->{dix/3,1}}
            trace: collect_build_prerequisites: postpone dix/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {dix | libbox->{dix/2,1}}!
            trace: collect_build_postponed (3): begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {dix | dox->{dix/3,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build: add dex/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
            trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
            trace: collect_build_prerequisites: postpone dox/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dix/1.0.0
            trace: collect_build_prerequisites: resume dix/1.0.0
            trace: collect_build_prerequisites: end dix/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {dix | dox->{dix/3,1}}!
            trace: collect_build_postponed (4): begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent dox/1.0.0
            trace: collect_build_prerequisites: resume dox/1.0.0
            trace: collect_build_prerequisites: end dox/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {dox | dex->{dox/1,1}}!
            trace: collect_build_postponed (5): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {dix | libbar->{dix/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (5): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (6): begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (6): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (6): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
            trace: collect_build_postponed (6): end {dex | libfoo->{dex/2,1}}
            trace: collect_build_postponed (5): end {dex | bar->{dex/1,1}}
            trace: collect_build_postponed (4): end {dox | dex->{dox/1,1}}
            trace: collect_build_postponed (3): end {dix | dox->{dix/3,1}}
            trace: collect_build_postponed (2): end {dix | libbox->{dix/2,1}}
            trace: collect_build_postponed (1): end {dix | libbar->{dix/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !dix configured 1.0.0
              dox configured 1.0.0
                dex configured 1.0.0
                  bar configured 1.0.0
                    libbar configured 1.0.0
                  libfoo configured 1.0.0
              libbar configured 1.0.0
              libbox configured 1.0.0
            EOO

          $pkg_drop dix
        }

        : args-tax-dex-diz
        :
        : Note that diz is a correct version of dix, which fixes the
        : configuration cycle.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  tax: depends: libbar(c)
          #       depends: libfoo
          #
          #  bar: depends: libbar(c)
          #
          #  dex: depends: bar(c)
          #       depends: libfoo(c)
          #
          #  dox: dex(c)
          #
          #  diz: depends: dox(c)
          #       depends: libbox(c)
          #       depends: libbar(c)
          #
          $* tax dex diz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add diz/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin diz/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | dox->{diz/1,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: no cfg-clause for dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
            trace: collect_build_postponed (2): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {tax | libbar->{tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (libfoo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add diz/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin diz/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | dox->{diz/1,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
            trace: collect_build_postponed (2): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {tax | libbar->{tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (3): begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (dex), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add tax/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add diz/1.0.0
            trace: collect_build_prerequisites: begin tax/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent tax/1.0.0
            trace: postponed_configurations::add: create {tax | libbar->{tax/1,1}}
            trace: collect_build_prerequisites: postpone tax/1.0.0
            trace: pkg_build: dep-postpone user-specified dex
            trace: collect_build_prerequisites: begin diz/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | dox->{diz/1,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {tax | libbar->{tax/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent tax/1.0.0
            trace: collect_build_prerequisites: resume tax/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: dep-postpone dependency libfoo/1.0.0 of dependent tax/1.0.0
            trace: collect_build_prerequisites: end tax/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {tax | libbar->{tax/1,1}}!
            trace: collect_build_postponed (2): begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
            trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
            trace: collect_build_prerequisites: postpone dox/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent diz/1.0.0
            trace: collect_build_prerequisites: resume diz/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | libbox->{diz/2,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {diz | dox->{diz/1,1}}!
            trace: collect_build_postponed (3): begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dox/1.0.0
            trace: collect_build_prerequisites: resume dox/1.0.0
            trace: collect_build_prerequisites: end dox/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {dox | dex->{dox/1,1}}!
            trace: collect_build_postponed (4): begin {diz | libbox->{diz/2,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {diz | libbox->{diz/2,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent diz/1.0.0
            trace: collect_build_prerequisites: resume diz/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: add {diz 3,1: libbar} to {tax | libbar->{tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent diz/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent diz/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end diz/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {diz | libbox->{diz/2,1}}!
            trace: collect_build_postponed (5): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {diz tax | libbar->{diz/3,1 tax/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (5): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (6): begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (6): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (6): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
            trace: collect_build_postponed (6): end {dex | libfoo->{dex/2,1}}
            trace: collect_build_postponed (5): end {dex | bar->{dex/1,1}}
            trace: collect_build_postponed (4): end {diz | libbox->{diz/2,1}}
            trace: collect_build_postponed (3): end {dox | dex->{dox/1,1}}
            trace: collect_build_postponed (2): end {diz | dox->{diz/1,1}}
            trace: collect_build_postponed (1): end {tax | libbar->{tax/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !tax configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !dex configured 1.0.0
              bar configured 1.0.0
                libbar configured 1.0.0
              libfoo configured 1.0.0
            !diz configured 1.0.0
              dox configured 1.0.0
                !dex configured 1.0.0
                  bar configured 1.0.0
                    libbar configured 1.0.0
                  libfoo configured 1.0.0
              libbar configured 1.0.0
              libbox configured 1.0.0
            EOO

          $pkg_drop tax dex diz --drop-dependent
        }

        : args-diz
        :
        : Note that diz is a correct version of dix, which fixes the
        : configuration cycle.
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  bar: depends: libbar(c)
          #
          #  dex: depends: bar(c)
          #       depends: libfoo(c)
          #
          #  dox: dex(c)
          #
          #  diz: depends: dox(c)
          #       depends: libbox(c)
          #       depends: libbar(c)
          #
          $* diz 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add diz/1.0.0
            trace: collect_build_prerequisites: begin diz/1.0.0
            %.*
            trace: collect_build: add dox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | dox->{diz/1,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {diz | dox->{diz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dox/1.0.0
            %.*
            trace: collect_build: add dex/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
            trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
            trace: collect_build_prerequisites: postpone dox/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent diz/1.0.0
            trace: collect_build_prerequisites: resume diz/1.0.0
            %.*
            trace: collect_build: add libbox/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | libbox->{diz/2,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {diz | dox->{diz/1,1}}!
            trace: collect_build_postponed (2): begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {dox | dex->{dox/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dox/1.0.0
            trace: collect_build_prerequisites: resume dox/1.0.0
            trace: collect_build_prerequisites: end dox/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {dox | dex->{dox/1,1}}!
            trace: collect_build_postponed (3): begin {diz | libbox->{diz/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {diz | libbox->{diz/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbox/1.0.0
            trace: collect_build_prerequisites: end libbox/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent diz/1.0.0
            trace: collect_build_prerequisites: resume diz/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent diz/1.0.0
            trace: postponed_configurations::add: create {diz | libbar->{diz/3,1}}
            trace: collect_build_prerequisites: postpone diz/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {diz | libbox->{diz/2,1}}!
            trace: collect_build_postponed (4): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {diz | libbar->{diz/3,1}}
            trace: collect_build_prerequisites: postpone bar/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (5): begin {bar diz | libbar->{bar/1,1 diz/3,1}}
            %.*
            trace: collect_build_postponed (5): cfg-negotiate begin {bar diz | libbar->{bar/1,1 diz/3,1}}
            %.*
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (5): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent bar/1.0.0
            trace: collect_build_prerequisites: resume bar/1.0.0
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent diz/1.0.0
            trace: collect_build_prerequisites: resume diz/1.0.0
            trace: collect_build_prerequisites: end diz/1.0.0
            trace: collect_build_postponed (5): cfg-negotiate end {bar diz | libbar->{bar/1,1 diz/3,1}}!
            trace: collect_build_postponed (6): begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
            %.*
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (6): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (6): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (6): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
            trace: collect_build_postponed (6): end {dex | libfoo->{dex/2,1}}
            trace: collect_build_postponed (5): end {bar diz | libbar->{bar/1,1 diz/3,1}}
            trace: collect_build_postponed (4): end {dex | bar->{dex/1,1}}
            trace: collect_build_postponed (3): end {diz | libbox->{diz/2,1}}
            trace: collect_build_postponed (2): end {dox | dex->{dox/1,1}}
            trace: collect_build_postponed (1): end {diz | dox->{diz/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !diz configured 1.0.0
              dox configured 1.0.0
                dex configured 1.0.0
                  bar configured 1.0.0
                    libbar configured 1.0.0
                  libfoo configured 1.0.0
              libbar configured 1.0.0
              libbox configured 1.0.0
            EOO

          $pkg_drop diz
        }

        : depends-depends-conflict
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  bar: depends: libbar(c)
          #
          #  dex: depends: bar(c)
          #       depends: libfoo(c)
          #
          #  bux: depends: libbar(c)
          #
          #  buc: depends: libfoo(c)
          #       depends: bux(c)
          #
          $* bar dex buc bux 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add buc/1.0.0
            trace: collect_build: add bux/1.0.0
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: postpone bar/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (bar), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add buc/1.0.0
            trace: collect_build: add bux/1.0.0
            trace: pkg_build: dep-postpone user-specified bar
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin buc/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent buc/1.0.0
            trace: postponed_configurations::add: create {buc | libfoo->{buc/1,1}}
            trace: collect_build_prerequisites: postpone buc/1.0.0
            trace: collect_build_prerequisites: begin bux/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bux/1.0.0
            trace: postponed_configurations::add: create {bux | libbar->{bux/1,1}}
            trace: collect_build_prerequisites: postpone bux/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: add {bar 1,1: libbar} to {bux | libbar->{bux/1,1}}
            trace: collect_build_prerequisites: postpone bar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: add {dex 2,1: libfoo} to {buc | libfoo->{buc/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (2): begin {buc dex | libfoo->{buc/1,1 dex/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {buc dex | libfoo->{buc/1,1 dex/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent buc/1.0.0
            trace: collect_build_prerequisites: resume buc/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency bux/1.0.0 of dependent buc/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (bux), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add buc/1.0.0
            trace: collect_build: add bux/1.0.0
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: postpone bar/1.0.0
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (bar), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add bar/1.0.0
            trace: collect_build: add dex/1.0.0
            trace: collect_build: add buc/1.0.0
            trace: collect_build: add bux/1.0.0
            trace: pkg_build: dep-postpone user-specified bar
            trace: collect_build_prerequisites: begin dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_prerequisites: begin buc/1.0.0
            %.*
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent buc/1.0.0
            trace: postponed_configurations::add: create {buc | libfoo->{buc/1,1}}
            trace: collect_build_prerequisites: postpone buc/1.0.0
            trace: pkg_build: dep-postpone user-specified bux
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {dex | bar->{dex/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bar/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
            trace: postponed_configurations::add: create {bar | libbar->{bar/1,1}}
            trace: collect_build_prerequisites: postpone bar/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
            trace: postponed_configurations::add: add {dex 2,1: libfoo} to {buc | libfoo->{buc/1,1}}
            trace: collect_build_prerequisites: postpone dex/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {dex | bar->{dex/1,1}}!
            trace: collect_build_postponed (2): begin {buc dex | libfoo->{buc/1,1 dex/2,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {buc dex | libfoo->{buc/1,1 dex/2,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent buc/1.0.0
            trace: collect_build_prerequisites: resume buc/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency bux/1.0.0 of dependent buc/1.0.0
            trace: postponed_configurations::add: create {buc | bux->{buc/2,1}}
            trace: collect_build_prerequisites: postpone buc/1.0.0
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dex/1.0.0
            trace: collect_build_prerequisites: resume dex/1.0.0
            trace: collect_build_prerequisites: end dex/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {buc dex | libfoo->{buc/1,1 dex/2,1}}!
            trace: collect_build_postponed (3): begin {bar | libbar->{bar/1,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {bar | libbar->{bar/1,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent bar/1.0.0
            trace: collect_build_prerequisites: resume bar/1.0.0
            trace: collect_build_prerequisites: end bar/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {bar | libbar->{bar/1,1}}!
            trace: collect_build_postponed (4): begin {buc | bux->{buc/2,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {buc | bux->{buc/2,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bux/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bux/1.0.0
            trace: postponed_configurations::add: add {bux 1,1: libbar} to {bar | libbar->{bar/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bux/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bux/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end bux/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent buc/1.0.0
            trace: collect_build_prerequisites: resume buc/1.0.0
            trace: collect_build_prerequisites: end buc/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {buc | bux->{buc/2,1}}!
            trace: collect_build_postponed (4): end {buc | bux->{buc/2,1}}
            trace: collect_build_postponed (3): end {bar | libbar->{bar/1,1}}
            trace: collect_build_postponed (2): end {buc dex | libfoo->{buc/1,1 dex/2,1}}
            trace: collect_build_postponed (1): end {dex | bar->{dex/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !bar configured 1.0.0
              libbar configured 1.0.0
            !dex configured 1.0.0
              !bar configured 1.0.0
                libbar configured 1.0.0
              libfoo configured 1.0.0
            !bux configured 1.0.0
              libbar configured 1.0.0
            !buc configured 1.0.0
              !bux configured 1.0.0
                libbar configured 1.0.0
              libfoo configured 1.0.0
            EOO

          $pkg_drop bar dex buc bux
        }

        : package-depends-conflict
        :
        {
          $clone_cfg;

          #  Dependencies:
          #
          #  baz: depends: {libbar libfoo} (c)
          #
          #  bas: depends: libbar(c)
          #       depends: bus (c)
          #
          #  bus: depends: libbaz(c)
          #       depends: foo (c)
          #
          #  foo: depends: libfoo(c)
          #
          #  bat: depends: libbaz(c)
          #
          $* baz bas bus foo bat 2>>~%EOE%;
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add baz/1.0.0
            trace: collect_build: add bas/1.0.0
            trace: collect_build: add bus/1.0.0
            trace: collect_build: add foo/1.0.0
            trace: collect_build: add bat/1.0.0
            trace: collect_build_prerequisites: begin baz/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent baz/1.0.0
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent baz/1.0.0
            trace: postponed_configurations::add: create {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone baz/1.0.0
            trace: collect_build_prerequisites: begin bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bas/1.0.0
            trace: postponed_configurations::add: add {bas 1,1: libbar} to {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone bas/1.0.0
            trace: collect_build_prerequisites: begin bus/1.0.0
            %.*
            trace: collect_build: add libbaz/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bus/1.0.0
            trace: postponed_configurations::add: create {bus | libbaz->{bus/1,1}}
            trace: collect_build_prerequisites: postpone bus/1.0.0
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: add {foo 1,1: libfoo} to {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_prerequisites: begin bat/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bat/1.0.0
            trace: postponed_configurations::add: add {bat 1,1: libbaz} to {bus | libbaz->{bus/1,1}}
            trace: collect_build_prerequisites: postpone bat/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {bas baz foo | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1 foo/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {bas baz foo | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1 foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bas/1.0.0
            trace: collect_build_prerequisites: resume bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency bus/1.0.0 of dependent bas/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (bus), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add baz/1.0.0
            trace: collect_build: add bas/1.0.0
            trace: collect_build: add bus/1.0.0
            trace: collect_build: add foo/1.0.0
            trace: collect_build: add bat/1.0.0
            trace: collect_build_prerequisites: begin baz/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent baz/1.0.0
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent baz/1.0.0
            trace: postponed_configurations::add: create {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone baz/1.0.0
            trace: collect_build_prerequisites: begin bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bas/1.0.0
            trace: postponed_configurations::add: add {bas 1,1: libbar} to {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone bas/1.0.0
            trace: pkg_build: dep-postpone user-specified bus
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: add {foo 1,1: libfoo} to {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone foo/1.0.0
            trace: collect_build_prerequisites: begin bat/1.0.0
            %.*
            trace: collect_build: add libbaz/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bat/1.0.0
            trace: postponed_configurations::add: create {bat | libbaz->{bat/1,1}}
            trace: collect_build_prerequisites: postpone bat/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {bas baz foo | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1 foo/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {bas baz foo | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1 foo/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bas/1.0.0
            trace: collect_build_prerequisites: resume bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency bus/1.0.0 of dependent bas/1.0.0
            trace: postponed_configurations::add: create {bas | bus->{bas/2,1}}
            trace: collect_build_prerequisites: postpone bas/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
            trace: collect_build_prerequisites: resume baz/1.0.0
            trace: collect_build_prerequisites: end baz/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
            trace: collect_build_prerequisites: resume foo/1.0.0
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {bas baz foo | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1 foo/1,1}}!
            trace: collect_build_postponed (2): begin {bat | libbaz->{bat/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {bat | libbaz->{bat/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbaz/1.0.0
            trace: collect_build_prerequisites: end libbaz/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bat/1.0.0
            trace: collect_build_prerequisites: resume bat/1.0.0
            trace: collect_build_prerequisites: end bat/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {bat | libbaz->{bat/1,1}}!
            trace: collect_build_postponed (3): begin {bas | bus->{bas/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {bas | bus->{bas/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bus/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bus/1.0.0
            trace: postponed_configurations::add: add {bus 1,1: libbaz} to {bat | libbaz->{bat/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bus/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbaz/1.0.0 of dependent bus/1.0.0 is already (being) recursively collected, skipping
            %.*
            trace: collect_build_prerequisites: cannot cfg-postpone dependency foo/1.0.0 of dependent bus/1.0.0 (collected prematurely), throwing postpone_dependency
            trace: pkg_build: collection failed due to prematurely collected dependency (foo), retry from scratch
            %.*
            trace: pkg_build: refine package collection/plan execution from scratch
            %.*
            trace: collect_build: add baz/1.0.0
            trace: collect_build: add bas/1.0.0
            trace: collect_build: add bus/1.0.0
            trace: collect_build: add foo/1.0.0
            trace: collect_build: add bat/1.0.0
            trace: collect_build_prerequisites: begin baz/1.0.0
            %.*
            trace: collect_build: add libbar/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent baz/1.0.0
            trace: collect_build: add libfoo/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent baz/1.0.0
            trace: postponed_configurations::add: create {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone baz/1.0.0
            trace: collect_build_prerequisites: begin bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bas/1.0.0
            trace: postponed_configurations::add: add {bas 1,1: libbar} to {baz | libbar->{baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_prerequisites: postpone bas/1.0.0
            trace: pkg_build: dep-postpone user-specified bus
            trace: pkg_build: dep-postpone user-specified foo
            trace: collect_build_prerequisites: begin bat/1.0.0
            %.*
            trace: collect_build: add libbaz/1.0.0
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bat/1.0.0
            trace: postponed_configurations::add: create {bat | libbaz->{bat/1,1}}
            trace: collect_build_prerequisites: postpone bat/1.0.0
            trace: collect_build_postponed (0): begin
            trace: collect_build_postponed (1): begin {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): cfg-negotiate begin {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}
            %.*
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbar/1.0.0
            trace: collect_build_prerequisites: end libbar/1.0.0
            trace: collect_build_prerequisites: begin libfoo/1.0.0
            trace: collect_build_prerequisites: end libfoo/1.0.0
            trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bas/1.0.0
            trace: collect_build_prerequisites: resume bas/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency bus/1.0.0 of dependent bas/1.0.0
            trace: postponed_configurations::add: create {bas | bus->{bas/2,1}}
            trace: collect_build_prerequisites: postpone bas/1.0.0
            trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent baz/1.0.0
            trace: collect_build_prerequisites: resume baz/1.0.0
            trace: collect_build_prerequisites: end baz/1.0.0
            trace: collect_build_postponed (1): cfg-negotiate end {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}!
            trace: collect_build_postponed (2): begin {bat | libbaz->{bat/1,1}}
            %.*
            trace: collect_build_postponed (2): cfg-negotiate begin {bat | libbaz->{bat/1,1}}
            %.*
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin libbaz/1.0.0
            trace: collect_build_prerequisites: end libbaz/1.0.0
            trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent bat/1.0.0
            trace: collect_build_prerequisites: resume bat/1.0.0
            trace: collect_build_prerequisites: end bat/1.0.0
            trace: collect_build_postponed (2): cfg-negotiate end {bat | libbaz->{bat/1,1}}!
            trace: collect_build_postponed (3): begin {bas | bus->{bas/2,1}}
            %.*
            trace: collect_build_postponed (3): cfg-negotiate begin {bas | bus->{bas/2,1}}
            %.*
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin bus/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libbaz/1.0.0 of dependent bus/1.0.0
            trace: postponed_configurations::add: add {bus 1,1: libbaz} to {bat | libbaz->{bat/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bus/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libbaz/1.0.0 of dependent bus/1.0.0 is already (being) recursively collected, skipping
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency foo/1.0.0 of dependent bus/1.0.0
            trace: postponed_configurations::add: create {bus | foo->{bus/2,1}}
            trace: collect_build_prerequisites: postpone bus/1.0.0
            trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent bas/1.0.0
            trace: collect_build_prerequisites: resume bas/1.0.0
            trace: collect_build_prerequisites: end bas/1.0.0
            trace: collect_build_postponed (3): cfg-negotiate end {bas | bus->{bas/2,1}}!
            trace: collect_build_postponed (4): begin {bus | foo->{bus/2,1}}
            %.*
            trace: collect_build_postponed (4): cfg-negotiate begin {bus | foo->{bus/2,1}}
            %.*
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
            trace: collect_build_prerequisites: begin foo/1.0.0
            %.*
            trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
            trace: postponed_configurations::add: add {foo 1,1: libfoo} to {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}!
            trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent foo/1.0.0 is negotiated
            trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent foo/1.0.0 is already (being) recursively collected, skipping
            trace: collect_build_prerequisites: end foo/1.0.0
            trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
            trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent bus/1.0.0
            trace: collect_build_prerequisites: resume bus/1.0.0
            trace: collect_build_prerequisites: end bus/1.0.0
            trace: collect_build_postponed (4): cfg-negotiate end {bus | foo->{bus/2,1}}!
            trace: collect_build_postponed (4): end {bus | foo->{bus/2,1}}
            trace: collect_build_postponed (3): end {bas | bus->{bas/2,1}}
            trace: collect_build_postponed (2): end {bat | libbaz->{bat/1,1}}
            trace: collect_build_postponed (1): end {bas baz | libbar->{bas/1,1 baz/1,1} libfoo->{baz/1,1}}
            trace: collect_build_postponed (0): end
            trace: execute_plan: simulate: yes
            %.*
            EOE

          $pkg_status -r >>EOO;
            !baz configured 1.0.0
              libbar configured 1.0.0
              libfoo configured 1.0.0
            !foo configured 1.0.0
              libfoo configured 1.0.0
            !bus configured 1.0.0
              !foo configured 1.0.0
                libfoo configured 1.0.0
              libbaz configured 1.0.0
            !bas configured 1.0.0
              !bus configured 1.0.0
                !foo configured 1.0.0
                  libfoo configured 1.0.0
                libbaz configured 1.0.0
              libbar configured 1.0.0
            !bat configured 1.0.0
              libbaz configured 1.0.0
            EOO

          $pkg_drop baz bas bus foo bat
        }

        : existing
        :
        {
          +$clone_cfg

          : negotiate
          :
          {
            $clone_cfg;

            #  Dependencies:
            #
            #  bar: depends: libbar(c)
            #
            #  dex: depends: bar(c)
            #       depends: libfoo(c)
            #
            #  dox: dex(c)
            #
            #  dix: depends: libbar(c)
            #       depends: libbox(c) # causes postponment and initial cluster finished negotiating
            #       depends: dox(c)
            #
            $* dex 2>!;

            $* dix 2>>~%EOE%;
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add dix/1.0.0
              trace: collect_build_prerequisites: begin dix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | libbar->{dix/1,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {dix | libbar->{dix/1,1}}
              %.*
              trace: collect_build_postponed (1): re-evaluate existing dependents for {dix | libbar->{dix/1,1}}
              %.*
              trace: collect_build: add bar/1.0.0
              trace: collect_build_prerequisites: reeval bar/1.0.0
              %.*
              trace: postponed_configurations::add: add {bar^ 1,1: libbar} to {dix | libbar->{dix/1,1}}
              trace: collect_build_prerequisites: re-evaluating dependent bar/1.0.0 results in {bar^ dix | libbar->{bar/1,1 dix/1,1}}
              trace: collect_build_prerequisites: re-evaluated bar/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate begin {bar^ dix | libbar->{bar/1,1 dix/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent bar/1.0.0
              trace: collect_build_prerequisites: resume bar/1.0.0
              trace: collect_build_prerequisites: end bar/1.0.0
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              %.*
              trace: collect_build: add libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {bar^ dix | libbar->{bar/1,1 dix/1,1}}!
              trace: collect_build_postponed (2): begin {dix | libbox->{dix/2,1}}
              %.*
              trace: collect_build_postponed (2): cfg-negotiate begin {dix | libbox->{dix/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin libbox/1.0.0
              trace: collect_build_prerequisites: end libbox/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              %.*
              trace: collect_build: add dox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | dox->{dix/3,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (2): cfg-negotiate end {dix | libbox->{dix/2,1}}!
              trace: collect_build_postponed (3): begin {dix | dox->{dix/3,1}}
              %.*
              trace: collect_build_postponed (3): cfg-negotiate begin {dix | dox->{dix/3,1}}
              %.*
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin dox/1.0.0
              %.*
              trace: collect_build: add dex/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
              trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
              trace: collect_build_prerequisites: postpone dox/1.0.0
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              trace: collect_build_prerequisites: end dix/1.0.0
              trace: collect_build_postponed (3): cfg-negotiate end {dix | dox->{dix/3,1}}!
              trace: collect_build_postponed (4): begin {dox | dex->{dox/1,1}}
              %.*
              trace: collect_build_postponed (4): cfg-negotiate begin {dox | dex->{dox/1,1}}
              %.*
              trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin dex/1.0.0
              %.*
              trace: collect_build_prerequisites: cannot cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0 (collected prematurely), throwing postpone_dependency
              trace: pkg_build: collection failed due to prematurely collected dependency (bar), retry from scratch
              %.*
              trace: pkg_build: refine package collection/plan execution from scratch
              %.*
              trace: collect_build: add dix/1.0.0
              trace: collect_build_prerequisites: begin dix/1.0.0
              %.*
              trace: collect_build: add libbar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | libbar->{dix/1,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (0): begin
              trace: collect_build_postponed (1): begin {dix | libbar->{dix/1,1}}
              %.*
              trace: collect_build_postponed (1): skip dep-postponed existing dependent bar of dependency libbar
              trace: collect_build_postponed (1): cfg-negotiate begin {dix | libbar->{dix/1,1}}
              %.*
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libbar/1.0.0
              trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              %.*
              trace: collect_build: add libbox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libbox/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | libbox->{dix/2,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (1): cfg-negotiate end {dix | libbar->{dix/1,1}}!
              trace: collect_build_postponed (2): begin {dix | libbox->{dix/2,1}}
              %.*
              trace: collect_build_postponed (2): cfg-negotiate begin {dix | libbox->{dix/2,1}}
              %.*
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin libbox/1.0.0
              trace: collect_build_prerequisites: end libbox/1.0.0
              trace: collect_build_postponed (2): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (2): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              %.*
              trace: collect_build: add dox/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency dox/1.0.0 of dependent dix/1.0.0
              trace: postponed_configurations::add: create {dix | dox->{dix/3,1}}
              trace: collect_build_prerequisites: postpone dix/1.0.0
              trace: collect_build_postponed (2): cfg-negotiate end {dix | libbox->{dix/2,1}}!
              trace: collect_build_postponed (3): begin {dix | dox->{dix/3,1}}
              %.*
              trace: collect_build_postponed (3): cfg-negotiate begin {dix | dox->{dix/3,1}}
              %.*
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin dox/1.0.0
              %.*
              trace: collect_build: add dex/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency dex/1.0.0 of dependent dox/1.0.0
              trace: postponed_configurations::add: create {dox | dex->{dox/1,1}}
              trace: collect_build_prerequisites: postpone dox/1.0.0
              trace: collect_build_postponed (3): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (3): select cfg-negotiated dependency alternative for dependent dix/1.0.0
              trace: collect_build_prerequisites: resume dix/1.0.0
              trace: collect_build_prerequisites: end dix/1.0.0
              trace: collect_build_postponed (3): cfg-negotiate end {dix | dox->{dix/3,1}}!
              trace: collect_build_postponed (4): begin {dox | dex->{dox/1,1}}
              %.*
              trace: collect_build_postponed (4): cfg-negotiate begin {dox | dex->{dox/1,1}}
              %.*
              trace: collect_build_postponed (4): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin dex/1.0.0
              %.*
              trace: collect_build: add bar/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency bar/1.0.0 of dependent dex/1.0.0
              trace: postponed_configurations::add: create {dex | bar->{dex/1,1}}
              trace: collect_build_prerequisites: postpone dex/1.0.0
              trace: collect_build_postponed (4): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (4): select cfg-negotiated dependency alternative for dependent dox/1.0.0
              trace: collect_build_prerequisites: resume dox/1.0.0
              trace: collect_build_prerequisites: end dox/1.0.0
              trace: collect_build_postponed (4): cfg-negotiate end {dox | dex->{dox/1,1}}!
              trace: collect_build_postponed (5): begin {dex | bar->{dex/1,1}}
              %.*
              trace: collect_build_postponed (5): skip being built existing dependent dex of dependency bar
              trace: collect_build_postponed (5): cfg-negotiate begin {dex | bar->{dex/1,1}}
              %.*
              trace: collect_build_postponed (5): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: begin bar/1.0.0
              %.*
              trace: collect_build_prerequisites: cfg-postpone dependency libbar/1.0.0 of dependent bar/1.0.0
              trace: postponed_configurations::add: add {bar 1,1: libbar} to {dix | libbar->{dix/1,1}}!
              trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent bar/1.0.0 is negotiated
              trace: collect_build_prerequisites: dependency libbar/1.0.0 of dependent bar/1.0.0 is already (being) recursively collected, skipping
              trace: collect_build_prerequisites: end bar/1.0.0
              trace: collect_build_postponed (5): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (5): select cfg-negotiated dependency alternative for dependent dex/1.0.0
              trace: collect_build_prerequisites: resume dex/1.0.0
              %.*
              trace: collect_build: add libfoo/1.0.0
              trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent dex/1.0.0
              trace: postponed_configurations::add: create {dex | libfoo->{dex/2,1}}
              trace: collect_build_prerequisites: postpone dex/1.0.0
              trace: collect_build_postponed (5): cfg-negotiate end {dex | bar->{dex/1,1}}!
              trace: collect_build_postponed (6): begin {dex | libfoo->{dex/2,1}}
              %.*
              trace: collect_build_postponed (6): skip being built existing dependent dex of dependency libfoo
              trace: collect_build_postponed (6): cfg-negotiate begin {dex | libfoo->{dex/2,1}}
              %.*
              trace: collect_build_postponed (6): recursively collect cfg-negotiated dependencies
              trace: collect_build_prerequisites: skip configured libfoo/1.0.0
              trace: collect_build_postponed (6): recursively collect cfg-negotiated dependents
              trace: collect_build_postponed (6): select cfg-negotiated dependency alternative for dependent dex/1.0.0
              trace: collect_build_prerequisites: resume dex/1.0.0
              trace: collect_build_prerequisites: end dex/1.0.0
              trace: collect_build_postponed (6): cfg-negotiate end {dex | libfoo->{dex/2,1}}!
              trace: collect_build_postponed (6): end {dex | libfoo->{dex/2,1}}
              trace: collect_build_postponed (5): end {dex | bar->{dex/1,1}}
              trace: collect_build_postponed (4): end {dox | dex->{dox/1,1}}
              trace: collect_build_postponed (3): end {dix | dox->{dix/3,1}}
              trace: collect_build_postponed (2): end {dix | libbox->{dix/2,1}}
              trace: collect_build_postponed (1): end {dix | libbar->{dix/1,1}}
              trace: collect_build_postponed (0): end
              %.*
              trace: execute_plan: simulate: yes
              %.*
              EOE

            $pkg_status -r >>EOO;
              !dex configured 1.0.0
                bar configured 1.0.0
                  libbar configured 1.0.0
                libfoo configured 1.0.0
              !dix configured 1.0.0
                dox configured 1.0.0
                  !dex configured 1.0.0
                    bar configured 1.0.0
                      libbar configured 1.0.0
                    libfoo configured 1.0.0
                libbar configured 1.0.0
                libbox configured 1.0.0
              EOO

            # @@ Note that if --drop-dependent is unspecified, the following
            #    command fails with:
            #
            #    following dependent packages will have to be dropped as well:
            #      dox (requires dex)
            #    error: refusing to drop dependent packages with just --yes
            #      info: specify --drop-dependent to confirm
            #
            #    Feels wrong.
            #
            $pkg_drop --drop-dependent dex dix
          }
        }
      }
    }

    : unaccept-alternative
    :
    {
      +$clone_cfg

      : unacceptable
      :
      {
        $clone_cfg;

        $* foo fox/0.1.0 ?libbar 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/0.1.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/0.1.0
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent fox/0.1.0 since max index is reached: 0
            info: dependency alternative: libfoo
          {
            prefer
            {
              config.libfoo.extras = true
            }

            accept (false)
          }
          trace: collect_build_prerequisites: postpone fox/0.1.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): index 1 collect alt-postponed fox/0.1.0
          trace: collect_build_prerequisites: resume fox/0.1.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/0.1.0
          %.*
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}!
          %.*
          trace: collect_build_prerequisites: unable to cfg-negotiate dependency alternative 1,1 for dependent fox/0.1.0, throwing unaccept_alternative
          trace: pkg_build: collection failed due to unacceptable alternative, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/0.1.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/0.1.0
          trace: collect_build_prerequisites: dependency alternative 1,1 for dependent fox/0.1.0 is unacceptable, skipping
          %.*
          trace: collect_build_prerequisites: no cfg-clause for dependency libbar/1.0.0 of dependent fox/0.1.0
          trace: collect_build_prerequisites: begin libbar/1.0.0
          trace: collect_build_prerequisites: end libbar/1.0.0
          trace: collect_build_prerequisites: end fox/0.1.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (0): end
          trace: execute_plan: simulate: yes
          %.*
          trace: evaluate_dependency: libbar/1.0.0: unchanged
          %.*
          trace: evaluate_dependency: libbar/1.0.0: unchanged
          %.*
          build plan:
            new libfoo/1.0.0 (required by foo)
              config.libfoo.extras=true (set by foo)
            new foo/1.0.0
            new libbar/1.0.0 (required by fox)
            new fox/0.1.0
          trace: execute_plan: simulate: no
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !fox configured !0.1.0 available 1.0.0 0.2.0
            libbar configured 1.0.0
          EOO

        $pkg_drop foo fox
      }

      : negotiation-cycle1
      :
      {
        $clone_cfg;

        $* foo fox/0.2.0 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/0.2.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/0.2.0
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent fox/0.2.0 since max index is reached: 0
            info: dependency alternative: libfoo
          {
            prefer
            {
              config.libfoo.extras = false
            }

            accept (!$config.libfoo.extras)
          }
          trace: collect_build_prerequisites: postpone fox/0.2.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): index 1 collect alt-postponed fox/0.2.0
          trace: collect_build_prerequisites: resume fox/0.2.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/0.2.0
          %.*
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}!
          %.*
          trace: collect_build_prerequisites: cfg-postponing dependent fox/0.2.0 involves (being) negotiated configurations and results in {foo fox | libfoo->{foo/1,1 fox/1,1}}!, throwing retry_configuration
          trace: collect_build_postponed (0): cfg-negotiation of {foo | libfoo->{foo/1,1}} failed due to dependent fox, refining configuration
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): index 1 collect alt-postponed fox/0.2.0
          trace: collect_build_prerequisites: resume fox/0.2.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/0.2.0
          %.*
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}!
          trace: collect_build_prerequisites: cfg-postponing dependent fox/0.2.0 involves (being) negotiated configurations and results in {foo fox | libfoo->{foo/1,1 fox/1,1}}!, throwing retry_configuration
          trace: collect_build_postponed (0): cfg-negotiation of {foo | libfoo->{foo/1,1}} failed due to dependent fox, refining configuration
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): index 1 collect alt-postponed fox/0.2.0
          trace: collect_build_prerequisites: resume fox/0.2.0
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/0.2.0
          %.*
          trace: postponed_configurations::add: add {fox 1,1: libfoo} to {foo | libfoo->{foo/1,1}}!
          trace: collect_build_prerequisites: unable to cfg-negotiate dependency alternative 1,1 for dependent fox/0.2.0, throwing unaccept_alternative
          trace: pkg_build: collection failed due to unacceptable alternative, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add foo/1.0.0
          trace: collect_build: add fox/0.2.0
          trace: collect_build_prerequisites: begin foo/1.0.0
          %.*
          trace: collect_build: add libfoo/1.0.0
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent foo/1.0.0
          trace: postponed_configurations::add: create {foo | libfoo->{foo/1,1}}
          trace: collect_build_prerequisites: postpone foo/1.0.0
          trace: collect_build_prerequisites: begin fox/0.2.0
          trace: collect_build_prerequisites: dependency alternative 1,1 for dependent fox/0.2.0 is unacceptable, skipping
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent fox/0.2.0 since max index is reached: 1
            info: dependency alternative: libfoo
          {
            prefer
            {
              config.libfoo.extras = true
            }

            accept (true)
          }
          trace: collect_build_prerequisites: postpone fox/0.2.0
          trace: collect_build_postponed (0): begin
          trace: collect_build_postponed (1): begin {foo | libfoo->{foo/1,1}}
          %.*
          trace: collect_build_postponed (1): cfg-negotiate begin {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependencies
          trace: collect_build_prerequisites: begin libfoo/1.0.0
          trace: collect_build_prerequisites: end libfoo/1.0.0
          trace: collect_build_postponed (1): recursively collect cfg-negotiated dependents
          trace: collect_build_postponed (1): select cfg-negotiated dependency alternative for dependent foo/1.0.0
          trace: collect_build_prerequisites: resume foo/1.0.0
          trace: collect_build_prerequisites: end foo/1.0.0
          trace: collect_build_postponed (1): cfg-negotiate end {foo | libfoo->{foo/1,1}}!
          trace: collect_build_postponed (1): index 1 collect alt-postponed fox/0.2.0
          trace: collect_build_prerequisites: resume fox/0.2.0
          trace: collect_build_prerequisites: dependency alternative 1,1 for dependent fox/0.2.0 is unacceptable, skipping
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent fox/0.2.0 since max index is reached: 1
            info: dependency alternative: libfoo
          {
            prefer
            {
              config.libfoo.extras = true
            }

            accept (true)
          }
          trace: collect_build_prerequisites: postpone fox/0.2.0
          trace: collect_build_postponed (1): index 2 collect alt-postponed fox/0.2.0
          trace: collect_build_prerequisites: resume fox/0.2.0
          trace: collect_build_prerequisites: dependency alternative 1,1 for dependent fox/0.2.0 is unacceptable, skipping
          %.*
          trace: collect_build_prerequisites: cfg-postpone dependency libfoo/1.0.0 of dependent fox/0.2.0
          %.*
          trace: postponed_configurations::add: add {fox 1,2: libfoo} to {foo | libfoo->{foo/1,1}}!
          trace: collect_build_prerequisites: configuration for cfg-postponed dependencies of dependent fox/0.2.0 is negotiated
          trace: collect_build_prerequisites: dependency libfoo/1.0.0 of dependent fox/0.2.0 is already (being) recursively collected, skipping
          trace: collect_build_prerequisites: end fox/0.2.0
          trace: collect_build_postponed (1): end {foo | libfoo->{foo/1,1}}
          trace: collect_build_postponed (0): end
          %.*
          build plan:
            new libfoo/1.0.0 (required by foo, fox)
              config.libfoo.extras=true (set by foo)
            new foo/1.0.0
            new fox/0.2.0
          trace: execute_plan: simulate: no
          %.*
          EOE

        $pkg_status -r >>EOO;
          !foo configured 1.0.0
            libfoo configured 1.0.0
          !fox configured !0.2.0 available 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop foo fox
      }

      : negotiation-cycle2
      :
      : Similar to the above but peforms one more negotiation half-cycle (see
      : negotiate_configuration() for details).
      :
      {
        $clone_cfg;

        # Note that this 'one more half-cycle' case doesn't reproduce always
        # and depends on the negotiate_configuration() calls order for the fox
        # and foo dependents. This order is not actually deterministic since
        # depends on the order of these packages in the postponed_packages set
        # (of the set<build_package*> type). Thus, the 'one more half-cycle'
        # case only takes place if the order of the packages as they appear on
        # the command line is preserved.
        #
        $* fox/0.2.0 foo/0.2.0 ?libfoo 2>>~%EOE%;
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build: add fox/0.2.0
          trace: collect_build: add foo/0.2.0
          trace: collect_build_prerequisites: begin fox/0.2.0
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent fox/0.2.0 since max index is reached: 0
            info: dependency alternative: libfoo
          {
            prefer
            {
              config.libfoo.extras = false
            }

            accept (!$config.libfoo.extras)
          }
          trace: collect_build_prerequisites: postpone fox/0.2.0
          trace: collect_build_prerequisites: begin foo/0.2.0
          %.*
          trace: collect_build_prerequisites: alt-postpone dependent foo/0.2.0 since max index is reached: 0
            info: dependency alternative: libfoo
          {
            require
            {
              config.libfoo.extras = true
            }
          }
          trace: collect_build_prerequisites: postpone foo/0.2.0
          %.*
          %.+: unable to cfg-negotiate dependency alternative 1,1 for dependent fox/0.2.0, throwing unaccept_alternative%
          trace: pkg_build: collection failed due to unacceptable alternative, retry from scratch
          %.*
          trace: pkg_build: refine package collection/plan execution from scratch
          %.*
          trace: collect_build_prerequisites: dependency alternative 1,1 for dependent fox/0.2.0 is unacceptable, skipping
          %.*
          build plan:
            new libfoo/1.0.0 (required by foo, fox)
              config.libfoo.extras=true (set by foo)
            new fox/0.2.0
            new foo/0.2.0
          trace: execute_plan: simulate: no
          %.*
          EOE

        $pkg_status -r >>EOO;
          !fox configured !0.2.0 available 1.0.0
            libfoo configured 1.0.0
          !foo configured !0.2.0 available 1.0.0
            libfoo configured 1.0.0
          EOO

        $pkg_drop foo fox
      }
    }

    : all-repo-packages
    :
    : Don't match the tracing but just make sure that pkg-build doesn't crash
    : or hang and ends up with an expected packages setup.
    :
    {
      $clone_cfg;

      $* libfoo libbar ?libbaz/0.1.0 ?libbox/0.1.0 \
         foo fox fux fix fex bar baz bac bat bas bus \
         box bax bux bix bex boo biz buz buc tax tex \
         tix tiz toz tez tux dex dix diz dox 2>!;

      $pkg_status -r >>EOO;
        !libfoo configured 1.0.0
        !libbar configured 1.0.0
        !bat configured 1.0.0
          libbaz configured !0.1.0 available 1.0.0
        !tix configured 0.1.0 available 1.0.0
        !toz configured 0.1.0 available 1.0.0 0.2.0
        !tux configured 1.0.0
          libbox configured !0.1.0 available 1.0.0
          !tix configured 0.1.0 available 1.0.0
        !bar configured 1.0.0
          !libbar configured 1.0.0
        !bux configured 1.0.0
          !libbar configured 1.0.0
        !bex configured 1.0.0
          !libbar configured 1.0.0
        !boo configured 1.0.0
          !libbar configured 1.0.0
        !biz configured 1.0.0
          !boo configured 1.0.0
            !libbar configured 1.0.0
        !buz configured 1.0.0
          !bux configured 1.0.0
            !libbar configured 1.0.0
        !tez configured 1.0.0
          !libbar configured 1.0.0
          libbox configured !0.1.0 available 1.0.0
          !toz configured 0.1.0 available 1.0.0 0.2.0
        !bix configured 1.0.0
          !bar configured 1.0.0
            !libbar configured 1.0.0
          !bux configured 1.0.0
            !libbar configured 1.0.0
          !libbar configured 1.0.0
        !foo configured 1.0.0
          !libfoo configured 1.0.0
        !fox configured 1.0.0
          !libfoo configured 1.0.0
        !fux configured 1.0.0
          !libfoo configured 1.0.0
        !baz configured 1.0.0
          !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !bac configured 1.0.0
          !libbar configured 1.0.0
          libbaz configured !0.1.0 available 1.0.0
          !libfoo configured 1.0.0
        !fix configured 1.0.0
          !foo configured 1.0.0
            !libfoo configured 1.0.0
        !fex configured 1.0.0
          !foo configured 1.0.0
            !libfoo configured 1.0.0
          !libfoo configured 1.0.0
        !bus configured 1.0.0
          !foo configured 1.0.0
            !libfoo configured 1.0.0
          libbaz configured !0.1.0 available 1.0.0
        !bas configured 1.0.0
          !bus configured 1.0.0
            !foo configured 1.0.0
              !libfoo configured 1.0.0
            libbaz configured !0.1.0 available 1.0.0
          !libbar configured 1.0.0
        !box configured 1.0.0
          !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !bax configured 1.0.0
          !libbar configured 1.0.0
          libbox configured !0.1.0 available 1.0.0
          !libfoo configured 1.0.0
        !buc configured 1.0.0
          !bux configured 1.0.0
            !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !tax configured 1.0.0
          !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !tex configured 1.0.0
          !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !tiz configured 1.0.0
          !libbar configured 1.0.0
          !tex configured 1.0.0
            !libbar configured 1.0.0
            !libfoo configured 1.0.0
        !dex configured 1.0.0
          !bar configured 1.0.0
            !libbar configured 1.0.0
          !libfoo configured 1.0.0
        !dox configured 1.0.0
          !dex configured 1.0.0
            !bar configured 1.0.0
              !libbar configured 1.0.0
            !libfoo configured 1.0.0
        !dix configured 1.0.0
          !dox configured 1.0.0
            !dex configured 1.0.0
              !bar configured 1.0.0
                !libbar configured 1.0.0
              !libfoo configured 1.0.0
          !libbar configured 1.0.0
          libbox configured !0.1.0 available 1.0.0
        !diz configured 1.0.0
          !dox configured 1.0.0
            !dex configured 1.0.0
              !bar configured 1.0.0
                !libbar configured 1.0.0
              !libfoo configured 1.0.0
          !libbar configured 1.0.0
          libbox configured !0.1.0 available 1.0.0
        EOO

      $pkg_drop libfoo libbar foo fox fux fix fex bar \
                baz bac bat bas bus box bax bux bix bex \
                boo biz buz buc tax tex tix tiz toz tez \
                tux dex dix diz dox
    }
  }

  : config-negotiation
  :
  {
    test.arguments += --yes --plan 'build plan:'

    : proj-better-choice
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13a && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.backend=cli (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.backend = cli
          EOO

        $pkg_drop bar
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz)
              config.liba.backend=gui (set by baz)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.backend = gui
          EOO

        $pkg_drop baz
      }

      : bar-baz
      :
      {
        $clone_cfg;

        $* bar baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar, baz)
              config.liba.backend=cli (set by bar)
            new bar/1.0.0
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          %info: .+bar.+ is up to date%
          %info: .+baz.+ is up to date%
          updated bar/1.0.0
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.backend = cli
          EOO

        $pkg_drop bar baz
      }

      : baz-bar
      :
      {
        $clone_cfg;

        $* baz bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar, baz)
              config.liba.backend=cli (set by bar)
            new baz/1.0.0
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          configured bar/1.0.0
          %info: .+baz.+ is up to date%
          %info: .+bar.+ is up to date%
          updated baz/1.0.0
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        # Would have been cool to end up with gui but looks like we have a map
        # in configuration cluster.
        #
        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.backend = cli
          EOO

        $pkg_drop baz bar
      }

      : bar-baz-biz
      :
      {
        $clone_cfg;

        $* bar baz biz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar, baz, biz)
              config.liba.backend=gui (set by biz)
            new bar/1.0.0
            new baz/1.0.0
            new biz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          fetched biz/1.0.0
          unpacked biz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          configured biz/1.0.0
          %info: .+bar.+ is up to date%
          %info: .+baz.+ is up to date%
          %info: .+biz.+ is up to date%
          updated bar/1.0.0
          updated baz/1.0.0
          updated biz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          !baz configured 1.0.0
            liba configured 1.0.0
          !biz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.backend = gui
          EOO

        $pkg_drop bar baz biz
      }
    }

    : proj-better-value
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13b && $rep_fetch

      : liba
      :
      {
        $clone_cfg;

        $* liba 2>>~%EOE%;
          build plan:
            new liba/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          configured liba/1.0.0
          %info: .+liba.+ is up to date%
          updated liba/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          config.liba.buffer = 1024
          EOO

        $pkg_drop liba
      }

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.buffer=2048 (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          config.liba.buffer = 2048
          EOO

        $pkg_drop bar
      }

      : bar-liba
      :
      {
        $clone_cfg;

        $* bar ?liba +{ config.liba.x=true } 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.x=true (user configuration)
              config.liba.buffer=10240 (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 10240
          EOO

        $pkg_drop bar
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz)
              config.liba.buffer=4096 (set by baz)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          config.liba.buffer = 4096
          EOO

        $pkg_drop baz
      }

      : baz-liba
      :
      {
        $clone_cfg;

        $* baz ?liba +{ config.liba.x=true } 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz)
              config.liba.x=true (user configuration)
              config.liba.buffer=10240 (set by baz)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 10240
          EOO

        $pkg_drop baz
      }

      : baz-biz
      :
      {
        $clone_cfg;

        $* baz biz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz, biz)
          %(
              config.liba.buffer=10240 (set by baz)
              config.liba.x=true (set by biz)
          %|
              config.liba.x=true (set by biz)
              config.liba.buffer=10240 (set by baz)
          %)
            new baz/1.0.0
            new biz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          fetched biz/1.0.0
          unpacked biz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          configured biz/1.0.0
          %info: .+baz.+ is up to date%
          %info: .+biz.+ is up to date%
          updated baz/1.0.0
          updated biz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          !biz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 10240
          EOO

        $pkg_drop baz biz
      }
    }

    : proj-disable-unused
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13c && $rep_fetch

      : liba
      :
      {
        $clone_cfg;

        $* liba 2>>~%EOE%;
          build plan:
            new liba/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          configured liba/1.0.0
          %info: .+liba.+ is up to date%
          updated liba/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          EOO

        $pkg_drop liba
      }

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          <depends-reflect-clause>:1:5: info: false
            info: reflect clause:
              info $config.liba.x
            info: in depends manifest value of package bar
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.x=false (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          EOO

        $pkg_drop bar
      }

      : bar-baz
      :
      {
        $clone_cfg;

        $* bar baz 2>>~%EOE%;
          <depends-reflect-clause>:1:5: info: true
            info: reflect clause:
              info $config.liba.x
            info: in depends manifest value of package bar
          build plan:
            new liba/1.0.0 (required by bar, baz)
              config.liba.x=true (set by baz)
            new bar/1.0.0
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          %info: .+bar.+ is up to date%
          %info: .+baz.+ is up to date%
          updated bar/1.0.0
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          EOO

        $pkg_drop bar baz
      }

      : bar-liba
      :
      {
        $clone_cfg;

        $* bar ?liba +{ config.liba.x=true } 2>>~%EOE%;
          <depends-reflect-clause>:1:5: info: true
            info: reflect clause:
              info $config.liba.x
            info: in depends manifest value of package bar
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.x=true (user configuration)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          EOO

        $pkg_drop bar
      }
    }

    : proj-use-if-available
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13d && $rep_fetch

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar, baz)
              config.liba.x=true (set by baz)
            new bar/1.0.0 (required by baz)
              config.bar.liba_x=true (set by bar)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            bar configured 1.0.0
              liba configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          EOO

        $pkg_drop baz
      }

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new libb/1.0.0 (required by bar)
            new bar/1.0.0
              config.bar.liba_x=false (set by bar)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched libb/1.0.0
          unpacked libb/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured libb/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
            libb configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          EOO

        $pkg_drop bar
      }
    }

    : proj-bogus-config
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13e && $rep_fetch

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz, biz)
              config.liba.x=true (set by biz)
            new biz/1.0.0 (required by baz)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched biz/1.0.0
          unpacked biz/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured biz/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            biz configured 1.0.0
              liba configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 1024
          EOO

        $pkg_drop baz
      }
    }

    : proj-bogus-config-cycle
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13f && $rep_fetch

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE% != 0;
          error: unable to remove bogus configuration values without causing configuration refinement cycle
            info: consider manually specifying one or more of the following variables as user configuration
          %(
              config.liba.buffer=2048
              config.liba.x=true
          %|
              config.liba.x=true
              config.liba.buffer=2048
          %)
          EOE

        $* baz ?liba +{ config.liba.x=true } 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz)
              config.liba.x=true (user configuration)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 1024
          EOO

        $pkg_drop baz
      }
    }

    : proj-detect-unset
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13g && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>EOE != 0
          <depends-accept-clause>:1:3: error: undefined dependency configuration variable config.liba.x
            info: was config.liba.x set in earlier prefer or require clause?
            info: accept condition: ($config.liba.x)
            info: in depends manifest value of package bar
          EOE
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>EOE != 0
          <depends-enable-clause>:1:3: error: undefined dependency configuration variable config.liba.x
            info: was config.liba.x set in earlier prefer or require clause?
            info: enable condition: ($config.liba.x)
            info: in depends manifest value of package baz
          info: while satisfying baz/1.0.0
          EOE
      }

      : biz
      :
      {
        $clone_cfg;

        $* biz 2>>EOE != 0
          <depends-prefer-clause>:1:12: error: undefined dependency configuration variable config.liba.x
            info: was config.liba.x set in earlier prefer or require clause?
            info: prefer clause:
              x = (!$config.liba.x) # Error.
            info: in depends manifest value of package biz
          EOE
      }

      : box
      :
      {
        $clone_cfg;

        $* box 2>>EOE != 0
          <depends-reflect-clause>:1:12: error: undefined dependency configuration variable config.liba.x
            info: was config.liba.x set in earlier prefer or require clause?
            info: reflect clause:
              x = (!$config.liba.x) # Error.
            info: in depends manifest value of package box
          EOE
      }
    }

    : proj-cycle
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13h && $rep_fetch

      : bar baz
      :
      {
        $clone_cfg;

        $* bar baz 2>>EOE != 0
          error: unable to negotiate acceptable configuration between dependents baz, bar for dependencies liba
            info: configuration before negotiation:
              config.liba.buffer=4096 (set by bar)
            info: configuration after negotiation:
              config.liba.buffer=8192 (set by baz)
          EOE
      }
    }

    : proj-dependency-reflect
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13i && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          <depends-reflect-clause>:1:5: info: yes
            info: reflect clause:
              info ($config.liba.x ? yes : no)
            info: in depends manifest value of package bar
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.x=true (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 1024
          EOO

        $pkg_drop bar
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          <depends-reflect-clause>:1:5: info: 4096
            info: reflect clause:
              info $config.liba.buffer
            info: in depends manifest value of package baz
          build plan:
            new liba/1.0.0 (required by baz)
              config.liba.buffer=4096 (set by baz)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = false
          config.liba.buffer = 4096
          EOO

        $pkg_drop baz
      }
    }

    : proj-non-sensible
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13j && $rep_fetch

      : bar-baz
      :
      {
        $clone_cfg;

        $* bar baz 2>>/~%EOE% != 0
          error: unable to negotiate sensible configuration for dependency liba
          %  .+/root.build:5:1: error: buffer must be at least 4096 if feature x is enabled%
            info: negotiated configuration:
          %(
              config.liba.buffer=2048 (set by bar)
              config.liba.x=true (set by baz)
          %|
              config.liba.x=true (set by baz)
              config.liba.buffer=2048 (set by bar)
          %)
          EOE
      }

      : biz-baz
      :
      {
        $clone_cfg;

        $* biz baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by baz, biz)
          %(
              config.liba.buffer=4096 (set by biz)
              config.liba.x=true (set by baz)
          %|
              config.liba.x=true (set by baz)
              config.liba.buffer=4096 (set by biz)
          %)
            new biz/1.0.0
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched biz/1.0.0
          unpacked biz/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured biz/1.0.0
          configured baz/1.0.0
          %info: .+biz.+ is up to date%
          %info: .+baz.+ is up to date%
          updated biz/1.0.0
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !biz configured 1.0.0
            liba configured 1.0.0
          !baz configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.buffer = 4096
          EOO

        $pkg_drop biz baz
      }
    }

    : proj-unaccept
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13k && $rep_fetch

      : bar-baz
      :
      {
        $clone_cfg;

        $* bar baz 2>>EOE != 0
          error: unable to negotiate acceptable configuration with dependent bar for dependencies liba
            info: configuration before negotiation:
              config.liba.buffer=8192 (set by baz)
          EOE
      }
    }

    : proj-require-system
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13l && $rep_fetch

      : bar
      :
      {
        +$clone_cfg

        : basic
        :
        {
          $clone_cfg;

          $* bar 2>>~%EOE%;
            build plan:
              new liba/1.0.0 (required by bar)
                config.liba.x=true (set by bar)
              new libb/1.0.0 (required by bar)
              new bar/1.0.0
            fetched liba/1.0.0
            unpacked liba/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched bar/1.0.0
            unpacked bar/1.0.0
            configured liba/1.0.0
            configured libb/1.0.0
            configured bar/1.0.0
            %info: .+bar.+ is up to date%
            updated bar/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !bar configured 1.0.0
              liba configured 1.0.0
              libb configured 1.0.0
            EOO

          cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.liba.x = true
            EOO

          $pkg_drop bar
        }

        : sys-liba-1
        :
        {
          $clone_cfg;

          $* bar '?sys:liba' 2>>~%EOE%;
            build plan:
              configure sys:liba/* (required by bar)
                config.liba.x=true (expected by bar)
              new libb/1.0.0 (required by bar)
              new bar/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched bar/1.0.0
            unpacked bar/1.0.0
            configured sys:liba/*
            configured libb/1.0.0
            configured bar/1.0.0
            %info: .+bar.+ is up to date%
            updated bar/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !bar configured 1.0.0
              liba configured,system !* available 1.0.0
              libb configured 1.0.0
            EOO

          $pkg_drop bar
        }

        : sys-liba-2
        :
        {
          $clone_cfg;

          $* bar '?sys:liba' +{ config.liba.x=false } 2>>EOE != 0
            error: unable to negotiate acceptable configuration with dependent bar for dependencies liba
              info: configuration before negotiation:
                config.liba.x=false (user configuration)
            EOE
        }

        : bar-sys-liba-3
        :
        {
          $clone_cfg;

          $* bar '?sys:liba' +{ config.liba.x=[null] } 2>>EOE != 0
            error: unable to negotiate acceptable configuration with dependent bar for dependencies liba
              info: configuration before negotiation:
                config.liba.x=[null] (user configuration)
            EOE
        }

        : sys-liba-4
        :
        {
          $clone_cfg;

          $* bar '?sys:liba' +{ config.liba.x=true } 2>>~%EOE%;
            build plan:
              configure sys:liba/* (required by bar)
                config.liba.x=true (expected user configuration)
              new libb/1.0.0 (required by bar)
              new bar/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched bar/1.0.0
            unpacked bar/1.0.0
            configured sys:liba/*
            configured libb/1.0.0
            configured bar/1.0.0
            %info: .+bar.+ is up to date%
            updated bar/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !bar configured 1.0.0
              liba configured,system !* available 1.0.0
              libb configured 1.0.0
            EOO

          $pkg_drop bar
        }
      }

      : baz
      :
      {
        +$clone_cfg

        : basic
        :
        {
          $clone_cfg;

          $* baz 2>>~%EOE%;
            build plan:
              new liba/1.0.0 (required by baz)
                config.liba.x=true (set by baz)
              new libb/1.0.0 (required by baz)
              new baz/1.0.0
            fetched liba/1.0.0
            unpacked liba/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched baz/1.0.0
            unpacked baz/1.0.0
            configured liba/1.0.0
            configured libb/1.0.0
            configured baz/1.0.0
            %info: .+baz.+ is up to date%
            updated baz/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !baz configured 1.0.0
              liba configured 1.0.0
              libb configured 1.0.0
            EOO

          cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
            %.*
            config.liba.x = true
            EOO

          $pkg_drop baz
        }

        : sys-liba-1
        :
        {
          $clone_cfg;

          $* baz '?sys:liba' +{ config.liba.x=false } 2>>EOE != 0
            error: unable to negotiate configuration for system dependency liba without configuration information
              info: consider specifying system dependency version that has corresponding available package
              info: dependent baz has prefer/accept clauses that cannot be evaluated without configuration information
            EOE
        }

        : sys-liba-2
        :
        {
          $clone_cfg;

          $* baz '?sys:liba/1.0.0' 2>>~%EOE%;
            build plan:
              configure sys:liba/1.0.0 (required by baz)
                config.liba.x=true (expected by baz)
              new libb/1.0.0 (required by baz)
              new baz/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched baz/1.0.0
            unpacked baz/1.0.0
            configured sys:liba/1.0.0
            configured libb/1.0.0
            configured baz/1.0.0
            %info: .+baz.+ is up to date%
            updated baz/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !baz configured 1.0.0
              liba configured,system !1.0.0
              libb configured 1.0.0
            EOO

          $pkg_drop baz
        }

        : sys-liba-3
        :
        {
          $clone_cfg;

          $* baz '?sys:liba/1.0.0' +{ config.liba.x=false } 2>>EOE != 0
            error: unable to negotiate acceptable configuration with dependent baz for dependencies liba
              info: configuration before negotiation:
                config.liba.x=false (user configuration)
            EOE
        }

        : bar-sys-liba-4
        :
        {
          $clone_cfg;

          $* baz '?sys:liba/1.0.0' +{ config.liba.x=[null] } 2>>EOE != 0
            <depends-accept-clause>:1: error: invalid bool value: null
              info: accept condition: ($config.liba.x)
              info: in depends manifest value of package baz
            EOE
        }

        : sys-liba-5
        :
        {
          $clone_cfg;

          $* baz '?sys:liba/1.0.0' +{ config.liba.x=true } 2>>~%EOE%;
            build plan:
              configure sys:liba/1.0.0 (required by baz)
                config.liba.x=true (expected user configuration)
              new libb/1.0.0 (required by baz)
              new baz/1.0.0
            fetched libb/1.0.0
            unpacked libb/1.0.0
            fetched baz/1.0.0
            unpacked baz/1.0.0
            configured sys:liba/1.0.0
            configured libb/1.0.0
            configured baz/1.0.0
            %info: .+baz.+ is up to date%
            updated baz/1.0.0
            EOE

          $pkg_status -r >>EOO;
            !baz configured 1.0.0
              liba configured,system !1.0.0
              libb configured 1.0.0
            EOO

          $pkg_drop baz
        }
      }
    }

    : proj-require-basics
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13m && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
              config.liba.x=true (set by bar)
            new bar/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.y = false
          config.liba.n = 1024
          EOO

        $pkg_drop bar
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar, baz)
          %(
              config.liba.y=true (set by baz)
              config.liba.x=true (set by bar)
          %|
              config.liba.x=true (set by bar)
              config.liba.y=true (set by baz)
          %)
            new bar/1.0.0 (required by baz)
            new baz/1.0.0
              config.baz.bar=true (set by baz)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            bar configured 1.0.0
              liba configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/liba-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.liba.x = true
          config.liba.y = true
          config.liba.n = 1024
          EOO

        cat cfg/baz-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.baz.bar = true
          EOO

        $pkg_drop baz
      }

      : biz
      :
      {
        $clone_cfg;

        $* biz 2>>EOE != 0
          error: configuration variable config.liba.x is not set to true
            info: config.liba.x set in require clause of dependent biz
            info: require clause:
              config.liba.x = false # Error: not true
            info: in depends manifest value of package biz
          EOE
      }

      : bix
      :
      {
        $clone_cfg;

        $* bix 2>>EOE != 0
          error: configuration variable config.liba.n is not of bool type
            info: config.liba.n set in require clause of dependent bix
            info: require clause:
              config.liba.n = 1    # Error: not bool
            info: in depends manifest value of package bix
          EOE
      }

      : box
      :
      {
        $clone_cfg;

        $* box 2>>EOE != 0
          error: package liba has no configuration variable config.liba.z
            info: config.liba.z set in require clause of dependent box
            info: require clause:
              config.liba.z = true # Error: no such variable
            info: in depends manifest value of package box
          EOE
      }
    }

    : proj-reflect-append
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13n && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new libb/1.0.0 (required by bar)
            new bar/1.0.0
              config.bar.libs=liba libb (set by bar)
              config.bar.x=true (set by bar)
              config.bar.y=true (set by bar)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched libb/1.0.0
          unpacked libb/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured libb/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
            libb configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.libs = liba libb
          EOO

        $pkg_drop bar
      }
    }

    : proj-reflect-override
    :
    {
      +$clone_root_cfg && $rep_add $rep/t13o && $rep_fetch

      : bar
      :
      {
        $clone_cfg;

        $* bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0
              config.bar.x=true (set by bar)
              config.bar.y=true (set by bar)
              config.bar.z=true (set by bar)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = true
          EOO

        $pkg_drop bar
      }

      : bar-config-1
      :
      {
        $clone_cfg;

        $* config.bar.y=true -- bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0
              config.bar.y=true (user configuration)
              config.bar.x=true (set by bar)
              config.bar.z=true (set by bar)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = true
          EOO

        $pkg_drop bar
      }

      : bar-config-2
      :
      {
        $clone_cfg;

        $* config.bar.y=false -- bar 2>>EOE != 0
          error: reflect variable config.bar.y overriden by user configuration
            info: reflect value: config.bar.y=true
            info: user value: config.bar.y=false
            info: reflect clause:
              config.bar.x = true
              config.bar.y = true
              if ($config.origin(config.bar.z) != 'override')
                config.bar.z = true
            info: in depends manifest value of package bar
          info: while satisfying bar/1.0.0
          EOE
      }

      : bar-config-3
      :
      {
        $clone_cfg;

        $* config.bar.z=false -- bar 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0
              config.bar.z=false (user configuration)
              config.bar.x=true (set by bar)
              config.bar.y=true (set by bar)
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          %info: .+bar.+ is up to date%
          updated bar/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bar configured 1.0.0
            liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = false
          EOO

        $pkg_drop bar
      }

      : baz
      :
      {
        $clone_cfg;

        $* baz 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0 (required by baz)
              config.bar.y=true (set by baz)
              config.bar.x=true (set by bar)
              config.bar.z=true (set by bar)
            new baz/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched baz/1.0.0
          unpacked baz/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured baz/1.0.0
          %info: .+baz.+ is up to date%
          updated baz/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !baz configured 1.0.0
            bar configured 1.0.0
              liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = true
          EOO

        $pkg_drop baz
      }

      : biz
      :
      {
        $clone_cfg;

        $* biz 2>>EOE != 0
          error: reflect variable config.bar.y overriden by dependent biz
            info: reflect value: config.bar.y=true
            info: dependent value: config.bar.y=false
            info: reflect clause:
              config.bar.x = true
              config.bar.y = true
              if ($config.origin(config.bar.z) != 'override')
                config.bar.z = true
            info: in depends manifest value of package bar
          info: while satisfying bar/1.0.0
          EOE
      }

      : biz-bar
      :
      {
        $clone_cfg;

        $* biz ?bar +{ config.bar.y=false } 2>>EOE != 0
          error: reflect variable config.bar.y overriden by user configuration
            info: reflect value: config.bar.y=true
            info: user value: config.bar.y=false
            info: reflect clause:
              config.bar.x = true
              config.bar.y = true
              if ($config.origin(config.bar.z) != 'override')
                config.bar.z = true
            info: in depends manifest value of package bar
          info: while satisfying bar/1.0.0
          EOE
      }

      : bix
      :
      {
        $clone_cfg;

        $* bix 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0 (required by bix)
              config.bar.z=false (set by bix)
              config.bar.x=true (set by bar)
              config.bar.y=true (set by bar)
            new bix/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched bix/1.0.0
          unpacked bix/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured bix/1.0.0
          %info: .+bix.+ is up to date%
          updated bix/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bix configured 1.0.0
            bar configured 1.0.0
              liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = false
          EOO

        $pkg_drop bix
      }

      : bix-bar
      :
      {
        $clone_cfg;

        $* bix ?bar +{ config.bar.z=false } 2>>~%EOE%;
          build plan:
            new liba/1.0.0 (required by bar)
            new bar/1.0.0 (required by bix)
              config.bar.z=false (user configuration)
              config.bar.x=true (set by bar)
              config.bar.y=true (set by bar)
            new bix/1.0.0
          fetched liba/1.0.0
          unpacked liba/1.0.0
          fetched bar/1.0.0
          unpacked bar/1.0.0
          fetched bix/1.0.0
          unpacked bix/1.0.0
          configured liba/1.0.0
          configured bar/1.0.0
          configured bix/1.0.0
          %info: .+bix.+ is up to date%
          updated bix/1.0.0
          EOE

        $pkg_status -r >>EOO;
          !bix configured 1.0.0
            bar configured 1.0.0
              liba configured 1.0.0
          EOO

        cat cfg/bar-1.0.0/build/config.build >>~%EOO%;
          %.*
          config.bar.x = true
          config.bar.y = true
          config.bar.z = false
          EOO

        $pkg_drop bix
      }
    }
  }
}

: test-dependency
:
{
  +$clone_cfg
  +$rep_add $rep/t10 && $rep_fetch

  : simultaneously
  :
  {
    $clone_cfg;

    $* libfoo-bar libfoo-tests 2>>~%EOE%;
      fetched libfoo-bar/1.0.0
      unpacked libfoo-bar/1.0.0
      fetched libfoo-tests/1.0.0
      unpacked libfoo-tests/1.0.0
      configured libfoo-bar/1.0.0
      configured libfoo-tests/1.0.0
      %info: .+libfoo-bar-1.0.0.+ is up to date%
      %info: .+libfoo-tests-1.0.0.+ is up to date%
      updated libfoo-bar/1.0.0
      updated libfoo-tests/1.0.0
      EOE

    cat cfg/libfoo-tests-1.0.0/build/config.build >>~%EOO%;
      %.*
      config.libfoo_tests.test = libfoo-bar
      %.*
      EOO

    $pkg_drop libfoo-bar libfoo-tests
  }

  : sequentially
  :
  {
    $clone_cfg;

    $* libfoo-baz 2>>~%EOE%;
      fetched libfoo-baz/1.0.0
      unpacked libfoo-baz/1.0.0
      configured libfoo-baz/1.0.0
      %info: .+libfoo-baz-1.0.0.+ is up to date%
      updated libfoo-baz/1.0.0
      EOE

    $* libfoo-tests 2>>~%EOE%;
      fetched libfoo-tests/1.0.0
      unpacked libfoo-tests/1.0.0
      configured libfoo-tests/1.0.0
      %info: .+libfoo-tests-1.0.0.+ is up to date%
      updated libfoo-tests/1.0.0
      EOE

    cat cfg/libfoo-tests-1.0.0/build/config.build >>~%EOO%;
      %.*
      config.libfoo_tests.test = libfoo-baz
      %.*
      EOO

    $pkg_drop libfoo-baz libfoo-tests
  }

  : tests-only
  :
  {
    $clone_cfg;

    $* libfoo-tests 2>>~%EOE% != 0
      error: unable to select dependency alternative for package libfoo-tests/1.0.0
        info: explicitly specify dependency packages to manually select the alternative
        info: alternative: libfoo-bar
        info: alternative: libfoo-baz
      info: while satisfying libfoo-tests/1.0.0
      EOE
  }
}

: dependent
:
{
  +$clone_cfg
  +$rep_add $rep/t2 && $rep_fetch

  : update
  :
  : Test --update-dependent option.
  :
  {
    $clone_cfg;

    $* --yes libbar 2>>~%EOE%;
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbar/1.0.0
      unpacked libbar/1.0.0
      configured libfoo/1.0.0
      configured libbar/1.0.0
      %info: .+ is up to date%
      updated libbar/1.0.0
      EOE

    $rep_add $rep/t4a && $rep_fetch;

    $* --update-dependent libfoo/1.1.0 <'y' 2>>~%EOE%;
        upgrade libfoo/1.1.0
        reconfigure libbar (dependent of libfoo)
      continue? [Y/n] disfigured libbar/1.0.0
      disfigured libfoo/1.0.0
      fetched libfoo/1.1.0
      unpacked libfoo/1.1.0
      configured libfoo/1.1.0
      configured libbar/1.0.0
      %info: .+ is up to date%{2}
      updated libfoo/1.1.0
      updated libbar/1.0.0
      EOE

    $pkg_disfigure libbar 2>'disfigured libbar/1.0.0';
    $pkg_purge     libbar 2>'purged libbar/1.0.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }

  : leave
  :
  : Test --leave-dependent option.
  :
  {
    $clone_cfg;

    $* --yes libbar 2>>~%EOE%;
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbar/1.0.0
      unpacked libbar/1.0.0
      configured libfoo/1.0.0
      configured libbar/1.0.0
      %info: .+ is up to date%
      updated libbar/1.0.0
      EOE

    $rep_add $rep/t4a && $rep_fetch;

    $* --leave-dependent libfoo/1.1.0 <'y' 2>>~%EOE%;
        upgrade libfoo/1.1.0
        reconfigure libbar (dependent of libfoo)
      continue? [Y/n] disfigured libbar/1.0.0
      disfigured libfoo/1.0.0
      fetched libfoo/1.1.0
      unpacked libfoo/1.1.0
      configured libfoo/1.1.0
      configured libbar/1.0.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    $pkg_disfigure libbar 2>'disfigured libbar/1.0.0';
    $pkg_purge     libbar 2>'purged libbar/1.0.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }
}

: dependency-cycle
:
{
  test.arguments += --yes

  +$cfg_create cxx $config_cxx -d cfg &cfg/***

  : direct
  :
  {
    $clone_cfg;

    cp -r $src/libfoo-1.1.0/ libfoo;
    echo "depends: libfoo" >+ libfoo/manifest;
    $rep_add libfoo --type dir;

    $rep_fetch;

    $* libfoo 2>>EOE != 0
      error: dependency cycle detected involving package libfoo
        info: libfoo/1.1.0 depends on libfoo/1.1.0
      EOE
  }

  : direct-config
  :
  : As above but with a linked configuration.
  :
  {
    $clone_cfg;
    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;

    cp -r $src/libfoo-1.1.0/ libfoo;
    echo "depends: libfoo" >+ libfoo/manifest;
    $rep_add libfoo --type dir -d cfg2;

    $rep_fetch -d cfg2;

    $* libfoo +{ --config-id 1 } 2>>~%EOE% != 0
      %error: dependency cycle detected involving package libfoo \[cfg2.\]%
      %  info: libfoo/1.1.0 \[cfg2.\] depends on libfoo/1.1.0 \[cfg2.\]%
      EOE
  }

  : indirect
  :
  {
    +$clone_cfg

    : new
    :
    {
      $clone_cfg;

      cp -r $src/libfoo-1.1.0/ libfoo;
      echo "depends: libbar" >+ libfoo/manifest;

      cat <<"EOI" >=libfoo/repositories.manifest;
        : 1
        summary: libfoo project repository

        :
        role: prerequisite
        location: $rep/t0b
        EOI

      $rep_add libfoo --type dir;

      $rep_fetch;

      $* libfoo 2>>EOE != 0
        error: dependency cycle detected involving package libfoo
          info: libfoo/1.1.0 depends on libbar/0.0.2
          info: libbar/0.0.2 depends on libbaz/0.0.2
          info: libbaz/0.0.2 depends on libfoo/1.1.0
        EOE
    }

    : upgrade
    :
    {
      $clone_cfg;

      cp -r $src/libfoo-1.1.0/ libfoo;
      $rep_add libfoo --type dir;

      cp -r $src/libhello-1.0.0/ libhello;
      echo "depends: libfoo" >+ libhello/manifest;
      $rep_add libhello --type dir;

      $rep_fetch;

      $* libhello 2>>~%EOE%;
        using libfoo/1.1.0 (external)
        using libhello/1.0.0 (external)
        configured libfoo/1.1.0
        configured libhello/1.0.0
        %(mkdir|c\+\+|ld|ar) .+%{8}
        updated libhello/1.0.0
        EOE

      echo "depends: libhello" >+ libfoo/manifest;
      sed -i -e 's/(version: 1.1).0/\1.1/' libfoo/manifest;

      $rep_fetch;

      $* ?libfoo 2>>EOE != 0;
        error: dependency cycle detected involving package libfoo
          info: libfoo/1.1.1 depends on libhello/1.0.0
          info: libhello/1.0.0 depends on libfoo/1.1.1
        EOE

      $pkg_drop libhello
    }
  }
}

: config-vars
:
{
  test.arguments += --yes

  +$cfg_create cxx $config_cxx -d cfg &cfg/***
  +cp -r $src/libhello-1.0.0 ./libhello
  +$rep_add libhello --type dir
  +$rep_fetch

  : global-and-local
  :
  {
    $clone_cfg;

    $* config.cxx.poptions=-DG -- libhello +{ config.cxx.poptions+=-DL } 2>>~%EOE%;
      using libhello/1.0.0 (external)
      configured libhello/1.0.0
      %(mkdir|c\+\+|ar|ld) .+%{8}
      updated libhello/1.0.0
      EOE

    cat cfg/libhello/build/config.build >>~%EOO%;
      %.*
      config.cxx.poptions = -DG -DL
      EOO

    $pkg_drop libhello
  }

  : global-and-options
  :
  {
    $clone_cfg;

    $* config.cxx.poptions=-DG --fetch-timeout=60 -- libhello 2>>~%EOE%;
      using libhello/1.0.0 (external)
      configured libhello/1.0.0
      %(mkdir|c\+\+|ar|ld) .+%{8}
      updated libhello/1.0.0
      EOE

    cat cfg/libhello/build/config.build >>~%EOO%;
      %.*
      config.cxx.poptions = -DG
      EOO

    $pkg_drop libhello
  }
}

: patch
:
{
  test.arguments += --configure-only --yes

  +$clone_root_cfg

  : held
  :
  {
    +$clone_cfg
    +$rep_fetch $rep/t0c

    : success
    :
    {
      $clone_cfg;

      $* libbaz/0.0.3 2>!;

      $* libbaz --patch 2>>EOE;
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.0.4
        unpacked libbaz/0.0.4
        configured libbaz/0.0.4
        EOE

      $pkg_drop libbaz
    }

    : ignore
    :
    {
      $clone_cfg;

      $* libbaz/0.0.3 --patch 2>>EOE;
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        fetched libbaz/0.0.3
        unpacked libbaz/0.0.3
        configured libfoo/1.0.0
        configured libbaz/0.0.3
        EOE

      $* libbaz/0.1.0 --patch 2>>EOE;
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.1.0
        unpacked libbaz/0.1.0
        configured libbaz/0.1.0
        EOE

      $pkg_drop libbaz
    }

    : warn
    :
    {
      $clone_cfg;

      $* 'sys:libbaz/0.0.3-alpha' 2>!;

      $* libbaz --patch 2>>EOE;
        warning: unable to patch libbaz/0.0.3-alpha
          info: package is not using semantic/standard version
        info: nothing to build
        EOE

      $pkg_drop libbaz
    }
  }

  : dependency
  :
  {
    +$clone_cfg
    +$rep_fetch $rep/t0c

    +$* libbox libfix ?libbaz/0.0.3 2>>EOE
       fetched libfoo/1.0.0
       unpacked libfoo/1.0.0
       fetched libbaz/0.0.3
       unpacked libbaz/0.0.3
       fetched libbox/0.0.1
       unpacked libbox/0.0.1
       fetched libfix/0.0.3
       unpacked libfix/0.0.3
       configured libfoo/1.0.0
       configured libbaz/0.0.3
       configured libbox/0.0.1
       configured libfix/0.0.3
       EOE

    clone_cfg = [cmdline] cp --no-cleanup -r ../cfg ./ &cfg/***

    : explicitly
    :
    : Here we also test that the package --path option overrides the global
    : --upgrade option.
    :
    {
      $clone_cfg;

      $* ?libbaz +{ --patch } --upgrade 2>>EOE
        disfigured libbox/0.0.1
        disfigured libfix/0.0.3
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.0.4
        unpacked libbaz/0.0.4
        configured libbaz/0.0.4
        configured libfix/0.0.3
        configured libbox/0.0.1
        EOE
    }

    : warn
    :
    {
      $clone_cfg;

      $* '?sys:libbaz/0.0.4-alpha' 2>!;

      $* ?libbaz --patch 2>>EOE
        warning: unable to patch libbaz/0.0.4-alpha
          info: package is not using semantic/standard version
        EOE
    }

    : recursive
    :
    {
      $clone_cfg;

      $* --patch --recursive 2>>EOE
        disfigured libfix/0.0.3
        disfigured libbox/0.0.1
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.0.4
        unpacked libbaz/0.0.4
        configured libbaz/0.0.4
        configured libbox/0.0.1
        configured libfix/0.0.3
        EOE
    }

    : upgrade-wins-patch
    :
    : Test that --upgrade options wins --patch.
    :
    {
      $clone_cfg;

      $* libbox +{ --upgrade-immediate } libfix +{ --patch-immediate } 2>>EOE
        disfigured libfix/0.0.3
        disfigured libbox/0.0.1
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.1.0
        unpacked libbaz/0.1.0
        configured libbaz/0.1.0
        configured libbox/0.0.1
        configured libfix/0.0.3
        EOE
    }

    : unavailable
    :
    {
      $clone_cfg;

      $* '?sys:libbaz/0.0.3' 2>>EOE;
        disfigured libbox/0.0.1
        disfigured libfix/0.0.3
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        purged libbaz/0.0.3
        configured sys:libbaz/0.0.3
        configured libfix/0.0.3
        configured libbox/0.0.1
        EOE

      $rep_remove $rep/t0c;
      $rep_fetch $rep/t0b;

      $* ?libbaz --patch --yes 2>>EOE != 0
        error: patch version for sys:libbaz/0.0.3 is not available from its dependents' repositories
        EOE
    }

    : unavailable-masked
    :
    : As above but using --mask-repository instead of rep-remove.
    :
    {
      $clone_cfg;

      $* '?sys:libbaz/0.0.3' 2>>EOE;
        disfigured libbox/0.0.1
        disfigured libfix/0.0.3
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        purged libbaz/0.0.3
        configured sys:libbaz/0.0.3
        configured libfix/0.0.3
        configured libbox/0.0.1
        EOE

      $rep_fetch $rep/t0b;

      $* --mask-repository $rep/t0c ?libbaz --patch --yes 2>>EOE != 0
        error: patch version for sys:libbaz/0.0.3 is not available from its dependents' repositories
        EOE
    }

    -$pkg_drop libbox libfix libbaz libfoo
  }

  : from-repository
  :
  {
    test.arguments += --patch --auth all --trust-yes

    +$clone_cfg

    +$* "libbaz/0.0.3@$rep/t0c" 2>>EOE
      added pkg:build2.org/pkg-build/t0c
      fetching pkg:build2.org/pkg-build/t0c
      fetched libfoo/1.0.0
      unpacked libfoo/1.0.0
      fetched libbaz/0.0.3
      unpacked libbaz/0.0.3
      configured libfoo/1.0.0
      configured libbaz/0.0.3
      EOE

    clone_cfg = [cmdline] cp --no-cleanup -r ../cfg ./ &cfg/***

    : explicit
    :
    {
      $clone_cfg;

      $* "libbaz@$rep/t0c" 2>>EOE
        fetching pkg:build2.org/pkg-build/t0c
        disfigured libbaz/0.0.3
        disfigured libfoo/1.0.0
        purged libfoo/1.0.0
        fetched libbaz/0.0.4
        unpacked libbaz/0.0.4
        configured libbaz/0.0.4
        EOE
    }

    : implicit
    :
    : Note that libfoo also becomes held.
    :
    {
      $clone_cfg;

      $* "@$rep/t0c" 2>>EOE;
        fetching pkg:build2.org/pkg-build/t0c
        info: package libbar is not present in configuration
        info: package libbox is not present in configuration
        info: package libfix is not present in configuration
        disfigured libbaz/0.0.3
        fetched libbaz/0.0.4
        unpacked libbaz/0.0.4
        configured libbaz/0.0.4
        EOE

      $pkg_status libfoo >'!libfoo configured !1.0.0'
    }

    -$pkg_drop libbaz libfoo
  }
}

: configure-only
:
: Test --configure-only option.
:
{
  $clone_cfg;
  $rep_add $rep/t2 && $rep_fetch;

  $* --configure-only --yes libbar 2>>EOE;
    fetched libfoo/1.0.0
    unpacked libfoo/1.0.0
    fetched libbar/1.0.0
    unpacked libbar/1.0.0
    configured libfoo/1.0.0
    configured libbar/1.0.0
    EOE

  $pkg_disfigure libbar 2>'disfigured libbar/1.0.0';
  $pkg_purge     libbar 2>'purged libbar/1.0.0';

  $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
  $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
}

: repository-location
:
{
  test.arguments += --yes --auth all --trust-yes

  : all-packages
  :
  {
    : explicit
    :
    {
      $clone_root_cfg;

      $* "@$rep/t4d" 2>>~%EOE%;
        %.+
        %info: .+ is up to date%{2}
        updated libfox/1.0.0
        updated libbiz/1.0.0
        EOE

      $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
      $pkg_purge     libbiz 2>'purged libbiz/1.0.0';

      $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
      $pkg_purge     libfox 2>'purged libfox/1.0.0';

      $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
      $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }

    : url-detection
    :
    {
      $clone_root_cfg;

      if! $remote
        rep = ($posix \
               ? "file:$rep" \
               : "file:/$regex.replace($rep, '\\', '/')")

        rep = "$regex.replace($rep, ' ', '%20')"
      end;

      $* "$rep/t4d" 2>>~%EOE%;
        %.+
        %info: .+ is up to date%{2}
        updated libfox/1.0.0
        updated libbiz/1.0.0
        EOE

      $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
      $pkg_purge     libbiz 2>'purged libbiz/1.0.0';

      $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
      $pkg_purge     libfox 2>'purged libfox/1.0.0';

      $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
      $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

      $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
      $pkg_purge     libbar 2>'purged libbar/1.1.0';

      $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
      $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
    }
  }

  : multiple-packages
  :
  {
    $clone_root_cfg;

    $* "libfox,libbiz/1.0.0@$rep/t4d" 2>>~%EOE%;
      %.+
      %info: .+ is up to date%{2}
      updated libfox/1.0.0
      updated libbiz/1.0.0
      EOE

    $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
    $pkg_purge     libbiz 2>'purged libbiz/1.0.0';

    $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
    $pkg_purge     libfox 2>'purged libfox/1.0.0';

    $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
    $pkg_purge     libbaz 2>'purged libbaz/1.1.0';

    $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
    $pkg_purge     libbar 2>'purged libbar/1.1.0';

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }

  : version
  :
  : Test that libfoo/0.0.1 package version is built (repository t0a), rather
  : than libfoo/1.0.0 (repository t4a).
  :
  {
    $clone_root_cfg;

    $rep_fetch $rep/t4c 2>!;

    $* "libfoo@$rep/t0a" 2>>~%EOE%;
      %.+
      configured libfoo/0.0.1
      %info: .+ is up to date%
      updated libfoo/0.0.1
      EOE

    $pkg_drop libfoo
  }

  : no-patch
  :
  : Here we also test that --patch options is ignored if there is no selected
  : package in the configuration.
  :
  {
    $clone_root_cfg;

    $* "libfoo@$rep/t1" --patch 2>>~%EOE%;
      %.+
      configured libfoo/1.0.0
      %info: .+ is up to date%
      updated libfoo/1.0.0
      EOE

    $* "libfoo@$rep/t3" --patch 2>>~%EOE% != 0;
      %.+
      error: patch version for libfoo/1.0.0 is not found in pkg:build2.org/pkg-build/t3
      EOE

    $pkg_drop libfoo
  }

  : no-patch-config
  :
  : As above but with a linked configuration.
  :
  {
    $clone_root_cfg;
    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;

    $* "libfoo@$rep/t1" +{ --config-id 1 } --patch 2>>~%EOE%;
      %.+
      %configured libfoo/1.0.0 \[cfg2.\]%
      %info: .+ is up to date%
      %updated libfoo/1.0.0 \[cfg2.\]%
      EOE

    $* "libfoo@$rep/t3" +{ --config-id 1 } --patch 2>>~%EOE% != 0;
      %.+
      %error: patch version for libfoo/1.0.0 \[cfg2.\] is not found in pkg:build2.org/pkg-build/t3%
      EOE

    $pkg_drop -d cfg2 libfoo
  }

  : package-in-complement
  :
  {
    $clone_root_cfg;

    $* "libfoo@$rep/t4d" 2>>~%EOE%;
      %.+
      %info: .+ is up to date%
      updated libfoo/1.0.0
      EOE

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.0.0'
  }

  : system
  :
  {
    $clone_root_cfg;

    $* "sys:libbiz/2.0.0@$rep/t4d" 2>>~%EOE%;
      %.+
      configured sys:libbiz/2.0.0
      EOE

    $pkg_disfigure libbiz 2>'purged libbiz/2.0.0'
  }

  : non-existent-package
  :
  {
    $clone_root_cfg;

    $* "libbar@$rep/t4d" 2>>~%EOE% != 0
      %.+
      error: package libbar is not found in pkg:build2.org/pkg-build/t4d or its complements
      EOE
  }

  : location-search
  :
  : Test that the repository location is searched in the database before being
  : parsed. The latest would fail as the repository type would be misguessed.
  :
  {
    $clone_root_cfg;
    $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch;

    d = $canonicalize([dir_path] $src/libfoo-1.1.0);

    # Note that on Windows the local repository canonical name path part is
    # converted to lower case.
    #
    $* "libfoo@$d" 2>>~"%EOE%";
      fetching dir:($posix ? "$d" : $string.lcase("$d"))
      using libfoo/1.1.0 \(external\)
      configured libfoo/1.1.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }
}

: dir-rep
:
{
  : preferred
  :
  : Test that dir (local) repository is preferred over non-dir local repository
  : that comes first.
  :
  {
    $clone_root_cfg;
    $rep_fetch $rep/t4a;
    $rep_add $src/libfoo-1.1.0 --type dir;

    d = $canonicalize([dir_path] $src/libfoo-1.1.0);

    if! $posix
      d = [dir_path] $string.lcase($d)
    end;

    $rep_fetch "dir:$d";

    $* libfoo 2>>~%EOE%;
      using libfoo/1.1.0 (external)
      configured libfoo/1.1.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     libfoo 2>'purged libfoo/1.1.0'
  }

  : preferred-config
  :
  : As above but with a linked configuration.
  :
  {
    $clone_root_cfg;

    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;

    $rep_fetch -d cfg2 $rep/t4a;
    $rep_add -d cfg2 $src/libfoo-1.1.0 --type dir;

    d = $canonicalize([dir_path] $src/libfoo-1.1.0);

    if! $posix
      d = [dir_path] $string.lcase($d)
    end;

    $rep_fetch -d cfg2 "dir:$d";

    $* libfoo +{ --config-id 1 } 2>>~%EOE%;
      %using libfoo/1.1.0 \[cfg2.\] \(external\)%
      %configured libfoo/1.1.0 \[cfg2.\]%
      %info: .+ is up to date%
      %updated libfoo/1.1.0 \[cfg2.\]%
      EOE

    $pkg_disfigure -d cfg2 libfoo 2>'disfigured libfoo/1.1.0';
    $pkg_purge     -d cfg2 libfoo 2>'purged libfoo/1.1.0'
  }
}

: disfigure
:
{
  +$cfg_create cxx $config_cxx -d cfg &cfg/***

  # Build libhello as an external package.
  #
  +cp -r $src/libhello-1.0.0 ./libhello
  +cat <<EOI >+libhello/build/root.build
    config [bool] config.libhello.develop ?= false
    config [bool] config.libhello.extras ?= false
    if ($build.mode != 'skeleton')
      text "develop=$config.libhello.develop"
    EOI
  +$rep_add libhello --type dir
  +$rep_fetch
  +$* config.libhello.develop=true -- libhello 2>!

  : without
  :
  : Make sure without --disfigure old configuration is preserved.
  :
  {
    $clone_cfg;
    $* libhello 2>!; # Update after output directory change.

    # Specify a configuration variable to trigger reconfiguration.
    #
    $* config.libhello.extras=true -- libhello 2>>~%EOE%
        disfigured libhello/1.0.0
        %.*: develop=true%
        configured libhello/1.0.0
        %.*: develop=true%
        %(mkdir|c\+\+|ld|ar) .+%{8}
        updated libhello/1.0.0
        EOE
  }

  : alone
  :
  : Make sure --disfigure alone causes reconfiguration.
  :
  {
    $clone_cfg;
    $* libhello 2>!; # Update after output directory change.

    $* --disfigure libhello 2>>~%EOE%
        disfigured libhello/1.0.0
        %.*: develop=false%
        configured libhello/1.0.0
        %.*: develop=false%
        %(mkdir|c\+\+|ld|ar) .+%{8}
        updated libhello/1.0.0
        EOE
  }

  : with-keep-out
  :
  {
    $clone_cfg;
    $* libhello 2>!; # Update after output directory change.

    $* --disfigure --keep-out libhello 2>>~%EOE%
        disfigured libhello/1.0.0
        %.*: develop=false%
        configured libhello/1.0.0
        %.*: develop=false%
        %info: .+ is up to date%
        updated libhello/1.0.0
        EOE
  }
}

: keep-out
:
{
  +$cfg_create cxx $config_cxx -d cfg &cfg/***

  # Build libhello as an external package.
  #
  +cp -r $src/libhello-1.0.0 ./libhello
  +$rep_add libhello --type dir
  +$rep_fetch
  +$* libhello 2>!

  # Move libhello version ahead.
  #
  +sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest
  +$rep_fetch

  test.arguments += --yes # Is a command-specific option.

  : unspecified
  :
  : Test that libhello is fully rebuilt.
  :
  {
    $clone_cfg;
    $rep_fetch;

    $* libhello 2>>~%EOE%
      disfigured libhello/1.0.0
      using libhello/1.0.1 (external)
      configured libhello/1.0.1
      %(mkdir|c\+\+|ld|ar) .+%{8}
      updated libhello/1.0.1
      EOE
  }

  : specified
  :
  {
    test.arguments += --keep-out

    +$clone_cfg

    : dir-repo
    :
    : Test that libhello is built incrementally. May re-link due to the
    : configuration copying.
    :
    {
      $clone_cfg;

      $* libhello 2>>~%EOE%;
        disfigured libhello/1.0.0
        using libhello/1.0.1 (external)
        configured libhello/1.0.1
        %(ld|ar) .+%*
        updated libhello/1.0.1
        EOE

      test -d cfg/libhello/;
      test -d cfg/libhello-1.0.1/ == 1
    }

    : directory
    :
    : Test that libhello is built incrementally. May re-link due to the
    : configuration copying.
    :
    {
      +$clone_cfg

      # To avoid 'external package is already available' failure for the
      # nested tests.
      #
      +$rep_remove --all

      : arg
      :
      {
        $clone_cfg;

        $* ../../../libhello/ 2>>~%EOE%;
          disfigured libhello/1.0.0
          using libhello/1.0.1 (external)
          configured libhello/1.0.1
          %(ld|ar) .+%*
          updated libhello/1.0.1
          EOE

        test -d cfg/libhello/;
        test -d cfg/libhello-1.0.1/ == 1
      }

      : unpacked
      :
      {
        $clone_cfg;
        $pkg_disfigure libhello --keep-out 2>!;
        $pkg_unpack --replace --existing ../../../libhello;

        $* libhello 2>>~%EOE%;
          configured libhello/1.0.1
          %(ld|ar) .+%*
          updated libhello/1.0.1
          EOE

        test -d cfg/libhello/;
        test -d cfg/libhello-1.0.1/ == 1
      }
    }

    : archive
    :
    : Test that libhello is fully rebuilt, as the resulted package is not
    : external.
    {
      clone_cfg = [cmdline] cp -pr --no-cleanup ../../cfg ./

      # Distribute using the dedicated configuration to avoid the 'c and cxx
      # module toolchain pattern mismatch' warning.
      #
      +$cfg_create cxx $config_cxx -d cfg &cfg/***

      +$build 'dist(../../libhello/@./cfg/libhello/)' \
              config.dist.root=./ \
              config.dist.archives=tar.gz 2>! \
              &libhello-1.0.1/*** &libhello-1.0.1.tar.gz

      : arg
      :
      {
        $clone_cfg;

        $* ../libhello-1.0.1.tar.gz 2>>~%EOE%;
          disfigured libhello/1.0.0
          fetched libhello/1.0.1
          unpacked libhello/1.0.1
          configured libhello/1.0.1
          %(c\+\+|ld|ar) .+%{6}
          updated libhello/1.0.1
          EOE

        test -d cfg/libhello-1.0.1/;
        test -d cfg/libhello/ == 1;

        $pkg_disfigure libhello 2>'disfigured libhello/1.0.1';
        $pkg_purge     libhello 2>'purged libhello/1.0.1';

        rm -r cfg/
      }

      : unpacked
      :
      {
        $clone_cfg;

        $pkg_disfigure libhello 2>!;
        $pkg_fetch --replace --existing ../libhello-1.0.1.tar.gz;
        $pkg_unpack libhello;

        $* libhello 2>>~%EOE%;
          configured libhello/1.0.1
          %(c\+\+|ld|ar) .+%{6}
          updated libhello/1.0.1
          EOE

        test -d cfg/libhello-1.0.1/;
        test -d cfg/libhello/ == 1;

        $pkg_disfigure libhello 2>'disfigured libhello/1.0.1';
        $pkg_purge     libhello 2>'purged libhello/1.0.1';

        rm -r cfg/
      }
    }
  }

  -$pkg_disfigure libhello 2>'disfigured libhello/1.0.0'
  -$pkg_purge     libhello 2>'purged libhello/1.0.0'
}

: iter
:
{
  test.arguments += --yes # Is a command-specific option.

  : already-available
  :
  {
    $clone_root_cfg;
    $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch;

    $* $src/libfoo-1.1.0/ 2>>~%EOE% != 0
      %error: external package libfoo/1.1.0 is already available from dir:.+libfoo-1.1.0%
      EOE
  }

  : upgrade
  :
  {
    $clone_root_cfg;

    $* $src/libfoo-1.1.0/ 2>>~%EOE%;
      using libfoo/1.1.0 (external)
      configured libfoo/1.1.0
      %info: .+ is up to date%
      updated libfoo/1.1.0
      EOE

    cp -pr $src/libfoo-1.1.0 libfoo;

    $* libfoo/ 2>>~%EOE%;
      disfigured libfoo/1.1.0
      using libfoo/1.1.0#1 (external)
      configured libfoo/1.1.0#1
      %info: .+ is up to date%
      updated libfoo/1.1.0#1
      EOE

    $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch;

    $* libfoo 2>>~%EOE%;
      disfigured libfoo/1.1.0#1
      using libfoo/1.1.0#2 (external)
      configured libfoo/1.1.0#2
      %info: .+ is up to date%
      updated libfoo/1.1.0#2
      EOE

    $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0#2'
  }
}

: ignore-case-pkg
:
{
  test.arguments += --yes --auth all --trust-yes

  $clone_cfg;

  $* "libbar@$rep/t5" 2>>~%EOE%;
    added pkg:build2.org/pkg-build/t5
    fetching pkg:build2.org/pkg-build/t5
    fetched libbar/1.2.0
    unpacked libbar/1.2.0
    configured libbar/1.2.0
    %info: .+ is up to date%
    updated libbar/1.2.0
    EOE

  $* "libbar@$rep/t6" 2>>~%EOE%;
    added pkg:build2.org/pkg-build/t6
    fetching pkg:build2.org/pkg-build/t6
    disfigured libbar/1.2.0
    fetched libBar/2.0.0
    unpacked libBar/2.0.0
    configured libBar/2.0.0
    %info: .+ is up to date%
    updated libBar/2.0.0
    EOE

  $pkg_status libbar >'!libBar configured !2.0.0';

  test -d cfg/libBar-2.0.0;

  $pkg_drop libbar
}

: ignore-case-rep
:
: Test that package spec local repository location is matched
: case-insensitively on Windows.
:
if (!$remote && !$posix)
{
  $clone_cfg;

  $* "libbar@$rep/t5" 2>>~%EOE%;
    added pkg:build2.org/pkg-build/t5
    fetching pkg:build2.org/pkg-build/t5
    fetched libbar/1.2.0
    unpacked libbar/1.2.0
    configured libbar/1.2.0
    %info: .+ is up to date%
    updated libbar/1.2.0
    EOE

  $* "libbar@$rep/T5" 2>>~%EOE%;
    fetching pkg:build2.org/pkg-build/t5
    %info: .+ is up to date%
    updated libbar/1.2.0
    EOE

  $rep_list >~'%pkg:build2\.org/pkg-build/t5 .+t5%';

  $pkg_drop libbar
}

: git-rep
:
if! $git_supported
{
  # Skip git repository tests.
  #
}
else
{
  rep0 = "$rep_git/state0"
  rep1 = "$rep_git/state1"

  test.arguments += --yes

  pkg_disfigure += 2>!
  pkg_purge     += 2>!

  : prerequisite-repo
  :
  : Dependency package of the dependent being built is in the prerequisite
  : repository.
  :
  {
    $clone_root_cfg;
    $rep_add "$rep0/libbar.git#master";
    $rep_add "$rep0/style-basic.git#master";
    $rep_fetch &cfg/.bpkg/repos/*/***;

    $* libmbar 2>>~%EOE%;
      %checked out style-basic/.+%
      checked out libmbar/1.0.0
      %configured style-basic/.+%
      configured libmbar/1.0.0
      %info: .+ is up to date%
      updated libmbar/1.0.0
      EOE

    $pkg_disfigure libmbar;
    $pkg_disfigure style-basic;

    $pkg_purge libmbar;
    $pkg_purge style-basic
  }

  : prerequisite-repo-config
  :
  : As above but with a linked configuration.
  :
  {
    $clone_root_cfg;
    $rep_add "$rep0/libbar.git#master";
    $rep_fetch &cfg/.bpkg/repos/*/***;

    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;

    $rep_add -d cfg2 "$rep0/style-basic.git#master";
    $rep_fetch -d cfg2 &cfg/.bpkg/repos/*/***;

    $* libmbar style-basic +{ --config-id 1 } 2>>~%EOE%;
      %checked out style-basic/.+ \[cfg2.\]%
      checked out libmbar/1.0.0
      %configured style-basic/.+ \[cfg2.\]%
      configured libmbar/1.0.0
      %info: .+ is up to date%{2}
      %updated style-basic/.+ \[cfg2.\]%
      updated libmbar/1.0.0
      EOE

    $pkg_disfigure         libmbar;
    $pkg_disfigure -d cfg2 style-basic;

    $pkg_purge         libmbar;
    $pkg_purge -d cfg2 style-basic
  }

  : no-prerequisite-repos
  :
  : Dependent package repository has no prerequisites nor complements. Its
  : dependency is picked up via the root repository that complements its
  : repository (see rep_fetch() function implementation for details).
  :
  {
    $clone_root_cfg;
    $rep_add "$rep1/libbaz.git#master";
    $rep_add "$rep0/style-basic.git#master";
    $rep_fetch &cfg/.bpkg/repos/*/***;

    $* libbaz 2>>~%EOE%;
      %checked out style-basic/.+%
      checked out libbaz/1.0.0
      %configured style-basic/.+%
      configured libbaz/1.0.0
      %info: .+ is up to date%
      updated libbaz/1.0.0
      EOE

    $pkg_disfigure libbaz;
    $pkg_disfigure style-basic;

    $pkg_purge libbaz;
    $pkg_purge style-basic
  }

  : build-unpacked
  :
  : Test that the unpacked external package is properly built for the first
  : time and is not rebuilt afterwards via the directory argument.
  :
  if! $remote
  {
    $clone_root_cfg;

    d = $canonicalize([dir_path] $out_git/state0/style-basic.git);
    $pkg_unpack -e $d;

    $* style-basic 2>>~%EOE%;
      %configured style-basic/1\.1\.0-a\.0\.\d+\..+%
      %info: .+ is up to date%
      %updated style-basic/1\.1\.0-a\.0\.\d+\..+%
      EOE

    $* $d 2>>~%EOE%;
      %info: .+ is up to date%
      %updated style-basic/1\.1\.0-a\.0\.\d+\..+%
      EOE

    $pkg_disfigure style-basic
  }

  : build-unpacked-config
  :
  : As above but with a linked configuration.
  :
  if! $remote
  {
    $clone_root_cfg;

    $cfg_create -d cfg2 &cfg2/***;
    $cfg_link -d cfg cfg2;

    d = $canonicalize([dir_path] $out_git/state0/style-basic.git);
    $pkg_unpack -d cfg2 -e $d;

    $* style-basic +{ --config-id 1 } 2>>~%EOE%;
      %configured style-basic/1\.1\.0-a\.0\.\d+\..+%
      %info: .+ is up to date%
      %updated style-basic/1\.1\.0-a\.0\.\d+\..+%
      EOE

    $* $d +{ --config-id 1 } 2>>~%EOE%;
      %info: .+ is up to date%
      %updated style-basic/1\.1\.0-a\.0\.\d+\..+%
      EOE

    $pkg_disfigure -d cfg2 style-basic
  }

  : checkout-root
  :
  {
    $clone_root_cfg;
    $rep_fetch "$rep0/libbar.git#master" &cfg/.bpkg/repos/*/***;

    # While at it, test the package checkout cache (thus build multiple
    # packages from the same git repository).
    #
    $* libbar libmbar --checkout-root $~ --checkout-purge 2>>~%EOE%;
      %checked out style-basic/.+%
      checked out libbar/1.0.0+1
      checked out libmbar/1.0.0
      %configured style-basic/.+%
      configured libbar/1.0.0+1
      configured libmbar/1.0.0
      %info: .+ is up to date%{2}
      updated libbar/1.0.0+1
      updated libmbar/1.0.0
      EOE

    test -d libmbar-1.0.0;

    $pkg_drop libbar libmbar
  }
}

: linked-configs
:
{
  : 2-configs
  :
  {
    +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch

    : invalid-cfg
    :
    {
      +$clone_cfg

      : config-id
      :
      {
        $clone_cfg;
        $* libbaz --config-id 1 2>>/EOE != 0
          error: no configuration with id 1 is linked with cfg/
          EOE
      }

      : config-name
      :
      {
        $clone_cfg;
        $* libbaz --config-name foo 2>>/EOE != 0
          error: no configuration with name 'foo' is linked with cfg/
          EOE
      }

      : config-uuid
      :
      {
        $clone_cfg;
        $* libbaz --config-uuid '18f48b4b-b5d9-4712-b98c-1930df1c4228' 2>>/EOE != 0
          error: no configuration with uuid 18f48b4b-b5d9-4712-b98c-1930df1c4228 is linked with cfg/
          EOE
      }
    }

    : baz
    :
    {
      $clone_cfg;
      $cfg_create -d cfg-bar-foo &cfg-bar-foo/***;
      $cfg_link -d cfg cfg-bar-foo;

      $* libbaz ?libbar +{ --config-id 1 } ?libfoo +{ --config-id 1 } 2>>~%EOE%;
        %fetched libfoo/1.1.0 \[cfg-bar-foo.\]%
        %unpacked libfoo/1.1.0 \[cfg-bar-foo.\]%
        %fetched libbar/1.1.0 \[cfg-bar-foo.\]%
        %unpacked libbar/1.1.0 \[cfg-bar-foo.\]%
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        %configured libfoo/1.1.0 \[cfg-bar-foo.\]%
        %configured libbar/1.1.0 \[cfg-bar-foo.\]%
        configured libbaz/1.1.0
        %info: cfg[^-].+libbaz-1.1.0.+ is up to date%
        updated libbaz/1.1.0
        EOE

      $pkg_status -r libbaz >>/EOO;
        !libbaz configured 1.1.0
          libbar [cfg-bar-foo/] configured 1.1.0
            libfoo [cfg-bar-foo/] configured 1.1.0
          libfoo [cfg-bar-foo/] configured 1.1.0
        EOO

      $pkg_status -d cfg-bar-foo -r libbar >>/EOO;
        libbar configured 1.1.0
          libfoo configured 1.1.0
        EOO

      $pkg_status -d cfg-bar-foo libfoo >'libfoo configured 1.1.0';

      $pkg_drop libbaz;

      $pkg_status libbaz libbar libfoo >>/EOO
        libbaz available 1.1.0
        libbar available [1.1.0]
        libfoo available [1.1.0] 1.0.0
        EOO
    }
  }

  : 3-configs
  :
  {
    +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch

    : baz
    :
    {
      uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228';

      $clone_cfg;
      $cfg_create -d cfg-bar &cfg-bar/***;
      $cfg_create -d cfg-foo --uuid $uuid &cfg-foo/***;

      $cfg_link -d cfg     cfg-bar;
      $cfg_link -d cfg-bar cfg-foo;

      test.arguments = $regex.apply($test.arguments, cfg, cfg-bar);

      $* libbar@"$rep/t4b" ?libfoo +{ --config-id 2 } --trust-yes 2>>~%EOE%;
        added pkg:build2.org/pkg-build/t4b
        fetching pkg:build2.org/pkg-build/t4b
        fetching pkg:build2.org/pkg-build/t4a (prerequisite of pkg:build2.org/pkg-build/t4b)
        %fetched libfoo/1.1.0 \[cfg-foo.\]%
        %unpacked libfoo/1.1.0 \[cfg-foo.\]%
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        %configured libfoo/1.1.0 \[cfg-foo.\]%
        configured libbar/1.1.0
        %info: cfg-bar.+libbar-1.1.0.+ is up to date%
        updated libbar/1.1.0
        EOE

      test.arguments = $regex.apply($test.arguments, cfg-bar, cfg);

      $* libfoo --config-uuid $uuid 2>>~%EOE%;
        %info: cfg-foo.+libfoo-1.1.0.+ is up to date%
        %updated libfoo/1.1.0 \[cfg-foo.\]%
        EOE

      $* libbaz 2>>~%EOE%;
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        configured libbaz/1.1.0
        %info: cfg[^-].+libbaz-1.1.0.+ is up to date%
        updated libbaz/1.1.0
        EOE

      $pkg_status --link -r >>/EOO;
        !libbaz configured 1.1.0
          !libbar [cfg-bar/] configured !1.1.0
            !libfoo [cfg-foo/] configured 1.1.0
          !libfoo [cfg-foo/] configured 1.1.0
        !libbar [cfg-bar/] configured !1.1.0
          !libfoo [cfg-foo/] configured 1.1.0
        !libfoo [cfg-foo/] configured 1.1.0
        EOO

      $pkg_drop libbaz;

      $* ?libfoo --config-uuid $uuid; # Unhold.

      $pkg_status libbaz libbar libfoo >>/EOO;
        libbaz available 1.1.0
        !libbar [cfg-bar/] configured !1.1.0
        libfoo [cfg-foo/] configured 1.1.0
        EOO

      $* ?libbar +{ --config-id 1 } <'y' 2>>~%EOE%;
        %  drop libfoo/1.1.0 \[cfg-foo.\] \(unused\)%
        %  drop libbar/1.1.0 \[cfg-bar.\] \(unused\)%
        %continue\? \[Y/n\] disfigured libbar/1.1.0 \[cfg-bar.\]%
        %disfigured libfoo/1.1.0 \[cfg-foo.\]%
        %purged libfoo/1.1.0 \[cfg-foo.\]%
        %purged libbar/1.1.0 \[cfg-bar.\]%
        EOE

      $pkg_status libbar libfoo >>/EOO
        libbar available [1.1.0]
        libfoo available [1.1.0] 1.0.0
        EOO
    }
  }

  : buildtime-dep
  :
  {
    +$clone_root_cfg && $rep_add $rep/t7a && $rep_fetch

    : external-config
    :
    {
      +$clone_cfg
      +$cfg_create -d cfg2 --type host --name cfg2 &cfg2/***
      +$cfg_link -d cfg cfg2

      : downgrade-dependency
      :
      {
        $clone_cfg;
        cp -pr ../cfg2 ./;

        $* libbar <'y' 2>>~%EOE%;
          %  new libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(required by foo \[cfg2.\]\)%
          %  new libbaz/1.0.0 \[cfg2.\] \(required by foo \[cfg2.\]\)%
          %  new foo/1.0.0 \[cfg2.\] \(required by libbar\)%
          %  new libbaz/1.0.0 \(required by libbar\)%
            new libbar/1.0.0
          %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %unpacked libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %fetched libbaz/1.0.0 \[cfg2.\]%
          %unpacked libbaz/1.0.0 \[cfg2.\]%
          %fetched foo/1.0.0 \[cfg2.\]%
          %unpacked foo/1.0.0 \[cfg2.\]%
          fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          %configured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %configured libbaz/1.0.0 \[cfg2.\]%
          %configured foo/1.0.0 \[cfg2.\]%
          configured libbaz/1.0.0
          configured libbar/1.0.0
          %info: .+libbar-1.0.0.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -r libbar >>/EOO;
          !libbar configured 1.0.0
            foo [cfg2/] configured 1.0.0
              libbaz [cfg2/] configured 1.0.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        # While at it, make sure that from several available host
        # configurations the selected package configuration is chosen and we
        # don't fail with the 'multiple possible host configurations'
        # diagnostics.
        #
        $cfg_create -d cfg3 --type host &cfg3/***;
        $cfg_link -d cfg cfg3;

        $rep_add $rep/t7b && $rep_fetch;

        $* libbar <'y' 2>>~%EOE%;
          %  upgrade libbaz/1.1.0 \[cfg2.\] \(required by foo \[cfg2.\]\)%
          %  drop libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(unused\)%
          %  upgrade foo/1.1.0 \[cfg2.\] \(required by libbar\)%
            upgrade libbar/1.1.0
          %continue\? \[Y/n\] disfigured libbar/1.0.0%
          %disfigured foo/1.0.0 \[cfg2.\]%
          %disfigured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %disfigured libbaz/1.0.0 \[cfg2.\]%
          %fetched libbaz/1.1.0 \[cfg2.\]%
          %unpacked libbaz/1.1.0 \[cfg2.\]%
          %purged libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %fetched foo/1.1.0 \[cfg2.\]%
          %unpacked foo/1.1.0 \[cfg2.\]%
          fetched libbar/1.1.0
          unpacked libbar/1.1.0
          %configured libbaz/1.1.0 \[cfg2.\]%
          %configured foo/1.1.0 \[cfg2.\]%
          configured libbar/1.1.0
          %info: .+libbar-1.1.0.+ is up to date%
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>/EOO;
          !libbar configured 1.1.0
            foo [cfg2/] configured 1.1.0
              libbaz [cfg2/] configured 1.1.0
            libbaz configured 1.0.0 available 1.1.0
          EOO

        $* libbar/1.0.0 ?foo/1.0.0 +{ --config-name cfg2 } \
           ?libbaz/1.0.0 +{ --config-id 1 } <'y' &cfg2/.bpkg/build2/*** 2>>~%EOE%;
          %  new libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(required by foo \[cfg2.\]\)%
          %  downgrade libbaz/1.0.0 \[cfg2.\]%
          %  downgrade foo/1.0.0 \[cfg2.\]%
            downgrade libbar/1.0.0
          continue? [Y/n] disfigured libbar/1.1.0
          %disfigured foo/1.1.0 \[cfg2.\]%
          %disfigured libbaz/1.1.0 \[cfg2.\]%
          %fetched libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %unpacked libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %fetched libbaz/1.0.0 \[cfg2.\]%
          %unpacked libbaz/1.0.0 \[cfg2.\]%
          %fetched foo/1.0.0 \[cfg2.\]%
          %unpacked foo/1.0.0 \[cfg2.\]%
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          %configured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %configured libbaz/1.0.0 \[cfg2.\]%
          %configured foo/1.0.0 \[cfg2.\]%
          configured libbar/1.0.0
          %info: cfg.+libbar-1.0.0.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -r libbar >>/EOO;
          !libbar configured !1.0.0 available 1.1.0
            foo [cfg2/] configured !1.0.0 available 1.1.0
              libbaz [cfg2/] configured !1.0.0 available 1.1.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0 available 1.1.0
          EOO

        $pkg_drop libbar libbaz
      }

      : resolve-host-config
      :
      {
        $clone_cfg;
        cp -pr ../cfg2 ./;

        $cfg_create -d cfg3 --type host &cfg3/***;
        $cfg_link -d cfg cfg3;

        $* libbar 2>>/~%EOE% != 0;
          error: multiple possible host configurations for build-time dependency (foo ^1.0.0)
            info: cfg2/
            info: cfg3/
            info: use --config-* to select the configuration
          %info: while satisfying libbar.1.0.0%
          EOE

        $* libbar ?foo +{ --config-id 2 } --yes 2>!;

        $pkg_status -r libbar >>/EOO;
          !libbar configured 1.0.0
            foo [cfg3/] configured 1.0.0
              libbaz [cfg3/] configured 1.0.0
              libbuild2-bar [cfg3/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbar
      }

      : 3-configs
      :
      {
        $clone_cfg;
        cp -pr ../cfg2 ./;

        $cfg_create -d cfg3 --type host &cfg3/***;
        $cfg_link -d cfg2 cfg3;

        $rep_add -d cfg3 $rep/t7a && $rep_fetch -d cfg3;

        test.arguments = $regex.apply($test.arguments, cfg, cfg2);

        $* libbaz +{ --config-id 2 } 2>!;

        test.arguments = $regex.apply($test.arguments, cfg2, cfg);

        $* libbar --yes &cfg2/.bpkg/build2/*** 2>>~%EOE%;
          %fetched libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %unpacked libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %fetched foo/1.0.0 \[cfg2.\]%
          %unpacked foo/1.0.0 \[cfg2.\]%
          fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          %configured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %configured foo/1.0.0 \[cfg2.\]%
          configured libbaz/1.0.0
          configured libbar/1.0.0
          %info: .+libbar-1.0.0.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -r libbar >>/EOO;
          !libbar configured 1.0.0
            foo [cfg2/] configured 1.0.0
              !libbaz [cfg3/] configured 1.0.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbar
      }
    }

    : private-config
    :
    {
      $clone_cfg;

      $* libbar <'y' 2>>~%EOE% &cfg/.bpkg/host/*** &cfg/.bpkg/build2/***;
        %  new libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\] \(required by foo \[cfg..bpkg.host.\]\)%
        %  new libbaz/1.0.0 \[cfg..bpkg.host.\] \(required by foo \[cfg..bpkg.host.\]\)%
        %  new foo/1.0.0 \[cfg..bpkg.host.\] \(required by libbar\)%
        %  new libbaz/1.0.0 \(required by libbar\)%
          new libbar/1.0.0
        %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %unpacked libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %fetched foo/1.0.0 \[cfg..bpkg.host.\]%
        %unpacked foo/1.0.0 \[cfg..bpkg.host.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %configured foo/1.0.0 \[cfg..bpkg.host.\]%
        configured libbaz/1.0.0
        configured libbar/1.0.0
        %info: .+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -r libbar >>/EOO;
        !libbar configured 1.0.0
          foo [cfg/.bpkg/host/] configured 1.0.0
            libbaz [cfg/.bpkg/host/] configured 1.0.0
            libbuild2-bar [cfg/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $rep_add $rep/t7b && $rep_fetch;

      $* libbar <'y' 2>>~%EOE%;
        %  upgrade libbaz/1.1.0 \[cfg..bpkg.host.\] \(required by foo \[cfg..bpkg.host.\]\)%
        %  drop libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\] \(unused\)%
        %  upgrade foo/1.1.0 \[cfg..bpkg.host.\] \(required by libbar\)%
          upgrade libbar/1.1.0
        %continue\? \[Y/n\] disfigured libbar/1.0.0%
        %disfigured foo/1.0.0 \[cfg..bpkg.host.\]%
        %disfigured libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %disfigured libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %fetched libbaz/1.1.0 \[cfg..bpkg.host.\]%
        %unpacked libbaz/1.1.0 \[cfg..bpkg.host.\]%
        %purged libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %fetched foo/1.1.0 \[cfg..bpkg.host.\]%
        %unpacked foo/1.1.0 \[cfg..bpkg.host.\]%
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        %configured libbaz/1.1.0 \[cfg..bpkg.host.\]%
        %configured foo/1.1.0 \[cfg..bpkg.host.\]%
        configured libbar/1.1.0
        %info: .+libbar-1.1.0.+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_status -r libbar >>/EOO;
        !libbar configured 1.1.0
          foo [cfg/.bpkg/host/] configured 1.1.0
            libbaz [cfg/.bpkg/host/] configured 1.1.0
          libbaz configured 1.0.0 available 1.1.0
        EOO

      $pkg_drop libbar
    }

    : self-hosted-config
    :
    {
      $cfg_create -d cfg --type host &cfg/***;
      $rep_add $rep/t7a && $rep_fetch;

      $* libbar <'y' 2>>~%EOE%;
        %  new libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\] \(required by foo\)%
          new libbaz/1.0.0 (required by foo, libbar)
          new foo/1.0.0 (required by libbar)
          new libbar/1.0.0
        %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        configured libbaz/1.0.0
        configured foo/1.0.0
        configured libbar/1.0.0
        %info: .+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -r libbar >>/EOO;
        !libbar configured 1.0.0
          foo configured 1.0.0
            libbaz configured 1.0.0
            libbuild2-bar [cfg/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $rep_add $rep/t7b && $rep_fetch;

      $* libbar <'y' 2>>~%EOE%;
          upgrade libbaz/1.1.0 (required by foo, libbar)
        %  drop libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\] \(unused\)%
          upgrade foo/1.1.0 (required by libbar)
          upgrade libbar/1.1.0
        continue? [Y/n] disfigured libbar/1.0.0
        disfigured foo/1.0.0
        %disfigured libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        disfigured libbaz/1.0.0
        fetched libbaz/1.1.0
        unpacked libbaz/1.1.0
        %purged libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        fetched foo/1.1.0
        unpacked foo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        configured libbaz/1.1.0
        configured foo/1.1.0
        configured libbar/1.1.0
        %info: .+libbar-1.1.0.+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_status -r libbar >>/EOO;
        !libbar configured 1.1.0
          foo configured 1.1.0
            libbaz configured 1.1.0
          libbaz configured 1.1.0
        EOO

      $pkg_drop libbar
    }
  }

  : verify-dependencies
  :
  {
    +$clone_root_cfg && $rep_add $rep/t7a && $rep_fetch

    : fail
    :
    {
      $cfg_create -d cfg2 &cfg2/***;
      $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

      $cfg_create -d cfg3 &cfg3/***;
      $rep_add -d cfg3 $rep/t7a && $rep_fetch -d cfg3;

      test.arguments = $regex.apply($test.arguments, cfg, cfg2);

      $* --yes libbar 2>!;

      test.arguments = $regex.apply($test.arguments, cfg2, cfg3);

      $* --yes libbox 2>!;

      $clone_cfg;
      $cfg_link -d cfg cfg2;
      $cfg_link -d cfg cfg3;

      test.arguments = $regex.apply($test.arguments, cfg3, cfg);

      $* libfix --yes 2>>~%EOE% != 0
        error: package libbaz indirectly required by libfix/1.0.0 is configured in multiple configurations
        %  info: libbaz/1.0.0 \[cfg3.\]%
        %  info: libbaz/1.0.0 \[cfg2.\]%
        EOE
    }

    : succeed
    :
    {
      $cfg_create -d cfg2 &cfg2/***;
      $rep_add -d cfg2 $rep/t7b && $rep_fetch -d cfg2;

      $cfg_create -d cfg3 &cfg3/***;
      $rep_add -d cfg3 $rep/t7b && $rep_fetch -d cfg3;

      test.arguments = $regex.apply($test.arguments, cfg, cfg2);

      $* --yes libbar 2>!;

      test.arguments = $regex.apply($test.arguments, cfg2, cfg3);

      $* --yes libbox 2>!;

      $clone_cfg;
      $cfg_link -d cfg cfg2;
      $cfg_link -d cfg cfg3;

      test.arguments = $regex.apply($test.arguments, cfg3, cfg);

      $* libfix --yes 2>>~%EOE%;
        fetched libfax/1.0.0
        unpacked libfax/1.0.0
        fetched libfix/1.0.0
        unpacked libfix/1.0.0
        configured libfax/1.0.0
        configured libfix/1.0.0
        %info: .+libfix-1.0.0.+ is up to date%
        updated libfix/1.0.0
        EOE

      $pkg_drop libfix
    }
  }

  : change-config
  :
  {
    : copy
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbaz --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbaz configured 1.0.0
        EOO

      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      $* libbaz +{ --config-name t2 } 2>>~%EOE%;
        %fetched libbaz/1.0.0 \[t2.\]%
        %unpacked libbaz/1.0.0 \[t2.\]%
        %configured libbaz/1.0.0 \[t2.\]%
        %info: t2.+libbaz-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[t2.\]%
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libbaz configured 1.0.0
        !libbaz [t2/] configured 1.0.0
        EOO
    }

    : copy-unhold
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbaz --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbaz configured 1.0.0
        EOO

      $* ?libbaz +{ --config-name t2 };

      $pkg_status -d t1 -r >>/EOO
        !libbaz configured 1.0.0
        EOO
    }

    : copy-point
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbaz --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbaz configured 1.0.0
        EOO

      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      $* foo libbaz +{ --config-name t2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[t1..bpkg.build2.\] \(required by foo\)%
        %  new libbaz/1.0.0 \[t2.\]%
          new foo/1.0.0
        %continue\? \[Y.n\] fetched libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[t2.\]%
        %unpacked libbaz/1.0.0 \[t2.\]%
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[t2.\]%
        configured foo/1.0.0
        %info: t2.+libbaz-1.0.0.+ is up to date%
        %info: t1.+foo-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[t2.\]%
        updated foo/1.0.0
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libbaz configured 1.0.0
        !foo configured 1.0.0
          !libbaz [t2/] configured 1.0.0
          libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
        !libbaz [t2/] configured 1.0.0
        EOO
    }

    : copy-unhold-point
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbaz --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbaz configured 1.0.0
        EOO

      $* foo ?libbaz +{ --config-name t2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[t1..bpkg.build2.\] \(required by foo\)%
        %  new libbaz/1.0.0 \[t2.\] \(required by foo\)%
        %  new foo/1.0.0%
        %continue\? \[Y.n\] fetched libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[t2.\]%
        %unpacked libbaz/1.0.0 \[t2.\]%
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[t2.\]%
        configured foo/1.0.0
        %info: t1.+foo-1.0.0.+ is up to date%
        updated foo/1.0.0
        EOE

      $pkg_status -d t1 -r >>/EOO
        !libbaz configured 1.0.0
        !foo configured 1.0.0
          libbaz [t2/] configured 1.0.0
          libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
        EOO
    }

    : copy-repoint
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d t1 h1;
      $cfg_link -d t1 h2;

      $cfg_link -d t2 h1;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;
      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbar ?foo +{ --config-name h1 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(required by foo \[h1.\]\)%
        %  new libbaz/1.0.0 \[h1.\] \(required by foo \[h1.\]\)%
        %  new foo/1.0.0 \[h1.\] \(required by libbar\)%
          new libbaz/1.0.0 (required by libbar)
          new libbar/1.0.0
        %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[h1.\]%
        %unpacked libbaz/1.0.0 \[h1.\]%
        %fetched foo/1.0.0 \[h1.\]%
        %unpacked foo/1.0.0 \[h1.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[h1.\]%
        %configured foo/1.0.0 \[h1.\]%
        configured libbaz/1.0.0
        configured libbar/1.0.0
        %info: t1.+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -d t1 -r >>/EOO;
        !libbar configured 1.0.0
          foo [h1/] configured 1.0.0
            libbaz [h1/] configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      test.arguments = $regex.apply($test.arguments, t1, t2);

      $* libbox ?foo +{ --config-name h1 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  update foo/1.0.0 \[h1.\]%
          new libbaz/1.0.0 (required by libbox)
          new libbox/1.0.0
        continue? [Y/n] fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched libbox/1.0.0
        unpacked libbox/1.0.0
        configured libbaz/1.0.0
        configured libbox/1.0.0
        %info: t2.+libbox-1.0.0.+ is up to date%
        updated libbox/1.0.0
        EOE

      $pkg_status -d t2 -r >>/EOO;
        !libbox configured 1.0.0
          foo [h1/] configured 1.0.0
            libbaz [h1/] configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      test.arguments = $regex.apply($test.arguments, t2, t1);

      $* ?foo +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[h2..bpkg.build2.\] \(required by foo \[h2.\]\)%
        %  new libbaz/1.0.0 \[h2.\] \(required by foo \[h2.\]\)%
        %  new foo/1.0.0 \[h2.\] \(required by libbar\)%
        %  reconfigure libbar/1.0.0 \(dependent of foo \[h2.\]\)%
        continue? [Y/n] update dependent packages? [Y/n] disfigured libbar/1.0.0
        %fetched libbuild2-bar/1.0.0 \[h2..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h2..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        %fetched foo/1.0.0 \[h2.\]%
        %unpacked foo/1.0.0 \[h2.\]%
        %configured libbuild2-bar/1.0.0 \[h2..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[h2.\]%
        %configured foo/1.0.0 \[h2.\]%
        configured libbar/1.0.0
        %info: t1.+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -d t1 -r >>/EOO;
        !libbar configured 1.0.0
          foo [h2/] configured 1.0.0
            libbaz [h2/] configured 1.0.0
            libbuild2-bar [h2/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $pkg_status -d t2 -r >>/EOO
        !libbox configured 1.0.0
          foo [h1/] configured 1.0.0
            libbaz [h1/] configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO
    }

    : copy-repoint-drop
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* foo --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
        EOO

      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      $* libbaz +{ --config-name t2 } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  new libbaz/1.0.0 \[t2.\]%
          drop libbaz/1.0.0 (unused)
        %  reconfigure foo/1.0.0 \(dependent of libbaz \[t2.\]\)%
        continue? [Y/n] update dependent packages? [Y/n] disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        %fetched libbaz/1.0.0 \[t2.\]%
        %unpacked libbaz/1.0.0 \[t2.\]%
        purged libbaz/1.0.0
        %configured libbaz/1.0.0 \[t2.\]%
        configured foo/1.0.0
        %info: t2.+libbaz-1.0.0.+ is up to date%
        %info: t1.+foo-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[t2.\]%
        updated foo/1.0.0
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !foo configured 1.0.0
          !libbaz [t2/] configured 1.0.0
          libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
        !libbaz [t2/] configured 1.0.0
        EOO
    }

    : drop-repointed
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* foo --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
        EOO

      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      $* ?foo libbaz +{ --config-name t2 } --verbose 5 <<EOI 2>>~%EOE%;
        y
        EOI
        %.*
        trace: pkg_build: refine package collection/plan execution from scratch
        %.*
        %trace: collect_build: add libbaz/1.0.0 \[t2.\]%
        %trace: collect_build_prerequisites: begin libbaz/1.0.0 \[t2.\]%
        %trace: collect_build_prerequisites: end libbaz/1.0.0 \[t2.\]%
        %.*
        trace: collect_build_prerequisites: begin foo/1.0.0
        %.*
        %trace: collect_build_prerequisites: no cfg-clause for dependency libbaz/1.0.0 \[t2.\] of dependent foo/1.0.0%
        trace: collect_build_prerequisites: end foo/1.0.0
        %.*
        trace: execute_plan: simulate: yes
        %.*
        trace: evaluate_dependency: libbaz/1.0.0: unused
        %.*
        trace: evaluate_dependency: foo/1.0.0: unused
        %.*
        trace: pkg_build: refine package collection/plan execution
        %.*
        trace: collect_drop: foo/1.0.0 package version needs to be replaced with drop
        trace: pkg_build: collection failed due to package version replacement, retry from scratch
        %.*
        trace: pkg_build: refine package collection/plan execution from scratch
        %.*
        %trace: collect_build: add libbaz/1.0.0 \[t2.\]%
        %trace: collect_build_prerequisites: begin libbaz/1.0.0 \[t2.\]%
        %trace: collect_build_prerequisites: end libbaz/1.0.0 \[t2.\]%
        trace: collect_build: apply version replacement for foo/1.0.0
        trace: collect_build: replacement: drop
        %.*
        trace: execute_plan: simulate: yes
        %.*
        %trace: evaluate_dependency: libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]: unused%
        %.*
        trace: pkg_build: refine package collection/plan execution
        %.*
        trace: execute_plan: simulate: yes
        %.*
        %  new libbaz/1.0.0 \[t2.\]%
        %  drop libbuild2-bar/1.0.0 \[t1..bpkg.build2.\] \(unused\)%
          drop libbaz/1.0.0 (unused)
          drop foo/1.0.0 (unused)
        continue? [Y/n] trace: execute_plan: simulate: no
        %.*
        disfigured foo/1.0.0
        %.*
        disfigured libbaz/1.0.0
        %.*
        %disfigured libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %.*
        %fetched libbaz/1.0.0 \[t2.\]%
        %.*
        %unpacked libbaz/1.0.0 \[t2.\]%
        %.*
        %purged libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %.*
        purged libbaz/1.0.0
        %.*
        purged foo/1.0.0
        %.*
        %configured libbaz/1.0.0 \[t2.\]%
        %.*
        %info: .+t2.+libbaz-1.0.0.+ is up to date%
        %.*
        %updated libbaz/1.0.0 \[t2.\]%
        %.*
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libbaz [t2/] configured 1.0.0
        EOO
    }

    : dependency-repointed
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* foo --yes 2>!;

      $pkg_status -d h1 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        EOO

      $rep_add -d h2 $rep/t7a && $rep_fetch -d h2;

      $* libbar libbaz +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.0.0 \[h2.\]%
          drop libbaz/1.0.0 (unused)
          reconfigure/update foo/1.0.0 (required by libbar)
          new libbar/1.0.0
        continue? [Y/n] disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        purged libbaz/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbaz/1.0.0 \[h2.\]%
        configured foo/1.0.0
        configured libbar/1.0.0
        %info: h2.+libbaz-1.0.0.+ is up to date%
        %info: h1.+libbar-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[h2.\]%
        updated libbar/1.0.0
        EOE

      $pkg_status -d h1 --link -r >>/EOO
        !foo configured 1.0.0
          !libbaz [h2/] configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        !libbar configured 1.0.0
          !foo configured 1.0.0
            !libbaz [h2/] configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          !libbaz [h2/] configured 1.0.0
        !libbaz [h2/] configured 1.0.0
        EOO
    }

    : dependency-repointed-system
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* foo --yes 2>!;

      $pkg_status -d h1 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        EOO

      $* libbar '?sys:foo/1.2.0' +{ --config-name h1 } \
                 ?libbaz +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.0.0 \[h2.\] \(required by libbar\)%
        %  drop libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(unused\)%
          drop libbaz/1.0.0 (unused)
          reconfigure/unhold sys:foo/1.2.0
          new libbar/1.0.0
        continue? [Y/n] disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        %disfigured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        %purged libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        purged libbaz/1.0.0
        purged foo/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbaz/1.0.0 \[h2.\]%
        configured sys:foo/1.2.0
        configured libbar/1.0.0
        %info: h1.+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -d h1 -r >>/EOO;
        !libbar configured 1.0.0
          foo configured,system !1.2.0
          libbaz [h2/] configured 1.0.0
        EOO

      $* ?foo ?libbaz <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  drop libbaz/1.0.0 \[h2.\] \(unused\)%
        %  new libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(required by foo\)%
          new libbaz/1.0.0 (required by foo, libbar)
          downgrade foo/1.0.0
          reconfigure libbar/1.0.0 (dependent of libbaz)
        continue? [Y/n] update dependent packages? [Y/n] disfigured libbar/1.0.0
        purged foo/1.2.0
        %disfigured libbaz/1.0.0 \[h2.\]%
        %purged libbaz/1.0.0 \[h2.\]%
        %fetched libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        configured libbaz/1.0.0
        configured foo/1.0.0
        configured libbar/1.0.0
        %info: h1.+libbar-1.0.0.+ is up to date%
        updated libbar/1.0.0
        EOE

      $pkg_status -d h1 -r >>/EOO
        !libbar configured 1.0.0
          foo configured 1.0.0
            libbaz configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO
    }

    : orphan-repointed
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7b && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* foo --yes 2>!;

      $rep_remove -d h1 $rep/t7b;
      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      $rep_add -d h2 $rep/t7a && $rep_fetch -d h2;

      $* libbaz +{ --config-name h2 } 2>>EOE != 0;
        error: package foo/1.1.0 is orphaned
          info: explicitly upgrade it to a new version
        info: while satisfying foo/1.1.0
        EOE

      # While at it, test foo deorphaning.
      #
      $* foo +{ --deorphan } libbaz +{ --config-name h2 } --yes --plan "" 2>>~%EOE%;
        %  new libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\] \(required by foo\)%
        %  new libbaz/1.0.0 \[h2.\]%
          drop libbaz/1.1.0 (unused)
          replace/downgrade foo/1.0.0
        disfigured foo/1.1.0
        disfigured libbaz/1.1.0
        %fetched libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        purged libbaz/1.1.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %configured libbaz/1.0.0 \[h2.\]%
        configured foo/1.0.0
        %info: h2.+libbaz-1.0.0.+ is up to date%
        %info: h1.+foo-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[h2.\]%
        updated foo/1.0.0
        EOE

      $pkg_status -d h1 -r >>/EOO
        !foo configured 1.0.0
          !libbaz [h2/] configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        EOO
    }

    : orphan-repointed-masked
    :
    : As above but using --mask-repository instead of rep-remove.
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7b && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* foo --yes 2>!;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;
      $rep_add -d h2 $rep/t7a && $rep_fetch -d h2;

      $* libbaz +{ --config-name h2 } --mask-repository $rep/t7b 2>>EOE != 0;
        error: package foo/1.1.0 is orphaned
          info: explicitly upgrade it to a new version
        info: while satisfying foo/1.1.0
        EOE

      # While at it, test foo deorphaning.
      #
      $* foo +{ --deorphan } libbaz +{ --config-name h2 } --yes --plan "" \
             --mask-repository $rep/t7b 2>>~%EOE%;
        %  new libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\] \(required by foo\)%
        %  new libbaz/1.0.0 \[h2.\]%
          drop libbaz/1.1.0 (unused)
          replace/downgrade foo/1.0.0
        disfigured foo/1.1.0
        disfigured libbaz/1.1.0
        %fetched libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        purged libbaz/1.1.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[h1.\.bpkg.build2.\]%
        %configured libbaz/1.0.0 \[h2.\]%
        configured foo/1.0.0
        %info: h2.+libbaz-1.0.0.+ is up to date%
        %info: h1.+foo-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[h2.\]%
        updated foo/1.0.0
        EOE

      $pkg_status -d h1 -r >>/EOO
        !foo configured 1.0.0 available 1.1.0
          !libbaz [h2/] configured 1.0.0 available 1.1.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        EOO
    }

    : unhold-repointed
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* foo --yes 2>!;

      $pkg_status -d h1 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        EOO

      $rep_add -d h2 $rep/t7a && $rep_fetch -d h2;

      $* libbar ?foo libbaz +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.0.0 \[h2.\]%
          drop libbaz/1.0.0 (unused)
          reconfigure/update/unhold foo/1.0.0
          new libbar/1.0.0
        continue? [Y/n] disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        %fetched libbaz/1.0.0 \[h2.\]%
        %unpacked libbaz/1.0.0 \[h2.\]%
        purged libbaz/1.0.0
        fetched libbar/1.0.0
        unpacked libbar/1.0.0
        %configured libbaz/1.0.0 \[h2.\]%
        configured foo/1.0.0
        configured libbar/1.0.0
        %info: h2.+libbaz-1.0.0.+ is up to date%
        %info: h1.+libbar-1.0.0.+ is up to date%
        %updated libbaz/1.0.0 \[h2.\]%
        updated libbar/1.0.0
        EOE

      $pkg_status -d h1 --link -r >>/EOO
        !libbar configured 1.0.0
          foo configured 1.0.0
            !libbaz [h2/] configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          !libbaz [h2/] configured 1.0.0
        !libbaz [h2/] configured 1.0.0
        EOO
    }

    : satisfy
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h2 $rep/t7b && $rep_fetch -d h2;

      test.arguments = $regex.apply($test.arguments, cfg, h2);

      $* foo --yes 2>!;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, h2, h1);

      $* foo ?libbaz <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(required by foo\)%
          new libbaz/1.0.0 (required by foo)
          new foo/1.0.0
        %continue\? \[Y.n\] fetched libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched foo/1.0.0
        unpacked foo/1.0.0
        %configured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        configured libbaz/1.0.0
        configured foo/1.0.0
        %info: h1.+foo-1.0.0.+ is up to date%
        updated foo/1.0.0
        EOE

      $pkg_status -d h1 --link -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        !foo [h2/] configured 1.1.0
          libbaz [h2/] configured 1.1.0
        EOO

      $* ?libbaz/1.0.0 +{ --config-name h2 } 2>>~%EOE% != 0;
        %error: unable to downgrade package libbaz/1.1.0 \[h2.\] to 1.0.0%
        %  info: because package foo \[h2.\] depends on \(libbaz \^1.1.0\)%
          info: explicitly request up/downgrade of package foo
          info: or explicitly specify package libbaz version to manually satisfy these constraints
        EOE

      $* ?libbaz +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        n
        EOI
        %  update libbaz/1.1.0 \[h2.\]%
          drop libbaz/1.0.0 (unused)
        %  reconfigure foo/1.0.0 \(dependent of libbaz \[h2.\]\)%
        continue? [Y/n] update dependent packages? [Y/n] disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        purged libbaz/1.0.0
        configured foo/1.0.0
        EOE

      $pkg_status -d h1 --link -r >>/EOO
        !foo configured 1.0.0
          libbaz [h2/] configured 1.1.0
          libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
        !foo [h2/] configured 1.1.0
          libbaz [h2/] configured 1.1.0
        EOO
    }

    : upgrade-repointed
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbar --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbar configured 1.0.0
          foo [t1/.bpkg/host/] configured 1.0.0
            libbaz [t1/.bpkg/host/] configured 1.0.0
            libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $cfg_create -d h1 --type host --name h1 &h1/***;

      $cfg_link -d t1 h1 2>!;

      $rep_add -d t1 $rep/t7b && $rep_fetch -d t1;

      $* libbar ?foo +{ --config-name h1 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.1.0 \[h1.\] \(required by foo \[h1.\]\)%
        %  new foo/1.1.0 \[h1.\] \(required by libbar\)%
        %  drop libbuild2-bar/1.0.0 \[t1..bpkg.build2.\] \(unused\)%
        %  drop libbaz/1.0.0 \[t1..bpkg.host.\] \(unused\)%
        %  drop foo/1.0.0 \[t1..bpkg.host.\] \(unused\)%
          upgrade libbar/1.1.0
        continue? [Y/n] disfigured libbar/1.0.0
        %disfigured foo/1.0.0 \[t1..bpkg.host.\]%
        %disfigured libbaz/1.0.0 \[t1..bpkg.host.\]%
        %disfigured libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %fetched libbaz/1.1.0 \[h1.\]%
        %unpacked libbaz/1.1.0 \[h1.\]%
        %fetched foo/1.1.0 \[h1.\]%
        %unpacked foo/1.1.0 \[h1.\]%
        %purged libbuild2-bar/1.0.0 \[t1..bpkg.build2.\]%
        %purged libbaz/1.0.0 \[t1..bpkg.host.\]%
        %purged foo/1.0.0 \[t1..bpkg.host.\]%
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        %configured libbaz/1.1.0 \[h1.\]%
        %configured foo/1.1.0 \[h1.\]%
        configured libbar/1.1.0
        %info: t1.+libbar-1.1.0.+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_status -d t1 -r >>/EOO
        !libbar configured 1.1.0
          foo [h1/] configured 1.1.0
            libbaz [h1/] configured 1.1.0
          libbaz configured 1.0.0 available 1.1.0
        EOO
    }

    : upgrade-repointed-dependency
    :
    {
      $cfg_create -d h1 --type host --name h1 &h1/***;
      $cfg_create -d h2 --type host --name h2 &h2/***;

      $cfg_link -d h1 h2;

      $rep_add -d h1 $rep/t7a && $rep_fetch -d h1;

      test.arguments = $regex.apply($test.arguments, cfg, h1);

      $* libbar --yes 2>!;

      $pkg_status -d h1 -r >>/EOO;
        !libbar configured 1.0.0
          foo configured 1.0.0
            libbaz configured 1.0.0
            libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $rep_add -d h1 $rep/t7b && $rep_fetch -d h1;

      $* libbar ?foo ?libbaz +{ --config-name h2 } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  new libbaz/1.1.0 \[h2.\] \(required by foo, libbar\)%
        %  drop libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(unused\)%
          drop libbaz/1.0.0 (unused)
          upgrade foo/1.1.0
          upgrade libbar/1.1.0
        continue? [Y/n] disfigured libbar/1.0.0
        disfigured foo/1.0.0
        disfigured libbaz/1.0.0
        %disfigured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %fetched libbaz/1.1.0 \[h2.\]%
        %unpacked libbaz/1.1.0 \[h2.\]%
        %purged libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        purged libbaz/1.0.0
        fetched foo/1.1.0
        unpacked foo/1.1.0
        fetched libbar/1.1.0
        unpacked libbar/1.1.0
        %configured libbaz/1.1.0 \[h2.\]%
        configured foo/1.1.0
        configured libbar/1.1.0
        %info: h1.+libbar-1.1.0.+ is up to date%
        updated libbar/1.1.0
        EOE

      $pkg_status -d h1 -r >>/EOO
        !libbar configured 1.1.0
          foo configured 1.1.0
            libbaz [h2/] configured 1.1.0
          libbaz [h2/] configured 1.1.0
        EOO
    }

    : upgrade-prerequisite-replacement
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbar --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbar configured 1.0.0
          foo [t1/.bpkg/host/] configured 1.0.0
            libbaz [t1/.bpkg/host/] configured 1.0.0
            libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $cfg_create -d t2 --name t2 &t2/***;

      $rep_add -d t2 $rep/t7a && $rep_fetch -d t2;

      test.arguments = $regex.apply($test.arguments, t1, t2);

      $* libbaz --yes 2>!;

      $cfg_link -d t1 t2 2>!;

      $rep_add -d t2 $rep/t7b && $rep_fetch -d t2;

      test.arguments = $regex.apply($test.arguments, t2, t1);

      $* libbaz +{ --config-name t2 } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  upgrade libbaz/1.1.0 \[t2.\]%
          drop libbaz/1.0.0 (unused)
        %  reconfigure libbar/1.0.0 \(dependent of libbaz \[t2.\]\)%
        continue? [Y/n] update dependent packages? [Y/n] disfigured libbar/1.0.0
        disfigured libbaz/1.0.0
        %disfigured libbaz/1.0.0 \[t2.\]%
        %fetched libbaz/1.1.0 \[t2.\]%
        %unpacked libbaz/1.1.0 \[t2.\]%
        purged libbaz/1.0.0
        %configured libbaz/1.1.0 \[t2.\]%
        configured libbar/1.0.0
        %info: t2.+libbaz-1.1.0.+ is up to date%
        %info: t1.+libbar-1.0.0.+ is up to date%
        %updated libbaz/1.1.0 \[t2.\]%
        updated libbar/1.0.0
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libbar configured 1.0.0
          foo [t1/.bpkg/host/] configured 1.0.0
            libbaz [t1/.bpkg/host/] configured 1.0.0
            libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
          !libbaz [t2/] configured 1.1.0
        !libbaz [t2/] configured 1.1.0
        EOO
    }

    : copy-upgrade-dependency-tree
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libbar --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libbar configured 1.0.0
          foo [t1/.bpkg/host/] configured 1.0.0
            libbaz [t1/.bpkg/host/] configured 1.0.0
            libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        EOO

      $cfg_create -d t2 --name t2 &t2/***;

      $cfg_link -d t1 t2 2>!;

      $rep_add -d t2 $rep/t7b && $rep_fetch -d t2;

      $* libbar +{ --config-name t2 } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.1.0 \[t2..bpkg.host.\] \(required by foo \[t2..bpkg.host.\]\)%
        %  new foo/1.1.0 \[t2..bpkg.host.\] \(required by libbar \[t2.\]\)%
        %  new libbaz/1.1.0 \[t2.\] \(required by libbar \[t2.\]\)%
        %  new libbar/1.1.0 \[t2.\]%
        %continue\? \[Y/n\] fetched libbaz/1.1.0 \[t2..bpkg.host.\]%
        %unpacked libbaz/1.1.0 \[t2..bpkg.host.\]%
        %fetched foo/1.1.0 \[t2..bpkg.host.\]%
        %unpacked foo/1.1.0 \[t2..bpkg.host.\]%
        %fetched libbaz/1.1.0 \[t2.\]%
        %unpacked libbaz/1.1.0 \[t2.\]%
        %fetched libbar/1.1.0 \[t2.\]%
        %unpacked libbar/1.1.0 \[t2.\]%
        %configured libbaz/1.1.0 \[t2..bpkg.host.\]%
        %configured foo/1.1.0 \[t2..bpkg.host.\]%
        %configured libbaz/1.1.0 \[t2.\]%
        %configured libbar/1.1.0 \[t2.\]%
        %info: t2.+libbar-1.1.0.+ is up to date%
        %updated libbar/1.1.0 \[t2.\]%
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libbar configured 1.0.0
          foo [t1/.bpkg/host/] configured 1.0.0
            libbaz [t1/.bpkg/host/] configured 1.0.0
            libbuild2-bar [t1/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
        !libbar [t2/] configured 1.1.0
          foo [t2/.bpkg/host/] configured 1.1.0
            libbaz [t2/.bpkg/host/] configured 1.1.0
          libbaz [t2/] configured 1.1.0
        EOO
    }

    : repointed-dependent-indirect-dependency-upgrade
    :
    {
      $cfg_create -d t1 --name t1 &t1/***;
      $cfg_create -d t2 --name t2 &t2/***;
      $cfg_create -d h1 --name h1 --type host &h1/***;

      $cfg_link -d t1 t2 2>!;
      $cfg_link -d t1 h1 2>!;
      $cfg_link -d t2 h1 2>!;

      $rep_add -d t1 $rep/t7a && $rep_fetch -d t1;

      test.arguments = $regex.apply($test.arguments, cfg, t1);

      $* libfix --yes 2>!;

      $pkg_status -d t1 -r >>/EOO;
        !libfix configured 1.0.0
          libbar configured 1.0.0
            foo [h1/] configured 1.0.0
              libbaz [h1/] configured 1.0.0
              libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          libbox configured 1.0.0
            foo [h1/] configured 1.0.0
              libbaz [h1/] configured 1.0.0
              libbuild2-bar [h1/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          libfax configured 1.0.0
        EOO

      $rep_add -d t1 $rep/t7b && $rep_fetch -d t1;
      $rep_add -d t2 $rep/t7b && $rep_fetch -d t2;
      $rep_add -d h1 $rep/t7b && $rep_fetch -d h1;

      $* libfix libfax +{ --config-name t2 } foo +{ --config-name h1 } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  new libfax/1.0.0 \[t2.\]%
        %  upgrade libbaz/1.1.0 \[h1.\] \(required by foo \[h1.\]\)%
        %  drop libbuild2-bar/1.0.0 \[h1..bpkg.build2.\] \(unused\)%
        %  upgrade foo/1.1.0 \[h1.\]%
        %  reconfigure libbox \(dependent of foo \[h1.\]\)%
        %  reconfigure libbar \(dependent of foo \[h1.\]\)%
        %  drop libfax/1.0.0 \(unused\)%
          reconfigure/update libfix/1.0.0
        continue? [Y/n] update dependent packages? [Y/n] disfigured libfix/1.0.0
        disfigured libfax/1.0.0
        disfigured libbar/1.0.0
        disfigured libbox/1.0.0
        %disfigured foo/1.0.0 \[h1.\]%
        %disfigured libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %disfigured libbaz/1.0.0 \[h1.\]%
        %fetched libfax/1.0.0 \[t2.\]%
        %unpacked libfax/1.0.0 \[t2.\]%
        %fetched libbaz/1.1.0 \[h1.\]%
        %unpacked libbaz/1.1.0 \[h1.\]%
        %purged libbuild2-bar/1.0.0 \[h1..bpkg.build2.\]%
        %fetched foo/1.1.0 \[h1.\]%
        %unpacked foo/1.1.0 \[h1.\]%
        purged libfax/1.0.0
        %configured libfax/1.0.0 \[t2.\]%
        %configured libbaz/1.1.0 \[h1.\]%
        %configured foo/1.1.0 \[h1.\]%
        configured libbox/1.0.0
        configured libbar/1.0.0
        configured libfix/1.0.0
        %info: t2.+libfax-1.0.0.+ is up to date%
        %info: h1.+foo-1.1.0.+ is up to date%
        %info: t1.+libfix-1.0.0.+ is up to date%
        %info: t1.+libbox-1.0.0.+ is up to date%
        %info: t1.+libbar-1.0.0.+ is up to date%
        %updated libfax/1.0.0 \[t2.\]%
        %updated foo/1.1.0 \[h1.\]%
        updated libfix/1.0.0
        updated libbox/1.0.0
        updated libbar/1.0.0
        EOE

      $pkg_status -d t1 --link -r >>/EOO
        !libfix configured 1.0.0
          libbar configured 1.0.0 available 1.1.0
            !foo [h1/] configured 1.1.0
              libbaz [h1/] configured 1.1.0
            libbaz configured 1.0.0 available 1.1.0
          libbox configured 1.0.0 available 1.1.0
            !foo [h1/] configured 1.1.0
              libbaz [h1/] configured 1.1.0
            libbaz configured 1.0.0 available 1.1.0
          !libfax [t2/] configured 1.0.0
        !libfax [t2/] configured 1.0.0
        !foo [h1/] configured 1.1.0
          libbaz [h1/] configured 1.1.0
        EOO
    }
  }

  : build2-module-dep
  :
  {
    +$clone_root_cfg && $rep_add $rep/t7a && $rep_fetch

    : private-config
    :
    {
      $clone_cfg;

      $* libbiz <<EOI 2>>~%EOE% &cfg/.bpkg/build2/*** &cfg/.bpkg/host/***;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\] \(required by foo \[cfg..bpkg.host.\]\)%
        %  new libbaz/1.0.0 \[cfg..bpkg.host.\] \(required by foo \[cfg..bpkg.host.\]\)%
        %  new foo/1.0.0 \[cfg..bpkg.host.\] \(required by libbiz\)%
        %  new libbaz/1.0.0 \[cfg..bpkg.build2.\] \(required by libbuild2-foo \[cfg..bpkg.build2.\]\)%
        %  new libbuild2-foo/1.0.0 \[cfg..bpkg.build2.\] \(required by libbiz\)%
          new libbaz/1.0.0 (required by libbiz)
          new libbiz/1.0.0
        %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %unpacked libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %fetched foo/1.0.0 \[cfg..bpkg.host.\]%
        %unpacked foo/1.0.0 \[cfg..bpkg.host.\]%
        %fetched libbaz/1.0.0 \[cfg..bpkg.build2.\]%
        %unpacked libbaz/1.0.0 \[cfg..bpkg.build2.\]%
        %fetched libbuild2-foo/1.0.0 \[cfg..bpkg.build2.\]%
        %unpacked libbuild2-foo/1.0.0 \[cfg..bpkg.build2.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched libbiz/1.0.0
        unpacked libbiz/1.0.0
        %configured libbuild2-bar/1.0.0 \[cfg..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[cfg..bpkg.host.\]%
        %configured foo/1.0.0 \[cfg..bpkg.host.\]%
        %configured libbaz/1.0.0 \[cfg..bpkg.build2.\]%
        %configured libbuild2-foo/1.0.0 \[cfg..bpkg.build2.\]%
        configured libbaz/1.0.0
        configured libbiz/1.0.0
        %info: cfg.+libbiz-1.0.0.+ is up to date%
        updated libbiz/1.0.0
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !libbiz configured 1.0.0
          foo [cfg/.bpkg/host/] configured 1.0.0
            libbaz [cfg/.bpkg/host/] configured 1.0.0
            libbuild2-bar [cfg/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-foo [cfg/.bpkg/build2/] configured 1.0.0
            libbaz [cfg/.bpkg/build2/] configured 1.0.0
        EOO

      $pkg_drop libbiz
    }

    : external-config
    :
    {
      $clone_cfg;

      $cfg_create -d cfg2 --type build2 --name cfg2 &cfg2/***;
      $cfg_link -d cfg cfg2;

      $cfg_create -d cfg3 --type host --name cfg3 &cfg3/***;
      $cfg_link -d cfg cfg3;

      $* libbiz <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[cfg3..bpkg.build2.\] \(required by foo \[cfg3.\]\)%
        %  new libbaz/1.0.0 \[cfg3.\] \(required by foo \[cfg3.\]\)%
        %  new foo/1.0.0 \[cfg3.\] \(required by libbiz\)%
        %  new libbaz/1.0.0 \[cfg2.\] \(required by libbuild2-foo \[cfg2.\]\)%
        %  new libbuild2-foo/1.0.0 \[cfg2.\] \(required by libbiz\)%
          new libbaz/1.0.0 (required by libbiz)
          new libbiz/1.0.0
        %continue\? \[Y/n\] fetched libbuild2-bar/1.0.0 \[cfg3..bpkg.build2.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg3..bpkg.build2.\]%
        %fetched libbaz/1.0.0 \[cfg3.\]%
        %unpacked libbaz/1.0.0 \[cfg3.\]%
        %fetched foo/1.0.0 \[cfg3.\]%
        %unpacked foo/1.0.0 \[cfg3.\]%
        %fetched libbaz/1.0.0 \[cfg2.\]%
        %unpacked libbaz/1.0.0 \[cfg2.\]%
        %fetched libbuild2-foo/1.0.0 \[cfg2.\]%
        %unpacked libbuild2-foo/1.0.0 \[cfg2.\]%
        fetched libbaz/1.0.0
        unpacked libbaz/1.0.0
        fetched libbiz/1.0.0
        unpacked libbiz/1.0.0
        %configured libbuild2-bar/1.0.0 \[cfg3..bpkg.build2.\]%
        %configured libbaz/1.0.0 \[cfg3.\]%
        %configured foo/1.0.0 \[cfg3.\]%
        %configured libbaz/1.0.0 \[cfg2.\]%
        %configured libbuild2-foo/1.0.0 \[cfg2.\]%
        configured libbaz/1.0.0
        configured libbiz/1.0.0
        %info: cfg.+libbiz-1.0.0.+ is up to date%
        updated libbiz/1.0.0
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !libbiz configured 1.0.0
          foo [cfg3/] configured 1.0.0
            libbaz [cfg3/] configured 1.0.0
            libbuild2-bar [cfg3/.bpkg/build2/] configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-foo [cfg2/] configured 1.0.0
            libbaz [cfg2/] configured 1.0.0
        EOO

      $pkg_drop libbiz
    }

    : build2-config
    :
    {
      $cfg_create -d cfg --type build2 &cfg/***;
      $rep_add $rep/t7a && $rep_fetch;

      $* libbiz 2>>EOE != 0
        error: build-time dependency foo in build system module configuration
          info: build system modules cannot have build-time dependencies
        info: while satisfying libbiz/1.0.0
        EOE
    }

    : duplicates
    :
    {
      $cfg_create -d cfg &cfg/***;

      $cfg_create -d cfg2 --name cfg2 &cfg2/***;
      $cfg_link -d cfg cfg2;

      $cfg_create -d cfg3 --name cfg3 &cfg3/***;
      $cfg_link -d cfg cfg3;

      $* "libbiz@$rep/t7a" +{ --config-name cfg2 } --yes --trust-yes 2>!;
      $* "libbuz@$rep/t7a" +{ --config-name cfg3 } --yes --trust-yes 2>!;

      $* "libbix@$rep/t7a" --trust-yes 2>>/~%EOE% != 0
        %(added|fetching).+%{2}
        error: building build system module libbuild2-bar in multiple configurations
        %  info: cfg(2|3)/.bpkg/build2/%{2}
        EOE
    }
  }

  : multiple-configs
  :
  {
    cfg_uuid  = '18f48b4b-b5d9-4712-b98c-1930df1c4228'
    cfg2_uuid = '28f48b4b-b5d9-4712-b98c-1930df1c4228'
    cfg3_uuid = '38f48b4b-b5d9-4712-b98c-1930df1c4228'
    cfg4_uuid = '48f48b4b-b5d9-4712-b98c-1930df1c4228'
    cfg5_uuid = '58f48b4b-b5d9-4712-b98c-1930df1c4228'

    : 2-current-configs
    :
    {
      $cfg_create -d cfg  --uuid $cfg_uuid                &cfg/***;
      $cfg_create -d cfg2 --uuid $cfg2_uuid               &cfg2/***;
      $cfg_create -d cfg3 --uuid $cfg3_uuid --type build2 &cfg3/***;

      $cfg_link -d cfg  cfg3;
      $cfg_link -d cfg2 cfg3;

      $rep_add         $rep/t7a && $rep_fetch;
      $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

      test.arguments += -d cfg2; # Now refers 2 current dirs: cfg/ and cfg2/.

      # While at it, make sure --config-uuid is only allowed for multiple
      # current configurations.
      #
      $* foo +{ --config-id 1 } 2>>EOE != 0;
        error: --config-id specified for multiple current configurations
          info: use --config-uuid to specify configurations in this mode
          info: while validating options for foo
        EOE

      $* foo +{ --config-name cfg2 } 2>>EOE != 0;
        error: --config-name specified for multiple current configurations
          info: use --config-uuid to specify configurations in this mode
          info: while validating options for foo
        EOE

      # While at it, make sure a package must have the configuration
      # specified.
      #
      $* foo 2>>EOE != 0;
        error: no configuration specified for foo
          info: configuration must be explicitly specified for each package in multi-configurations mode
          info: use --config-uuid to specify its configuration
        EOE

      # Build foo in cfg/ and cfg2/ with its libbaz dependency colocated and
      # libbuild2-bar dependency shared in cfg3/.
      #
      $* foo +{ --config-uuid $cfg_uuid --config-uuid $cfg2_uuid } <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.0.0 \[cfg.\] \(required by foo \[cfg.\]\)%
        %  new libbuild2-bar/1.0.0 \[cfg3.\] \(required by foo \[cfg.\], foo \[cfg2.\]\)%
        %  new foo/1.0.0 \[cfg.\]%
        %  new libbaz/1.0.0 \[cfg2.\] \(required by foo \[cfg2.\]\)%
        %  new foo/1.0.0 \[cfg2.\]%
        %continue\? \[Y/n\] fetched libbaz/1.0.0 \[cfg.\]%
        %unpacked libbaz/1.0.0 \[cfg.\]%
        %fetched libbuild2-bar/1.0.0 \[cfg3.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg3.\]%
        %fetched foo/1.0.0 \[cfg.\]%
        %unpacked foo/1.0.0 \[cfg.\]%
        %fetched libbaz/1.0.0 \[cfg2.\]%
        %unpacked libbaz/1.0.0 \[cfg2.\]%
        %fetched foo/1.0.0 \[cfg2.\]%
        %unpacked foo/1.0.0 \[cfg2.\]%
        %configured libbaz/1.0.0 \[cfg.\]%
        %configured libbuild2-bar/1.0.0 \[cfg3.\]%
        %configured foo/1.0.0 \[cfg.\]%
        %configured libbaz/1.0.0 \[cfg2.\]%
        %configured foo/1.0.0 \[cfg2.\]%
        %info: cfg.+foo-1.0.0.+ is up to date%
        %info: cfg2.+foo-1.0.0.+ is up to date%
        %updated foo/1.0.0 \[cfg.\]%
        %updated foo/1.0.0 \[cfg2.\]%
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [cfg3/] configured 1.0.0
        EOO

      $pkg_status -d cfg2 -r >>/EOO;
        !foo configured 1.0.0
          libbaz configured 1.0.0
          libbuild2-bar [cfg3/] configured 1.0.0
        EOO

      # Move libbuild2-bar to cfg4/ and libbaz to cfg5/.
      #
      $cfg_create -d cfg4 --uuid $cfg4_uuid --type build2 &cfg4/***;
      $cfg_create -d cfg5 --uuid $cfg5_uuid               &cfg5/***;

      $cfg_link -d cfg  cfg4;
      $cfg_link -d cfg2 cfg4;
      $cfg_link -d cfg  cfg5;
      $cfg_link -d cfg2 cfg5;

      $* ?libbuild2-bar +{ --config-uuid $cfg4_uuid } \
         ?libbaz +{ --config-uuid $cfg5_uuid } <<EOI 2>>~%EOE%;
        y
        y
        EOI
        %  new libbuild2-bar/1.0.0 \[cfg4.\] \(required by foo \[cfg.\], foo \[cfg2.\]\)%
        %  new libbaz/1.0.0 \[cfg5.\] \(required by foo \[cfg.\], foo \[cfg2.\]\)%
        %  drop libbaz/1.0.0 \[cfg2.\] \(unused\)%
        %  drop libbuild2-bar/1.0.0 \[cfg3.\] \(unused\)%
        %  reconfigure foo/1.0.0 \[cfg2.\] \(dependent of libbaz \[cfg5.\], libbuild2-bar \[cfg4.\]\)%
        %  drop libbaz/1.0.0 \[cfg.\] \(unused\)%
        %  reconfigure foo/1.0.0 \[cfg.\] \(dependent of libbaz \[cfg5.\], libbuild2-bar \[cfg4.\]\)%
        %continue\? \[Y/n\] update dependent packages\? \[Y/n\] disfigured foo/1.0.0 \[cfg.\]%
        %disfigured libbaz/1.0.0 \[cfg.\]%
        %disfigured foo/1.0.0 \[cfg2.\]%
        %disfigured libbuild2-bar/1.0.0 \[cfg3.\]%
        %disfigured libbaz/1.0.0 \[cfg2.\]%
        %fetched libbuild2-bar/1.0.0 \[cfg4.\]%
        %unpacked libbuild2-bar/1.0.0 \[cfg4.\]%
        %fetched libbaz/1.0.0 \[cfg5.\]%
        %unpacked libbaz/1.0.0 \[cfg5.\]%
        %purged libbaz/1.0.0 \[cfg2.\]%
        %purged libbuild2-bar/1.0.0 \[cfg3.\]%
        %purged libbaz/1.0.0 \[cfg.\]%
        %configured libbuild2-bar/1.0.0 \[cfg4.\]%
        %configured libbaz/1.0.0 \[cfg5.\]%
        %configured foo/1.0.0 \[cfg2.\]%
        %configured foo/1.0.0 \[cfg.\]%
        %info: cfg2.+foo-1.0.0.+ is up to date%
        %info: cfg.+foo-1.0.0.+ is up to date%
        %updated foo/1.0.0 \[cfg2.\]%
        %updated foo/1.0.0 \[cfg.\]%
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !foo configured 1.0.0
          libbaz [cfg5/] configured 1.0.0
          libbuild2-bar [cfg4/] configured 1.0.0
        EOO

      $pkg_status -d cfg2 -r >>/EOO;
        !foo configured 1.0.0
          libbaz [cfg5/] configured 1.0.0
          libbuild2-bar [cfg4/] configured 1.0.0
        EOO

      $rep_add $rep/t7b && $rep_fetch;

      $* foo ?libbaz --config-uuid $cfg_uuid <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.1.0 \[cfg.\] \(required by foo \[cfg.\]\)%
        %  upgrade foo/1.1.0 \[cfg.\]%
        %continue\? \[Y/n\] disfigured foo/1.0.0 \[cfg.\]%
        %fetched libbaz/1.1.0 \[cfg.\]%
        %unpacked libbaz/1.1.0 \[cfg.\]%
        %fetched foo/1.1.0 \[cfg.\]%
        %unpacked foo/1.1.0 \[cfg.\]%
        %configured libbaz/1.1.0 \[cfg.\]%
        %configured foo/1.1.0 \[cfg.\]%
        %info: cfg.+foo-1.1.0.+ is up to date%
        %updated foo/1.1.0 \[cfg.\]%
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !foo configured 1.1.0
          libbaz configured 1.1.0
        EOO

      $pkg_status -d cfg2 -r >>/EOO;
        !foo configured 1.0.0
          libbaz [cfg5/] configured 1.0.0
          libbuild2-bar [cfg4/] configured 1.0.0
        EOO

      $rep_add -d cfg2 $rep/t7b && $rep_fetch -d cfg2;

      $* --no-move foo +{ --config-uuid $cfg2_uuid } \
         ?libbaz +{ --config-uuid $cfg5_uuid } <<EOI 2>>~%EOE%;
        y
        EOI
        %  upgrade libbaz/1.1.0 \[cfg5.\]%
        %  drop libbuild2-bar/1.0.0 \[cfg4.\] \(unused\)%
        %  upgrade foo/1.1.0 \[cfg2.\]%
        %continue\? \[Y/n\] disfigured foo/1.0.0 \[cfg2.\]%
        %disfigured libbuild2-bar/1.0.0 \[cfg4.\]%
        %disfigured libbaz/1.0.0 \[cfg5.\]%
        %fetched libbaz/1.1.0 \[cfg5.\]%
        %unpacked libbaz/1.1.0 \[cfg5.\]%
        %purged libbuild2-bar/1.0.0 \[cfg4.\]%
        %fetched foo/1.1.0 \[cfg2.\]%
        %unpacked foo/1.1.0 \[cfg2.\]%
        %configured libbaz/1.1.0 \[cfg5.\]%
        %configured foo/1.1.0 \[cfg2.\]%
        %info: cfg2.+foo-1.1.0.+ is up to date%
        %updated foo/1.1.0 \[cfg2.\]%
        EOE

      $pkg_status -d cfg2 -r >>/EOO
        !foo configured 1.1.0
          libbaz [cfg5/] configured 1.1.0
        EOO
    }

    : variable
    :
    {
      $cfg_create -d cfg  --uuid $cfg_uuid              &cfg/***;
      $cfg_create -d cfg2 --uuid $cfg2_uuid             &cfg2/***;
      $cfg_create -d cfg3 --uuid $cfg3_uuid --type host &cfg3/***;

      $cfg_link -d cfg  cfg3;
      $cfg_link -d cfg2 cfg3;

      $rep_add         $rep/t7a && $rep_fetch;
      $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

      test.arguments += -d cfg2; # Now refers 2 current dirs: cfg/ and cfg2/.

      $* --configure-only \
         { --config-uuid $cfg_uuid  config.libbaz=true }+ libbaz \
         { --config-uuid $cfg2_uuid                    }+ libbaz 2>!;

      sed -n -e 's/^config.libbaz = (.+)$/\1/p' \
          cfg/libbaz-1.0.0/build/config.build >'true';

      sed -n -e 's/^config.libbaz = (.+)$/\1/p' \
          cfg2/libbaz-1.0.0/build/config.build >'false'
    }

    : system-dependency
    :
    {
      $cfg_create -d cfg  --uuid $cfg_uuid              &cfg/***;
      $cfg_create -d cfg2 --uuid $cfg2_uuid             &cfg2/***;
      $cfg_create -d cfg3 --uuid $cfg3_uuid --type host &cfg3/***;

      $cfg_link -d cfg  cfg3;
      $cfg_link -d cfg2 cfg3;

      $rep_add         $rep/t7a && $rep_fetch;
      $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

      test.arguments += -d cfg2; # Now refers 2 current dirs: cfg/ and cfg2/.

      $* libbox +{ --config-uuid $cfg_uuid  --config-uuid $cfg2_uuid } \
         '?sys:foo' <<EOI 2>>~%EOE%;
        y
        EOI
        %  new libbaz/1.0.0 \[cfg.\] \(required by libbox \[cfg.\]\)%
        %  configure sys:foo/\* \[cfg3.\] \(required by libbox \[cfg.\], libbox \[cfg2.\]\)%
        %  new libbox/1.0.0 \[cfg.\]%
        %  new libbaz/1.0.0 \[cfg2.\] \(required by libbox \[cfg2.\]\)%
        %  new libbox/1.0.0 \[cfg2.\]%
        %continue\? \[Y/n\] fetched libbaz/1.0.0 \[cfg.\]%
        %unpacked libbaz/1.0.0 \[cfg.\]%
        %fetched libbox/1.0.0 \[cfg.\]%
        %unpacked libbox/1.0.0 \[cfg.\]%
        %fetched libbaz/1.0.0 \[cfg2.\]%
        %unpacked libbaz/1.0.0 \[cfg2.\]%
        %fetched libbox/1.0.0 \[cfg2.\]%
        %unpacked libbox/1.0.0 \[cfg2.\]%
        %configured libbaz/1.0.0 \[cfg.\]%
        %configured sys:foo/\* \[cfg3.\]%
        %configured libbox/1.0.0 \[cfg.\]%
        %configured libbaz/1.0.0 \[cfg2.\]%
        %configured libbox/1.0.0 \[cfg2.\]%
        %info: cfg.+libbox-1.0.0.+ is up to date%
        %info: cfg2.+libbox-1.0.0.+ is up to date%
        %updated libbox/1.0.0 \[cfg.\]%
        %updated libbox/1.0.0 \[cfg2.\]%
        EOE

      $pkg_status -d cfg -r >>/EOO;
        !libbox configured 1.0.0
          foo [cfg3/] configured,system !* available 1.0.0
          libbaz configured 1.0.0
        EOO

      $pkg_status -d cfg2 -r >>/EOO
        !libbox configured 1.0.0
          foo [cfg3/] configured,system !* available 1.0.0
          libbaz configured 1.0.0
        EOO
    }

    : build2-module-different-clusters
    :
    : Test that the same module can successfully be built in 2 configurations
    : if they belong to different linked configuration clusters.
    :
    {
      $cfg_create -d cfg  --uuid $cfg_uuid  &cfg/***;
      $cfg_create -d cfg2 --uuid $cfg2_uuid &cfg2/***;

      test.arguments += -d cfg2; # Now refers 2 current dirs: cfg/ and cfg2/.

      $* "libbiz@$rep/t7a" +{ --config-uuid $cfg_uuid  } \
         "libbuz@$rep/t7a" +{ --config-uuid $cfg2_uuid } --yes --trust-yes 2>>~%EOE%
        %(added|fetching) .+%{4}
        %(fetched|unpacked) .+%{26}
        %configured .+%{13}
        %info: .+ is up to date%{2}
        %updated .+%{2}
        EOE
    }
  }

  : system
  :
  {
    +$clone_root_cfg && $rep_add $rep/t7a && $rep_fetch

    : no-config
    :
    {
      +$clone_cfg

      : linked
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $* libbox '?sys:foo' <<EOI 2>>~%EOE%;
          y
          EOI
          %  configure sys:foo/\* \[cfg2.\] \(required by libbox\)%
            new libbaz/1.0.0 (required by libbox)
            new libbox/1.0.0
          continue? [Y/n] fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbox/1.0.0
          unpacked libbox/1.0.0
          %configured sys:foo/\* \[cfg2.\]%
          configured libbaz/1.0.0
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : private-host
      :
      {
        $clone_cfg;

        $* libbox '?sys:foo' &cfg/.bpkg/host/*** <<EOI 2>>~%EOE%;
          y
          EOI
          %  configure sys:foo/\* \[cfg..bpkg.host.\] \(required by libbox\)%
            new libbaz/1.0.0 (required by libbox)
            new libbox/1.0.0
          continue? [Y/n] fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbox/1.0.0
          unpacked libbox/1.0.0
          %configured sys:foo/\* \[cfg..bpkg.host.\]%
          configured libbaz/1.0.0
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg/.bpkg/host/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : private-module
      :
      {
        $clone_cfg;

        $* libbox '?sys:libbuild2-bar' &cfg/.bpkg/host/*** &cfg/.bpkg/build2/*** <<EOI 2>>~%EOE%;
          y
          EOI
          %  configure sys:libbuild2-bar/\* \[cfg..bpkg.build2.\] \(required by foo \[cfg..bpkg.host.\]\)%
          %  new libbaz/1.0.0 \[cfg..bpkg.host.\] \(required by foo \[cfg..bpkg.host.\]\)%
          %  new foo/1.0.0 \[cfg..bpkg.host.\] \(required by libbox\)%
            new libbaz/1.0.0 (required by libbox)
            new libbox/1.0.0
          %continue\? \[Y/n\] fetched libbaz/1.0.0 \[cfg..bpkg.host.\]%
          %unpacked libbaz/1.0.0 \[cfg..bpkg.host.\]%
          %fetched foo/1.0.0 \[cfg..bpkg.host.\]%
          %unpacked foo/1.0.0 \[cfg..bpkg.host.\]%
          fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbox/1.0.0
          unpacked libbox/1.0.0
          %configured sys:libbuild2-bar/\* \[cfg..bpkg.build2.\]%
          %configured libbaz/1.0.0 \[cfg..bpkg.host.\]%
          %configured foo/1.0.0 \[cfg..bpkg.host.\]%
          configured libbaz/1.0.0
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg/.bpkg/host/] configured 1.0.0
              libbaz [cfg/.bpkg/host/] configured 1.0.0
              libbuild2-bar [cfg/.bpkg/build2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }
    }

    : config
    :
    {
      +$clone_cfg

      : linked
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $cfg_create -d cfg3 --type host --name cfg3 &cfg3/***;
        $cfg_link -d cfg cfg3;

        $* libbox '?sys:foo' +{ --config-name cfg3 } <<EOI 2>>~%EOE%;
          y
          EOI
          %  configure sys:foo/\* \[cfg3.\] \(required by libbox\)%
            new libbaz/1.0.0 (required by libbox)
            new libbox/1.0.0
          continue? [Y/n] fetched libbaz/1.0.0
          unpacked libbaz/1.0.0
          fetched libbox/1.0.0
          unpacked libbox/1.0.0
          %configured sys:foo/\* \[cfg3.\]%
          configured libbaz/1.0.0
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg3/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : src-sys
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $* libbox --yes 2>!;

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured 1.0.0
              libbaz [cfg2/] configured 1.0.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        $* '?sys:foo' <<EOI 2>>~%EOE%;
          y
          y
          EOI
          %  drop libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(unused\)%
          %  drop libbaz/1.0.0 \[cfg2.\] \(unused\)%
          %  reconfigure sys:foo/\* \[cfg2.\]%
          %  reconfigure libbox \(dependent of foo \[cfg2.\]\)%
          continue? [Y/n] update dependent packages? [Y/n] disfigured libbox/1.0.0
          %disfigured foo/1.0.0 \[cfg2.\]%
          %disfigured libbaz/1.0.0 \[cfg2.\]%
          %disfigured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbaz/1.0.0 \[cfg2.\]%
          %purged foo/1.0.0 \[cfg2.\]%
          %configured sys:foo/\* \[cfg2.\]%
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : src-sys-upgrade
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $* libbox --yes 2>!;

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured 1.0.0
              libbaz [cfg2/] configured 1.0.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        $* '?sys:foo/1.1.0' <<EOI 2>>~%EOE%;
          y
          y
          EOI
          %  drop libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(unused\)%
          %  drop libbaz/1.0.0 \[cfg2.\] \(unused\)%
          %  reconfigure sys:foo/1.1.0 \[cfg2.\]%
          %  reconfigure libbox \(dependent of foo \[cfg2.\]\)%
          continue? [Y/n] update dependent packages? [Y/n] disfigured libbox/1.0.0
          %disfigured foo/1.0.0 \[cfg2.\]%
          %disfigured libbaz/1.0.0 \[cfg2.\]%
          %disfigured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbaz/1.0.0 \[cfg2.\]%
          %purged foo/1.0.0 \[cfg2.\]%
          %configured sys:foo/1.1.0 \[cfg2.\]%
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured,system !1.1.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : src-sys-unhold
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

        $* libbox foo +{ --config-name cfg2 } --yes 2>!;

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            !foo [cfg2/] configured 1.0.0
              libbaz [cfg2/] configured 1.0.0
              libbuild2-bar [cfg2/.bpkg/build2/] configured 1.0.0
            libbaz configured 1.0.0
          EOO

        $* '?sys:foo' <<EOI 2>>~%EOE%;
          y
          y
          EOI
          %  drop libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\] \(unused\)%
          %  drop libbaz/1.0.0 \[cfg2.\] \(unused\)%
          %  reconfigure/unhold sys:foo/\* \[cfg2.\]%
          %  reconfigure libbox \(dependent of foo \[cfg2.\]\)%
          continue? [Y/n] update dependent packages? [Y/n] disfigured libbox/1.0.0
          %disfigured foo/1.0.0 \[cfg2.\]%
          %disfigured libbaz/1.0.0 \[cfg2.\]%
          %disfigured libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbuild2-bar/1.0.0 \[cfg2..bpkg.build2.\]%
          %purged libbaz/1.0.0 \[cfg2.\]%
          %purged foo/1.0.0 \[cfg2.\]%
          %configured sys:foo/\* \[cfg2.\]%
          configured libbox/1.0.0
          %info: cfg.+libbox-1.0.0.+ is up to date%
          updated libbox/1.0.0
          EOE

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }

      : sys-unhold
      :
      {
        $clone_cfg;

        $cfg_create -d cfg2 --type host --name cfg2 &cfg2/***;
        $cfg_link -d cfg cfg2;

        $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2;

        $* libbox 'sys:foo' +{ --config-name cfg2 } --yes 2>!;

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            !foo [cfg2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $* '?sys:foo';

        $pkg_status -r >>/EOO;
          !libbox configured 1.0.0
            foo [cfg2/] configured,system !* available 1.0.0
            libbaz configured 1.0.0
          EOO

        $pkg_drop libbox
      }
    }
  }
}

: deorphan
:
{
  test.arguments += --yes --plan ""

  : dependency
  :
  {
    : unhold
    :
    {
      : basics
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        $* libfoo 2>!;
        $rep_fetch $rep/t4b;

        $* libbar 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0
          EOO

        echo "" >+ libfoo/manifest;
        $rep_fetch;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0 available 1.1.0#1
          EOO

        # Deorphan libfoo/1.1.0 to libfoo/1.1.0#1.
        #
        # Note that libfoo/1.1.0 is considered as an orphan since its version
        # is replaced with 1.1.0#1 in its existing repository fragment. This is
        # in contrast to the subsequent tests where the package repository is
        # removed.
        #
        $* --deorphan libfoo 2>>~%EOE%;
            replace/upgrade libfoo/1.1.0#1
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0
          using libfoo/1.1.0#1 (external)
          configured libfoo/1.1.0#1
          configured libbar/1.1.0
          %info: .+libfoo.+ is up to date%
          %info: .+libbar-1.1.0.+ is up to date%
          updated libfoo/1.1.0#1
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        # Noop.
        #
        $* --deorphan libfoo 2>'info: nothing to build';

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        # Deorphan libfoo/1.1.0#1 to ?libfoo/1.1.0.
        #
        $rep_remove $~/libfoo/;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade/unhold libfoo/1.1.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          fetched libfoo/1.1.0
          unpacked libfoo/1.1.0
          configured libfoo/1.1.0
          configured libbar/1.1.0
          %info: .+libbar-1.1.0.+ is up to date%
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0
          EOO

        # Deorphan libfoo/1.1.0#1 to ?libfoo/1.1.0.
        #
        $rep_add --type dir libfoo/ && $rep_fetch;
        $* libfoo 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        $rep_remove $~/libfoo/;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade/unhold libfoo/1.1.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          fetched libfoo/1.1.0
          unpacked libfoo/1.1.0
          configured libfoo/1.1.0
          configured libbar/1.1.0
          %info: .+libbar-1.1.0.+ is up to date%
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0
          EOO

        $pkg_drop libbar
      }

      : basics-masked
      :
      : As above but using --mask-repository* instead of rep-remove.
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        $* libfoo 2>!;
        $rep_fetch $rep/t4b;

        $* libbar 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0
          EOO

        echo "" >+ libfoo/manifest;
        $rep_fetch;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0 available 1.1.0#1
          EOO

        # Deorphan libfoo/1.1.0 to libfoo/1.1.0#1.
        #
        # Note that libfoo/1.1.0 is considered as an orphan since its version
        # is replaced with 1.1.0#1 in its existing repository fragment. This is
        # in contrast to the subsequent tests where the package repository is
        # removed.
        #
        $* --deorphan libfoo 2>>~%EOE%;
            replace/upgrade libfoo/1.1.0#1
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0
          using libfoo/1.1.0#1 (external)
          configured libfoo/1.1.0#1
          configured libbar/1.1.0
          %info: .+libfoo.+ is up to date%
          %info: .+libbar-1.1.0.+ is up to date%
          updated libfoo/1.1.0#1
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        # Noop.
        #
        $* --deorphan libfoo 2>'info: nothing to build';

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        # Deorphan libfoo/1.1.0#1 to ?libfoo/1.1.0.
        #
        # Note that on Windows the local repository canonical name path part
        # is converted to lower case.
        #
        cn = "$canonicalize([dir_path] $~/libfoo)";
        if! $posix
          cn = $lcase([string] $cn)
        end;
        cn = "dir:$cn";

        $* --mask-repository $cn --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade/unhold libfoo/1.1.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          fetched libfoo/1.1.0
          unpacked libfoo/1.1.0
          configured libfoo/1.1.0
          configured libbar/1.1.0
          %info: .+libbar-1.1.0.+ is up to date%
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0 available 1.1.0#1
          EOO

        # Noop.
        #
        $* --mask-repository-uuid "$cfg_uuid=$cn" --deorphan ?libfoo;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0 available 1.1.0#1
          EOO

        # Deorphan libfoo/1.1.0#1 to ?libfoo/1.1.0.
        #
        $* libfoo 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        $* --mask-repository $cn --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade/unhold libfoo/1.1.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          fetched libfoo/1.1.0
          unpacked libfoo/1.1.0
          configured libfoo/1.1.0
          configured libbar/1.1.0
          %info: .+libbar-1.1.0.+ is up to date%
          updated libbar/1.1.0
          EOE

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0 available 1.1.0#1
          EOO

        # Noop.
        #
        $* --mask-repository $cn --deorphan ?libfoo;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            libfoo configured 1.1.0 available 1.1.0#1
          EOO

        $pkg_drop libbar
      }

      : drop
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        $* libfoo 2>!;
        $rep_fetch $rep/t4b;

        $* libbar 2>!;

        echo "" >+ libfoo/manifest;
        $rep_fetch;
        $* libfoo 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        $rep_remove $~/libfoo/;

        $* --deorphan ?libfoo ?libbar 2>>EOE;
            drop libfoo/1.1.0#1 (unused)
            drop libbar/1.1.0 (unused)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          purged libfoo/1.1.0#1
          purged libbar/1.1.0
          EOE

        $pkg_status -ar 2>'info: no packages in the configuration'
      }

      : drop-masked
      :
      : As above but using --mask-repository instead of rep-remove.
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        $* libfoo 2>!;
        $rep_fetch $rep/t4b;

        $* libbar 2>!;

        echo "" >+ libfoo/manifest;
        $rep_fetch;
        $* libfoo 2>!;

        $pkg_status -r libbar >>EOO;
          !libbar configured 1.1.0
            !libfoo configured 1.1.0#1
          EOO

        # Note that on Windows the local repository canonical name path part
        # is converted to lower case.
        #
        cn = "$canonicalize([dir_path] $~/libfoo)";
        if! $posix
          cn = $lcase([string] $cn)
        end;
        cn = "dir:$cn";

        $* --mask-repository $cn --deorphan ?libfoo ?libbar 2>>EOE;
            drop libfoo/1.1.0#1 (unused)
            drop libbar/1.1.0 (unused)
          disfigured libbar/1.1.0
          disfigured libfoo/1.1.0#1
          purged libfoo/1.1.0#1
          purged libbar/1.1.0
          EOE

        $pkg_status -ar 2>'info: no packages in the configuration'
      }

      : no-dependent
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        echo "" >+ libfoo/manifest;
        $rep_fetch;
        $* libfoo 2>!;

        $rep_fetch $rep/t4b;
        $rep_remove $~/libfoo/;

        $pkg_status libfoo >'!libfoo configured 1.1.0';

        $* --deorphan ?libfoo 2>>EOE;
            drop libfoo/1.1.0 (unused)
          disfigured libfoo/1.1.0
          purged libfoo/1.1.0
          EOE

        $pkg_status -ar 2>'info: no packages in the configuration'
      }

      : no-dependent-masked
      :
      : As above but using --mask-repository instead of rep-remove.
      :
      {
        $clone_root_cfg;

        cp -r $src/libfoo-1.1.0 libfoo;
        $rep_add --type dir libfoo/ && $rep_fetch;

        echo "" >+ libfoo/manifest;
        $rep_fetch;
        $* libfoo 2>!;

        $rep_fetch $rep/t4b;

        $pkg_status libfoo >'!libfoo configured 1.1.0';

        # Note that on Windows the local repository canonical name path part
        # is converted to lower case.
        #
        cn = "$canonicalize([dir_path] $~/libfoo)";
        if! $posix
          cn = $lcase([string] $cn)
        end;
        cn = "dir:$cn";

        $* --mask-repository $cn --deorphan ?libfoo 2>>EOE;
            drop libfoo/1.1.0 (unused)
          disfigured libfoo/1.1.0
          purged libfoo/1.1.0
          EOE

        $pkg_status -ar 2>'info: no packages in the configuration'
      }

      : preference
      :
      {
        $clone_root_cfg;

        tar (!$posix ? --force-local : ) -xf $src/t14d/libfoo-1.1.0+2.tar.gz &libfoo-1.1.0+2/***;
        mv libfoo-1.1.0+2 libfoo;

        $rep_add --type dir libfoo/ && $rep_fetch;

        $* libfoo 2>!;

        tar (!$posix ? --force-local : ) -xf $src/t2/libbar-1.0.0.tar.gz &libbar-1.0.0/***;
        mv libbar-1.0.0 libbar;

        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          :
          location: $rep/t14c
          role: prerequisite
          :
          location: $rep/t14d
          role: prerequisite
          :
          location: $rep/t14e
          role: prerequisite
          :
          location: $rep/t14f
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            !libfoo configured 1.1.0+2 available [1.2.0] [1.1.1] [1.1.0+3] (1.1.0+2) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Deorphan/unhold libfoo/1.1.0+2 to the exactly same version.
        #
        $rep_remove $~/libfoo/;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/update/unhold libfoo/1.1.0+2
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0+2
          fetched libfoo/1.1.0+2
          unpacked libfoo/1.1.0+2
          configured libfoo/1.1.0+2
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+2 available [1.2.0] [1.1.1] [1.1.0+3] (1.1.0+2) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+2 available [1.2.0] [1.1.1] [1.1.0+3] (1.1.0+2) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Deorphan libfoo/1.1.0+2 to the later revision of same version
        # (1.1.0+3).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          :
          location: $rep/t14c
          role: prerequisite
          :
          location: $rep/t14e
          role: prerequisite
          :
          location: $rep/t14f
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/upgrade libfoo/1.1.0+3
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0+2
          fetched libfoo/1.1.0+3
          unpacked libfoo/1.1.0+3
          configured libfoo/1.1.0+3
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+3 available [1.2.0] [1.1.1] (1.1.0+3) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+3 available [1.2.0] [1.1.1] (1.1.0+3) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Deorphan libfoo/1.1.0+3 to the later patch of same version (1.1.1).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          :
          location: $rep/t14c
          role: prerequisite
          :
          location: $rep/t14f
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/upgrade libfoo/1.1.1
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0+3
          fetched libfoo/1.1.1
          unpacked libfoo/1.1.1
          configured libfoo/1.1.1
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.1 available [1.2.0] (1.1.1) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.1 available [1.2.0] (1.1.1) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Deorphan libfoo/1.1.1 to later minor of same version (1.2.0).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          :
          location: $rep/t14c
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/upgrade libfoo/1.2.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.1
          fetched libfoo/1.2.0
          unpacked libfoo/1.2.0
          configured libfoo/1.2.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.2.0 available (1.2.0) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.2.0 available (1.2.0) [1.1.0+1] [1.1.0] [1.0.0]
          EOO

        # Deorphan libfoo/1.2.0 to latest available version (1.1.0+1).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          :
          location: $rep/t14c
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade libfoo/1.1.0+1
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.2.0
          fetched libfoo/1.1.0+1
          unpacked libfoo/1.1.0+1
          configured libfoo/1.1.0+1
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+1 available (1.1.0+1) [1.1.0] [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        # Deorphan libfoo/1.1.0+1 to latest available version (1.1.0).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          :
          location: $rep/t14b
          role: prerequisite
          EOI

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0+1 available (1.1.0+1) [1.1.0] [1.0.0]
          EOO

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade libfoo/1.1.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0+1
          fetched libfoo/1.1.0
          unpacked libfoo/1.1.0
          configured libfoo/1.1.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0 available (1.1.0) [1.0.0]
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.1.0 available (1.1.0) [1.0.0]
          EOO

        # Deorphan libfoo/1.1.0 to latest available version (1.0.0).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14a
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            reconfigure libbar (dependent of libfoo)
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.0.0 available (1.0.0)
          EOO

        # Noop.
        #
        $* --deorphan ?libfoo;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.0.0 available (1.0.0)
          EOO

        # Deorphan fails (none available).
        #
        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          EOI

        $rep_fetch;

        $* --deorphan ?libfoo 2>>/EOE != 0;
          error: unknown package libfoo
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured 1.0.0
          EOO

        $pkg_drop libbar
      }
    }

    : recursive
    :
    {
      +tar (!$posix ? --force-local : ) -xf $src/t2/libbar-1.0.0.tar.gz &libbar-1.0.0/***
      +mv libbar-1.0.0 libbar

      +cat <<"EOI" >=libbar/repositories.manifest
        : 1
        :
        location: $rep/t14b
        role: prerequisite
        :
        location: $rep/t14f
        role: prerequisite
        :
        location: $rep/t14i
        role: prerequisite
        EOI

      : immediate
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        $rep_remove $~/libbar/;
        $rep_add $rep/t2 $rep/t4b $rep/t14c && $rep_fetch;

        $* --deorphan --immediate libbar 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            replace/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available 1.1.0 (1.0.0)
            libfoo configured !1.0.0 available 1.1.0+1 [1.1.0] (1.0.0)
          EOO

        $pkg_drop libbar
      }

      : immediate-masked
      :
      : As above but using --mask-repository instead of rep-remove.
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        $rep_add $rep/t2 $rep/t4b $rep/t14c && $rep_fetch;

        # Note that on Windows the local repository canonical name path part
        # is converted to lower case.
        #
        cn = "$canonicalize([dir_path] $~/libbar)";
        if! $posix
          cn = $lcase([string] $cn)
        end;
        cn = "dir:$cn";

        $* --mask-repository $cn --deorphan --immediate libbar 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            replace/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available 1.1.0 (1.0.0)
            libfoo configured !1.0.0 available [1.2.0] [1.1.1] 1.1.0+1 [1.1.0] (1.0.0)
          EOO

        $pkg_drop libbar
      }

      : recursive
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        $rep_remove $~/libbar/;
        $rep_add $rep/t2 $rep/t4b $rep/t14c && $rep_fetch;

        $* --deorphan --recursive libbar 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            replace/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available 1.1.0 (1.0.0)
            libfoo configured !1.0.0 available 1.1.0+1 [1.1.0] (1.0.0)
          EOO

        $pkg_drop libbar
      }

      : deorphan-immediate
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14f
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan-immediate libbar 2>>~%EOE%;
            replace/upgrade libfoo/1.1.1
            reconfigure/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.1.1
          unpacked libfoo/1.1.1
          configured libfoo/1.1.1
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.1 available [1.2.0] (1.1.1)
          EOO

        $pkg_drop libbar
      }

      : deorphan-recursive
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $rep_add $rep/t3 && $rep_fetch;
        $* libbaz 2>!;

        $pkg_status -or libbaz >>EOO;
          !libbaz configured 1.0.0 available (1.0.0)
            !libbar configured 1.0.0 available (1.0.0)
              libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0) [1.0.0]
          EOO

        cat <<"EOI" >=libbar/repositories.manifest;
          : 1
          :
          location: $rep/t14f
          role: prerequisite
          :
          location: $rep/t14i
          role: prerequisite
          EOI

        $rep_fetch;

        $* --deorphan-recursive libbaz 2>>~%EOE%;
            replace/upgrade libfoo/1.1.1
            reconfigure libbar (dependent of libfoo)
            reconfigure/update libbaz/1.0.0
          disfigured libbaz/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.1.1
          unpacked libfoo/1.1.1
          configured libfoo/1.1.1
          configured libbar/1.0.0
          configured libbaz/1.0.0
          %info: .+libbaz.+ is up to date%
          %info: .+libbar.+ is up to date%
          updated libbaz/1.0.0
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbaz >>EOO;
          !libbaz configured 1.0.0 available (1.0.0)
            !libbar configured 1.0.0 available (1.0.0)
              libfoo configured !1.1.1 available [1.2.0] (1.1.1) [1.0.0]
          EOO

        $pkg_drop libbaz libbar
      }
    }

    : recursive-all-held
    :
    : As above but uses 'deorphan all held packages form'.
    :
    {
      +tar (!$posix ? --force-local : ) -xf $src/t2/libbar-1.0.0.tar.gz &libbar-1.0.0/***
      +mv libbar-1.0.0 libbar

      +cat <<"EOI" >=libbar/repositories.manifest
        : 1
        :
        location: $rep/t14b
        role: prerequisite
        :
        location: $rep/t14f
        role: prerequisite
        :
        location: $rep/t14i
        role: prerequisite
        EOI

      : immediate
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        $rep_remove $~/libbar/;
        $rep_add $rep/t2 $rep/t4b $rep/t14c && $rep_fetch;

        $* --deorphan --immediate 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            replace/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available 1.1.0 (1.0.0)
            libfoo configured !1.0.0 available 1.1.0+1 [1.1.0] (1.0.0)
          EOO

        $pkg_drop libbar
      }

      : recursive
      :
      {
        $clone_root_cfg;
        cp -rp ../libbar ./;

        $rep_add --type dir libbar/ && $rep_fetch;
        $* libbar ?libfoo/1.1.0 2>!;

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available (1.0.0)
            libfoo configured !1.1.0 available [1.2.0] [1.1.1] (1.1.0)
          EOO

        $rep_remove $~/libbar/;
        $rep_add $rep/t2 $rep/t4b $rep/t14c && $rep_fetch;

        $* --deorphan --recursive 2>>~%EOE%;
            replace/downgrade libfoo/1.0.0
            replace/update libbar/1.0.0
          disfigured libbar/1.0.0
          disfigured libfoo/1.1.0
          fetched libfoo/1.0.0
          unpacked libfoo/1.0.0
          fetched libbar/1.0.0
          unpacked libbar/1.0.0
          configured libfoo/1.0.0
          configured libbar/1.0.0
          %info: .+libbar.+ is up to date%
          updated libbar/1.0.0
          EOE

        $pkg_status -or libbar >>EOO;
          !libbar configured 1.0.0 available 1.1.0 (1.0.0)
            libfoo configured !1.0.0 available 1.1.0+1 [1.1.0] (1.0.0)
          EOO

        $pkg_drop libbar
      }
    }
  }

  : held
  :
  {
    : basics
    :
    {
      $clone_root_cfg;

      cp -r $src/libfoo-1.1.0 libfoo;
      sed -i -e 's/(version:).+/\1 1.0.0/' libfoo/manifest;

      $rep_add --type dir libfoo/ && $rep_fetch;

      $* libfoo 2>!;

      echo "" >+ libfoo/manifest;
      $rep_fetch;

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0 available 1.0.0#1
        EOO

      # Deorphan libfoo/1.0.0 to libfoo/1.0.0#1.
      #
      $* --deorphan libfoo 2>>~%EOE%;
          replace/upgrade libfoo/1.0.0#1
        disfigured libfoo/1.0.0
        using libfoo/1.0.0#1 (external)
        configured libfoo/1.0.0#1
        %info: .+libfoo.+ is up to date%
        updated libfoo/1.0.0#1
        EOE

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0#1 available (1.0.0#1)
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $rep_fetch $rep/t4a $rep/t4c;

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0#1 available 1.1.0 (1.0.0#1) 1.0.0
        EOO

      # Deorphan libfoo/1.0.0#1 to libfoo/1.0.0.
      #
      $rep_remove $~/libfoo/;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/downgrade libfoo/1.0.0
        disfigured libfoo/1.0.0#1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+libfoo-1.0.0.+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.0.0 available 1.1.0';

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status libfoo >'!libfoo configured 1.0.0 available 1.1.0';

      # Deorphan libfoo/1.0.0 to libfoo/1.1.0.
      #
      $rep_remove $rep/t4c;

      # While at it, use the 'deorphan all held packages' form.
      #
      $* --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.0
        disfigured libfoo/1.0.0
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        configured libfoo/1.1.0
        %info: .+libfoo-1.1.0.+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.1.0';

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status libfoo >'!libfoo configured 1.1.0';

      $pkg_drop libfoo
    }

    : basics-masked
    :
    : As above but using --mask-repository instead of rep-remove.
    :
    {
      $clone_root_cfg;

      cp -r $src/libfoo-1.1.0 libfoo;
      sed -i -e 's/(version:).+/\1 1.0.0/' libfoo/manifest;

      $rep_add --type dir libfoo/ && $rep_fetch;

      $* libfoo 2>!;

      echo "" >+ libfoo/manifest;
      $rep_fetch;

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0 available 1.0.0#1
        EOO

      # Deorphan libfoo/1.0.0 to libfoo/1.0.0#1.
      #
      $* --deorphan libfoo 2>>~%EOE%;
          replace/upgrade libfoo/1.0.0#1
        disfigured libfoo/1.0.0
        using libfoo/1.0.0#1 (external)
        configured libfoo/1.0.0#1
        %info: .+libfoo.+ is up to date%
        updated libfoo/1.0.0#1
        EOE

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0#1 available (1.0.0#1)
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $rep_fetch $rep/t4a $rep/t4c;

      $pkg_status -ro libfoo >>EOO;
        !libfoo configured 1.0.0#1 available 1.1.0 (1.0.0#1) 1.0.0
        EOO

      # Deorphan libfoo/1.0.0#1 to libfoo/1.0.0.
      #
      # Note that on Windows the local repository canonical name path part is
      # converted to lower case.
      #
      cn = "$canonicalize([dir_path] $~/libfoo)";
      if! $posix
        cn = $lcase([string] $cn)
      end;
      cn = "dir:$cn";

      $* --mask-repository $cn --deorphan libfoo 2>>~%EOE%;
          replace/downgrade libfoo/1.0.0
        disfigured libfoo/1.0.0#1
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+libfoo-1.0.0.+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.0.0 available 1.1.0 1.0.0#1';

      # Noop.
      #
      $* --mask-repository $cn --deorphan libfoo 2>'info: nothing to build';

      $pkg_status libfoo >'!libfoo configured 1.0.0 available 1.1.0 1.0.0#1';

      # Deorphan libfoo/1.0.0 to libfoo/1.1.0.
      #
      # While at it, use the 'deorphan all held packages' form.
      #
      $* --mask-repository $cn --mask-repository $rep/t4c --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.0
        disfigured libfoo/1.0.0
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        configured libfoo/1.1.0
        %info: .+libfoo-1.1.0.+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status libfoo >'!libfoo configured 1.1.0';

      # Noop.
      #
      $* --mask-repository $cn --mask-repository $rep/t4c --deorphan libfoo \
         2>'info: nothing to build';

      $pkg_status libfoo >'!libfoo configured 1.1.0';

      $pkg_drop libfoo
    }

    : preference
    :
    {
      $clone_root_cfg;

      tar (!$posix ? --force-local : ) -xf $src/t14d/libfoo-1.1.0+2.tar.gz &libfoo-1.1.0+2/***;
      mv libfoo-1.1.0+2 libfoo;

      $rep_add --type dir libfoo/ && $rep_fetch;

      $* libfoo 2>!;

      $rep_fetch $rep/t14a $rep/t14b $rep/t14c $rep/t14d $rep/t14e $rep/t14f $rep/t14i;

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the exactly same version.
      #
      $rep_remove $~/libfoo/;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/update libfoo/1.1.0+2
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+2
        unpacked libfoo/1.1.0+2
        configured libfoo/1.1.0+2
        %info: .+libfoo-1.1.0\+2.+ is up to date%
        updated libfoo/1.1.0+2
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the later revision of same version (1.1.0+3).
      #
      $rep_remove $rep/t14d;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/upgrade libfoo/1.1.0+3
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+3
        unpacked libfoo/1.1.0+3
        configured libfoo/1.1.0+3
        %info: .+libfoo-1.1.0\+3.+ is up to date%
        updated libfoo/1.1.0+3
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+3 to the later patch of same version (1.1.1).
      #
      $rep_remove $rep/t14e;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/upgrade libfoo/1.1.1
        disfigured libfoo/1.1.0+3
        fetched libfoo/1.1.1
        unpacked libfoo/1.1.1
        configured libfoo/1.1.1
        %info: .+libfoo-1.1.1.+ is up to date%
        updated libfoo/1.1.1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.1 to later minor of same version (1.2.0).
      #
      $rep_remove $rep/t14f;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/upgrade libfoo/1.2.0
        disfigured libfoo/1.1.1
        fetched libfoo/1.2.0
        unpacked libfoo/1.2.0
        configured libfoo/1.2.0
        %info: .+libfoo-1.2.0.+ is up to date%
        updated libfoo/1.2.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.2.0 to latest available version (1.1.0+1).
      #
      $rep_remove $rep/t14i;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0+1
        disfigured libfoo/1.2.0
        fetched libfoo/1.1.0+1
        unpacked libfoo/1.1.0+1
        configured libfoo/1.1.0+1
        %info: .+libfoo-1.1.0\+1.+ is up to date%
        updated libfoo/1.1.0+1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+1 to latest available version (1.1.0).
      #
      $rep_remove $rep/t14c;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0
        disfigured libfoo/1.1.0+1
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        configured libfoo/1.1.0
        %info: .+libfoo-1.1.0.+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available (1.1.0) 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available (1.1.0) 1.0.0
        EOO

      # Deorphan libfoo/1.1.0 to latest available version (1.0.0).
      #
      $rep_remove $rep/t14b;

      $* --deorphan libfoo 2>>~%EOE%;
          replace/downgrade libfoo/1.0.0
        disfigured libfoo/1.1.0
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+libfoo-1.0.0.+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available (1.0.0)
        EOO

      # Noop.
      #
      $* --deorphan libfoo 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available (1.0.0)
        EOO

      # Deorphan fails (none available).
      #
      $rep_remove $rep/t14a;

      $* --deorphan libfoo 2>>/EOE != 0;
        error: unknown package libfoo
          info: configuration cfg/ has no repositories
          info: use 'bpkg rep-add' to add a repository
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0
        EOO

      $pkg_drop libfoo
    }

    : preference-all-held
    :
    : As above but uses 'deorphan all held packages form'.
    :
    {
      $clone_root_cfg;

      tar (!$posix ? --force-local : ) -xf $src/t14d/libfoo-1.1.0+2.tar.gz &libfoo-1.1.0+2/***;
      mv libfoo-1.1.0+2 libfoo;

      $rep_add --type dir libfoo/ && $rep_fetch;

      $* libfoo 2>!;

      $rep_fetch $rep/t14a $rep/t14b $rep/t14c $rep/t14d $rep/t14e $rep/t14f $rep/t14i;

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the exactly same version.
      #
      $rep_remove $~/libfoo/;

      $* --deorphan 2>>~%EOE%;
          replace/update libfoo/1.1.0+2
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+2
        unpacked libfoo/1.1.0+2
        configured libfoo/1.1.0+2
        %info: .+libfoo-1.1.0\+2.+ is up to date%
        updated libfoo/1.1.0+2
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the later revision of same version (1.1.0+3).
      #
      $rep_remove $rep/t14d;

      $* --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.0+3
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+3
        unpacked libfoo/1.1.0+3
        configured libfoo/1.1.0+3
        %info: .+libfoo-1.1.0\+3.+ is up to date%
        updated libfoo/1.1.0+3
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+3 to the later patch of same version (1.1.1).
      #
      $rep_remove $rep/t14e;

      $* --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.1
        disfigured libfoo/1.1.0+3
        fetched libfoo/1.1.1
        unpacked libfoo/1.1.1
        configured libfoo/1.1.1
        %info: .+libfoo-1.1.1.+ is up to date%
        updated libfoo/1.1.1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.1 to later minor of same version (1.2.0).
      #
      $rep_remove $rep/t14f;

      $* --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.2.0
        disfigured libfoo/1.1.1
        fetched libfoo/1.2.0
        unpacked libfoo/1.2.0
        configured libfoo/1.2.0
        %info: .+libfoo-1.2.0.+ is up to date%
        updated libfoo/1.2.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.2.0 to latest available version (1.1.0+1).
      #
      $rep_remove $rep/t14i;

      $* --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0+1
        disfigured libfoo/1.2.0
        fetched libfoo/1.1.0+1
        unpacked libfoo/1.1.0+1
        configured libfoo/1.1.0+1
        %info: .+libfoo-1.1.0\+1.+ is up to date%
        updated libfoo/1.1.0+1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+1 to latest available version (1.1.0).
      #
      $rep_remove $rep/t14c;

      $* --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0
        disfigured libfoo/1.1.0+1
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        configured libfoo/1.1.0
        %info: .+libfoo-1.1.0.+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available (1.1.0) 1.0.0
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available (1.1.0) 1.0.0
        EOO

      # Deorphan libfoo/1.1.0 to latest available version (1.0.0).
      #
      $rep_remove $rep/t14b;

      $* --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.0.0
        disfigured libfoo/1.1.0
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+libfoo-1.0.0.+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available (1.0.0)
        EOO

      # Noop.
      #
      $* --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available (1.0.0)
        EOO

      # Deorphan fails (none available).
      #
      $rep_remove $rep/t14a;

      $* --deorphan 2>>/EOE != 0;
        error: libfoo is not available
          info: configuration cfg/ has no repositories
          info: use 'bpkg rep-add' to add a repository
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0
        EOO

      $pkg_drop libfoo
    }

    : preference-all-held-masked
    :
    : As above but using --mask-repository instead of rep-remove.
    :
    {
      $clone_root_cfg;

      tar (!$posix ? --force-local : ) -xf $src/t14d/libfoo-1.1.0+2.tar.gz &libfoo-1.1.0+2/***;
      mv libfoo-1.1.0+2 libfoo;

      $rep_add --type dir libfoo/ && $rep_fetch;

      $* libfoo 2>!;

      $rep_fetch $rep/t14a $rep/t14b $rep/t14c $rep/t14d $rep/t14e $rep/t14f $rep/t14i;

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the exactly same version.
      #
      # Note that on Windows the local repository canonical name path part is
      # converted to lower case.
      #
      cn = "$canonicalize([dir_path] $~/libfoo)";
      if! $posix
        cn = $lcase([string] $cn)
      end;
      cn = "dir:$cn";

      mask = --mask-repository $cn;

      $* $mask --deorphan 2>>~%EOE%;
          replace/update libfoo/1.1.0+2
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+2
        unpacked libfoo/1.1.0+2
        configured libfoo/1.1.0+2
        %info: .+libfoo-1.1.0\+2.+ is up to date%
        updated libfoo/1.1.0+2
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+2 available 1.2.0 1.1.1 1.1.0+3 (1.1.0+2) 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+2 to the later revision of same version (1.1.0+3).
      #
      mask += --mask-repository $rep/t14d;

      $* $mask --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.0+3
        disfigured libfoo/1.1.0+2
        fetched libfoo/1.1.0+3
        unpacked libfoo/1.1.0+3
        configured libfoo/1.1.0+3
        %info: .+libfoo-1.1.0\+3.+ is up to date%
        updated libfoo/1.1.0+3
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+3 available 1.2.0 1.1.1 (1.1.0+3) 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+3 to the later patch of same version (1.1.1).
      #
      mask += --mask-repository $rep/t14e;

      $* $mask --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.1.1
        disfigured libfoo/1.1.0+3
        fetched libfoo/1.1.1
        unpacked libfoo/1.1.1
        configured libfoo/1.1.1
        %info: .+libfoo-1.1.1.+ is up to date%
        updated libfoo/1.1.1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.1 available 1.2.0 (1.1.1) 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.1 to later minor of same version (1.2.0).
      #
      mask += --mask-repository $rep/t14f;

      $* $mask --deorphan 2>>~%EOE%;
          replace/upgrade libfoo/1.2.0
        disfigured libfoo/1.1.1
        fetched libfoo/1.2.0
        unpacked libfoo/1.2.0
        configured libfoo/1.2.0
        %info: .+libfoo-1.2.0.+ is up to date%
        updated libfoo/1.2.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.2.0 available (1.2.0) 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.2.0 to latest available version (1.1.0+1).
      #
      mask += --mask-repository $rep/t14i;

      $* $mask --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0+1
        disfigured libfoo/1.2.0
        fetched libfoo/1.1.0+1
        unpacked libfoo/1.1.0+1
        configured libfoo/1.1.0+1
        %info: .+libfoo-1.1.0\+1.+ is up to date%
        updated libfoo/1.1.0+1
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0+1 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 (1.1.0+1) 1.1.0 1.0.0
        EOO

      # Deorphan libfoo/1.1.0+1 to latest available version (1.1.0).
      #
      mask += --mask-repository $rep/t14c;

      $* $mask --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.1.0
        disfigured libfoo/1.1.0+1
        fetched libfoo/1.1.0
        unpacked libfoo/1.1.0
        configured libfoo/1.1.0
        %info: .+libfoo-1.1.0.+ is up to date%
        updated libfoo/1.1.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 (1.1.0) 1.0.0
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.1.0 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 (1.1.0) 1.0.0
        EOO

      # Deorphan libfoo/1.1.0 to latest available version (1.0.0).
      #
      mask += --mask-repository $rep/t14b;

      $* $mask --deorphan 2>>~%EOE%;
          replace/downgrade libfoo/1.0.0
        disfigured libfoo/1.1.0
        fetched libfoo/1.0.0
        unpacked libfoo/1.0.0
        configured libfoo/1.0.0
        %info: .+libfoo-1.0.0.+ is up to date%
        updated libfoo/1.0.0
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 (1.0.0)
        EOO

      # Noop.
      #
      $* $mask --deorphan 2>'info: nothing to build';

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 (1.0.0)
        EOO

      # Deorphan fails (none available).
      #
      mask += --mask-repository $rep/t14a;

      $* $mask --deorphan 2>>/EOE != 0;
        error: libfoo is not available
        EOE

      $pkg_status -o libfoo >>EOO;
        !libfoo configured 1.0.0 available 1.2.0 1.1.1 1.1.0+3 1.1.0+2 1.1.0+1 1.1.0 (1.0.0)
        EOO

      $pkg_drop libfoo
    }
  }
}
