I was confused of exactly what order various functions of the install/unintsall script run with a package.

This is what my tests show (Joomla 3.10)

Assuming a package with a number of elements (plugins in this case)

On install the following order of functions:

  1. Package preflight()
  2. plugin1 preflight()
  3. plugin1 install()
  4. plugin1 postflight()
  5. plugin2 preflight()
  6. plugin2 install()
  7. plugin2 postflight()
  8. ... and so on for any other extensions in the order that they appear in the package xml
  9. Package install()
  10. Package postflight()

So the package install() and postflight() are run after all the extensions have installed

The extensions can generate messages $app->enqueueMessage() which will display, but any html output echo'd in their functions will not be shown (unless passed to the message queue

For a given message type the messages will appear in one block in the order in which they are generated.

 

For uninstall the following order applies

  1. Package uninstall()
  2. plugin1 preflight()
  3. plugin1 uninstall()
  4. plugin2 preflight()
  5. plugin2 uninstall()

Note that Package preflight() does not run, but the extension preflight()s do.

None of the postflights() run

The extension order is again as found in the package xml file

With two components it goes like this

Install:

  1. pkg preflight install
  2. people preflight install
  3. people install
  4. people postflight install
  5. book preflight install
  6. book install
  7. book postflight install
  8. pkg install
  9. pkg postflight install
 
Update:
  1. pkg preflight update
  2. people preflight update
  3. people update
  4. people postflight update
  5. book preflight update
  6. book update
  7. book postflight update
  8. pkg update
  9. pkg postflight update
 
Uninstall:
  1. pkg uninstall
  2. people uninstall
  3. book uninstall
 
In this case no preflights run at all, and again postflight doesn't run