Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
ff9971b7
Verified
Commit
ff9971b7
authored
6 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
If verification fails, delete, download and re-verify.
parent
0823934e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bramble-android/build.gradle
+44
-20
44 additions, 20 deletions
bramble-android/build.gradle
with
44 additions
and
20 deletions
bramble-android/build.gradle
+
44
−
20
View file @
ff9971b7
import
de.undercouch.gradle.tasks.download.Download
import
de.undercouch.gradle.tasks.download.Verify
import
java.security.NoSuchAlgorithmException
apply
plugin:
'com.android.library'
apply
plugin:
'witness'
apply
plugin:
'de.undercouch.download'
...
...
@@ -67,38 +69,60 @@ def torBinaries = [
"geoip"
:
'8239b98374493529a29096e45fc5877d4d6fdad0146ad8380b291f90d61484ea'
]
def
downloadBinary
(
name
)
{
return
tasks
.
create
(
"downloadBinary${name}"
,
Download
)
{
def
verifyOrDeleteBinary
(
name
,
chksum
)
{
return
tasks
.
create
(
"verifyOrDeleteBinary${name}"
,
VerifyOrDelete
)
{
src
"${torBinaryDir}/${name}.zip"
algorithm
'SHA-256'
checksum
chksum
onlyIf
{
src
.
exists
()
}
}
}
def
downloadBinary
(
name
,
chksum
)
{
return
tasks
.
create
([
name:
"downloadBinary${name}"
,
type:
Download
,
dependsOn:
verifyOrDeleteBinary
(
name
,
chksum
)])
{
src
"${torDownloadUrl}${name}.zip"
.
replace
(
'tor_'
,
"tor-${torVersion}-"
)
.
replace
(
'geoip'
,
"geoip-${geoipVersion}"
)
.
replaceAll
(
'_'
,
'-'
)
dest
"${torBinaryDir}/${name}.zip"
onlyIf
{
!
dest
.
exists
()
}
}
}
def
verifyBinary
(
name
,
chksum
)
{
String
filename
=
"${torBinaryDir}/${name}.zip"
if
(
new
File
(
"bramble-android/${filename}"
).
exists
())
{
return
tasks
.
create
(
"verifyBinary${name}"
,
Verify
)
{
src
filename
algorithm
'SHA-256'
checksum
chksum
}
}
else
{
return
tasks
.
create
([
name
:
"verifyBinary${name}"
,
type
:
Verify
,
dependsOn:
downloadBinary
(
name
)])
{
src
filename
algorithm
'SHA-256'
checksum
chksum
}
return
tasks
.
create
([
name
:
"verifyBinary${name}"
,
type
:
Verify
,
dependsOn:
downloadBinary
(
name
,
chksum
)])
{
src
"${torBinaryDir}/${name}.zip"
algorithm
'SHA-256'
checksum
chksum
}
}
project
.
afterEvaluate
{
torBinaries
.
every
{
key
,
value
->
preBuild
.
dependsOn
.
add
(
verifyBinary
(
key
,
value
))
torBinaries
.
every
{
name
,
checksum
->
preBuild
.
dependsOn
.
add
(
verifyBinary
(
name
,
checksum
))
}
}
class
VerifyOrDelete
extends
Verify
{
@TaskAction
@Override
void
verify
()
throws
IOException
,
NoSuchAlgorithmException
{
try
{
super
.
verify
()
}
catch
(
Exception
e
)
{
println
"${src} failed verification - deleting"
src
.
delete
()
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment