Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Fixes for Linux packaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehearn committed Dec 24, 2018
1 parent 5dcdbd6 commit 26e4c15
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 44 deletions.
6 changes: 3 additions & 3 deletions bootstrap/src/main/kotlin/bootstrap-posix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ private fun findHighestVersion(): Int {
var highestVersionFound = 0
while (true) {
val entry = (readdir(d) ?: break).pointed
// Skip entries that aren't directories.
if (entry.d_type != DT_DIR.toUByte()) continue
// Skip entries that don't have integer names.
// Skip entries that don't have integer names. We can't use the d_type field because it's not
// always set on every filesystem.
val entryName = entry.d_name.toKString()
if (entryName.any { !it.isDigit() }) continue
// Is this higher than any version number found so far?
val versionNumber = entryName.toInt()
highestVersionFound = max(highestVersionFound, versionNumber)
}
closedir(d)
check(highestVersionFound > 0) { "Could not locate versioned directories" }
return highestVersionFound
}
6 changes: 3 additions & 3 deletions bootstrap/src/main/kotlin/linux.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import platform.posix.readlink
val fullBinaryPath: String
get() {
memScoped {
val length = PATH_MAX.toLong()
val pathBuf = allocArray<ByteVar>(length)
val length = PATH_MAX.toULong()
val pathBuf = allocArray<ByteVar>(length.toInt())
val myPid = getpid()
val res = readlink("/proc/$myPid/exe", pathBuf, length)
if (res < 1)
Expand All @@ -21,4 +21,4 @@ val fullBinaryPath: String
}
}

val exeFile: String get() = "GravitonBrowser"
val exeFile: String get() = "graviton"
45 changes: 7 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

def allJars = configurations.runtime.collect { it.getName() }

jar {
inputs.property("moduleName", moduleName)
manifest {
attributes(
'Automatic-Module-Name': moduleName,
'Main-Class': mainClassName,
'Class-Path': configurations.runtime.collect { it.getName() }.join(' ')
'Class-Path': allJars.join(' ')
)
}
}
Expand All @@ -72,7 +74,7 @@ task copyBootstrapToLibs(type: Copy, dependsOn: [installDist, tasks.getByPath(':
else if (os.contains('win'))
from 'bootstrap/build/konan/bin/mingw_x64'
else if (os.contains('linux'))
from 'bootstrap/build/konan/bin/linux'
from 'bootstrap/build/konan/bin/linux_x64'
from 'LICENSE'
into('build/install/graviton/lib')
}
Expand Down Expand Up @@ -121,48 +123,15 @@ task makeWinInstaller(type: Exec, dependsOn: [copyBootstrapToLibs]) {
// You need InnoSetup and the Windows SDK to run this task. For code signing you also need a valid certificate and
// accessible private key.
task packageWin(type: Exec, dependsOn: [makeWinInstaller]) {
group = "Packaging"
description = "Build the EXE installer for Windows and sign it"

inputs.files("build/packaged/GravitonBrowser.exe")

// Now sign the EXE to help reduce warnings from IE.
commandLine = ['signtool', 'sign', '/a', '/t', 'http://time.certum.pl', '/fd', 'sha256', '/v', '/debug', 'build\\packaged\\bundles\\GravitonBrowser.exe']
}

// TODO: Use the bootstrapper tool. Lay out files in numbered directories.
task packageLinux(type: Exec, dependsOn: [copyBootstrapToLibs]) {
workingDir project.projectDir
def outDir = "${buildDir}/packaged"
outputs.dir(outDir)
inputs.files(copyBootstrapToLibs.outputs)
inputs.files('package/linux')

environment "GRAVITON_VERSION", project.version

commandLine = [
'javapackager',
'-deploy',
'-nosign',
'-native', 'deb',
'-outdir', outDir,
'-outfile', 'GravitonBrowser',
'-name', 'Graviton Browser',
'-appclass', mainClassName,
'-srcdir', 'build/install/graviton/lib',
'-Bidentifier=app.graviton.browser',
"-BmainJar=graviton-${project.version}.jar",
"-BappVersion=${project.version}",
"-Bcategory=Network",
"-Bemail=mike@plan99.net",
"-Bcopyright=Graviton",
"-BlicenseType=Apache-2.0",
"-BlicenseFile=LICENSE",
"-Bvendor=Mike Hearn",
"-v"
]

// TODO: Signing
// TODO: Icons
}

task refreshAPIDocs(type: Copy) {
dependsOn(getTasks().findByPath(":api:javadoc"))
from 'api/build/docs/javadoc'
Expand Down
34 changes: 34 additions & 0 deletions package-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# javapackager in Java 8 is an awful, awful program ... so buggy. Well use it anyway to put together a basic
# image, albeit with workarounds. Then well modify that image to use the bootstrapper, then tarball it.

set -e

v=$( ./gradlew -q printVersion )
export GRAVITON_VERSION=$v

echo "Building Linux package for Graviton $v"
echo

./gradlew copyBootstrapToLibs
bundles=build/packaged/bundles
srcfiles=$( ls build/install/graviton/lib )
# The -outfile flag doesn't seem to actually be used, instead name is combined with
# version to produce the output file name, but it has to be specified anyway.
#
# We can't pass -srcfiles "$srcfiles" in the obvious and correct way because I get
# an out of memory error regardless of what heap size I use. Not sure why but I'll
# copy the files manually afterwards.
rm -rf $bundles || true
javapackager -deploy -nosign -native image -outdir build/packaged/ -outfile graviton-$GRAVITON_VERSION -name graviton -appclass app.graviton.shell.Graviton -srcdir build/install/graviton/lib -Bidentifier=app.graviton.browser -BmainJar=graviton-$GRAVITON_VERSION.jar -BappVersion=$GRAVITON_VERSION -Bcategory=Network -Bemail=mike@plan99.net -Bcopyright=Graviton -BlicenseType=Apache-2.0 -BlicenseFile=build/install/graviton/lib/LICENSE -v
for f in $srcfiles; do
cp build/install/graviton/lib/$f $bundles/graviton/app/$f
done

[[ -d /tmp/graviton-image ]] && rm -rf /tmp/graviton-image
mv $bundles/graviton /tmp/graviton-image
mkdir $bundles/graviton
mv /tmp/graviton-image $bundles/graviton/$GRAVITON_VERSION
mv $bundles/graviton/$GRAVITON_VERSION/app/bootstrap.kexe $bundles/graviton/graviton
tar czvf $bundles/graviton.tar.gz $bundles/graviton

0 comments on commit 26e4c15

Please sign in to comment.