Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit e23767d

Browse files
mariogripUniversalSuperBox
authored andcommitted
Add apt pin to branch repos
This adds apt pin to branch repos, this is higher priority then what we ship default. This makes sure it installs the requested branch regardless if version.
1 parent a4c6886 commit e23767d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ubports-qa

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,18 @@ def list_exists(branch):
102102
return os.path.isfile(get_list_file(branch))
103103

104104

105+
def pref_exists(branch):
106+
return os.path.isfile(get_pref_file(branch))
107+
108+
105109
def list_lists():
106110
return [
107111
f.split("ubports-")[1].split(".list")[0]
108112
for f in os.listdir("/etc/apt/sources.list.d/")
109113
if os.path.isfile("/etc/apt/sources.list.d/" + f) and f.startswith("ubports-")
110114
]
111115

116+
112117
def add_list(branch):
113118
if list_exists(branch):
114119
return
@@ -118,13 +123,31 @@ def add_list(branch):
118123
repo_list.write("deb http://repo.ubports.com/ {} main".format(branch))
119124

120125

126+
def add_pref(branch):
127+
if pref_exists(branch):
128+
return
129+
with open(get_pref_file(branch), "w+") as pref:
130+
# TODO: edit and set own pin priority to allow up/down/side-grade without
131+
# removal of repo etc
132+
pref.write("Package: *\n"
133+
"Pin: release o=UBports,a={}\n"
134+
"Pin-Priority: 2000\n".format(branch))
135+
136+
121137
def remove_list(branch):
122138
# If it does not exist, just ignore
123139
if not list_exists(branch):
124140
return
125141
os.remove(get_list_file(branch))
126142

127143

144+
def remove_pref(branch):
145+
# If it does not exist, just ignore
146+
if not pref_exists(branch):
147+
return
148+
os.remove(get_pref_file(branch))
149+
150+
128151
def get_github_pr(repo, num):
129152
pull_request_url = GITHUB_API_PULLREQUEST.format(repo=repo, num=num)
130153
LOG.debug("Getting pull request information from " + pull_request_url)
@@ -180,6 +203,7 @@ def install_command(args):
180203

181204
with WritableRootFS():
182205
add_list(repository_name)
206+
add_pref(repository_name)
183207
apt_update()
184208
apt_upgrade()
185209

@@ -198,6 +222,7 @@ def remove_command(args):
198222
die("Repo {} is not installed".format(repository))
199223
with WritableRootFS():
200224
remove_list(repository)
225+
remove_pref(repository)
201226
apt_update()
202227
apt_upgrade()
203228

0 commit comments

Comments
 (0)