Creates a self-extracting install script.

This commit is contained in:
Markil3
2021-09-15 09:03:48 -06:00
parent 90f82cb05d
commit f7370ba08a
9 changed files with 210 additions and 9 deletions

View File

@@ -20,6 +20,10 @@ configurations {
canBeConsumed = true canBeConsumed = true
canBeResolved = false canBeResolved = false
} }
install {
canBeConsumed = true
canBeResolved = false
}
} }
// In this section you declare where to find the dependencies of your project // In this section you declare where to find the dependencies of your project
@@ -57,4 +61,5 @@ artifacts {
nativeBuild(installDist.destinationDir) { nativeBuild(installDist.destinationDir) {
builtBy installDist builtBy installDist
} }
install(distTar)
} }

View File

@@ -15,9 +15,6 @@
"Fingerprinting": true "Fingerprinting": true
}, },
"DontCheckDefaultBrowser": true, "DontCheckDefaultBrowser": true,
"ExtensionSettings": {
${preinstalled}
},
"Permissions": { "Permissions": {
"Camera": { "Camera": {
"BlockNewRequests": true "BlockNewRequests": true

View File

@@ -16,6 +16,10 @@ configurations {
canBeConsumed = false canBeConsumed = false
canBeResolved = true canBeResolved = true
} }
install {
canBeConsumed = true
canBeResolved = false
}
} }
// In this section you declare where to find the dependencies of your project // In this section you declare where to find the dependencies of your project
@@ -45,9 +49,6 @@ repositories {
} }
} }
def firefox_module = "devedition"
def firefox_revision = "92.0b7"
abstract class InstallBrowserTask extends DefaultTask { abstract class InstallBrowserTask extends DefaultTask {
@OutputFile @OutputFile
final abstract DirectoryProperty installation = project.objects.directoryProperty() final abstract DirectoryProperty installation = project.objects.directoryProperty()
@@ -248,6 +249,31 @@ task installAddons(type: Copy) {
} }
} }
task zipPolicies(type: Tar) {
archiveFileName = "conf.tar"
destinationDirectory = file("$buildDir")
from(configurations.addon.files) {
into "distribution/extensions"
}
from files("browserConf")
filesMatching('**/policies.json'){
def pre = ""
for (File addon: configurations.addon.resolve())
{
if (pre.length() > 0)
{
pre += ",\n"
}
pre += "\"" + addon.name.substring(0, addon.name.lastIndexOf('.')) + "\": {\n"
pre += "\"installation_mode\": \"forced_install\","
pre += "\"install_url\": \"" + addon.toURI().toString() + "\""
pre += "}"
}
println "Expanding ${pre}"
expand(preinstalled: pre)
}
}
tasks.named('clean') { tasks.named('clean') {
dependsOn uninstallFirefoxWindows dependsOn uninstallFirefoxWindows
} }
@@ -255,3 +281,7 @@ println configurations.getNames()
compileJava.dependsOn installAddons compileJava.dependsOn installAddons
compileJava.dependsOn movePolicies compileJava.dependsOn movePolicies
artifacts {
install(zipPolicies)
}

View File

@@ -0,0 +1,2 @@
firefox_module = devedition
firefox_revision = 92.0b7

View File

