Skip to content

Commit

Permalink
Hopefully fix Linux CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Heath123 committed Dec 22, 2020
1 parent 4e7d30c commit d024a63
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pipeline {
sh 'cp -r javaCompiledReleaseWindows/Release out/pakkit-win32-x64/resources/app/node_modules/java/build/Release'
sh 'npx electron-forge package --platform linux'
sh 'cd out/pakkit-linux-x64/resources/app/; node-prune; npx electron-rebuild -v 8.5.2;'
sh 'mv out/pakkit-linux-x64/pakkit out/pakkit-linux-x64/dont_run_directly'
sh 'mv launch_linux_ci_builds.sh out/pakkit-linux-x64/pakkit'
sh 'chmod +x out/pakkit-linux-x64/pakkit'
sh 'npx electron-forge package --platform darwin'
sh 'cd out/pakkit-darwin-x64/pakkit.app/Contents/Resources/app/; npx electron-rebuild -v 8.5.2;'
sh 'mv out/pakkit-win32-x64 pakkit-windows-x64'
Expand Down
14 changes: 14 additions & 0 deletions launch_linux_ci_builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Hacky workaround for problems on Linux
chmod +x dont_run_directly
output="SHOULD RESTART PROGRAM"
while [[ $output == *"SHOULD RESTART PROGRAM"* ]]; do
if test -f "resources/app/node_modules/java/build/jvm_dll_path.json"; then
LD_LIBRARY_PATH=$(cat resources/app/node_modules/java/build/jvm_dll_path.json| sed 's/"//g' | sed 's/://g') ./dont_run_directly
output=""
else
exec 3>&1
output=$(LD_LIBRARY_PATH=$(cat resources/app/node_modules/java/build/jvm_dll_path.json| sed 's/"//g' | sed 's/://g') ./dont_run_directly 2>&1 1>&3)
exec 3>&-
fi
done
42 changes: 24 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let setupDataFolder

let continueProgram = true

// Hacky workaround for problems with java module in CI builds

try {
javaProxy = require('./proxy/java/proxy.js')
bedrockProxy = require('./proxy/bedrock/proxy.js')
Expand All @@ -26,27 +28,31 @@ try {
console.log('err', err.message)
if (err.message.includes('The specified module could not be found.') || err.message.includes('Cannot find module')) {
console.log('fix!!!')
if (!fs.existsSync(resourcesPath + 'flag_java_fixed.txt')) {
fs.openSync(resourcesPath + 'flag_java_fixed.txt', 'w')
// Run postInstall.js for java module
if (fs.existsSync(resourcesPath + 'node_modules/java/')) {
console.log('Running postInstall.js...')
const oldDir = process.cwd()
process.chdir(resourcesPath + 'node_modules/java/')
require(oldDir + '/' + resourcesPath + 'node_modules/java/postInstall.js')
process.chdir(oldDir)

continueProgram = false
setTimeout(() => {
continueProgram = false
// Run postInstall.js for java module
if (fs.existsSync(resourcesPath + 'node_modules/java/')) {
console.log('Running postInstall.js...')
const oldDir = process.cwd()
process.chdir(resourcesPath + 'node_modules/java/')
require(oldDir + '/' + resourcesPath + 'node_modules/java/postInstall.js')
process.chdir(oldDir)

if (process.platform !== 'win32') {
console.error('SHOULD RESTART PROGRAM')
}

setTimeout(() => {
// Handled by start script on Linux
if (process.platform === 'win32') {
app.relaunch()
app.exit()
process.exit(0)
}, 3000)
} else {
console.error(resourcesPath + 'node_modules/java/ does not exist!')
app.exit()
}
process.exit(0)
}
}, 3000)
} else {
console.error(resourcesPath + 'node_modules/java/ does not exist!')
app.exit()
process.exit(0)
}
}
}
Expand Down

0 comments on commit d024a63

Please sign in to comment.