UPack Documentation

Assembling Virtual Package Contents

  • Last Modified: 2019-02-14

Virtual packages are essentially pointers to other packages and resources, and before consuming a virtual package, it must be "assembled" into a regular package first.

Assembling a virtual package basically involves following the resource pointers and combining the contents of those resources. Once you do that, it's totally indistinguishable from a regular package, and thus it is no longer considered "virtual". Thus, it's a one-way operation.

To assemble a virtual package, the following logic must be used.

  • The contents array is enumerated; each resources is assessed as follows:
    • If it's a file resource: the contents are downloaded, verified (if a hash is specified), and written to the target virtual path. A directory is created if it doesn't exist, and a file is overwritten if it already exists.
    • If it's a package resource: the current package source is queried for the specified package (including hash). The contents are then extracted to the target virtual path, overwriting any existing files.
  • The metaContents array is enumerated; each resources is assessed as follows:
    • If the virtualPath is upack.json or within the packages directory: the operation fails
    • If it's a file resource: the contents are downloaded, verified (if a hash is specified), and written to the target virtual path. A directory is created if it doesn't exist, and a file is overwritten if it already exists.
    • If it's a package resource: the current package source is queried for the specified package (including hash). The contents are then extracted to the target virtual path, overwriting any existing files.
  • If any error occurs during assembly, then the entire operation fails.

Is this documentation incorrect or incomplete? Help us by contributing!

This documentation is licensed under CC-BY-SA-4.0 and stored in GitHub.