diff --git a/build.sh b/build.sh index 413483690..ed180bb66 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,12 @@ set -o xtrace set -eu ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +if [ "$(uname)" == "Darwin" ]; then + ICON="$ROOT/package/osx/app.icns" +else + ICON="$ROOT/package/icons/lbry48.png" +fi + if [ -n "${TEAMCITY_VERSION:-}" ]; then # install dependencies @@ -17,6 +23,7 @@ if [ -n "${TEAMCITY_VERSION:-}" ]; then set +u source "$VENV/bin/activate" set -u + pip install -U pip setuptools fi @@ -27,17 +34,13 @@ fi ( cd "$ROOT/lbry" - git fetch - git reset --hard origin/master - git cherry-pick bd75e88ebebb67897c62a1ee1d3228fd269677dc pip install -r requirements.txt pip install . - git reset --hard origin/master ) ( cd "$ROOT/lbrynet" - pyinstaller lbry.py -y --windowed --onefile --icon="$ROOT/lbry/packaging/osx/lbry-osx-app/app.icns" + pyinstaller lbry.py -y --windowed --onefile --icon="${ICON}" ) ( @@ -52,21 +55,25 @@ cp -R "$ROOT/lbry-web-ui/dist" "$ROOT/electron/" mv "$ROOT/lbrynet/dist/lbry" "$ROOT/electron/dist" if [ -n "${TEAMCITY_VERSION:-}" ]; then - electron-packager --electron-version=1.4.14 --overwrite "$ROOT/electron" LBRY + electron-packager --electron-version=1.4.14 --overwrite "$ROOT/electron" LBRY --icon="${ICON}" + # TODO: sign the app ( + cd "$ROOT/lbry" + VERSION=$(python setup.py -V) cd "$ROOT" if [ "$(uname)" == "Darwin" ]; then - OS="osx" PLATFORM="darwin" + mv "LBRY-${PLATFORM}-x64/LBRY.app" "$ROOT/lbry/package/osx/lbry-osx-app/LBRY.app" + cd "$ROOT/lbry/packaging/osx/lbry-osx-app" + dmgbuild -s dmg_settings.py "LBRY" "lbry-${VERSION}.dmg" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then OS="linux" PLATFORM="linux" + tar cvzf "lbry-${OS}.tgz" "LBRY-${PLATFORM}-x64/" else OS="unknown" fi - - tar cvzf "lbry-${OS}.tgz" "LBRY-${PLATFORM}-x64/" ) echo 'Build and packaging complete.' diff --git a/electron/main.js b/electron/main.js index a0fb29565..862cef69e 100644 --- a/electron/main.js +++ b/electron/main.js @@ -8,6 +8,8 @@ var client = jayson.client.http('http://localhost:5279/lbryapi'); let win // Also keep the daemon subprocess alive let subpy +// set to true when the quitting sequence has started +let quitting = false; function createWindow () { // Create the browser window. @@ -30,12 +32,19 @@ function createWindow () { }; function lauchDaemon() { - // TODO: check if the daemon is already running + if (subpy) { + return; + } subpy = require('child_process').spawn(`${__dirname}/dist/lbry`, ['--no-launch', '--log-to-console'], {stdio: ['ignore', process.stdout, process.stderr]}) subpy.on('exit', () => { console.log('The daemon has exited. Quitting the app'); subpy = null; - app.quit(); + if (quitting) { + app.quit(); + } else { + win.loadURL(`file://${__dirname}/dist/warning.html`); + setTimeout(5000, app.quit) + } }); console.log('lbrynet daemon has launched') } @@ -44,9 +53,19 @@ function lauchDaemon() { // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', function(){ - lauchDaemon(); - createWindow(); -}) + // Check if the daemon is already running. If we get + // an error its because its not running + client.request( + 'status', [], + function (err, res) { + // Did it all work ? + if (err) { + lauchDaemon(); + } + } + ); + createWindow(); +}); // Quit when all windows are closed. @@ -61,6 +80,10 @@ app.on('window-all-closed', () => { app.on('before-quit', (event) => { if (subpy != null) { event.preventDefault() + if (win) { + win.loadURL(`file://${__dirname}/dist/quit.html`); + } + quitting = true; subpy.kill('SIGINT'); } }) diff --git a/lbry b/lbry index 91d673a53..3e37765c1 160000 --- a/lbry +++ b/lbry @@ -1 +1 @@ -Subproject commit 91d673a539f5943cc219d9bec270fa840fa0895c +Subproject commit 3e37765c1bdd7007c5c66c97fe9857104d595396 diff --git a/lbry-web-ui b/lbry-web-ui index 8452dd8bd..114d7868a 160000 --- a/lbry-web-ui +++ b/lbry-web-ui @@ -1 +1 @@ -Subproject commit 8452dd8bd56653d8072b04ec592d9c944a8b9843 +Subproject commit 114d7868ac28b3c7e9ca9798aab129624b0c8a48 diff --git a/package/icons/lbry128.png b/package/icons/lbry128.png new file mode 100644 index 000000000..de083fcbc Binary files /dev/null and b/package/icons/lbry128.png differ diff --git a/package/icons/lbry256.png b/package/icons/lbry256.png new file mode 100644 index 000000000..659957406 Binary files /dev/null and b/package/icons/lbry256.png differ diff --git a/package/icons/lbry32.png b/package/icons/lbry32.png new file mode 100644 index 000000000..ece10998c Binary files /dev/null and b/package/icons/lbry32.png differ diff --git a/package/icons/lbry48.png b/package/icons/lbry48.png new file mode 100644 index 000000000..bba3a8e9d Binary files /dev/null and b/package/icons/lbry48.png differ diff --git a/package/icons/lbry96.png b/package/icons/lbry96.png new file mode 100644 index 000000000..195c31ea7 Binary files /dev/null and b/package/icons/lbry96.png differ diff --git a/package/osx/app.icns b/package/osx/app.icns new file mode 100644 index 000000000..199a1b59d Binary files /dev/null and b/package/osx/app.icns differ diff --git a/package/osx/dmg_settings.py b/package/osx/dmg_settings.py new file mode 100644 index 000000000..1fa6b0b03 --- /dev/null +++ b/package/osx/dmg_settings.py @@ -0,0 +1,12 @@ +badge_icon = 'app.icns' +icon_locations = { + 'LBRY.app': (115, 164), + 'Applications': (387, 164) +} +background='dmg_background.png' +default_view='icon-view' +symlinks = { 'Applications': '/Applications' } +window_rect=((200, 200), (500, 320)) +files = [ 'LBRY.app' ] +icon_size=128 +size = '200M' diff --git a/prebuild.sh b/prebuild.sh index 60cc2686f..16b3ef107 100755 --- a/prebuild.sh +++ b/prebuild.sh @@ -27,7 +27,7 @@ cmd_exists() { return $? } - +set +eu GITUSERNAME=$(git config --global --get user.name) GITEMAIL=$(git config --global --get user.email) if [ -z "$GITUSERNAME" ]; then @@ -36,6 +36,7 @@ fi if [ -z "$GITEMAIL" ]; then git config --global user.email "$(whoami)@lbry.io" fi +set -eu if $LINUX; then @@ -95,3 +96,7 @@ fi if ! cmd_exists electron-packager; then $SUDO npm install --global electron-packager fi + +if $OSX && ! cmd_exists dmgbuild; then + $SUDO pip install dmgbuild +fi