@@ -1,3 +1,5 @@
import java.util.stream.Collectors
/* /*
* Copyright (c) 2021 William Hubbard. All Rights Reserved. * Copyright (c) 2021 William Hubbard. All Rights Reserved.
*/ */
@@ -10,3 +12,55 @@
* user guide available at https://docs.gradle.org/4.4.1/userguide/tutorial_java_projects.html * user guide available at https://docs.gradle.org/4.4.1/userguide/tutorial_java_projects.html
*/ */
ext.defaultPackage = "edu.regis.universeplayer" ext.defaultPackage = "edu.regis.universeplayer"
configurations {
browserData {
canBeConsumed = false
canBeResolved = true
}
appData {
canBeConsumed = false
canBeResolved = true
}
}
dependencies {
browserData project(path: ":browser", configuration: 'install')
appData project(path: ":interface", configuration: "install")
appData project(path: ":addonInter", configuration: "install")
}
task mergeApps(type: Tar) {
dependsOn configurations.appData
for (File file : configurations.appData.files) {
from(tarTree(file)) {
exclude "*"
include "*/bin/**"
include "*/lib/**"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
}
archiveFileName = "${project.name}.tar"
destinationDirectory = file("$buildDir")
doFirst {
println "$buildDir"
}
}
task buildscriptNix(type: Copy) {
dependsOn configurations.browserData
dependsOn mergeApps
from "$project.rootDir/src/install.sh"
into "$buildDir"
expand(project(":browser").properties)
doLast {
file("${buildDir}/install.sh").append "__BROWSERCONF__\n".bytes
file("${buildDir}/install.sh").append configurations.browserData.resolve().stream().findFirst().map(file -> file.bytes).get()
file("${buildDir}/install.sh").append "\n__APPDATA__\n".bytes
file("${buildDir}/install.sh").append mergeApps.archiveFile.get().asFile.bytes
}
}

View File

@@ -15,6 +15,13 @@ repositories {
} }
} }
configurations {
install {
canBeConsumed = true
canBeResolved = false
}
}
// In this section you declare the dependencies for your production and test code // In this section you declare the dependencies for your production and test code
dependencies { dependencies {
// The production code uses the SLF4J logging API at compile time // The production code uses the SLF4J logging API at compile time
@@ -46,3 +53,7 @@ targetCompatibility = JavaVersion.VERSION_16
// Define the main class for the application // Define the main class for the application
mainClassName = defaultPackage + '.PlayerEnvironment' mainClassName = defaultPackage + '.PlayerEnvironment'
//mainClassName = defaultPackage + '.localPlayer.Player' //mainClassName = defaultPackage + '.localPlayer.Player'
artifacts {
install(distTar)
}

View File

@@ -203,7 +203,10 @@ public class PlayerEnvironment
*/ */
runArguments(ops, params, System.out); runArguments(ops, params, System.out);
Runtime.getRuntime().addShutdownHook(new Thread(connector::stop)); Runtime.getRuntime().addShutdownHook(new Thread(() -> {
connector.stop();
PlayerManager.getPlayers().shutdownPlayers();
}));
} }
/** /**

View File

@@ -619,12 +619,13 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
@Override @Override
public void windowClosing(WindowEvent windowEvent) public void windowClosing(WindowEvent windowEvent)
{ {
PlayerManager.getPlayers().shutdownPlayers(); logger.info("Window closing");
} }
@Override @Override
public void windowClosed(WindowEvent windowEvent) public void windowClosed(WindowEvent windowEvent)
{ {
logger.info("Window closed");
} }
@Override @Override

98
src/install.sh Normal file
View File

@@ -0,0 +1,98 @@
#!/bin/sh
installDir="/usr/share/universal"
if [ -d "\$installDir" ]
then
rm -r "\$installDir"
fi
mkdir "\$installDir"
if [ \$? -ne 0 ]
then
installDir="\$HOME/.local/share/universal"
if [ -d "\$installDir" ]
then
rm -r "\$installDir"
fi
mkdir "\$installDir"
if [ \$? -ne 0 ]
then
echo "Could not create install directory. Try running with sudo" 1>&2
exit 1
fi
fi
mkdir "\$installDir/firefox"
if [ \$? -ne 0 ]
then
echo "Could not create browser directory" 1>&2
exit 1
fi
# Install Firefox
if [ ! -f "/tmp/firefox.tar.bz2" ]
then
firefoxDownload="https://download-installer.cdn.mozilla.net/pub/${firefox_module}/releases/${firefox_revision}/linux-x86_64/en-US/firefox-${firefox_revision}.tar.bz2"
echo "Downloading Firefox"
if [ `command -v wget` ]
then
wget -O "/tmp/firefox.tar.bz2" "\$firefoxDownload"
elif [ `command -v curl` ]
then
curl -o "/tmp/firefox.tar.bz2" "\$firefoxDownload"
fi
if [ \$? -ne 0 ]
then
echo "Could not download Firefox from \$firefoxDownload" 1>&2
exit 2
fi
fi
cd "\$installDir"
echo "Installing Firefox"
tar -xj -f "/tmp/firefox.tar.bz2"
if [ \$? -ne 0 ]
then
echo "Could not extract firefox" 1>&2
exit 3
fi
chmod +X "\$installDir/firefox/firefox"
rm "/tmp/firefox.tar.bz2"
if [ \$? -ne 0 ]
then
echo "WARNING: Could not clean up firefox!" 1>&2
fi
cd "\$OLDPWD"
cd "\$installDir/firefox"
# Install browser configurations
echo "Extracting browser configuration"
echo "Loading browser configuration"
confIndex=`awk '/^__BROWSERCONF__/ {print NR + 1; exit 0;}' \$0`
appIndex=`awk '/^__APPDATA__/ {print NR + 1; exit 0;}' \$0`
confLength=`expr \$appIndex - 1 - \$confIndex`
tail -n+\$confIndex \$0 | head -n-\$confLength | tar -x
mkdir -p "\$HOME/.mozilla/native-messaging-hosts"
echo "Installing native app"
cat >"\$HOME/.mozilla/native-messaging-hosts/universalmusic.json" << ENDNATIVE
{
"name": "universalmusic",
"description": "A link between the Universal Music Player and the web browser.",
"path": "\$installDir/bin/addonInter",
"type": "stdio",
"allowed_extensions": ["universalmusic@regis.edu"]
}
ENDNATIVE
cd "\$OLDPWD"
# Install the actual application
cd "\$installDir"
echo "Copying application data"
echo "Extracting application data"
tail -n+\$appIndex \$0 | tar -x
chmod +X "\$installDir/bin/interface"
chmod +X "\$installDir/bin/addonInter"
cd "\$OLDPWD"
ln -fs "\$installDir/bin/interface" "\$installDir/../../bin/universalplayer"
echo "Done!"
exit 0