Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
8c18d21d
Unverified
Commit
8c18d21d
authored
Jan 14, 2021
by
Nikolay Igotti
Committed by
GitHub
Jan 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement remote codesign (#42)
parent
5d43c933
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
14 deletions
+53
-14
build.gradle.kts
skiko/build.gradle.kts
+53
-14
No files found.
skiko/build.gradle.kts
View file @
8c18d21d
...
@@ -291,6 +291,51 @@ project.tasks.register<Exec>("objcCompile") {
...
@@ -291,6 +291,51 @@ project.tasks.register<Exec>("objcCompile") {
outputs
.
files
(
"$outDir/$objcSrc.o"
)
outputs
.
files
(
"$outDir/$objcSrc.o"
)
}
}
fun
localSign
(
signer
:
String
,
lib
:
File
)
{
println
(
"Local signing $lib as $signer"
)
val
proc
=
ProcessBuilder
(
"codesign"
,
"-f"
,
"-s"
,
signer
,
lib
.
absolutePath
)
.
redirectOutput
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
redirectError
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
start
()
proc
.
waitFor
(
5
,
TimeUnit
.
MINUTES
)
if
(
proc
.
exitValue
()
!=
0
)
{
val
out
=
proc
.
inputStream
.
bufferedReader
().
readText
()
val
err
=
proc
.
errorStream
.
bufferedReader
().
readText
()
println
(
out
)
println
(
err
)
throw
GradleException
(
"Cannot sign $lib: $err"
)
}
}
fun
remoteSign
(
sign_host
:
String
,
lib
:
File
)
{
println
(
"Remote signing $lib on $sign_host"
)
val
user
=
project
.
properties
[
"sign_host_user"
]
as
String
val
token
=
project
.
properties
[
"sign_host_token"
]
as
String
val
out
=
file
(
"${lib.absolutePath}.signed"
)
val
cmd
=
"""
TOKEN=`curl -fsSL --user $user:$token --url "$sign_host/auth" | grep token | cut -d '"' -f4` \
&& curl --no-keepalive --data-binary @${lib.absolutePath} \
-H "Authorization: Bearer ${'$'}TOKEN" \
-H "Content-Type:application/x-mac-app-bin" \
"$sign_host/sign?name=${lib.name}" -o "${out.absolutePath}"
"""
.
trimIndent
()
val
proc
=
ProcessBuilder
(
"bash"
,
"-c"
,
cmd
)
.
redirectOutput
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
redirectError
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
start
()
proc
.
waitFor
(
5
,
TimeUnit
.
MINUTES
)
if
(
proc
.
exitValue
()
!=
0
)
{
val
out
=
proc
.
inputStream
.
bufferedReader
().
readText
()
val
err
=
proc
.
errorStream
.
bufferedReader
().
readText
()
println
(
out
)
println
(
err
)
throw
GradleException
(
"Cannot sign $lib: $err"
)
}
else
{
lib
.
delete
()
out
.
renameTo
(
lib
)
}
}
tasks
.
withType
(
LinkSharedLibrary
::
class
.
java
).
configureEach
{
tasks
.
withType
(
LinkSharedLibrary
::
class
.
java
).
configureEach
{
when
(
targetOs
)
{
when
(
targetOs
)
{
OS
.
MacOS
->
{
OS
.
MacOS
->
{
...
@@ -331,21 +376,15 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach {
...
@@ -331,21 +376,15 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach {
}
}
doLast
{
doLast
{
val
dylib
=
outputs
.
files
.
files
.
singleOrNull
{
it
.
name
.
endsWith
(
".dylib"
)
}
(
project
.
properties
[
"signer"
]
as
String
?)
?.
let
{
signer
->
(
project
.
properties
[
"signer"
]
as
String
?)
?.
let
{
signer
->
outputs
.
files
.
files
.
singleOrNull
{
it
.
name
.
endsWith
(
".dylib"
)
}
?.
let
{
lib
->
dylib
?.
let
{
lib
->
println
(
"Signing $lib as $signer"
)
localSign
(
signer
,
lib
)
val
proc
=
ProcessBuilder
(
"codesign"
,
"-f"
,
"-s"
,
signer
,
lib
.
absolutePath
)
}
.
redirectOutput
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
redirectError
(
ProcessBuilder
.
Redirect
.
PIPE
)
.
start
()
proc
.
waitFor
(
5
,
TimeUnit
.
MINUTES
)
if
(
proc
.
exitValue
()
!=
0
)
{
val
out
=
proc
.
inputStream
.
bufferedReader
().
readText
()
val
err
=
proc
.
errorStream
.
bufferedReader
().
readText
()
println
(
out
)
println
(
err
)
throw
GradleException
(
"Cannot sign $lib: $err"
)
}
}
(
project
.
properties
[
"sign_host"
]
as
String
?)
?.
let
{
sign_host
->
dylib
?.
let
{
lib
->
remoteSign
(
sign_host
,
lib
)
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment