-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathxbps.py
More file actions
70 lines (52 loc) · 2.13 KB
/
Copy pathxbps.py
File metadata and controls
70 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# pkgs.void - web catalog of Void Linux packages.
# Copyright (C) 2019-2020 Piotr Wójcik <chocimier@tlen.pl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
DEFAULT_LIBC = 'glibc'
def pkgname_from_pkgver(pkgver):
'''Extracts pkgname (like python3) from pkgver (like python3-3.8.1_1)'''
return pkgver.rpartition('-')[0]
def verrev_from_pkgver(pkgver):
'''Extracts verrev (like 3.8.1_1) from pkgver (like python3-3.8.1_1)'''
return pkgver.rpartition('-')[2]
def version_from_pkgver(pkgver):
'''Extracts version (like 3.8.1) from pkgver (like python3-3.8.1_1)'''
return version_from_verrev(verrev_from_pkgver(pkgver))
def revision_from_pkgver(pkgver):
'''Extracts revision (like 1) from pkgver (like python3-3.8.1_1)'''
return revision_from_verrev(verrev_from_pkgver(pkgver))
def version_from_verrev(verrev):
'''Extracts version (like 3.8.1) from verrev (like 3.8.1_1)'''
return verrev.partition('_')[0]
def revision_from_verrev(verrev):
'''Extracts revision (like 1) from verrev (like 3.8.1_1)'''
return verrev.rpartition('_')[2]
def split_arch(arch):
'''Returns instruction set and libc matching arch, like
x86_64-musl -> x86_64, musl
aarch64 -> aarch64, glibc
'''
try:
iset, libc = arch.split('-')
except ValueError:
iset = arch
libc = DEFAULT_LIBC
return iset, libc
def join_arch(iset, libc):
'''Returns arch matching instruction set and libc, like
x86_64, musl -> x86_64-musl
aarch64, glibc -> aarch64
'''
if not libc or libc == DEFAULT_LIBC:
return iset
return f'{iset}-{libc}'