···55requests to fix and enhance the quality of packages are always
66welcome. Thanks for your time and involvement.
7788-Becoming the maintainer of orphaned packages is
99-[easy](#adopting-and-relinquishing-package-maintainership) and very
1010-welcome.
1111-1212-The following lists a few points that help in making the contribution
1313-process and repository management as smooth and efficient as possible
1414-for everyone involved.
1515-1616-Note that if your have an issue with the opam tool itself this
1717-should not be filed here but on the opam tool
1818-[issue tracker](https://github.com/ocaml/opam/issues).
88+Table of content:
99+* [Add a new package](#add-a-new-package)
1010+* [Fixing packages](#fixing-packages)
1111+* [Governance](#governance)
1212+* [Policies](#policies)
1313+* [How to deal with CI](#how-to-deal-with-ci)
19142020-Reporting package installation issues
2121--------------------------------------
1515+Add a new package
1616+-----------------
22172323-To report package installation issues:
2424-2525-1. First try to search the issue tracker to see if someone already
2626- reported the issue. If that is the case mention on this issue that
2727- you are also affected and, if available, add more diagnostic details.
2828-2. If you create a new issue make sure the issue title mentions the
2929- package name and the affected version.
3030-3. Try to give as much information as possible about your setup in
3131- the issue body:
3232- 1. Add the output of `opam config report`
3333- 2. Add the exact opam invocation and the resulting tool output.
3434-3535-Fixing packages
3636----------------
3737-3838-If you happen to have a fix for a package, please have a look at the
3939-issue tracker to see if it doesn't concern an existing issue. If that
4040-is the case mention it in your pull request.
4141-4242-Adding new packages
4343--------------------
1818+There are several ways to add a new package to opam-repository.
1919+You can either use a tool such as `dune-release` or `opam-publish`, or open a PR manually.
2020+Each ones have their strenghts and weaknesses. For example:
2121+* `dune-release` is a tool more focused into helping people do their whole release process from start to finish for them. To that end it:
2222+ * helps with tagging
2323+ * parses (and enforces a format, can be good or bad) for the changelog, to put it in the tag
2424+ * creates the github release with that information
2525+ * builds, run tests, lint
2626+ * uploads the documentation
2727+ * creates and uploads a separate archive (also has an option to include the git submodules)
2828+ * works only if your project is on GitHub
2929+ * doesn’t support force-pushed tags
3030+* `opam-publish` is a more malleable tool focused on publishing. To that end it:
3131+ * works for any type of projects (you can just use a custom archive as an argument)
3232+ * simpler to use than dune-release
3333+ * more focused tool so you should encounter less issues and resistance but it’s more manual
3434+ * only handles the opam linting and publishing
3535+* you can also open a PR manually:
3636+ * this one gives you the most freedom. It is only recommended for experienced users
3737+ * this is however currently the only way to fix packages (as opposed to adding packages). See the appropriate section below
44384545-Information about creating new packages and adding them to repository
4646-is available in
4747-[opam's manual](https://opam.ocaml.org/doc/Packaging.html).
3939+We'll cover each ones in the following subsections:
48404949-If you are using `dune` and hosting your git repository on `github` you can use the following tutorial that provides a step-by-step procedure to
5050-make a `hello` package available in opam.ocaml.org.
5151-If you are not using `dune` or hosting your project on `github` you can still use `opam-publish` as described by the manual page linked above.
4141+### using dune-release
52425353-The top-level sources contain the following files with the opam file having the same
5454-name of the project.
4343+*if you encounter any issues, please read [dune-release's README](https://github.com/tarides/dune-release/blob/main/README.md)*
55444545+First, make sure your project is using dune and is hosted on GitHub.
4646+Then, make sure you’ve forked opam-repository on GitHub. If not go to https://github.com/ocaml/opam-repository/fork
4747+Then, create a new file in `~/.config/dune/release.yml` with the content as indicated below, change `<username>` by your local username and `<github-user>` by your own github username:
5648```
5757-$ ls hello/
5858-5959-src/
6060-dune
6161-dune-project
6262-hello.opam
4949+remote: git@github.com:<github-username>/opam-repository.git
5050+local: /home/<username>/.cache/dune/opam-repository/
5151+```
5252+Then, you can tag the release using:
5353+```
5454+dune-release tag
6355```
6464-6565-A quick summary of the steps to be followed are listed below:
6666-5656+Once done, you can simply call:
6757```
6868-$ dune build
6969-$ dune-release lint
7070-$ dune-release tag
7171-$ dune-release distrib
7272-$ dune-release publish
7373-$ dune-release opam pkg
7474-$ dune-release opam submit
5858+dune release
7559```
6060+If all goes well this should create the Release on GitHub and open the PR to publish the package on opam-repository.
76617777-We will now go through each of the above commands in detail:
6262+For any subsequent releases only the last two steps are necessary.
78637979-* `dune build`
6464+### using opam-publish
80658181-The OCaml source package needs to be built with `dune`, `dune-project`
8282-and `.opam` files along with the sources. The build should be
8383-successful before proceeding further. For example:
6666+*if you encounter any issues, please read [opam-publish's README](https://github.com/ocaml-opam/opam-publish/blob/master/README.md)*
84676868+Once you have done your release and have an archive available publicly on the internet, simply call:
8569```
8686-$ dune build
8787-Done: 56/61 (jobs: 1)
7070+opam-publish <url>
8871```
7272+This will open the PR to publish the package on opam-repository.
89739090-* `dune-release lint`
7474+For other options, please refer to `opam-publish --help`
91759292-The `lint` command checks for the presence of meta files in the
9393-project folder, and also runs `opam lint`. A sample output is given
9494-below for your reference:
7676+### publish manually
95777878+An opam repository is a tree-like structure of directories and files as follow:
9679```
9797-$ dune-release lint
9898-[ OK ] File README is present.
9999-[ OK ] File LICENSE is present.
100100-[ OK ] File CHANGES is present.
101101-[ OK ] File opam is present.
102102-[ OK ] lint opam file hello.opam.
103103-[ OK ] opam field description is present
104104-[ OK ] opam fields homepage and dev-repo can be parsed by dune-release
105105-[ OK ] Skipping doc field linting, no doc field found
106106-[ OK ] lint /home/guest/hello success
8080+./
8181+|- packages/
8282+ |- pkgname/
8383+ | |- pkgname.2.0/
8484+ | |- opam
8585+ |- another-pkgname/
8686+ |- another-pkgname.1.0.0/
8787+ | |- opam
8888+ | |- files/
8989+ | |- fix1.patch
9090+ | |- fix2.patch
9191+ |- another-pkgname.1.0.1/
9292+ |- opam
9393+|- ...
10794```
108108-109109-You need to fix any errors reported by linting, and commit the changes
110110-locally.
111111-112112-* `dune-release tag`
113113-114114-A ChangeLog `CHANGES` file is required, and the format used is
115115-available in the
116116-[dune-release](https://github.com/ocamllabs/dune-release)
117117-documentation. A minimal example is as follows:
118118-9595+So to add a package, simply create a directory with your package name (pkgname) and version
11996```
120120-$ cat CHANGES
121121-122122-## v0.0.1 (2021-02-23)
123123-### Added
124124-- Meta files for dune release
9797+mkdir -p packages/pkgname/pkgname.version/
12598```
126126-127127-After updating the CHANGES file, you need to tag the release. You will
128128-be prompted to confirm the version, as can be seen in the following
129129-output:
130130-9999+once done, copy the opam file for said package into the newly created directory.
100100+Edit that copied opam file by removing redundant or forbidden fields such as `name`, `version`, `pin-depends` if present, as well as adding or editing the `url` section as follow:
131101```
132132-$ dune-release tag
133133-[-] Extracting tag from first entry in CHANGES
134134-[-] Using tag "v0.0.1"
135135-[?] Create git tag v0.0.1 for HEAD? [Y/n]
136136-Y
137137-[+] Tagged HEAD with version v0.0.1
102102+url {
103103+ src: "https://a.publicly-accessible.url/your-archive.tar.gz"
104104+ checksum: [
105105+ "sha256=the-sha256-hash-of-your-archive"
106106+ "sha512=the-sha512-hash-of-your-archive"
107107+ ]
108108+}
138109```
110110+we recommend using more than one checksum and at least sha256 or stronger. Opam currently supports only md5, sha256 and sha512.
139111140140-* `dune-release distrib`
141141-142142-The sources are then archived to create a distribution as illustrated
143143-below:
144144-112112+Optionally you might want to integrate files (such as patches) in the repository.
113113+To do so, create a `files` directory in the directory of your package
114114+```
115115+mkdir packages/pkgname/pkgname.version/files/
145116```
146146- $ dune-release distrib
147147-[-] Building source archive
148148-[+] Wrote archive _build/hello-v0.0.1.tbz
117117+then add the files you want to add to this directory. Note that large files are forbidden and the [extra-source](https://opam.ocaml.org/doc/Manual.html#opamsection-extra-sources) section should be used instead.
149118150150-[-] Linting distrib in _build/hello-v0.0.1
151151-[ OK ] File README is present.
152152-[ OK ] File LICENSE is present.
153153-[ OK ] File CHANGES is present.
154154-[ OK ] File opam is present.
155155-[ OK ] lint opam file hello.opam.
156156-[ OK ] opam field description is present
157157-[ OK ] opam fields homepage and dev-repo can be parsed by dune-release
158158-[ OK ] Skipping doc field linting, no doc field found
159159-[ OK ] lint _build/hello-v0.0.1 success
160160-161161-[-] Building package in _build/hello-v0.0.1
162162-Done: 56/60 (jobs: 1)[ OK ] package builds
163163-164164-[-] Running package tests in _build/hello-v0.0.1
165165-Done: 0/0 (jobs: 0)[ OK ] package tests
119119+Each time you add a file to the `files` directory, you must edit the associated opam file to add the file to the `extra-files` field as follow:
120120+```
121121+extra-files: [
122122+ ["the-filename" "md5=the-checksum-for-that-file"]
123123+ ...
124124+]
125125+```
166126167167-[+] Distribution for hello 0.0.1
168168-[+] Commit c9935ac42271ce23cc422c299c5c3aaf92646499
169169-[+] Archive _build/hello-v0.0.1.tbz
127127+Once all that is done, you need to create a new git branch, commit your change, push it to your own fork
170128```
129129+git switch -c release-yourpkg-version
130130+git add packages/yourpkg/yourpkg.version/
131131+git commit -pm "Release yourpkg.version"
132132+git remote add your-github-handle git@github.com:your-github-handle/opam-repository.git
133133+git push your-github-handle release-yourpkg-version
134134+```
135135+and open a PR on opam-repository on GitHub. Congratulation!
171136172172-* `dune-release publish`
137137+For more technical information about opam files, please read the [opam manual](https://opam.ocaml.org/doc/Manual.html)
173138174174-You can now publish the distribution to your GitHub repository as
175175-follows:
139139+Fixing packages
140140+---------------
176141177177-```
178178-$ dune-release publish
179179-[-] Skipping documentation publication for package hello: no doc field in hello.opam
180180-[-] Publishing distribution
181181-[-] Publishing to github
182182-[?] Push tag v0.0.1 to git@github.com:guest/hello? [Y/n]
183183-Y
184184-[-] Pushing tag v0.0.1 to git@github.com:guest/hello
185185-[?] Create release v0.0.1 on git@github.com:guest/hello? [Y/n]
186186-Y
187187-[-] Creating release v0.0.1 on git@github.com:guest/hello via github's API
188188-[+] Succesfully created release with id 38465706
189189-[?] Upload _build/hello-v0.0.1.tbz as release asset? [Y/n]
190190-Y
191191-[-] Uploading _build/hello-v0.0.1.tbz as a release asset for v0.0.1 via github's API
192192-```
142142+Packages are fixed as they show up as broken, if the opam-repository maintainers have time.
143143+If, as an external contributor, you are willing to help out, you can send a PR to fix the packages that are broken. This is extremely helpful.
193144194194-* `dune-release opam pkg`
145145+There are several types of fixes:
146146+* **Changes to the metadata** (e.g. `homepage`, `synopsis`, …) are simple, usualy harmless and easy to do and get merged.
147147+* **Changes to the dependencies or availibility** require some scrutiny from the opam-repository maintainers to verify that the new constraints are correct and do not break existing working installations.
148148+* **Changes to the way the package is built** (e.g. changes to the build rules, addition of patches, …) require a lot more scrutiny from the opam-repository maintainers and maybe a new revision.
149149+* **Changes to the source archive(s)** is prohibited but in the case where there is no other choice and the checksum is not the same, the difference with the original must be negligable.
195150196196-The .opam file can then be generated using the following command:
151151+**PSA**: if the PR envisioned is large or involved, please ping the maintainers beforehand.
197152198198-```
199199-$ dune-release opam pkg
200200-[-] Creating opam package description for hello
201201-[+] Wrote opam package description _build/hello.0.0.1/opam
202202-```
153153+**IMPORTANT**: If you are maintaining a package that you want to fix, never change the source archive pointed by a package that has already been merged in opam-repository. This would otherwise break anyone who is trying to install it and the archive's checksum would change which renders the installation impossible. Sending a PR in opam-repository that change this checksum is **prohibited** (see [wiki/Policies](https://github.com/ocaml/opam-repository/wiki/Policies)). Instead, if the already released version is broken in some way you can send a PR making it `available: false` and make a new point-release. If this is really too complicated or impossible, you can also send a patch.
203154204204-* `dune-release opam submit`
155155+#### Revisions
205156206206-The `~/.config/dune/release.yml` file should then be updated with your
207207-opam repository settings as indicated below (in particular, change `<username>` by your local username and `<github-user>` by your own github username):
157157+Revision versions are packages whose version is of the form `<version>-<revision>` with the revision number typically starting at 1.
158158+They typically privide a slightly modified version of an original release.
208159209209-```
210210-$ cat ~/.config/dune/release.yml
160160+For example `pkg.1.0.0` is not maintained anymore (be it this specific version or the package as a whole), and someone would like to privide a patch to fix something that some people might rely on even if it might be a buggy behivour. In this case the package is duplicated into the original version (left untouched) and the revision with the fix. This way, if the fix broke someone's setup they case still use the original version.
211161212212-user: <username>
213213-remote: git@github.com:<github-username>/opam-repository.git
214214-local: /home/<username>/.cache/dune/opam-repository/
215215-```
162162+#### Patches
216163217217-You can now submit your package to be included to opam.ocaml.org using
218218-the following command, which will create a new pull request to
219219-ocaml/opam-repository:
164164+To fix packages, patches might sometimes be useful. This can be given to a package through the [patches field](https://opam.ocaml.org/doc/Manual.html#opamfield-patches), and either added through the [extra-source section](https://opam.ocaml.org/doc/Manual.html#opamsection-extra-sources) or the [extra-files field and the files/ subdirectory](https://opam.ocaml.org/doc/Manual.html#opamfield-extra-files) (`extra-source` is preferred to avoid making opam-repository too big).
220165221221-```
222222-$ dune-release opam submit
223223-[-] Submitting
224224-[-] Preparing pull request to ocaml/opam-repository
225225-[-] Fetching https://github.com/ocaml/opam-repository.git#master
226226-[-] Checking out a local release-hello-0.0.1 branch
227227-[-] Pushing release-hello-0.0.1 to git@github.com:guest/opam-repository
228228-[?] Open PR to ocaml/opam-repository? [Y/n]
229229-Y
230230-[-] Opening pull request to merge branch release-hello-0.0.1 of git@github.com:guest/opam-repository into ocaml/opam-repository
231231-```
166166+As a rule of thumb, unless urgent, the patch should go through upstream first and only if the maintainer is not responding in a reasonable timeframe, we can then think about including the patch in opam-repository, the focus should be for upstream to do a new release.
232167233233-Congratulations on submitting your first OCaml package!
168168+As an external contributor looking to patch a package, whose maintainer do not agree with it or is unresponsive, another solution could be to fork the project or ask the current maintainer to transfer the maintenance to you.
234169235235-Adopting and relinquishing package maintainership
236236--------------------------------------------------
170170+Governance
171171+----------
237172238238-Orphaned packages either have no `maintainer:` field or the field is
239239-set to the repository issue tracker:
173173+The current points of contact and the full list of maintainers is available in [wiki/Governance](https://github.com/ocaml/opam-repository/wiki/Governance).
174174+Informations about the infrastructure is available in [wiki/Infrastructure-info](https://github.com/ocaml/opam-repository/wiki/Infrastructure-info).
240175241241-```
242242-maintainer: "https://github.com/ocaml/opam-repository/issues"
243243-```
176176+Typically maintainers gather weekly to discuss ongoing topics, review PRs together and train maintainers in training.
177177+If you wish to help and become an opam-repository maintainer, you can send a message to the maintainers listed above and you will be invited to the next meeting in which they will explain how things work.
244178245245-If you care about a package and it is orphaned we are keen on having
246246-you as the maintainer of the package. In order to do so simply issue a
247247-pull request on the latest version of the package and add your contact
248248-details in the `maintainer:` field.
249249-250250-If it is no longer possible for you to commit to maintain a package
251251-you can either:
179179+Policies
180180+--------
252181253253-1. Try to find a person to replace yourself in that role. Let her
254254-issue a pull request that updates all the `maintainer:` fields that
255255-contain your details with her own and do acknowledge the transfer on
256256-her pull request.
257257-2. Or, if you cannot find someone to replace you, simply issue a pull
258258-request that updates all the `maintainer:` fields that have your details
259259-with the address of the repository issue tracker (see above).
182182+Maintainers enforce a certain number of policies applied on packages in opam-repository.
183183+You can read about them in [wiki/Policies](https://github.com/ocaml/opam-repository/wiki/Policies).
260184261261-Other questions
262262----------------
185185+How to deal with CI
186186+-------------------
263187264264-If your question about contributing is not answered here, please post on the
265265-<https://discuss.ocaml.org> forum in the `ecosystem` category with your query.
266266-Beginners questions are welcome there, particularly since we can use your
267267-question to refine the documentation of the project.
188188+When you open a PR, a number of checks are done to verify that builds and runs correctly on a number of different platforms.
189189+You can read about how to deal with our CI (Continuous Integration) in [wiki/How-to-deal-with-CI](https://github.com/ocaml/opam-repository/wiki/How-to-deal-with-CI).
+2-12
README.md
···11-This repository contains OCaml package and compiler metadata and is
22-used by the default installation of [opam](https://opam.ocaml.org/).
11+This repository contains OCaml package and compiler metadata and is used by the default installation of [opam](https://opam.ocaml.org/).
3243The state of the package ecosystem can be explored using opam-health-check<sup>[[1]]</sup>: http://check.ci.ocaml.org/
5466-# CI troubleshooting
77-88-* If you have an issue or a feature request for opam-CI (used for all PRs), please open a ticket at https://github.com/ocurrent/opam-repo-ci/issues
99-* If you think there is an issue in the CI infrastructure, please open a ticket at https://github.com/ocaml/infrastructure/issues
1010-* If you have an issue or a feature request for opam-health-check, please open a ticket at https://github.com/ocurrent/opam-health-check/issues
1111-125## How to Contribute
136147Contributions are welcome !
158169The [CONTRIBUTING.md](CONTRIBUTING.md) document has general guidelines
1717-on how to contribute.
1818-1919-If you would like to add a new package consult
2020-[these instructions](https://opam.ocaml.org/doc/Packaging.html#Publishing).
1010+on how to contribute and add new packages.
21112212## License
2313