Creating patches

From Alpine Linux
Revision as of 11:21, 7 March 2020 by Cogitri (talk | contribs) (Mention Gitlab)

New aports should normally go into testing repository. After a reasonable testing period if the package is complete (e.g. it has an init script, it has a working and sane default configuration, etc.) and it has a maintainer it can be moved into community repository. Main repository is for packages that are either core of the linux system or are dependencies of other core packages. A package in main cannot have a dependency in community or testing and a package in community cannot have a dependency on packages in testing.

There are currently two ways to contribute to propose changes, via Gitlab and via the mailing list.

Submitting patches via Gitlab

To submit patches on Alpine Linux' Gitlab instance you first have to create an account for it here. It's recommended to set a SSH now, refer to the Gitlab docs for how to do that. Afterwards, you have to fork the repository you want to contribute to, for example if you want to open a merge request for aports you would have to fork alpine/aports, see the Gitlab docs if you're having problems with that. Other repositories belonging to Alpine Linux live in the Alpine organisation. After forking you can clone the repository like so:

git clone git@gitlab.alpinelinux.org:$USER/$REPO.git

Replace $USER with the nickname of your Gitlab account and $REPO with the repository you want to work on. Now you can change to another branch (e.g. the name of the package you want to edit) with:

git checkout -b pkgname

Do your changes now and then push with:

git push -u origin $branchname

Gitlab will print an URL to create a merge request in your terminal.

Submitting patches via the mailing list

Patches should be created with git and submitted to alpine-aports mailing list with git send-email (which needs the git-email Alpine package).

Only the last commit with 'git send-email'

To submit the last commit as a patch to alpine-aports mailing list:

git send-email --to alpine-aports@lists.alpinelinux.org -1

Tip: You save the To-address (does not require '--to alpine-aports@lists.alpinelinux.org') in the git config with:

git config sendemail.to alpine-aports@lists.alpinelinux.org

The first line in commit message will be subject and the long description (separated with empty line) will be the body in the email. The example below shows

testing/packagename: new aport <- header

https://example.com/packagename <- body
wonderful package
Note: The git send-email command is provided by the git-email package (git-perl in v2.7 and older).

See Development using git#Email_configuration on how configure SMTP Auth.

Multiple commits with 'git send-email'

If you have many commits you can create a directory with patches and send them with git send-email.

rm -Rf patches mkdir patches git format-patch -o patches origin git send-email patches --compose --no-chain-reply-to --to alpine-aports@lists.alpinelinux.org

You can also format patches for the last x number of commits with:

git format-patch -x -o patches

This will produce the patches for each local commit in the directory "patches" and send them. Use --no-chain-reply-to to avoid that each patch is sent as a reply to the previous patch.

Eg.

  • [PATCH 0/m]
    • [PATCH 1/m]
      • [PATCH 2/m]
        • ...

With the option --no-chain-reply-to the patches will be sent as a reply to the first email, the cover letter (the [PATCH 0/m]) and will make the email thread nicer. Like this:

  • [PATCH 0/m]
    • [PATCH 1/m]
    • [PATCH 2/m]
    • ..

Resend an updated patch

Sometimes patches are rejected due to minor issues in the patch. Do not send an incremental patch on top of your initial, bad, patch. Instead, recreate the patch and send a new, fixed version of your patch. (use git commit --amend to edit a local commit).

When you sending a second version of the patch use --subject-prefix "PATCH v2" to indicate that this is a new version of a previously sent patch. You may also use --in-reply-to <message-id> where <message-id> the the id of email requesting the resend.

You should also write a note on the what was changed. Use --annotate for this and write the comment under the three dashes "---" so the note is not included in the commit message. For example:

...
Subject: [PATCH v2] testing/mypackage: new aport

https://example.com
Example package
---
Changes v1 -> v2:
 - removed depends
 - added zlib-dev to makedepends

 testing/mypackage/APKBUILD | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 testing/mypackage/APKBUILD
...

Note that the notes that are below the "---" will not be included in the commit message.

See also