Skip to content

Commit

Permalink
#8 - Try the suggested patch for EventBus RB
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Oct 29, 2023
1 parent 7031000 commit 3bfee78
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 3 deletions.
33 changes: 33 additions & 0 deletions app/build.gradle
Expand Up @@ -67,6 +67,34 @@ android {
lint {
abortOnError false
}


// https://codeberg.org/Bazsalanszky/Eternity/commit/05123c70682e5988ad5f0ff111f97b66a87d8806
// Patch that solves the problem with EventBus and Reproducible Builds

task rearrangeClass(type: Exec) {
commandLine 'python', '../scripts/fixEventBus.py'
}

applicationVariants.all { variant ->
if (variant.name == 'release') {
task("compileSingleFile${variant.name.capitalize()}", type: JavaCompile, dependsOn: rearrangeClass) {
def filePath = project.rootDir.absolutePath + '/app/build/generated/ap_generated_sources/release/out/eu/basicairdata/graziano/gpslogger/'
source = files(filePath)
includes = ["**/EventBusIndex.java"]
classpath = variant.getCompileClasspath() + files(project.rootDir.absolutePath + '/app/build/intermediates/javac/release/classes')
destinationDir = file("$buildDir/intermediates/javac/release/classes")
}

tasks.withType(JavaCompile).all { task ->
if (task.name == 'compileReleaseJavaWithJavac') {
task.finalizedBy "compileSingleFile${variant.name.capitalize()}"
}
}
}
}

// end patch
}

dependencies {
Expand All @@ -85,4 +113,9 @@ dependencies {

implementation "org.greenrobot:eventbus:3.3.1"
annotationProcessor "org.greenrobot:eventbus-annotation-processor:3.3.1"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
17 changes: 14 additions & 3 deletions build.gradle
Expand Up @@ -26,6 +26,17 @@ allprojects {
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
//task clean(type: Delete) {
// delete rootProject.buildDir
//}

// https://codeberg.org/Bazsalanszky/Eternity/commit/05123c70682e5988ad5f0ff111f97b66a87d8806
// Patch that solves the problem with EventBus and Reproducible Builds

tasks.whenTaskAdded {
if (name.contains("ArtProfile")) {
enabled = false
}
}

// end patch
32 changes: 32 additions & 0 deletions scripts/fixEventBus.py
@@ -0,0 +1,32 @@
import re
import sys


def rearrange(filename):
with open(filename, 'r') as file:
content = file.read()

# Regex to find the blocks of code to rearrange
pattern = re.compile(r'(putIndex\(new SimpleSubscriberInfo\(.*?\)\);)', re.DOTALL)
blocks = pattern.findall(content)

# Sort blocks based on the class names mentioned in SimpleSubscriberInfo instances
sorted_blocks = sorted(blocks, key=lambda x: re.search(r'SimpleSubscriberInfo\((.*?),', x).group(1))

# Replace the original blocks with the sorted blocks
sorted_content = pattern.sub(lambda match: sorted_blocks.pop(0), content)

with open(filename, 'w') as file:
file.write(sorted_content)


# Project root relative to the script
project_root = __file__[:-len('/scripts/fixEventBus.py')]

path = './build/generated/ap_generated_sources/release/out/eu/basicairdata/graziano/gpslogger/EventBusIndex.java'

# Print the path to the file to stderr
print(path, file=sys.stderr)

# Call the function with the path to EventBusIndex.java
rearrange(path)

1 comment on commit 3bfee78

@GrazianoCapelli
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to compile some times the signed app with the patch here above, and now the diffoscope shows only one difference: the APK Signing block.

Schermata del 2023-10-29 23-31-47

It should be good.

Please sign in to comment.