init_mega.py is a standalone Mega initialization script. After the Mega service is up, it runs a set of “import/initialization” workflows:
- Buckal Bundles import: clones the
toolchainsrepo, vendors thebuckal-bundlesrepo into it and commits the changes, then uses the Mega API to find and merge the corresponding CL. - Libra dependency import: clones the
librarepo and calls the in-repo scriptscripts/import-buck2-deps/import-buck2-deps.pyto import Buck2 dependencies underthird-party/into Mega.
This script is extracted from the server-side initialization logic so you can run initialization manually (locally or in CI) without relying on the server’s internal startup flow.
- Python 3
- Git (available on the command line)
- A reachable Mega service (HTTP/HTTPS)
--base-url BASE_URL- Mega service base URL (default:
https://git.gitmega.com). Use this to point to a local/dev server, for example:http://127.0.0.1:8000
- Mega service base URL (default:
--skip-buckal- Skip the Buckal Bundles workflow
--skip-libra- Skip the Libra workflow
Run full initialization (use default base URL):
python3 scripts/init_mega/init_mega.pyRun full initialization (override base URL):
python3 scripts/init_mega/init_mega.py --base-url http://127.0.0.1:8000Run only Buckal Bundles (skip Libra, override base URL):
python3 scripts/init_mega/init_mega.py --base-url http://127.0.0.1:8000 --skip-libraRun only Libra (skip Buckal Bundles, override base URL):
python3 scripts/init_mega/init_mega.py --base-url http://127.0.0.1:8000 --skip-buckalShow help:
python3 scripts/init_mega/init_mega.py --helpThe script polls:
GET {base_url}/api/v1/status
When it returns HTTP 2xx, the service is considered ready and the script proceeds.
In a temporary directory, it performs:
- Clone
toolchains:
git clone {base_url}/toolchains.git
- Configure the commit identity (repo-local):
git config user.email mega-bot@example.comgit config user.name Mega Bot
- Clone
buckal-bundlesinside thetoolchainsrepo:
git clone --depth 1 https://github.com/buck2hub/buckal-bundles.git
- Remove
buckal-bundles/.gitso it becomes a regular directory tracked bytoolchains(vendoring). - Commit and push:
git add .git commit -m "import buckal-bundles"git push
- Use Mega APIs to find and merge the corresponding CL:
POST {base_url}/api/v1/cl/list(paginate open CLs and matchtitle == "import buckal-bundles")POST {base_url}/api/v1/cl/{link}/merge-no-auth
Also in a temporary directory:
- Clone
libra:
git clone https://github.com/gitmono-dev/libra.git .
- Use
third-party/in the temporary directory as the scan root, and call the existing in-repo import script:
python3 scripts/import-buck2-deps/import-buck2-deps.py --scan-root <temp>/third-party --git-base-url {base_url} ...
- The script runs
git push, so your machine must have push access/authentication to the Git service behind{base_url}. - CL discovery for Buckal Bundles depends on an exact title match:
import buckal-bundles(customize via theCOMMIT_MSGconstant in the script if needed). - This script does not start the Mega service. Start the service first, then run the script.