Gentoo Archives: gentoo-dev

From: Andrew Udvare <audvare@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] How to correctly use golang-vcs with the Google API libraries?
Date: Wed, 26 Aug 2015 20:56:32
Message-Id: 55DE27F4.5020708@gmail.com
In Reply to: Re: [gentoo-dev] How to correctly use golang-vcs with the Google API libraries? by William Hubbs
1 On 26/08/15 12:41, William Hubbs wrote:
2 > On Mon, Aug 24, 2015 at 05:35:39PM -0700, Andrew Udvare wrote:
3 >
4 > Let me know what you think about how we could automate it. I think
5 > we'll have to manually create the ebuilds.
6
7 It appears they either use GitHub as the official place to get the API
8 or it is a mirror. Either way, it is on GitHub so the API can be
9 utilised. This can be scripted more astutely but jq can be used against
10 the GitHub API (and no login is required; however unauthenticated users
11 have limits).
12
13 Example getting all the directories at the top level (uses app-misc/jq):
14
15 curl -H 'Accept: application/vnd.github.v3+json'
16 https://api.github.com/repos/google/google-api-go-client/contents/ | jq
17 -r '.[] | select(type="dir") | .name'
18
19 Once you have this, for each one you have to get the v1, v2, etc. I do
20 not know how that should work in Portage because I think it is very
21 likely one package would require v1 while another will require v2. This
22 would seem to indicate slotting.
23
24 An ugly example to generate GO_PN lines:
25
26 contents_uri='https://api.github.com/repos/google/google-api-go-client/contents/'
27 accept='Accept: application/vnd.github.v3+json'
28 pn_prefix=github.com/google/google-api-go-client/
29 jq_filter='.[] | select(.type=="dir") | .name')
30
31
32 for i in $(curl -H $accept "$contents_uri" | jq -r "$jq_filter"); do
33 versions=$(curl -H $accept "${contents_uri}${i}" | jq -r "$jq_filter")
34 for j in versions; do
35 echo "SLOT=\"${j/v/ }\"" # Remove v prefix
36 echo "GO_PN="${pn_prefix}${i}/${j}"
37 done
38
39 break # Added to not exceed the very small API limit
40 done
41
42 As for the actual version number for the ebuild, from the API I think
43 you can get the last modified date for the directory. This would be to
44 create a version number like some of the others: 0_pre<date>, e.g.
45 0_pre20150729.
46
47 Andrew