Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com.blizzard.BattleNet.BaseApp] Add json editor 'jq' #101

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

[com.blizzard.BattleNet.BaseApp] Add json editor 'jq' #101

wants to merge 6 commits into from

Conversation

johnramsden
Copy link

@johnramsden johnramsden commented Jul 22, 2018

A json editor is needed to modified Battlenet configuration easily. This has been discussed as something that could be helpful in #73 and #88.

Right now it is difficult to edit battle net configuration, without destroying the existing file. Using the json editor would make it much easier to make small configuration edits.

@johnramsden
Copy link
Author

While jq runs fine, I've noticed some strange behavior I mentioned in #73 (comment) related to ld-linux.so. I'm not sure how it would affect things if in the baseapp.

@julianrichen
Copy link
Contributor

julianrichen commented Aug 6, 2018

I changed the module around a bit on my side

  - name: jq
    config-opts:
      - --prefix=/app
      - --disable-maintainer-mode
      - --disable-docs
    sources:
      - type: archive
        url: https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
        sha256: c4d2bfec6436341113419debf479d833692cc5cdab7eb0326b5a4d4fbe9f493c
    modules:
      - name: oniguruma
        config-opts:
          - --prefix=/app
        sources:
          - type: archive
            url: https://github.com/kkos/oniguruma/releases/download/v6.8.2/onig-6.8.2.tar.gz
            sha256: adeada5f6b54c2a6f58ff021831a01b18a62b55ea9935e972e36ebb19e7c4903
        cleanup:
          - /lib/debug
          - /lib/*.a
          - /lib/pkgconfig
          - /include
          - /share
    cleanup:
      - /lib/debug
      - /lib/*.a
      - /include
      - /share

So that the oniguruma dependency would be built. jq and/or oniguruma seems to delete ld-linux.so.2 and I'm not sure why/how.

If you run

flatpak-builder --stop-at=setup --arch=x86_64 --force-clean --repo=winepak-repo builds/application/com.blizzard.BattleNet.BaseApp applications/com.blizzard.BattleNet.BaseApp/com.blizzard.BattleNet.BaseApp.yml

and check builds/application/com.blizzard.BattleNet.BaseApp you'll see ld-linux.so.2 exists. But if you run

flatpak-builder --stop-at=oniguruma --arch=x86_64 --force-clean --repo=winepak-repo builds/application/com.blizzard.BattleNet.BaseApp applications/com.blizzard.BattleNet.BaseApp/com.blizzard.BattleNet.BaseApp.yml

or

flatpak-builder --stop-at=jq --arch=x86_64 --force-clean --repo=winepak-repo builds/application/com.blizzard.BattleNet.BaseApp applications/com.blizzard.BattleNet.BaseApp/com.blizzard.BattleNet.BaseApp.yml

Then it gets deleted...

jq and oniguruma run ldconfig -n /app/lib in their install scripts,
which removes symbolic links in /app/lib. The fix is to move the
setup-compat32 module to the bottom.

Also other clean-ups to the modules.
@julianrichen
Copy link
Contributor

julianrichen commented Aug 6, 2018

It's this command in the build script

ldconfig -n /app/lib

The final libtool command:

 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libjq.la '/app/lib'
libtool: install: /usr/bin/install -c .libs/libjq.so.1.0.4 /app/lib/libjq.so.1.0.4
libtool: install: (cd /app/lib && { ln -s -f libjq.so.1.0.4 libjq.so.1 || { rm -f libjq.so.1 && ln -s libjq.so.1.0.4 libjq.so.1; }; })
libtool: install: (cd /app/lib && { ln -s -f libjq.so.1.0.4 libjq.so || { rm -f libjq.so && ln -s libjq.so.1.0.4 libjq.so; }; })
libtool: install: /usr/bin/install -c .libs/libjq.lai /app/lib/libjq.la
libtool: install: /usr/bin/install -c .libs/libjq.a /app/lib/libjq.a
libtool: install: chmod 644 /app/lib/libjq.a
libtool: install: ranlib /app/lib/libjq.a
libtool: finish: PATH="/app/bin:/usr/bin:/sbin" ldconfig -n /app/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /app/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

I guess ldconfig deletes symbolic links ...

Changes here:
https://github.com/winepak/applications/blob/pr/101/com.blizzard.BattleNet.BaseApp/com.blizzard.BattleNet.BaseApp.yml

Do you want to amend your pr or should I merge the branch above? You'll be credited for both.

Entire file:

id: com.blizzard.BattleNet.BaseApp
branch: stable

runtime: org.winepak.Platform
runtime-version: 3.0
sdk: org.winepak.Sdk

add-extensions:
  org.winepak.Platform.Compat32:
    directory: lib/32bit
    version: 3.0
    add-ld-path: lib
    no-autodownload: false
    
  org.winepak.Platform.Extension.corefonts:
    directory: lib/extension/corefonts
    version: 3.0
    no-autodownload: false

  org.winepak.Platform.Extension.vcrun2015:
    directory: lib/extension/vcrun2015
    version: 3.0
    no-autodownload: false
    
tags:
  - proprietary

finish-args:
  - --socket=x11
  - --socket=pulseaudio
  - --share=ipc
  - --share=network
  - --device=dri
  - --allow=multiarch
    
modules:
  - name: setup
    buildsystem: simple
    build-commands:
      - mkdir -p /app/lib/extension/corefonts
      - mkdir -p /app/lib/extension/vcrun2015
    
  - name: jq
    config-opts:
      - --prefix=/app
      - --with-oniguruma=/app
      - --disable-maintainer-mode
      - --disable-docs
    sources:
      - type: archive
        url: https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
        sha256: c4d2bfec6436341113419debf479d833692cc5cdab7eb0326b5a4d4fbe9f493c
    modules:
      - name: oniguruma
        config-opts:
          - --prefix=/app
        sources:
          - type: archive
            url: https://github.com/kkos/oniguruma/releases/download/v6.8.2/onig-6.8.2.tar.gz
            sha256: adeada5f6b54c2a6f58ff021831a01b18a62b55ea9935e972e36ebb19e7c4903
        cleanup:
          - /lib/debug
          - /lib/*.a
          - /lib/pkgconfig
          - /include
          - /share
    cleanup:
      - /lib/debug
      - /lib/*.a
      - /include
      - /share

  - name: battlenet
    only-arches:
      - x86_64
    buildsystem: simple
    build-commands:
      - install -d /app/bin
      - install battlenet-installer /app/bin
    sources:
      - type: script
        dest-filename: battlenet-installer
        commands:
          - if [ -z "$WINEPREFIX" ] ; then
          - '    echo "No wine prefix set or is empty, abort."'
          - '    exit 1'
          - fi
          - 
          - if [ -e "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net" ] ; then
          - '    echo "This prefix already has an exisiting ''Battle.Net'' install at ${WINEPREFIX}"'
          - '    echo "In order to install ''Battle.Net'' you must move or delete the current prefix."'
          - '    exit 1'
          - fi
          - 
          - echo "Downloading installer..."
          - mkdir -p "${XDG_CACHE_HOME}/winepak"
          - curl -L --progress-bar --output "${XDG_CACHE_HOME}/winepak/battlenet-installer.exe" "https://www.battle.net/download/getInstallerForGame?os=win&version=LIVE&gameProgram=BATTLENET_APP"
          - 
          - echo "Setting-up wine prefix..."
          - wineboot
          - 
          - echo "Installing Extension(s)..."
          - source /app/lib/extension/corefonts/bin/corefonts-install64
          - source /app/lib/extension/vcrun2015/bin/vcrun2015-install64
          - source /app/lib/extension/vcrun2015/bin/vcrun2015-install64-wow64
          - 
          - echo "Performing tweak(s)..."
          - echo "Disable winemenubuilder.exe..."
          - wine64 reg add "HKEY_CURRENT_USER\Software\Wine\DllOverrides" /v "winemenubuilder.exe" /d "" /f
          - 
          - echo "Set Windows Version for Steam and Steamwebhelper..."
          - wine64 reg add "HKEY_CURRENT_USER\Software\Wine\AppDefaults\Steam.exe" /v "Version" /t "REG_SZ" /d "win10" /f
          - wine64 reg add "HKEY_CURRENT_USER\Software\Wine\AppDefaults\steamwebhelper.exe" /v "Version" /t "REG_SZ" /d "win10" /f
          - 
          - echo "Disable crash dialog..."
          - wine64 reg add "HKEY_CURRENT_USER\Software\Wine\WineDbg" /v "ShowCrashDialog" /t "REG_DWORD" /d "00000000" /f
          - 
          - echo "Create Battle.net config"
          - battlenet_config="${WINEPREFIX}/dosdevices/c:/users/${USER}/Application Data/Battle.net/Battle.net.config"
          - battlenet_config_temp=$(mktemp)
          - 
          - mkdir -p "${WINEPREFIX}/dosdevices/c:/users/${USER}/Application Data/Battle.net"
          - jq --null-input '.Client.HardwareAcceleration = "false" | .Client.Sound.Enabled = "false" | .Client.Version.FirstRun = "false" | .Client.Version.Release.FirstRun = "false" | .Client.GameSearch.PerformedSearch = "true"' "$battlenet_config" > "$battlenet_config_temp"
          - mv -f "$battlenet_config_temp" "$battlenet_config"
          - 
          - echo "Installing application..."
          - wine64 "${XDG_CACHE_HOME}/winepak/battlenet-installer.exe" "$@"
          - 
          - echo "Delete SystemSurvey.exe..."
          - if [ -f "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/SystemSurvey.exe" ] ; then
          - '    mv "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/SystemSurvey.exe" "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/SystemSurvey.exe.bak"'
          - fi
          - 
          - echo "Delete Battle.net Helper.exe..."
          - if [ -f "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/Battle.net Helper.exe" ] ; then
          - '    mv "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/Battle.net Helper.exe" "${WINEPREFIX}/dosdevices/c:/Program Files (x86)/Battle.net/Battle.net*/Battle.net Helper.exe.bak"'
          - fi
          - 
          - echo "Installer finished"

  - name: setup-compat32
    buildsystem: simple
    build-commands:
      - mkdir -p /app/lib/32bit
      - ln -s /app/lib/32bit/lib/ld-linux.so.2 /app/lib/ld-linux.so.2

