Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

[Android] Get unstable package suffix from git

Carsten Hartenfels201ae241e6d2
diff --git a/build-tools/ci-scripts/build-android-appbundle.py b/build-tools/ci-scripts/build-android-appbundle.py
index 425aded56c..13038847aa 100644
--- a/build-tools/ci-scripts/build-android-appbundle.py
+++ b/build-tools/ci-scripts/build-android-appbundle.py
@@ -32,8 +32,23 @@ buildEnvironment = dict(os.environ)
buildEnvironment['KRITA_BUILD_APPBUNDLE'] = '1'
buildEnvironment['APK_PATH'] = artifactsFolder
buildEnvironment['KRITA_INSTALL_PREFIX'] = '.xxx' # just a fake path to trigger an error if used (if shouldn't be used for aab)
-buildEnvironment['KRITA_UNSTABLE_PACKAGE_SUFFIX'] = '' if arguments.package_type == 'release' \
- else '-{}'.format(os.environ['CI_COMMIT_SHORT_SHA'])
+
+if arguments.package_type == 'release':
+ unstablePackageSuffix = ''
+else:
+ shortSha = os.environ.get('CI_COMMIT_SHORT_SHA')
+ if shortSha is None:
+ print('## CI_COMMIT_SHORT_SHA not set, attempting to retrieve it through git')
+ scriptDir = os.path.dirname(os.path.abspath(__file__))
+ shortSha = subprocess.check_output(['git', 'log', '--pretty=%h', '-n', '1'], cwd=scriptDir).decode().strip()
+
+ if not shortSha:
+ print('## ERROR: no unstable package suffix, please set CI_COMMIT_SHORT_SHA')
+ sys.exit(1)
+
+ unstablePackageSuffix = '-{}'.format(shortSha)
+
+buildEnvironment['KRITA_UNSTABLE_PACKAGE_SUFFIX'] = unstablePackageSuffix
try:
print( "## MERGING libs.xml" )
diff --git a/build-tools/ci-scripts/build-android-package.py b/build-tools/ci-scripts/build-android-package.py
index fcd7fecd1d..0f8bcac48c 100644
--- a/build-tools/ci-scripts/build-android-package.py
+++ b/build-tools/ci-scripts/build-android-package.py
@@ -49,8 +49,22 @@ buildEnvironment = dict(os.environ)
buildEnvironment['ANDROID_ABI'] = os.environ['KDECI_ANDROID_ABI']
buildEnvironment['KRITA_INSTALL_PREFIX'] = depsPath
-buildEnvironment['KRITA_UNSTABLE_PACKAGE_SUFFIX'] = '' if arguments.package_type == 'release' \
- else '-{}'.format(os.environ['CI_COMMIT_SHORT_SHA'])
+if arguments.package_type == 'release':
+ unstablePackageSuffix = ''
+else:
+ shortSha = os.environ.get('CI_COMMIT_SHORT_SHA')
+ if shortSha is None:
+ print('## CI_COMMIT_SHORT_SHA not set, attempting to retrieve it through git')
+ scriptDir = os.path.dirname(os.path.abspath(__file__))
+ shortSha = subprocess.check_output(['git', 'log', '--pretty=%h', '-n', '1'], cwd=scriptDir).decode().strip()
+
+ if not shortSha:
+ print('## ERROR: no unstable package suffix, please set CI_COMMIT_SHORT_SHA')
+ sys.exit(1)
+
+ unstablePackageSuffix = '-{}'.format(shortSha)
+
+buildEnvironment['KRITA_UNSTABLE_PACKAGE_SUFFIX'] = unstablePackageSuffix
commandToRun = 'cmake --build . --target create-apk'
try: