Skip to content

Commit 02e8416

Browse files
committed
chore: sync with microG unofficial installer
Signed-off-by: ale5000 <15793015+ale5000-git@users.noreply.github.com>
1 parent 113c7f5 commit 02e8416

5 files changed

Lines changed: 83 additions & 49 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"ruff.lineLength": 80,
5757
"ruff.lint.select": ["ALL"],
58-
"ruff.lint.ignore": ["ANN001", "ANN201", "ANN202", "PTH", "SIM105", "UP009", "UP030", "UP032"],
58+
"ruff.lint.ignore": ["ANN001", "ANN201", "ANN202", "PTH", "SIM105", "UP009", "UP030", "UP032", "TD002", "TD003"],
5959
"[python]": {
6060
"editor.rulers": [80, 100, 120],
6161
"editor.defaultFormatter": "charliermarsh.ruff",

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DEPENDENCIES
2424
simplecov-lcov
2525

2626
RUBY VERSION
27-
ruby 3.4.5p51
27+
ruby 3.4.5p51
2828

2929
BUNDLED WITH
30-
2.7.2
30+
4.0.10

build.gradle

Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,30 @@ configure(project) {
4141

4242
/* ===FUNCTIONS=== */
4343

44-
private Provider<String> getScriptExt() {
45-
ext.lazyOsName.map { it.toLowerCase(Locale.ROOT).contains('windows') ? '.bat' : '.sh' }
46-
}
47-
48-
private Provider<String> getMavenVersion() {
49-
ext.lazyVersion.map { it.endsWith('-alpha') ? "${it}-SNAPSHOT" : it }
50-
}
44+
import groovy.transform.Memoized
5145

46+
@Memoized
5247
private Provider<String> getProjectId() {
5348
ext.lazyProjectId.map { it ?: { throw new InvalidUserDataException('id in "zip-content/module.prop" is empty or not set.') }() }
5449
}
5550

51+
@Memoized
52+
private Provider<String> getScriptExt() {
53+
ext.lazyOsName.map { it.toLowerCase(Locale.ROOT).contains('windows') ? '.bat' : '.sh' }
54+
}
55+
56+
@Memoized
5657
private Provider<String> getGitCommitHash() {
5758
providers.exec {
5859
commandLine 'git', 'rev-parse', '--short=8', 'HEAD'
5960
}.standardOutput.asText.map{ it.trim() }.orElse('unknown')
6061
}
6162

63+
@Memoized
64+
private Provider<String> getMavenVersion() {
65+
ext.lazyVersion.map { it.endsWith('-alpha') ? "${it}-SNAPSHOT" : it }
66+
}
67+
6268
private Provider<String> getZipName(String variant = '*') {
6369
ext.lazyVersion.flatMap { v ->
6470
getProjectId().zip(getGitCommitHash()) { id, hash ->
@@ -181,7 +187,7 @@ tasks.register('cleanRecoveryOutput', Delete) {
181187

182188
tasks.named('clean') {
183189
group = '- Cleanup'
184-
dependsOn tasks.named('cleanRecoveryOutput')
190+
dependsOn 'cleanRecoveryOutput'
185191
}
186192

187193
tasks.register('cleanCache', Delete) {
@@ -190,10 +196,26 @@ tasks.register('cleanCache', Delete) {
190196
delete layout.projectDirectory.dir('cache')
191197
}
192198

199+
tasks.register('cleanPubTmpFiles', Delete) {
200+
group = '- Cleanup'
201+
dependsOn 'cleanGeneratePomFileForMavenPublication'
202+
203+
delete layout.buildDirectory.dir('tmp/publishMavenPublicationToMavenLocal')
204+
delete layout.buildDirectory.dir('tmp/generatedChecksums')
205+
206+
doLast {
207+
['publications/maven', 'publications', 'tmp'].each {
208+
if(layout.buildDirectory.dir(it).get().asFile?.delete()) {
209+
logger.info "Removed empty temporary folder: ${-> it}"
210+
}
211+
}
212+
}
213+
}
214+
193215
tasks.register('distClean') {
194216
group = '- Cleanup'
195217
description = 'Cleans all build outputs, local caches, and removes all untracked/ignored files via Git.'
196-
dependsOn tasks.named('clean'), tasks.named('cleanCache')
218+
dependsOn 'clean', 'cleanCache', 'cleanPubTmpFiles'
197219

198220
doLast {
199221
if (layout.projectDirectory.dir('.git').asFile.exists()) {
@@ -268,7 +290,7 @@ tasks.register('buildOtaOSS', Exec) {
268290
tasks.named('assemble') {
269291
group = null
270292
description = 'Alias of "buildOtaOSS" task.'
271-
dependsOn tasks.named('buildOtaOSS')
293+
dependsOn 'buildOtaOSS'
272294
}
273295

274296
tasks.named('build') {
@@ -277,20 +299,23 @@ tasks.named('build') {
277299
}
278300

279301
tasks.register('installTest', Exec) {
280-
notCompatibleWithConfigurationCache('Not yet compatible with CC.')
281302
group = 'verification'
282303
description = 'Test the flashable zip in a simulated Android recovery environment on your PC.'
283304

284305
doNotTrackState('Force task execution by disabling up-to-date checks.')
285306
mustRunAfter buildOta, buildOtaOSS
286307

287-
doFirst {
288-
environment LIVE_SETUP_ALLOWED: 'false' /* Live setup doesn't work when executed through Gradle */
289-
environment NO_PAUSE: '1'
290-
environment BB_GLOBBING: '1'
291-
executable "${projectDir}/recovery-simulator/recovery" + getScriptExt()
292-
args "${projectDir}/output/*.zip"
293-
}
308+
workingDir = layout.projectDirectory
309+
executable = "${-> layout.projectDirectory.dir('recovery-simulator').file("recovery${ getScriptExt().get() }") }"
310+
311+
final Provider<RegularFile> outFilesProv = layout.buildDirectory.file('*.zip')
312+
argumentProviders.add({ [outFilesProv.get().asFile.absolutePath] } as CommandLineArgumentProvider)
313+
314+
environment([
315+
'LIVE_SETUP_ALLOWED': 'false', /* Live setup doesn't work when executed through Gradle */
316+
'NO_PAUSE': '1',
317+
'BB_GLOBBING': '1'
318+
])
294319
}
295320

296321
tasks.register('test') {
@@ -310,8 +335,7 @@ tasks.named('wrapper') {
310335

311336
/* === PUBLISHING === */
312337

313-
final Closure<String> getMemoizedZipName = { getZipName().get() }.memoize()
314-
final Provider<FileTree> zipFilesTree = layout.buildDirectory.map { dir -> dir.asFileTree.matching { include getMemoizedZipName() } }
338+
final Provider<FileTree> zipFilesTree = getZipName().map { name -> layout.buildDirectory.asFileTree.matching { include name } }
315339

316340
/*abstract class DynamicArtifactSource implements ValueSource<Integer, DynamicArtifactParams> {
317341
private static final List<String> artifactTypes = ['oss', 'full'].asImmutable()
@@ -327,8 +351,8 @@ final Provider<FileTree> zipFilesTree = layout.buildDirectory.map { dir -> dir.a
327351
parameters.zipFiles.files.each { foundFile ->
328352
String type = artifactTypes.find { foundFile.name.contains("-${it}-") } ?: { throw new GradleException("Publishing failed: File ${foundFile.name} is missing a valid build type.") }()
329353
if(!seen.add(type)) throw new GradleException("Publishing failed: The type '${type}' already exists.")
330-
String currClsf = (type == 'oss' ? null : type)
331-
mavenPub.artifact(foundFile) { extension = 'zip'; classifier = currClsf; builtBy 'collectArtifacts' }
354+
String clsf = (type == 'oss' ? null : type)
355+
mavenPub.artifact(foundFile) { extension = 'zip'; classifier = clsf; builtBy 'collectArtifacts' }
332356
}
333357
if(seen.isEmpty()) throw new GradleException("Publishing failed: No artifact found. Check if build tasks were executed.")
334358
seen.size()
@@ -342,33 +366,39 @@ final Provider<Integer> artifactsProcessor = providers.of(DynamicArtifactSource)
342366
import java.security.MessageDigest
343367
import java.security.DigestInputStream
344368

345-
File generateChecksum(targetFile, algorithm) {
346-
final MessageDigest md = MessageDigest.getInstance(algorithm.toUpperCase().replace('SHA256', 'SHA-256').replace('SHA1', 'SHA-1'))
369+
File generateChecksum(targetFile, hashExt, checksumsDir) {
370+
final MessageDigest md = MessageDigest.getInstance(hashExt.toUpperCase().replace('SHA256', 'SHA-256').replace('SHA1', 'SHA-1'))
347371
final byte[] buffer = new byte[65536]
348372
targetFile.withInputStream {
349373
final DigestInputStream dis = new DigestInputStream(it, md)
350374
while(dis.read(buffer) != -1) { }
351375
}
352-
final File chksumFile = file("${targetFile.absolutePath}.${algorithm}")
376+
final File chksumFile = new File(checksumsDir, "${targetFile.name}.${hashExt}")
353377
chksumFile.text = md.digest().encodeHex().toString()
354378

355379
chksumFile
356380
}
357381

358382
Integer processArtifacts(parameters, mavenPub) {
383+
final Directory tmpDir = layout.buildDirectory.dir('tmp').get()
384+
final File checksumsDir = tmpDir.dir('generatedChecksums').asFile
385+
checksumsDir?.deleteDir()
386+
checksumsDir.mkdirs()
387+
tmpDir.asFile?.deleteOnExit()
388+
359389
final List<String> artifactTypes = ['oss', 'full'].asImmutable()
360390
final HashSet<String> seen = []
361391
final boolean isLocal = gradle.startParameter.taskNames.any { it == 'publishToMavenLocal' || it.endsWith(':publishToMavenLocal') }
362392
parameters.zipFiles.files.each { foundFile ->
363393
final String type = artifactTypes.find { foundFile.name.contains("-${it}-") } ?: { throw new GradleException("Publishing failed: File ${foundFile.name} is missing a valid build type.") }()
364394
if(!seen.add(type)) throw new GradleException("Publishing failed: The type '${type}' already exists.")
365-
final String currClsf = (type == 'oss' ? null : type)
366-
mavenPub.artifact(foundFile) { extension = 'zip'; classifier = currClsf; builtBy 'collectArtifacts' }
395+
final String clsf = (type == 'oss' ? null : type)
396+
mavenPub.artifact(foundFile) { extension = 'zip'; classifier = clsf; builtBy 'collectArtifacts' }
367397
if(isLocal) {
368398
['sha256', 'sha1', 'md5'].each { hashExt ->
369399
final File existChksumFile = file("${foundFile.absolutePath}.${hashExt}")
370-
final File chksumFile = existChksumFile.exists() ? existChksumFile : generateChecksum(foundFile, hashExt)
371-
mavenPub.artifact(chksumFile) { extension = "zip.${hashExt}"; classifier = currClsf; builtBy 'collectArtifacts' }
400+
final File chksumFile = existChksumFile.exists() ? existChksumFile : generateChecksum(foundFile, hashExt, checksumsDir)
401+
mavenPub.artifact(chksumFile) { extension = "zip.${hashExt}"; classifier = clsf; builtBy 'collectArtifacts' }
372402
}
373403
}
374404
}
@@ -417,6 +447,10 @@ tasks.register('showPublishedArtifacts') {
417447
}
418448
}
419449

450+
tasks.named('publishToMavenLocal') {
451+
finalizedBy 'cleanPubTmpFiles'
452+
}
453+
420454
tasks.withType(GenerateMavenPom).configureEach {
421455
dependsOn 'collectArtifacts'
422456
}
@@ -431,7 +465,7 @@ tasks.withType(GenerateMavenPom).configureEach {
431465

432466
/* ===HEADER=== */
433467

434-
abstract class HeaderPrinter implements ValueSource<Boolean, HeaderParams> {
468+
abstract class HeaderPrinter implements ValueSource<String, HeaderParams> {
435469
private static final log = Logging.getLogger(HeaderPrinter)
436470

437471
interface HeaderParams extends ValueSourceParameters {
@@ -441,13 +475,13 @@ abstract class HeaderPrinter implements ValueSource<Boolean, HeaderParams> {
441475
}
442476

443477
@Override
444-
Boolean obtain() {
478+
String obtain() {
445479
log.lifecycle '=' * 36
446480
log.lifecycle "Project: ${parameters.projectName.get()}"
447481
log.lifecycle "Version: ${parameters.version.get()}"
448482
log.lifecycle "OS: ${parameters.osName.get()}"
449483
log.lifecycle '=' * 36
450-
true
484+
''
451485
}
452486
}
453487

@@ -458,5 +492,5 @@ def headerTrigger = providers.of(HeaderPrinter) {
458492
}
459493

460494
gradle.taskGraph.whenReady {
461-
{ headerTrigger.get() }
495+
logger.info "${-> headerTrigger.get()}"
462496
}

docs/conf.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
# SPDX-FileCopyrightText: 2026 ale5000
4-
# SPDX-License-Identifier: GPL-3.0-or-later
4+
# SPDX-License-Identifier: LGPL-3.0-or-later
55

66
"""Configuration file for the Sphinx documentation builder.
77
@@ -12,7 +12,7 @@
1212

1313
import datetime
1414
import os
15-
import subprocess # nosec B404
15+
import subprocess # nosec: B404
1616
import sys
1717

1818
from docutils import nodes
@@ -30,7 +30,7 @@
3030
pass
3131

3232
try:
33-
from subprocess import DEVNULL as _TMP_DEVNULL
33+
from subprocess import DEVNULL as _TMP_DEVNULL # nosec: B404
3434

3535
_DEVNULL = _TMP_DEVNULL # type: int | IO[Any]
3636
except ImportError:
@@ -143,14 +143,14 @@ def get_revision():
143143
try:
144144
return (
145145
# Safe: uses list-based arguments (no shell) to prevent injection
146-
subprocess.check_output( # nosec B603 # noqa: S603
147-
[git, "rev-parse", "--short=8", "HEAD"],
146+
subprocess.check_output( # nosec: B603 # noqa: S603
147+
[git, "rev-parse", "--short=8", "HEAD"], # nosemgrep
148148
stderr=_DEVNULL,
149149
)
150150
.decode("utf-8")
151151
.strip()
152152
)
153-
except Exception:
153+
except (FileNotFoundError, subprocess.CalledProcessError):
154154
return None
155155

156156

@@ -197,11 +197,10 @@ def _transform_rst_links(app, doctree):
197197
parts = uri.split("#", 1)
198198
has_anchor = len(parts) > 1
199199
reftype = "ref" if has_anchor else "doc"
200-
reftarget = (
201-
parts[1]
202-
if has_anchor
203-
else (parts[0][:-4] if parts[0].endswith(".rst") else parts[0])
204-
)
200+
if has_anchor:
201+
reftarget = parts[1]
202+
else:
203+
reftarget = parts[0][:-4] if parts[0].endswith(".rst") else parts[0]
205204
logger.info(
206205
"[DEBUG] Converting %s -> :%s:`%s`",
207206
uri,
@@ -275,7 +274,8 @@ def setup(app):
275274

276275
# Links are working using implicit references but MyST still emit warnings
277276
# instead of verify
278-
suppress_warnings = ["myst.xref_missing"] # TODO: Find an alternative way
277+
# TODO: Find an alternative way
278+
suppress_warnings = ["myst.xref_missing"]
279279

280280
# Options for HTML output
281281
html_theme = "sphinx_rtd_theme"

zip-content/module.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
id=google-sync-addon
55
numericId=928871
66
name=Google sync add-on
7-
version=v1.3.2.46-alpha
7+
version=v1.3.2.47-alpha
88
versionCode=6
99
author=ale5000
1010
description=It installs Google sync adapters on Android.

0 commit comments

Comments
 (0)