submodule hell is blocking fdroid build.
I had a "fun" (mis)adventure with git submodules this weekend trying to re-build bitmask_android
at our last stable release tag so that we can publish a signed apk and get published on fdroid as per izzysoft's generous offer.
I'm at an impasse and publishing my steps here as an issue in the hopes that someone with more submodule fu (or perhaps just a cleaner set of eyes?) can help me get unstuck.
Your humble narrator's adventure began, dear reader, from this innocuous-enough looking release tag:
https://0xacab.org/leap/bitmask_android/tree/0.9.4_FDROID
Which, as the keen-eyed reader might note, is pinned to commit 0c5ab6b9
in some version -- but which? -- of the ics-openvpn
repo. Stick around to find out!
Assuming we have started by cloning git@0xacab:leap/bitmask_android.git
into a directory called fdroid-release
, let's start retracing our humble narrator's steps:
aguestuser@tikva:~/-/leap/code/fdroid-release$ git checkout 0.9.4_FDROID
Note: checking out '0.9.4_FDROID'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at c11c0c70... Merge branch 'feature/f-droid-verify-support-#6165' into develop
okay, let's attach that head!
aguestuser@tikva:~/-/leap/code/fdroid-release$ git checkout -b froid-release
Switched to a new branch 'froid-release'
And, as was our wont in simpler days, let's try to initialize submodules:
aguestuser@tikva:~/-/leap/code/fdroid-release$ git submodule init
aguestuser@tikva:~/-/leap/code/fdroid-release$ git submodule sync
Synchronizing submodule url for 'ics-openvpn'
aguestuser@tikva:~/-/leap/code/fdroid-release$ git submodule update --init --recursive
Cloning into '/home/aguestuser/-/leap/code/fdroid-release/ics-openvpn'...
error: no such remote ref 0c5ab6b91844319433932b67e97fbb23649ca006
Fetched in submodule path 'ics-openvpn', but it did not contain 0c5ab6b91844319433932b67e97fbb23649ca006. Direct fetching of that commit failed.
Oh noes! Why in the world would git not be able to find the commit that we saw with our own eyes the submodule was pinned to at the top of our adventure?
Let's navigate to this pesky 0c5ab6b9
by clicking link in link from 0xacab repo:
Recall we started here:
https://0xacab.org/leap/bitmask_android/tree/0.9.4_FDROID
Let's click on pinned commit 0c5ab6b9
!
Lo and behold, here we are at @parmegv's personal clone of ics-openvpn
:
https://github.com/parmegv/ics-openvpn/tree/0c5ab6b91844319433932b67e97fbb23649ca006
If we are curious about what happened at that commit, we can find out easily enough:
https://github.com/parmegv/ics-openvpn/commit/0c5ab6b91844319433932b67e97fbb23649ca006
A quick cat
reveals that this is indeed the repo that bitmask_android
associates with the ics-openvpn
submodule:
aguestuser@tikva:~/-/leap/code/fdroid-release$ cat .gitmodules
[submodule "ics-openvpn"]
path = ics-openvpn
branch = bitmask
url = https://github.com/parmegv/ics-openvpn.git
cd'ing into ics-openvpn
dir and showing this commit fails:
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git show 0c5ab6b9
fatal: ambiguous argument '0c5ab6b9': unknown revision or path not in the working tree.
Well gosh, golly! I wonder what would happen if we tried simply cloning the repo and trying to show the commit?
aguestuser@tikva:~/-/leap/code$ git clone git@github.com:parmegv/ics-openvpn.git
Cloning into 'ics-openvpn'...
remote: Counting objects: 19291, done.
remote: Total 19291 (delta 0), reused 0 (delta 0), pack-reused 19291
Receiving objects: 100% (19291/19291), 49.75 MiB | 1.97 MiB/s, done.
Resolving deltas: 100% (11952/11952), done.
aguestuser@tikva:~/-/leap/code$ git show 0c5ab6b9
fatal: Not a git repository (or any of the parent directories): .git
aguestuser@tikva:~/-/leap/code$ cd ics-openvpn/
aguestuser@tikva:~/-/leap/code/ics-openvpn$ git show 0c5ab6b9
fatal: ambiguous argument '0c5ab6b9': unknown revision or path not in the working tree.
No dice!
Okay, well let's get sneaky and grep for the commit message we saw on github! Sounds crazy, but hey, we seem to be in the Twilight Zone anyway, so couldn't hurt!
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git log --all --grep="Saving some time, only compile mips"
commit fa3ec1e18415e87ab050b8aa4dc9d749edf49f5e
Author: Parménides GV <parmegv@sdf.org>
Date: Tue Jun 23 13:26:04 2015 +0200
Revert "Saving some time, only compile mips"
This reverts commit dabccaea04e8ed37dacef626135cbd6d2557b319.
Hey! That appears to be the exact same commit we just saw on github, only with a completely different commit hash. Weird!
But hey, everything's wierd, so let's try showing it:
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git show fa3ec1e18415e87ab050b8aa4dc9d749edf49f5
commit fa3ec1e18415e87ab050b8aa4dc9d749edf49f5e
Author: Parménides GV <parmegv@sdf.org>
Date: Tue Jun 23 13:26:04 2015 +0200
Revert "Saving some time, only compile mips"
This reverts commit dabccaea04e8ed37dacef626135cbd6d2557b319.
diff --git a/main/jni/Application.mk b/main/jni/Application.mk
index 149418f8..9ecbf2e1 100644
--- a/main/jni/Application.mk
+++ b/main/jni/Application.mk
@@ -1,4 +1,4 @@
-APP_ABI := mips
+APP_ABI := arm64-v8a armeabi armeabi-v7a mips x86 x86_64
APP_PLATFORM := android-14
APP_STL:=stlport_static
@@ -8,4 +8,4 @@ APP_STL:=stlport_static
#LOCAL_ARM_MODE := arm
-#NDK_TOOLCHAIN_VERSION=clang
+#NDK_TOOLCHAIN_VERSION=clang
Looks identical! Okay, let's check that out and see if we can update all the submodules.
First let's checkout the commit in question:
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git checkout fa3ec1e18415e87ab050b8aa4dc9d749edf
49f5
Note: checking out 'fa3ec1e18415e87ab050b8aa4dc9d749edf49f5'.
...omited...
HEAD is now at fa3ec1e1... Revert "Saving some time, only compile mips"
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git checkout -b fdroid-release
Switched to a new branch 'fdroid-release'
Then let's initialize submodules:
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git submodule update --init --recursive
Submodule 'main/openssl' (https://github.com/schwabe/platform_external_openssl.git) registered for path 'main/openssl'
Submodule 'main/openvpn' (https://github.com/schwabe/openvpn.git) registered for path 'main/openvpn'
Cloning into '/home/aguestuser/-/leap/code/fdroid-release/ics-openvpn/main/openssl'...
Cloning into '/home/aguestuser/-/leap/code/fdroid-release/ics-openvpn/main/openvpn'...
Submodule path 'main/openssl': checked out '00a8f82a71d642557dcac8b158290b01328e3702'
error: no such remote ref 16ecc6b792258c35f311607fe8338cf5f125bd60
Fetched in submodule path 'main/openvpn', but it did not contain 16ecc6b792258c35f311607fe8338cf5f125bd60. Direct fetching of that commit failed.
Oh noes! we're having the same problem recursively with the commits in ics-openvpn
's nested submodules of openvpn
that we had in ics-openvpn
! (luckily openssl
appears to be okay?)
also, weird is that if we inspect the commit of openvpn
pinned by the commit of in parmegv's forked repo of ics-openvpn
pinned by 0xaca/bitmask_android...
https://github.com/parmegv/ics-openvpn/tree/0c5ab6b91844319433932b67e97fbb23649ca006/main
... we see that the commit pinned here is not the one referenced in our error message, but instead an entirely different commit: c9b2b7d
, ie:
https://github.com/schwabe/openvpn/tree/c9b2b7dc10e7781d335e8799479304f64e06caac
Seems odd, but what's new! Let's try checking out c9b2b7d
:
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn/main/openvpn$ git checkout c9b2b7d
Note: checking out 'c9b2b7d'.
...omitted...
HEAD is now at c9b2b7dc... Add files for building for Android
Well.. that seemed to work! let's try running the build!
It's missing files that are (1) needed for the build and (2) present in the github repo.
./gradlew assembleDebug
...omitted...
FAILURE: Build failed with an exception.
* Where:
Build file '/home/aguestuser/-/leap/code/fdroid-release/app/build.gradle' line: 189
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not list contents of '/home/aguestuser/-/leap/code/fdroid-release/app/snappy'.
It seems like there's a missing file in <project-root>/app/snappy
!
In fact, if we look at <project-root>/app/snappy
, we see a symlink to <project-root>/ics-openvpn/snappy
, but no file exists at that path in our local copy of the repo, even though it does exist in @parmegv's github repo at commit oc5ab6b9
:
https://github.com/parmegv/ics-openvpn/tree/0c5ab6b91844319433932b67e97fbb23649ca006/main/snappy
Well, that's discouraging! I guess while we're mucking about this annoying repo, we might as well see what other branches it has....
Well hey there! There's this awful suspicious looking branch called bitmask
:
https://github.com/parmegv/ics-openvpn/tree/bitmask
Hmm... what if we tried cloning a fresh version of bitmask_android
, cd-ing into ics-openvpn
, checking out the bitmask
branch, then trying to initialize submodules? So crazy it just might work???
Nah. I'll spare you all the gory terminal output, but if you run something like the below:
aguestuser@tikva:~/-/leap/code/fdroid-release$ git submodule init
aguestuser@tikva:~/-/leap/code/fdroid-release$ git submodule sync
aguestuser@tikva:~/-/leap/code/fdroid-release$ cd ics-openvpn
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git submodule init
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git submodule update
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git checkout -b foobar
aguestuser@tikva:~/-/leap/code/fdroid-release/ics-openvpn$ git submodule update --init --recursive
You will find that you can successfully update the ics-openvpn
submodule (but, mind you, only from within the ics-openvpn
directory, not from ):
Submodule 'main/openssl' (https://github.com/schwabe/platform_external_openssl.git) registered for path 'main/openssl'
Submodule 'main/openvpn' (https://github.com/schwabe/openvpn.git) registered for path 'main/openvpn'
Cloning into '/home/aguestuser/-/leap/code/fdroid-release/ics-openvpn/main/opensPaging @micah , who offered to try to reproduce the error. But also perhaps @kwadronaut sl'...
Cloning into '/home/aguestuser/-/leap/code/fdroid-release/ics-openvpn/main/openvpn'...
Submodule path 'main/openssl': checked out 'f6da7c53fd01990e8e039dbfd5e9ea87e50d1d44'
Submodule path 'main/openvpn': checked out 'f950206d3f6d181eea5a267548e793c2429aace4'
But that for all your troubles, the problem with the symlink pointing to an empty snappy
directory still haunts you.
At this point, dear reader, your humble author hangs his head in frustration and trundles off to bed to watch Rick and Morty.
Anyone got bright ideas? Or a stiff drink?
Paging @micah , who offered to try to reproduce the error. But also perhaps @kwadronaut or @varac might have the requisite fu at hand?