Project

General

Profile

DeveloperGuide » History » Version 89

Denis 'GNUtoo' Carikli, 09/06/2019 03:23 PM
Add patch requirements, a howto for making patches will follow

1 31 Paul Kocialkowski
h1. Developer guide
2 1 Paul Kocialkowski
3 15 Paul Kocialkowski
{{>toc}}
4
5 3 Paul Kocialkowski
h2. Prerequisites
6
7 8 Paul Kocialkowski
Developing on Replicant isn't much harder than developing on any other free software project as it doesn't require specific knowledge. In fact, you'll probably learn a lot along the way regarding how hardware works, how the Android system is composed, how the kernel works, etc, but you don't need to know all of this to start. However a basic set of skills is required, among which:
8 83 Denis 'GNUtoo' Carikli
* C language programming skills and the ability to understand other languages such as C++, Java and shell scripts.
9 82 Denis 'GNUtoo' Carikli
* Makefile skills (no need to know every detail about it, a general idea of how Makefiles work is enough). If you don't know how Makefiles work, Wikipedia has "an good article on make":https://en.wikipedia.org/wiki/Make_(software)#Makefile that has some examples Makefiles.
10
* Git skills (basically, how to commit changes, send them to our repos, dealing with branches without making a mess, etc). If you don't know git yet, you can find some documentation about Git at: https://git-scm.com/documentation to learn it.
11 3 Paul Kocialkowski
12
If you think you can cope with the requirements, then developing on Replicant should cause you no particular issue.
13
14 70 Wolfgang Wiedmeyer
The [[Index#Replicant-porting-guides|porting guides]] provide instructions for porting a new device to Replicant and also offer some tips for developing on Replicant.
15 3 Paul Kocialkowski
16 70 Wolfgang Wiedmeyer
Have a look at the [[Tasks]] page and feel free to [[Index#Contact|ask around]] for help to get started.
17 40 Wolfgang Wiedmeyer
18 70 Wolfgang Wiedmeyer
h3. Notes on writing free software replacements
19 59 Wolfgang Wiedmeyer
20 70 Wolfgang Wiedmeyer
Writing free software replacements for non-free components may require more skills depending on what you're trying to achieve, though there may be people with the adequate knowledge to help you and from whom you will likely learn a lot.
21 50 Wolfgang Wiedmeyer
22 88 Denis 'GNUtoo' Carikli
h2. Code hosting
23 40 Wolfgang Wiedmeyer
24 1 Paul Kocialkowski
Replicant's source code is hosted at "git.replicant.us":https://git.replicant.us/replicant. If you plan to contribute to Replicant, you are welcome to host your Replicant-related projects there under your own username there. You only need to [[People#Active-developers|contact one of Replicant's developers]] and ask for an account. Please include in your request the name, username and Email address that should be used for creating your account. Your repos will then show up on the "contributor repos":https://git.replicant.us/contrib page.
25 88 Denis 'GNUtoo' Carikli
26 89 Denis 'GNUtoo' Carikli
h2. Requirements for submitting patches
27 1 Paul Kocialkowski
28 89 Denis 'GNUtoo' Carikli
There are two ways to get your patches included:
29
* You can either send them directly to the "mailing list":https://lists.osuosl.org/mailman/listinfo/replicant
30
* You cal also open an issue on the "issue tracker":/projects/replicant/issues and attach the patches to the issue. At some point the patch will need to be sent to the mailing list by someone.
31 1 Paul Kocialkowski
32 89 Denis 'GNUtoo' Carikli
Replicant developers will then review your changes on the mailing list.
33
34
There are many ways to send patches to the mailing list
35
* You can simply attach the patch to a mail
36
* If you like the command line, git has a tool called "@git send-email@":https://git-scm.com/docs/git-send-email to send patches directly from it . If it's too much hassle for you to set up @git send-email@, sending the patches with your favorite mail client should be fine, too.
37
* If you want to send the patch from your command line to your mail client, git's "@git imap-send@":https://git-scm.com/docs/git-imap-send can do that
38 3 Paul Kocialkowski
39 81 Denis 'GNUtoo' Carikli
h2. Pushing patches
40
41
If you already have the ability to push patches into the main Replicant repositories, you still need to send your patches to the mailing list if they are to be applied on a Replicant version that is currently supported, or if they apply to the Replicant website.
42
43
You will then need to wait either for:
44
* One other developer to review the patch and add "per's":https://stallman.org/articles/genderless-pronouns.html Acknowledgement.
45
* One week if no other developer did review your patches.
46
47 71 Wolfgang Wiedmeyer
h2. Writing free software replacements
48 1 Paul Kocialkowski
49 71 Wolfgang Wiedmeyer
Here are some tips that may help you achieving a free software replacement for a specific component (some may be more or less relevant regarding the nature of what the component does):
50
* Look for interested people from other projects: LineageOS people are constantly fighting with non-free blobs and are sometimes happy to help replacing one.
51 1 Paul Kocialkowski
* Try to make the non-free binary as verbose as possible by enabling all the possible debug options on the config file or such.
52 85 Denis 'GNUtoo' Carikli
* You can use @string@ to try to find out the command line debug options, list of commands, etc.
53 71 Wolfgang Wiedmeyer
* Run the program in @strace@ and analyze the trace to understand what the program does.
54
* Add verbose debug prints in the concerned kernel driver (with @printk@ and show them via the @dmesg@ tool).
55
* Read the corresponding kernel driver: you can sometimes learn a lot by reading comments or headers.
56
* Collect data out of the kernel driver (via debug prints) and out of the non-free binary (via debug prints on the upper-layer).
57
* If there is a mathematical algorithm involved, force the values returned by the kernel to the non-free binary and analyze how it reacts, for instance with spreadsheet software.
58 1 Paul Kocialkowski
* If you're directly dealing with a hardware component, try to find a datasheet for the chip, it may hold precious details. In the best case, you may also be able to find a reference software implementation!
59 84 Denis 'GNUtoo' Carikli
* Make sure that the methods you use are legal where you live, and that the Replicant project is able to legally redistribute your work. In doubt, you could ask the Replicant developers in the mailing list and/or at the private contact address. The Replicant project has also access to legal advise through the FSF.
60 2 Paul Kocialkowski
61
h2. Upstreaming work
62
63 1 Paul Kocialkowski
It is generally a good idea to send some changes back to upstream, assuming that they will benefit from it as well.
64 2 Paul Kocialkowski
65 1 Paul Kocialkowski
When it is about the replacement of a non-free component present in the upstream systems, make sure that your replacement is reliable and complete.
66
Contact the interested developers on the upstream projects before attempting to send your replacement.
67
68
h3. LineageOS
69
70 86 Denis 'GNUtoo' Carikli
The LineageOS project has a "checklist":https://github.com/LineageOS/charter/blob/master/device-support-requirements.md of requirements for adding support for a device.
71
72
As the LineageOS developers have to make sure that the checklist requirements are met, make sure that your replacement is complete enough to either meet the checklist requirements, or that the LineageOS developers are interested in working together with you to make sure that the free software replacement meets such requirements.
73
74 1 Paul Kocialkowski
The LineageOS team uses Gerrit to manage patch submissions. The process to get your patch included in LineageOS repos is explained on their wiki: "Gerrit":http://wiki.lineageos.org/usinggerrit-howto.html#submitting-to-gerrit
75 2 Paul Kocialkowski
76
You can also push directly using git using the following scheme (untested):
77
<pre>
78
git push ssh://<sshusername>@review.lineageos.org:29418/LineageOS/<projectname> HEAD:refs/for/<branchname>
79
</pre>
80 25 Paul Kocialkowski
81
h3. AOSP
82
83
The Android Open Source Project uses Gerrit to manage patch submissions. Some information about submitting patches to AOSP is available: https://source.android.com/source/submit-patches.html
84
85
You can push to AOSP's review using:
86 3 Paul Kocialkowski
<pre>
87
git push https://android-review.googlesource.com/platform/system/core HEAD:refs/for/master
88
</pre>
89 43 Wolfgang Wiedmeyer
90 71 Wolfgang Wiedmeyer
h2. Commonly-used terminology
91 3 Paul Kocialkowski
92 71 Wolfgang Wiedmeyer
In order to keep everything clear and consistent, we use the following terms with a precise meaning in mind:
93
* *Driver*: Software that is part of the *kernel* (builtin or as a module) and deals with communicating with the hardware
94
* *Hardware Abstraction Layer (HAL)*: Software that runs in *user-space* and deals with communicating with the hardware (usually through a kernel driver)
95
* *module*: Android HALs are also often called modules, so we may referrer to e.g. the @audio HAL@ as the @audio module@
96
* *blob*: Proprietary HAL
97
* *firmware*: Software that does not run on the main processor (the CPU) but rather in a separate chip (e.g. the Wi-Fi firmwares runs on the Wi-Fi chip)
98 1 Paul Kocialkowski
99
h2. Wiki guidelines
100
101
In order the keep the wiki simple and consistent, a few guidelines must be followed when editing.
102
103
Regarding the content:
104
* Only Replicant-specific topics should be covered by the wiki: there is no point in writing usage guides for generic Android aspects, such as the user interface.
105
* The content on each page should *only* be relevant to the latest Replicant version: make sure to update the content with newer Replicant versions.
106
* Substantial changes must be discussed before modifying the wiki.
107
* A comment should be added in the comment field at the bottom that shortly describes the change.
108 72 Wolfgang Wiedmeyer
* Make use of the wiki formatting possibilities: "quick reference":/help/en/wiki_syntax_textile.html and "detailed syntax overview":/help/en/wiki_syntax_detailed_textile.html
109 1 Paul Kocialkowski
  By using @[[Index]]@, it's possible to link to the start page of the wiki.
110 6 Paul Kocialkowski
111 3 Paul Kocialkowski
Regarding the writing style:
112
* Every page in the wiki has to be written in correct English, we do not aim to provide information in any other language.
113 17 Paul Kocialkowski
* Addressing readers directly should be avoided when possible: Instead, what is described should always be the subject of sentences.
114 4 Paul Kocialkowski
* Links to pages should be incorporated in text (Instructions to [[ToolsInstallation#ADB|install ADB]] shouldn't be: Instructions to install ADB: [[ToolsInstallation#ADB]]).
115 14 Paul Kocialkowski
116
Regarding the naming of pages:
117 34 Paul Kocialkowski
* Pages must be named in a consistent manner ([[NexusSI902xFirmwares]] is not to be called [[FirmwaresOnTheI902xNexusS]]).
118 1 Paul Kocialkowski
* Common prefixes and suffixes should be used for naming new pages ([[BuildDependenciesInstallation]] is not to be called [[InstallationOfBuildDependencies]]).
119 34 Paul Kocialkowski
* Page and section names should always be named using nouns, not verbs, either active or not ([[DeveloperGuide]] is not to be called [[DevelopingGuide]]).
120
* Page titles shouldn't contain space or any delimiter character (such as - or_) but use upper-case characters as word delimiters ([[BuildDependenciesInstallation]] is not to be called [[Build_dependencies_installation]]).
121
* Page titles *as shown on the page* should use lower-case when upper-case is not needed, even if the page name uses upper-case as word delimiters.
122
123 49 Wolfgang Wiedmeyer
Regarding the naming of devices:
124 53 Wolfgang Wiedmeyer
* Devices should be named after their model number and codename, without mention of the manufacturer.
125 49 Wolfgang Wiedmeyer
* Common device naming conventions should be followed consistently (the @Galaxy S 3 (I9300)@ is not to be called @Samsung S3 GT-I9300@ or @Galaxy S III@).
126 34 Paul Kocialkowski
127 71 Wolfgang Wiedmeyer
h2. Repositories
128 34 Paul Kocialkowski
129 71 Wolfgang Wiedmeyer
When working with Replicant repos, make sure to avoid breaking things. For instance, if you push a commit introducing a compilation error, it will break the whole build process.
130
It is better to create separate branches (that are not used by the official manifest branches) when your work is still in progress.
131
Creating branches that add debug infos on a particular topic is usually a good idea since it will save you time next time you want to debug the same component.
132
133 80 Denis 'GNUtoo' Carikli
See [[SourceCodeRepositories]] for more details about how to create or mirror repositories on Replicant server.
134 71 Wolfgang Wiedmeyer
135
h3. When creating a repository
136 78 Denis 'GNUtoo' Carikli
137 71 Wolfgang Wiedmeyer
In order to keep repo naming consistent, please name repositories by their name on the tree, replacing the @/@ by @_@.
138
For instance, when forking the LineageOS repo: @android_device_samsung_crespo@, rename it to @device_samsung_crespo@ on the Replicant repos.
139
This creates a more consistent way of naming repositories and makes it easier when pushing: just look at the location in the source tree and replace @/@ by @_@.
140
141
h3. When creating a branch
142
143
Official Replicant branches are named the following way:
144
* The @replicant-@ prefix
145
* The Replicant version
146
147
Such as: @replicant-2.3@ This should be used on the projects repositories as well as the manifest repository.
148
Any other branch should be considered as Work In Progress (WIP) and thus not be part of any official branch of the manifest.
149
150
There is although one exception, with the @master@ branch, that can be used by any project and be in any manifest given that the code held in the @master@ branch will work on any Replicant version.
151 16 Paul Kocialkowski
152 33 Paul Kocialkowski
h2. New images release
153 1 Paul Kocialkowski
154 33 Paul Kocialkowski
# Modify the changelog in the vendor files:
155
<pre>
156 54 Wolfgang Wiedmeyer
cd path/to/replicant-6.0/vendor/replicant
157 33 Paul Kocialkowski
edit CHANGELOG.mkdn
158
git add CHANGELOG.mkdn
159 54 Wolfgang Wiedmeyer
git commit -sS -m "Replicant 6.0 0001 images release"
160
git push git@git.replicant.us:replicant/vendor_replicant.git replicant-6.0
161 33 Paul Kocialkowski
</pre>
162 65 Wolfgang Wiedmeyer
# Increment the release in the "release scripts":https://git.replicant.us/replicant/release-scripts:
163 33 Paul Kocialkowski
<pre>
164
cd path/to/release-scripts
165 58 Wolfgang Wiedmeyer
edit releasevars.sh
166
git add releasevars.sh
167 1 Paul Kocialkowski
git commit -sS -m "Replicant 6.0 0001 images release"
168
git push git@git.replicant.us:replicant/release-scripts.git replicant-6.0
169 58 Wolfgang Wiedmeyer
</pre>
170 63 Wolfgang Wiedmeyer
# Tag all the repositories with the release tag script:
171
<pre>
172
path/to/release-scripts/releasetag.sh path/to/replicant-6.0
173
</pre>
174 58 Wolfgang Wiedmeyer
# In the manifest repo, merge the replicant-6.0-dev branch into the replicant-6.0 branch and increment the release in the manifest:
175
<pre>
176
cd path/to/manifest
177
git checkout replicant-6.0
178
git merge replicant-6.0-dev
179
edit default.xml
180
git add default.xml
181
git commit -sS -m "Replicant 6.0 0001 images release"
182
git push git@git.replicant.us:replicant/manifest.git replicant-6.0
183 33 Paul Kocialkowski
</pre>
184
# Tag the manifest:
185 61 Wolfgang Wiedmeyer
<pre>
186
git tag -u 5816A24C10757FC4 replicant-6.0-0001 -m "Replicant 6.0 0001 images release"
187
git push git@git.replicant.us:replicant/manifest.git replicant-6.0-0001
188
</pre>
189 64 Wolfgang Wiedmeyer
# Verify all tags:
190
<pre>
191
cd .repo/manifests
192
git verify-tag $(git describe)
193
cd ../..
194 68 Wolfgang Wiedmeyer
repo forall -ec ' { echo "Verifying $REPO_PROJECT" && git verify-tag $(git describe) 2>/dev/null; } || { echo "Error: verification failed!" && exit 1; } '
195 64 Wolfgang Wiedmeyer
</pre>
196 56 Wolfgang Wiedmeyer
# Update prebuilts and start the build (in a newly opened shell with the Replicant keys and certificates installed):
197
<pre>
198
path/to/release-scripts/releasebuild.sh path/to/replicant-6.0
199
</pre>
200 33 Paul Kocialkowski
# Release the images with the release script:
201
<pre>
202 55 Wolfgang Wiedmeyer
rm -rf path/to/images/replicant-6.0/0001
203 54 Wolfgang Wiedmeyer
mkdir -p path/to/images/replicant-6.0/0001
204
path/to/release-scripts/release.sh path/to/replicant-6.0 path/to/images/replicant-6.0/0001
205 1 Paul Kocialkowski
</pre>
206 33 Paul Kocialkowski
# Sign the binaries with the release script:
207
<pre>
208 54 Wolfgang Wiedmeyer
path/to/release-scripts/release.sh path/to/replicant-6.0 path/to/images/replicant-6.0/0001 signatures
209 1 Paul Kocialkowski
</pre>
210 33 Paul Kocialkowski
# Compress the release files
211
<pre>
212 54 Wolfgang Wiedmeyer
cd path/to/images/replicant-6.0
213
tar -cjf 0001.tar.bz2 0001
214 1 Paul Kocialkowski
</pre>
215 33 Paul Kocialkowski
# Upload the release to OSUOSL:
216
<pre>
217 66 Wolfgang Wiedmeyer
rsync -P -4 -ze ssh 0001.tar.bz2 replicant@ftp-osl.osuosl.org:/home/replicant/data/images/replicant-6.0/
218 54 Wolfgang Wiedmeyer
</pre>
219 67 Wolfgang Wiedmeyer
# Unpack the release on OSUOSL, ensure permissions are correct and run the @trigger-replicant@ script
220 33 Paul Kocialkowski
# Update [[ReplicantImages]] with the release
221
# Update each device's page with the release
222
# Update [[ReplicantStatus]] with the latest status
223 62 Wolfgang Wiedmeyer
# Verify if other wiki pages need to be updated due to changes introduced by the release (e.g. [[Index#Replicant-build|build pages]] or [[ToolsInstallation]])
224 33 Paul Kocialkowski
# Announce the release on the blog
225
# Update the release on the website and IRC topic
226 5 Paul Kocialkowski
227 33 Paul Kocialkowski
h2. New device documentation
228 22 Paul Kocialkowski
229 19 Paul Kocialkowski
1. Create the device main page, following the naming guidelines applied to other devices (e.g. the Samsung Galaxy S II GT-I9100 is called *Galaxy S 2 (I9100)* and its page is [[GalaxyS2I9100]])
230 74 Wolfgang Wiedmeyer
2. Create all the related sub-pages (build guide, install guide and firmwares list at least), following the naming guidelines applied to other devices (e.g. [[GalaxyS2I9100Build]], [[GalaxyS2I9100Installation]] and [[GalaxyS2I9100LoadedFirmwares]])
231 5 Paul Kocialkowski
3. Link the sub-pages to the main page in the index
232
4. Update the [[ReplicantStatus]] page of the wiki with the current status of the device
233 47 Wolfgang Wiedmeyer
5. Modify the [[Index]] page of the wiki and add the new device in the following sections:
234
* [[Index#Replicant-status|Replicant status]]
235
* [[Index#Replicant-installation|Replicant installation]]
236
* [[Index#Replicant-build|Replicant build]]
237
* [[Index#Supported-devices|Supported devices]]
238 24 Paul Kocialkowski
239 43 Wolfgang Wiedmeyer
6. Add new issues categories to the Replicant project Redmine
240 73 Wolfgang Wiedmeyer
241
7. Add the device to the "Supported devices page":https://www.replicant.us/supported-devices.php on the website