Skip to content
James Reynolds edited this page Nov 17, 2022 · 24 revisions

Welcome to the pantry.zero wiki!

Creating Packages

There are 2 ways of creating packages. You can create your own pantry, or you can contribute a package.

Create Your Own Pantry

The packages contained in your fork will be searchable when using tea/cli itself. Thus decentralizing the upkeep of the open source package graph.

Forks of specific pantries will also be able to inherit functionality from those pantries.

This is not built yet, but it’s a near term goal.

Contribute a Package

  • Fork pantry.extra.
  • Create a branch for your new package (git checkout -b example.com).
  • Complete step-by-step section.
  • Submit a pull request for your packages. Once they are stable and if otherwise deemed appropriate we will move them to pantry.core.

Step-by-step

Here is an example session starting from scratch. You should replace "example.com/your.pantry.git" with the url of your pantry (assuming you renamed your fork). You should replace projects/example.com with the domain of the package. If you are in doubt about what domain to use, look at the existing names in pantry.core/projects and pantry.extra/projects. For example, if you were building a package for the product Ansible, you'd use projects/ansible.com because the Ansible product has that domain registered to them. If they don't have a domain for their product, I don't know what you should use.

sh <(curl https://tea.xyz)
mkdir pkgdev
cd pkgdev
git clone https://github.com/example.com/your.pantry.git
git clone https://github.com/teaxyz/cli.git
git clone https://github.com/teaxyz/pantry.core.git
mkdir your.pantry/projects/example.com
touch your.pantry/projects/example.com/package.yml

Edit your.pantry/projects/example.com/package.yml.

Editing package.yml

The best way to get started is to find an existing package.yml that is as close to what you need and copy it. You've already downloaded pantry.core, download pantry.extra too.

git clone https://github.com/teaxyz/pantry.core.git

Now grep it to see if there's something like what you need. For example, if you're building a python package, grep for python.

Also, check out the Packaging Guide and package.yml documentation.

Here is the simplest package.yml file.

distributable:
  url: https://example.com/download/{{version}}/src.tar.gz
  strip-components: 1

versions:
  - 1.0.0

build:
  script: |
    touch "{{prefix}}"/example

test:
  script: |
    ls -l
  working-directory: build

The "build" -> "script" section must create something in "{{prefix}}" or else the build will fail. "{{prefix}}" is "$TEA_PREFIX/example.com/v1.0.0".

Personal Access Token

Before you can build you need a GitHub PAT if the package.yml script gets versions from GitHub. In other words, this code requires a PAT.

versions:
  github: user/project/tags

This code doesn't require a PAT.

versions:
  - 1.0.0.

Here's the instructions for creating a (classic) personal access token. Then add it to the shell environment like the following.

export GITHUB_TOKEN=ghp_secret

Build

export TEA_PANTRY_PATH="$PWD/your.pantry"
./pantry.core/scripts/build.ts example.com

Test

Packages require a test YAML node. This script should thoroughly verify all the functionality of the package is working. You can run the test with:

pantry.core/scripts/test.ts pkg.com

tea requires all packages be relocatable and cross platform. Our CI will verify this for you. You can check locally by moving the installation from ~/.tea to another tea installation (eg. ~/scratch/tea§ and running the test again.

Now make a pull request! We’ll test on all platforms we support in the PR. If it passes both CI and review: we’ll merge!

§ TEA_PREFIX=~/scratch/tea sh <(curl tea.xyz)

After Your Contribution

We build “bottles” (tar’d binaries) and upload them to both our centralized bottle storage and decentralized IPFS.

tea automatically builds new releases of packages as soon as they are released (usually starting the builds within seconds). There is no need to submit PRs for updates.

Basics

Advanced

^^ Guides for specific build tools and scenarios

Appendix

Clone this wiki locally