Skip to content

Commit ed996f5

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

5 files changed

Lines changed: 77 additions & 39 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ docs/CODEOWNERS text eol=lf
1919
.shellcheckrc text eol=lf
2020
.tool-versions text eol=lf
2121

22+
*.cff text eol=lf
2223
*.gpg text eol=lf
2324
*.js text eol=lf
2425
*.json text eol=lf

CITATION.cff

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ authors:
1212
identifiers:
1313
- type: other
1414
value: "License: GPL-3.0-or-later WITH LicenseRef-Archive-packaging-exception"
15-
description: >-
16-
Licensed under GPL-3.0-or-later WITH LicenseRef-Archive-packaging-exception.
17-
The full text of this exception is available in the LICENSE-EXCEPTION.rst file at the root of this repository.
15+
description: "The full text of the licenses can be found in the LICENSES directory."
1816
repository-code: "https://github.com/micro5k/google-sync-addon"
1917
abstract: "A tool to simplify Google sync adapters installation on Android devices."
2018
keywords:

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SPDX-FileComment = [
2727
path = [
2828
"gradle/wrapper/gradle-wrapper.jar"
2929
]
30-
SPDX-FileCopyrightText = "2007 the original author or authors"
30+
SPDX-FileCopyrightText = "2007 The original author or authors"
3131
SPDX-License-Identifier = "Apache-2.0"
3232
SPDX-FileComment = [
3333
"Sources: https://github.com/gradle/gradle/tree/master/subprojects/wrapper"

build.gradle

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ plugins {
1313
//id 'com.github.spotbugs' version '4.7.6'
1414
}
1515

16-
def moduleProps = providers.fileContents(layout.projectDirectory.file('zip-content/module.prop'))
17-
.asText
18-
.map { text ->
19-
def p = new Properties()
20-
p.load(new StringReader(text))
21-
return p
22-
}
23-
24-
//def moduleProps = providers.properties(layout.projectDirectory.file('zip-content/module.prop'))
25-
2616
configure(project) {
2717
defaultTasks 'tasks'
2818

2919
ext {
30-
lazyDescription = moduleProps.map { it.getProperty('description', 'Unknown flashable ZIP') }
20+
moduleProps = providers.fileContents(layout.projectDirectory.file('zip-content/module.prop'))
21+
.asText
22+
.map {
23+
final Properties p = new Properties()
24+
p.load(new StringReader(it))
25+
p
26+
} as Provider<Properties>
27+
28+
//moduleProps = providers.properties(layout.projectDirectory.file('zip-content/module.prop')) as Provider<Properties>
29+
30+
//lazyDescription = moduleProps.map { it.getProperty('description', 'Unknown flashable ZIP') }
3131
lazyVersion = moduleProps.map { it.getProperty('version', 'v0.0.0-unknown').trim().toLowerCase(Locale.ROOT) }
32-
lazyGroup = moduleProps.map { it.getProperty('group', 'unknown').trim() }
32+
//lazyGroup = moduleProps.map { it.getProperty('group', 'unknown') }
3333
lazyProjectId = moduleProps.map { it.getProperty('id', '').trim() }
3434
lazyOsName = providers.systemProperty('os.name')
3535
}
@@ -48,16 +48,47 @@ private Provider<String> getProjectId() {
4848
ext.lazyProjectId.map { it ?: { throw new InvalidUserDataException('id in "zip-content/module.prop" is empty or not set.') }() }
4949
}
5050

51+
@Memoized
52+
private Provider<String> getLazyAuthor() {
53+
moduleProps.map { it.getProperty('author', 'unknown') }
54+
}
55+
56+
@Memoized
57+
private Provider<String> getLazyDescription() {
58+
moduleProps.map { it.getProperty('description', 'Unknown flashable ZIP.') }
59+
}
60+
61+
@Memoized
62+
private Provider<String> getLazyGroup() {
63+
moduleProps.map { it.getProperty('group', 'unknown') }
64+
}
65+
66+
@Memoized
67+
private Provider<String> getLazyOrg() {
68+
moduleProps.map { it.getProperty('organization', 'unknown') }
69+
}
70+
71+
@Memoized
72+
private Provider<String> getLazyLicense() {
73+
moduleProps.map { it.getProperty('license', 'unknown') }
74+
}
75+
5176
@Memoized
5277
private Provider<String> getScriptExt() {
5378
ext.lazyOsName.map { it.toLowerCase(Locale.ROOT).contains('windows') ? '.bat' : '.sh' }
5479
}
5580

5681
@Memoized
5782
private Provider<String> getGitCommitHash() {
58-
providers.exec {
59-
commandLine 'git', 'rev-parse', '--short=8', 'HEAD'
60-
}.standardOutput.asText.map{ it.trim() }.orElse('unknown')
83+
providers.provider { layout.projectDirectory.dir('.git').asFile.exists() }.flatMap { exists ->
84+
if(!exists) {
85+
return providers.provider { 'NOGIT' }
86+
}
87+
88+
providers.exec {
89+
commandLine 'git', 'rev-parse', '--short=8', 'HEAD'
90+
}.standardOutput.asText.map { "g${ it.trim() }" }.orElse('unknown')
91+
}
6192
}
6293

6394
@Memoized
@@ -68,14 +99,14 @@ private Provider<String> getMavenVersion() {
6899
private Provider<String> getZipName(String variant = '*') {
69100
ext.lazyVersion.flatMap { v ->
70101
getProjectId().zip(getGitCommitHash()) { id, hash ->
71-
"${id}-${v}-g${hash}-${variant}-by-ale5000-signed.zip"
102+
"${id}-${v}-${hash}-${variant}-by-ale5000-signed.zip"
72103
}
73104
}
74105
}
75106

76107
/*private Provider<String> getZipName(String variant = '*') {
77108
providers.zip(getProjectId(), getGitCommitHash(), ext.lazyVersion) { id, hash, v ->
78-
"${id}-${v}-g${hash}-${variant}-by-ale5000-signed.zip"
109+
"${id}-${v}-${hash}-${variant}-by-ale5000-signed.zip"
79110
}
80111
}*/
81112

@@ -143,32 +174,32 @@ project.afterEvaluate {
143174
// Keep it as lazy as possible while ensuring values show up correctly in 'gradlew properties',
144175
// since these Gradle properties and the maven-publish plugin don't support Providers.
145176

146-
description = "${-> ext.lazyDescription.get()}"
147-
version = "${-> ext.lazyVersion.get()}"
148-
group = "${-> ext.lazyGroup.get()}"
177+
description = "${-> lazyDescription.get() }"
178+
version = "${-> ext.lazyVersion.get() }"
179+
group = "${-> lazyGroup.get() }"
149180

150181
publishing {
151182
publications {
152183
maven(MavenPublication) {
153-
groupId = 'com.github.micro5k'
154-
artifactId = "${-> getProjectId().get()}"
155-
version = "${-> getMavenVersion().get()}"
184+
groupId = "com.github.${-> lazyOrg.get() }"
185+
artifactId = "${-> getProjectId().get() }"
186+
version = "${-> getMavenVersion().get() }"
156187
pom {
157-
name = "${-> project.name}"
188+
name = "${-> project.name }"
158189
packaging = 'zip'
159190

160191
licenses {
161192
license {
162-
name = 'GPL-3.0-or-later WITH LicenseRef-Archive-packaging-exception'
193+
name = "${-> lazyLicense.get() }"
163194
url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
164195
distribution = 'repo'
165-
comments = 'Licensed under GNU General Public License v3.0 or later with Archive Packaging Exception. Full license texts are available in LICENSES within the ZIP.'
196+
comments = 'The full text of the licenses can be found in the LICENSES directory contained in the ZIP archive.'
166197
}
167198
}
168199

169200
developers {
170201
developer {
171-
id = 'ale5000'
202+
id = "${-> lazyAuthor.get() }"
172203
}
173204
}
174205
}

build.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ cat << 'LICENSE'
1818
This program is free software: you can redistribute it and/or modify
1919
it under the terms of the GNU General Public License as published by
2020
the Free Software Foundation, either version 3 of the License, or
21-
(at your option) any later version, w/ zip exception.
21+
(at your option) any later version, w/ Archive Packaging Exception.
2222
2323
This program is distributed in the hope that it will be useful,
2424
but WITHOUT ANY WARRANTY; without even the implied warranty of
25-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2626
GNU General Public License for more details.
2727
2828
You should have received a copy of the GNU General Public License
@@ -119,17 +119,25 @@ OUT_DIR="${MAIN_DIR:?}/output"
119119
MODULE_ID="$(simple_get_prop 'id' "${MAIN_DIR:?}/zip-content/module.prop")" || ui_error 'Failed to parse the module id string'
120120
MODULE_VER="$(simple_get_prop 'version' "${MAIN_DIR:?}/zip-content/module.prop")" || ui_error 'Failed to parse the module version string'
121121
MODULE_AUTHOR="$(simple_get_prop 'author' "${MAIN_DIR:?}/zip-content/module.prop")" || ui_error 'Failed to parse the module author string'
122+
MODULE_ORG="$(simple_get_prop 'organization' "${MAIN_DIR:?}/zip-content/module.prop")" || ui_error 'Failed to parse the module organization string'
122123
case "${MODULE_VER:?}" in
123124
*'-alpha') MODULE_IS_ALPHA='true' ;;
124125
*) MODULE_IS_ALPHA='false' ;;
125126
esac
126127

128+
if test "${GITHUB_ACTIONS:-false}" != 'false'; then
129+
CI_NAME='github'
130+
elif test "${CI:-false}" != 'false'; then
131+
CI_NAME="${CI:?}"
132+
else
133+
CI_NAME='false'
134+
fi
135+
127136
# Set short commit ID
128-
ZIP_SHORT_COMMIT_ID=''
129-
if test "${CI:-false}" != 'false'; then
137+
if test "${CI_NAME:?}" != 'false'; then
130138
ZIP_SHORT_COMMIT_ID="${CI_COMMIT_SHA:-${GITHUB_SHA:?Missing commit ID}}" || ZIP_SHORT_COMMIT_ID=''
131139
else
132-
ZIP_SHORT_COMMIT_ID="$(git 2> /dev/null rev-parse HEAD)" || ZIP_SHORT_COMMIT_ID=''
140+
ZIP_SHORT_COMMIT_ID="$(git 2> /dev/null rev-parse --short=8 HEAD)" || ZIP_SHORT_COMMIT_ID=''
133141
fi
134142
if test -n "${ZIP_SHORT_COMMIT_ID?}"; then
135143
ZIP_SHORT_COMMIT_ID="$(printf '%s' "${ZIP_SHORT_COMMIT_ID:?}" | cut -b '-8')" || ZIP_SHORT_COMMIT_ID=''
@@ -211,14 +219,14 @@ FILENAME_START="${MODULE_ID:?}-${MODULE_VER:?}-"
211219
FILENAME_MIDDLE="${FILENAME_COMMIT_ID:?}"
212220
FILENAME_END="-${BUILD_TYPE:?}-by-${MODULE_AUTHOR:?}"
213221

214-
if test "${CI:-false}" != 'false'; then
222+
if test "${CI_NAME:?}" != 'false'; then
215223
if test -n "${CI_COMMIT_BRANCH-}" && test "${CI_COMMIT_BRANCH:?}" != "${CI_DEFAULT_BRANCH:-unknown}"; then
216224
BRANCH_NAME="$(sanitize_filename_part "${CI_COMMIT_BRANCH:?}" || :)" # GitLab
217225
elif test "${GITHUB_REF_TYPE-}" = 'branch' && test -n "${GITHUB_REF_NAME-}" && test "${GITHUB_REF_NAME:?}" != "${GITHUB_REPOSITORY_DEFAULT_BRANCH:-main}"; then
218226
BRANCH_NAME="$(sanitize_filename_part "${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:?}}" || :)" # GitHub
219227
fi
220228
test -z "${BRANCH_NAME?}" || FILENAME_MIDDLE="${BRANCH_NAME:?}-${FILENAME_MIDDLE:?}"
221-
if test "${CI_PROJECT_NAMESPACE:-${GITHUB_REPOSITORY_OWNER:-unknown}}" != 'micro''5k'; then
229+
if test "${CI_PROJECT_NAMESPACE:-${GITHUB_REPOSITORY_OWNER:-unknown}}" != "${MODULE_ORG:?}"; then
222230
FILENAME_MIDDLE="fork-${FILENAME_MIDDLE:?}" # GitLab / GitHub
223231
fi
224232
else
@@ -376,7 +384,7 @@ cd "${OUT_DIR:?}" || ui_error 'Failed to change the folder' "${LINENO-}" "${FUNC
376384

377385
# Cleanup remnants (skip on CI)
378386
pid=''
379-
if test "${CI:-false}" = 'false'; then
387+
if test "${CI_NAME:?}" = 'false'; then
380388
rm -r -f -- "${TEMP_DIR:?}" &
381389
#pid="${!}"
382390
fi

0 commit comments

Comments
 (0)