@@ -5,7 +5,11 @@ dependencies. They require special attention when making `xbps-src` templates.
55
66<!-- toc -->
77
8- ## Should the dependency be a submodule?
8+ ## Preface
9+ Before talking about using git submodules in templates, few things have to be
10+ considered:
11+
12+ ### Should the dependency be a submodule?
913` xbps-src ` should handle all dependencies if possible. If the project depends on
1014a git submodule that is already packaged in ` void-packages ` and you are sure
1115that breakage won't occur, you should replace the submodule with actual packaged
@@ -26,7 +30,7 @@ requirements](../xbps-src-tutorial/packaging-j4-dmenu-desktop.md#quality-require
2630depends), so packaging them as a dependency might not be reasonable. Leaving the
2731header only dependency as a git submodule is preferable in this scenario.
2832
29- ## Release archives
33+ ### Release archives
3034This tutorial assumes that the submodule isn't included in the release archive.
3135GitHub doesn't include submodules in default release archives and upstream
3236developers usually don't care to add a proper release archive with all
@@ -37,8 +41,12 @@ submodules because they're already there.
3741
3842## Downloading
3943The proper official way to handle submodules is to add their archive to
40- ` distfiles ` . But you must the version of the submodule that is used in the
41- packaged release.
44+ ` distfiles ` . ` git --recursive ` is not tolerable in templates. ` git ` usage in
45+ general should be avoided in templates.
46+
47+ To add the submodule to ` distfiles ` , you must have link to an archive containing
48+ the submodule. To get that link, you need to know the version of the submodule
49+ that is being used in the packaged release.
4250
4351## Hunting for submodule archives
4452I will be showing this off on the
@@ -50,7 +58,9 @@ I will show off two ways to figure out the submodule source archive. One is
5058second method is [ using plain ` git ` ] ( #using-git ) .
5159
5260### Using GitHub UI
53- Go to the release the package is using (here it's the latest release ` v0.3.3 ` ):
61+ Go to the release the template is using
62+ ([ ` gazou ` ] ( https://github.com/void-linux/void-packages/blob/3ddc63b10ff4f7a574996a3a43952c39c732101f/srcpkgs/gazou/template ) 's
63+ template is using release ` v0.3.3 ` ):
5464
5565![ main page] ( ../images/git_submodules/main_page.png )
5666
@@ -95,23 +105,55 @@ The URL will now contain the commit hash:
95105https://github.com/Skycoder42/QHotkey/tree/eb7ddaba57b108f99c2fefcd4eb23cef9c0ed681
96106```
97107
108+ Here the commit hash is
109+
110+ ```
111+ eb7ddaba57b108f99c2fefcd4eb23cef9c0ed681
112+ ```
113+
98114This hash is usable, but you should make sure that the commit isn't tied to a
99- tag. Tags should be preferred over commit hashes because they are nicer and
100- shorted. To do that, click on the top commit:
115+ tag. Tags should be preferred over commit hashes because they are nicer,
116+ shorter and more descriptive.
117+
118+ #### Finding out submodule's tag
119+ To find out whether a commit is tied to a tag, click on the top commit:
101120
102121![ tag commit] ( ../images/git_submodules/tag_commit.png )
103122
104- You should see whether there is a tag listed:
123+ You should see one or more tags listed:
105124
106- ![ tagged pin ] ( ../images/git_submodules/tagged_pin .png )
125+ ![ commit tags ] ( ../images/git_submodules/commit_tags .png )
107126
108- If it isn't (it is on the picture), return to the root of the repo while
109- preserving the checkout like before and proceed with [ getting the
110- archive ] ( #getting-the-archive ) .
127+ You should take note of the commit hash of the commit. We know the commit hash
128+ from before, but it's highlighted here in green again for good measure (it is a
129+ shortened version of it ).
111130
112- Click on the tag. If you get brought to a release page, click on the tag again:
131+ You should check all of the tags mentioned (there may be only a single one or
132+ multiple like in the screenshot). We check them to see whether the examined
133+ commit (here ` eb7ddab ` ) is tied to a tag.
113134
114- ![ next tag] ( ../images/git_submodules/next_tag.png )
135+ We first click on tag ` 1.5.0 ` :
136+
137+ ![ tag 1.5.0] ( ../images/git_submodules/v1.5.0.png )
138+
139+ ![ commit 1.5.0] ( ../images/git_submodules/v1.5.0-commit.png )
140+
141+ The commit hash doesn't match ` eb7ddab ` . ` 1.5.0 ` isn't the correct tag. Let's
142+ try ` 1.4.2 ` :
143+
144+ ![ tag 1.4.2] ( ../images/git_submodules/v1.4.2.png )
145+
146+ ![ commit 1.4.2] ( ../images/git_submodules/v1.4.2-commit.png )
147+
148+ ` eb7ddab ` , that's our commit. This means that tag ` 1.4.2 ` is the same as the
149+ commit ` eb7ddaba57b108f99c2fefcd4eb23cef9c0ed681 ` . We can therefore use tag
150+ ` 1.4.2 ` instead of the commit hash. Click on the tag (highlighted in green) and
151+ proceed with instructions.
152+
153+ If there isn't a tag tied to the commit (it is on the picture, but it might not
154+ be in the project you're packaging), return to the root of the repo while
155+ preserving the checkout like before and proceed with [ getting the
156+ archive] ( #getting-the-archive ) .
115157
116158#### Getting the archive
117159Click on "Code" and copy the link for downloading ZIP:
@@ -123,11 +165,11 @@ This is the link to download the submodule. Note that `void-packages` prefers
123165but you can simply change the link:
124166
125167```
126- https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.5.0 .zip
168+ https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.4.2 .zip
127169```
128170
129171```
130- https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.5.0 .tar.gz
172+ https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.4.2 .tar.gz
131173```
132174
133175This is the resulting archive. It might contain the commit hash if the submodule
@@ -203,7 +245,7 @@ https://github.com/<repo owner>/<repo name>/archive/<COMMIT>.tar.gz
203245
204246For ` QHotkey ` it looks like this:
205247```
206- https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.5.0 .tar.gz
248+ https://github.com/Skycoder42/QHotkey/archive/refs/tags/1.4.2 .tar.gz
207249```
208250```
209251https://github.com/Skycoder42/QHotkey/archive/eb7ddaba57b108f99c2fefcd4eb23cef9c0ed681.tar.gz
0 commit comments