diff --git a/.gitmodules b/.gitmodules index a096fd79b..ae7580289 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,7 +36,7 @@ ignore = dirty [submodule "extern/android-support-v4-preferencefragment"] path = extern/android-support-v4-preferencefragment - url = https://github.com/CyberEagle/android-support-v4-preferencefragment.git + url = https://github.com/kolavar/android-support-v4-preferencefragment.git ignore = dirty [submodule "extern/zxing-core"] path = extern/zxing-core diff --git a/CHANGELOG.md b/CHANGELOG.md index e45eee306..bd0a7d225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Show when packages are installed but not via F-Droid (mismatching signature) +* Enable building F-Droid without having to build all dependencies yourself + ### 0.78 (2014-12-31) * Fix repo updates on 5.0 (which caused no apps to show on clean installs) diff --git a/F-Droid/AndroidManifest.xml b/F-Droid/AndroidManifest.xml index 1a637a095..3cde9b343 100644 --- a/F-Droid/AndroidManifest.xml +++ b/F-Droid/AndroidManifest.xml @@ -7,6 +7,7 @@ android:versionName="0.79-test" > diff --git a/F-Droid/build.gradle b/F-Droid/build.gradle index 369ae742e..70fafd29b 100644 --- a/F-Droid/build.gradle +++ b/F-Droid/build.gradle @@ -1,19 +1,113 @@ apply plugin: 'com.android.application' -dependencies { - compile project(':support-v4') - compile project(':support-appcompat-v7') - compile project(':extern:AndroidPinning') - compile project(':extern:UniversalImageLoader:library') - compile project(':extern:MemorizingTrustManager') - compile project(':extern:libsuperuser:libsuperuser') - compile project(':extern:nanohttpd:core') - compile project(':extern:jmdns') - compile project(':extern:zipsigner') - compile project(':extern:zxing-core') - compile( project(':extern:android-support-v4-preferencefragment') ) { - exclude module: 'support-v4' +if ( !hasProperty( 'sourceDeps' ) ) { + + logger.info "Setting up *binary* dependencies for F-Droid (if you'd prefer to build from source, pass the -PsourceDeps argument to gradle while building)." + + repositories { + jcenter() + + // This is here until we sort out all dependencies from mavenCentral/jcenter. Once all of + // the dependencies below have been sorted out, this can be removed. + flatDir { + dirs 'libs' + } } + + dependencies { + + // TODO: A little hazy as to what commit in the source repo these support libraries + // correspond to. As a result, I'm not sure that developers using source dependencies + // and those using binary dependencies are even using the same API. + compile 'com.android.support:support-v4:18.0.+', + 'com.android.support:appcompat-v7:18.0.+', + 'com.android.support:support-annotations:20.0.+', + + 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0', + 'javax.jmdns:jmdns:3.4.1', + 'com.nostra13.universalimageloader:universal-image-loader:1.9.3', + 'com.google.zxing:core:3.1.0', + 'eu.chainfire:libsuperuser:1.0.0.+', + 'com.madgag.spongycastle:pkix:1.51.0.0', + 'com.madgag.spongycastle:prov:1.51.0.0', + 'com.madgag.spongycastle:core:1.51.0.0' + + // Upstream doesn't have a binary on mavenCentral/jcenter yet: + // https://github.com/kolavar/android-support-v4-preferencefragment/issues/13 + compile(name: 'android-support-v4-preferencefragment-release', ext: 'aar') + + // Fork for F-Droid, including support for https. Not merged into upstream + // yet (seems to be a little unsupported as of late), so not using mavenCentral/jcenter. + compile(name: 'nanohttpd-2.1.0') + + // Upstream doesn't have a binary on mavenCentral. + compile(name: 'zipsigner') + + // Upstream doesn't have a binary on mavenCentral, but we are currently not using this + // library due to bugs anyway. In the future, it will likely get included again though. + // compile(name: 'MemorizingTrustManager-release', ext: 'aar') + } + +} else { + + logger.info "Setting up *source* dependencies for F-Droid (because you passed in the -PsourceDeps argument to gradle while building)." + + dependencies { + compile project(':support-v4') + compile project(':support-appcompat-v7') + compile project(':extern:AndroidPinning') + compile project(':extern:UniversalImageLoader:library') + compile project(':extern:libsuperuser:libsuperuser') + compile project(':extern:nanohttpd:core') + compile project(':extern:jmdns') + compile project(':extern:zipsigner') + compile project(':extern:zxing-core') + compile( project(':extern:android-support-v4-preferencefragment') ) { + exclude module: 'support-v4' + } + + // Removed for now, until it is reimplemented. + // compile project(':extern:MemorizingTrustManager') + } + +} + +task cleanBinaryDeps(type: Delete) { + + enabled = project.hasProperty('sourceDeps') + description = "Removes all .jar and .aar files from F-Droid/libs/. Requires the sourceDeps property to be set (\"gradle -PsourceDeps cleanBinaryDeps\")" + + delete fileTree('libs') { + include '*.aar' + include '*.jar' + } +} + +task binaryDeps(type: Copy, dependsOn: ':F-Droid:prepareReleaseDependencies') { + + enabled = project.hasProperty('sourceDeps') + description = "Copies .jar and .aar files from subproject dependencies in extern/ to F-Droid/libs. Requires the sourceDeps property to be set (\"gradle -PsourceDeps binaryDeps\")" + + from ('../extern/' ) { + include 'android-support-v4-preferencefragment/build/outputs/aar/android-support-v4-preferencefragment-release.aar', + 'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar', + 'zipsigner/build/libs/zipsigner.jar', + 'Support/v4/build/libs/support-v4.jar' + + // Removed for now, until it is reimplemented. + // 'MemorizingTrustManager/build/outputs/aar/MemorizingTrustManager-release.aar' + } + + into 'libs' + + includeEmptyDirs false + + eachFile { FileCopyDetails details -> + // Don't copy to a sub folder such as libs/Project/build/outputs/aar/project.aar, but + // rather libs/project.aar. + details.path = details.name + } + } android { @@ -62,7 +156,7 @@ android { } -// TODO: This person took the example code below from another blogpost online, however +// This person took the example code below from another blogpost online, however // I lost the reference to it: // http://stackoverflow.com/questions/23297562/gradle-javadoc-and-android-documentation android.applicationVariants.all { variant -> diff --git a/F-Droid/libs/README.md b/F-Droid/libs/README.md new file mode 100644 index 000000000..08374572e --- /dev/null +++ b/F-Droid/libs/README.md @@ -0,0 +1,50 @@ +# Licenses + +To see which license any one of these libraries is under, consult the extern/ directory. +If you have checked out the source for all dependencies (`git submodule update --init` from the root directory), +then you should be able to find the relevant LICENSE file for each, or else you can consult upstream. + + +# Building libraries from source + +As a matter of principle, and also to comply with the GPLv3+, F-Droid should always be able to be built +from source, _including all of its dependencies_. + +For practical reasons, developers often don't want the overhead of having to fetch the source of each +dependency though. Also, they may not want their build script to have to take the time to configure and +check that each subproject is up-to-date. Building from binary dependencies is _much_ faster, requires +less downloading of external source, and should import into Android Studio and other IDE's more easily. + +To deal with these two goals (building dependencies from source, and relying on prebuilt binaries), the +build script can be run in two modes. + + +## Gradle commands + +`gradle build` will build _F-Droid_ from source, but _not the depenencies_ from source. It will instead depend +on binaries from jcenter where possible, and .jar and .aar files in F-Droid/libs/ elsewhere. + +`gradle -PsourceDeps build` will include all dependencies and build the entire F-Droid binary +and all of its dependencies from source. + +`gradle -PsourceDeps binaryDeps` will build all dependencies from source, and then copy the ones which +are not found in jcenter to F-Droid/libs/, making sure that the latest versions of the libraries are available +for developers wishing to build F-Droid from binary dependencies. + +`gradle -PsourceDeps cleanBinaryDeps` will remove all binary dependencies. It shouldn't be neccesary, +because the `binaryDeps` will copy fresh .jar and .aar files to the F-Droid/libs/ directory when they change. +It may be handy if you are updating the build script though, as a nice way to empty the F-Droid/libs/ directory. + + +# Adding new dependencies + +When adding a new dependency, *DON'T* copy the .jar or .aar file into F-Droid/libs/. This will get deleted +when somebody runs `gradle -PsourceDeps cleanBinaryDeps`. Also, the version of F-Droid built for distribution +on https://f-droid.org will be build from source depednencies, so adding a binary is not enough. + +Instead, you should add the source repo as a submodule in the extern/ diretory. You will also need to modify +the F-Droid/build.gradle file, adding both the source dependency on the project in the extern/ directory, and +a dependency on its jcenter/mavenCentral artifact. If that artifact is not available, then you should add +the library to those to be copied using `gradler -PsourceDeps binaryDeps`. Then, you can commit that binary so that +anyone who clones the F-Droid repo will have all of the dependencies ready in either jcetner or the +F-Droid/libs/ directory. diff --git a/F-Droid/libs/android-support-v4-preferencefragment-release.aar b/F-Droid/libs/android-support-v4-preferencefragment-release.aar new file mode 100644 index 000000000..1515258cc Binary files /dev/null and b/F-Droid/libs/android-support-v4-preferencefragment-release.aar differ diff --git a/F-Droid/libs/android-support-v4.jar b/F-Droid/libs/android-support-v4.jar deleted file mode 100644 index ac4181fca..000000000 Binary files a/F-Droid/libs/android-support-v4.jar and /dev/null differ diff --git a/F-Droid/libs/android-support-v4.jar.LICENSE b/F-Droid/libs/android-support-v4.jar.LICENSE deleted file mode 100644 index ca7abc6a3..000000000 --- a/F-Droid/libs/android-support-v4.jar.LICENSE +++ /dev/null @@ -1,190 +0,0 @@ - Copyright (c) 2005-2013, The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - diff --git a/F-Droid/libs/android-support-v4.jar.README b/F-Droid/libs/android-support-v4.jar.README deleted file mode 100644 index bcdfce018..000000000 --- a/F-Droid/libs/android-support-v4.jar.README +++ /dev/null @@ -1,5 +0,0 @@ -The Android support library v4 is currently at *revision 21.0.1* from the Android SDK. -This reversion was released on October 2014. - -See NOTICE.android-support-v4.txt for license. -See http://developer.android.com/tools/extras/support-library.html for further info. diff --git a/F-Droid/libs/android-support-v4.jar.properties b/F-Droid/libs/android-support-v4.jar.properties deleted file mode 100644 index bc9c2009a..000000000 --- a/F-Droid/libs/android-support-v4.jar.properties +++ /dev/null @@ -1,8 +0,0 @@ -src=android-support-v4.jar -doc=/opt/android-sdk/docs/reference -# The String value of 'doc' is handed straight to `new java.io.File()` so it -# is not possible to use variables. Therefore, change "/opt/android-sdk" to -# the path to your Android SDK, i.e. the value of $ANDROID_HOME or ${sdk.dir} -# -# Here's the relevant source: -# https://android-review.googlesource.com/#/c/35702/3/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java diff --git a/F-Droid/libs/nanohttpd-2.1.0.jar b/F-Droid/libs/nanohttpd-2.1.0.jar new file mode 100644 index 000000000..21e46717c Binary files /dev/null and b/F-Droid/libs/nanohttpd-2.1.0.jar differ diff --git a/F-Droid/libs/support-v4.jar b/F-Droid/libs/support-v4.jar new file mode 100644 index 000000000..4b3b41e62 Binary files /dev/null and b/F-Droid/libs/support-v4.jar differ diff --git a/F-Droid/libs/zipsigner.jar b/F-Droid/libs/zipsigner.jar new file mode 100644 index 000000000..dc2ab6802 Binary files /dev/null and b/F-Droid/libs/zipsigner.jar differ diff --git a/build.gradle b/build.gradle index 6ad9853ef..76e429ef7 100644 --- a/build.gradle +++ b/build.gradle @@ -17,13 +17,22 @@ buildscript { repositories { - mavenCentral() + jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' + + // libsuperuser submodule requires these plugins, even though + // the F-Droid build process never invokes code from them. It + // would be nice to do away with this in the future, so we don't + // force people do download stuff they wont use. + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' + classpath 'com.github.dcendents:android-maven-plugin:1.2' } } +if ( hasProperty( 'sourceDeps' ) ) { + project(':extern:UniversalImageLoader:library') { apply plugin: 'android-library' @@ -77,6 +86,8 @@ project(':support-v4') { } +} + /** * Finds a reference to the prefered Android SDK directory. * Ideally we'd use "android.plugin.sdkFolder" to find this, however this is diff --git a/settings.gradle b/settings.gradle index f8029a65c..3d00da296 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,25 +1,26 @@ include ':F-Droid' -include ':extern:AndroidPinning' -include ':extern:UniversalImageLoader:library' -include ':extern:MemorizingTrustManager' -include ':extern:libsuperuser:libsuperuser' -include ':extern:nanohttpd:core' -include ':extern:jmdns' -include ':extern:zipsigner' -include ':extern:spongycastle:core' -include ':extern:spongycastle:pg' -include ':extern:spongycastle:pkix' -include ':extern:spongycastle:prov' -include ':extern:zxing-core' -include ':extern:android-support-v4-preferencefragment' +if ( hasProperty( 'sourceDeps' ) ) { + include ':extern:AndroidPinning' + include ':extern:UniversalImageLoader:library' + include ':extern:MemorizingTrustManager' + include ':extern:libsuperuser:libsuperuser' + include ':extern:nanohttpd:core' + include ':extern:jmdns' + include ':extern:zipsigner' + include ':extern:spongycastle:core' + include ':extern:spongycastle:pg' + include ':extern:spongycastle:pkix' + include ':extern:spongycastle:prov' + include ':extern:zxing-core' + include ':extern:android-support-v4-preferencefragment' -include ':support-v4' -project(':support-v4').projectDir = new File('extern/Support/v4') + include ':support-v4' + project(':support-v4').projectDir = new File('extern/Support/v4') -include ':support-appcompat-v7' -project(':support-appcompat-v7').projectDir = new File('extern/Support/v7/appcompat') - -include ':support-annotations' -project(':support-annotations').projectDir = new File('extern/Support/annotations') + include ':support-appcompat-v7' + project(':support-appcompat-v7').projectDir = new File('extern/Support/v7/appcompat') + include ':support-annotations' + project(':support-annotations').projectDir = new File('extern/Support/annotations') +}