Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix native lib extraction #24

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ android {
buildFeatures {
viewBinding true
}

packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}

dependencies {
Expand Down
27 changes: 22 additions & 5 deletions app/src/main/java/de/lolhens/resticui/restic/Restic.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.lolhens.resticui.restic

import android.system.Os
import java.io.File
import java.io.InputStream
import java.net.InetAddress
Expand All @@ -9,10 +10,26 @@ import java.util.concurrent.CompletableFuture
class Restic(
private val storage: ResticStorage
) {
private val proot = storage.lib().resolve("proot")
private val restic = storage.lib().resolve("restic")
private val loader = storage.lib().resolve("loader")
private val loader32 = storage.lib().resolve("loader32")
private fun executable(name: String) =
storage.lib().resolve("libdata_$name.so")

private val lib = storage.cache().resolve("lib")

private fun initLib(name: String) {
lib.mkdirs()
val linkFile = lib.resolve(name)
linkFile.delete()
Os.symlink(executable(name).absolutePath, linkFile.absolutePath)
}

init {
initLib("libtalloc.so.2")
}

private val proot = executable("proot")
private val restic = executable("restic")
private val loader = executable("loader")
private val loader32 = executable("loader32")

private fun binds(hostsFile: File): List<Pair<String, String>> = listOf(
Pair("/system", "/system"),
Expand All @@ -36,7 +53,7 @@ class Restic(
private fun vars(): List<Pair<String, String>> = listOf(
Pair("PATH", "/system/bin"),
Pair("TMPDIR", storage.cache().absolutePath),
Pair("LD_LIBRARY_PATH", storage.lib().absolutePath),
Pair("LD_LIBRARY_PATH", lib.absolutePath),
Pair("PROOT_LOADER", loader.absolutePath),
Pair("PROOT_LOADER_32", loader32.absolutePath),
Pair("PROOT_TMP_DIR", storage.cache().absolutePath),
Expand Down