@julianrichen
Copy link
Contributor

julianrichen commented Aug 6, 2018

Also above & in the branch includes the jq code to modify the Battle.net.config. The changes include:

.Client.HardwareAcceleration = "false"
.Client.Sound.Enabled = "false"
.Client.Version.FirstRun = "false"
.Client.Version.Release.FirstRun = "false"
.Client.GameSearch.PerformedSearch = "true"' 

Interesting enough the Battle.net client doesn't even respect it's own configs, .Client.Version.Release.FirstRun should stop the patches note window from poping-up yet it still does...


This might also be worth adding:

.Client.Install.CreateDesktopShortcut = "false"

@johnramsden
Copy link
Author

@julianrichen I just pulled from your branch for history's sake. Interesting that ldconfig would be deleting symbolic links.

Use '-c <filter>' to pass en extra filters
@johnramsden
Copy link
Author

Added a -c option to battlenet-installer to allow passing in jq filters as discussed in #73

Example usage might be:

battlenet-installer -c \
  '.Games.diablo3.Run64Bit = "false" | .Games.diablo3.Run64BitSet = "true"' \
  "battlenet://D3" 

Which would output:

{
  "Client": {
    "HardwareAcceleration": "false",
    "Sound": {
      "Enabled": "false"
    },
    "Version": {
      "FirstRun": "false",
      "Release": {
        "FirstRun": "false"
      }
    },
    "GameSearch": {
      "PerformedSearch": "true"
    }
  },
  "Games": {
    "diablo3": {
      "Run64Bit": "false",
      "Run64BitSet": "true"
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants